babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630
  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. _getVertexShaderCode(): string | null;
  1088. /** @hidden */
  1089. _getFragmentShaderCode(): string | null;
  1090. /** @hidden */
  1091. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1092. }
  1093. }
  1094. declare module "babylonjs/Meshes/dataBuffer" {
  1095. /**
  1096. * Class used to store gfx data (like WebGLBuffer)
  1097. */
  1098. export class DataBuffer {
  1099. /**
  1100. * Gets or sets the number of objects referencing this buffer
  1101. */
  1102. references: number;
  1103. /** Gets or sets the size of the underlying buffer */
  1104. capacity: number;
  1105. /**
  1106. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1107. */
  1108. is32Bits: boolean;
  1109. /**
  1110. * Gets the underlying buffer
  1111. */
  1112. get underlyingResource(): any;
  1113. }
  1114. }
  1115. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1116. /** @hidden */
  1117. export interface IShaderProcessor {
  1118. attributeProcessor?: (attribute: string) => string;
  1119. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1120. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1121. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1122. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1123. lineProcessor?: (line: string, isFragment: boolean) => string;
  1124. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1125. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. }
  1127. }
  1128. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1129. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1148. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1149. /** @hidden */
  1150. export class ShaderCodeNode {
  1151. line: string;
  1152. children: ShaderCodeNode[];
  1153. additionalDefineKey?: string;
  1154. additionalDefineValue?: string;
  1155. isValid(preprocessors: {
  1156. [key: string]: string;
  1157. }): boolean;
  1158. process(preprocessors: {
  1159. [key: string]: string;
  1160. }, options: ProcessingOptions): string;
  1161. }
  1162. }
  1163. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1164. /** @hidden */
  1165. export class ShaderCodeCursor {
  1166. private _lines;
  1167. lineIndex: number;
  1168. get currentLine(): string;
  1169. get canRead(): boolean;
  1170. set lines(value: string[]);
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1174. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1175. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1176. /** @hidden */
  1177. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1178. process(preprocessors: {
  1179. [key: string]: string;
  1180. }, options: ProcessingOptions): string;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1184. /** @hidden */
  1185. export class ShaderDefineExpression {
  1186. isTrue(preprocessors: {
  1187. [key: string]: string;
  1188. }): boolean;
  1189. }
  1190. }
  1191. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1192. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1193. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1194. /** @hidden */
  1195. export class ShaderCodeTestNode extends ShaderCodeNode {
  1196. testExpression: ShaderDefineExpression;
  1197. isValid(preprocessors: {
  1198. [key: string]: string;
  1199. }): boolean;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1203. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1204. /** @hidden */
  1205. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1206. define: string;
  1207. not: boolean;
  1208. constructor(define: string, not?: boolean);
  1209. isTrue(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1215. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1216. /** @hidden */
  1217. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1218. leftOperand: ShaderDefineExpression;
  1219. rightOperand: ShaderDefineExpression;
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1226. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1227. /** @hidden */
  1228. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1237. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Offline/IOfflineProvider" {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module "babylonjs/Misc/filesInputStore" {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/retryStrategy" {
  1301. import { WebRequest } from "babylonjs/Misc/webRequest";
  1302. /**
  1303. * Class used to define a retry strategy when error happens while loading assets
  1304. */
  1305. export class RetryStrategy {
  1306. /**
  1307. * Function used to defines an exponential back off strategy
  1308. * @param maxRetries defines the maximum number of retries (3 by default)
  1309. * @param baseInterval defines the interval between retries
  1310. * @returns the strategy function to use
  1311. */
  1312. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1313. }
  1314. }
  1315. declare module "babylonjs/Misc/baseError" {
  1316. /**
  1317. * @ignore
  1318. * Application error to support additional information when loading a file
  1319. */
  1320. export abstract class BaseError extends Error {
  1321. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/fileTools" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. import { Nullable } from "babylonjs/types";
  1327. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1328. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1329. import { BaseError } from "babylonjs/Misc/baseError";
  1330. /** @ignore */
  1331. export class LoadFileError extends BaseError {
  1332. request?: WebRequest;
  1333. file?: File;
  1334. /**
  1335. * Creates a new LoadFileError
  1336. * @param message defines the message of the error
  1337. * @param request defines the optional web request
  1338. * @param file defines the optional file
  1339. */
  1340. constructor(message: string, object?: WebRequest | File);
  1341. }
  1342. /** @ignore */
  1343. export class RequestFileError extends BaseError {
  1344. request: WebRequest;
  1345. /**
  1346. * Creates a new LoadFileError
  1347. * @param message defines the message of the error
  1348. * @param request defines the optional web request
  1349. */
  1350. constructor(message: string, request: WebRequest);
  1351. }
  1352. /** @ignore */
  1353. export class ReadFileError extends BaseError {
  1354. file: File;
  1355. /**
  1356. * Creates a new ReadFileError
  1357. * @param message defines the message of the error
  1358. * @param file defines the optional file
  1359. */
  1360. constructor(message: string, file: File);
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export class FileTools {
  1366. /**
  1367. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1368. */
  1369. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1370. /**
  1371. * Gets or sets the base URL to use to load assets
  1372. */
  1373. static BaseUrl: string;
  1374. /**
  1375. * Default behaviour for cors in the application.
  1376. * It can be a string if the expected behavior is identical in the entire app.
  1377. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1378. */
  1379. static CorsBehavior: string | ((url: string | string[]) => string);
  1380. /**
  1381. * Gets or sets a function used to pre-process url before using them to load assets
  1382. */
  1383. static PreprocessUrl: (url: string) => string;
  1384. /**
  1385. * Removes unwanted characters from an url
  1386. * @param url defines the url to clean
  1387. * @returns the cleaned url
  1388. */
  1389. private static _CleanUrl;
  1390. /**
  1391. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1392. * @param url define the url we are trying
  1393. * @param element define the dom element where to configure the cors policy
  1394. */
  1395. static SetCorsBehavior(url: string | string[], element: {
  1396. crossOrigin: string | null;
  1397. }): void;
  1398. /**
  1399. * Loads an image as an HTMLImageElement.
  1400. * @param input url string, ArrayBuffer, or Blob to load
  1401. * @param onLoad callback called when the image successfully loads
  1402. * @param onError callback called when the image fails to load
  1403. * @param offlineProvider offline provider for caching
  1404. * @param mimeType optional mime type
  1405. * @returns the HTMLImageElement of the loaded image
  1406. */
  1407. 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>;
  1408. /**
  1409. * Reads a file from a File object
  1410. * @param file defines the file to load
  1411. * @param onSuccess defines the callback to call when data is loaded
  1412. * @param onProgress defines the callback to call during loading process
  1413. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1414. * @param onError defines the callback to call when an error occurs
  1415. * @returns a file request object
  1416. */
  1417. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1418. /**
  1419. * Loads a file from a url
  1420. * @param url url to load
  1421. * @param onSuccess callback called when the file successfully loads
  1422. * @param onProgress callback called while file is loading (if the server supports this mode)
  1423. * @param offlineProvider defines the offline provider for caching
  1424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1425. * @param onError callback called when the file fails to load
  1426. * @returns a file request object
  1427. */
  1428. 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;
  1429. /**
  1430. * Loads a file
  1431. * @param url url to load
  1432. * @param onSuccess callback called when the file successfully loads
  1433. * @param onProgress callback called while file is loading (if the server supports this mode)
  1434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1435. * @param onError callback called when the file fails to load
  1436. * @param onOpened callback called when the web request is opened
  1437. * @returns a file request object
  1438. */
  1439. 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;
  1440. /**
  1441. * Checks if the loaded document was accessed via `file:`-Protocol.
  1442. * @returns boolean
  1443. */
  1444. static IsFileURL(): boolean;
  1445. }
  1446. }
  1447. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1448. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1449. import { WebRequest } from "babylonjs/Misc/webRequest";
  1450. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1451. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1452. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1453. /** @hidden */
  1454. export class ShaderProcessor {
  1455. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1456. private static _ProcessPrecision;
  1457. private static _ExtractOperation;
  1458. private static _BuildSubExpression;
  1459. private static _BuildExpression;
  1460. private static _MoveCursorWithinIf;
  1461. private static _MoveCursor;
  1462. private static _EvaluatePreProcessors;
  1463. private static _PreparePreProcessors;
  1464. private static _ProcessShaderConversion;
  1465. private static _ProcessIncludes;
  1466. /**
  1467. * Loads a file from a url
  1468. * @param url url to load
  1469. * @param onSuccess callback called when the file successfully loads
  1470. * @param onProgress callback called while file is loading (if the server supports this mode)
  1471. * @param offlineProvider defines the offline provider for caching
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @returns a file request object
  1475. * @hidden
  1476. */
  1477. 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;
  1478. }
  1479. }
  1480. declare module "babylonjs/Maths/math.like" {
  1481. import { float, int, DeepImmutable } from "babylonjs/types";
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IColor4Like {
  1486. r: float;
  1487. g: float;
  1488. b: float;
  1489. a: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IColor3Like {
  1495. r: float;
  1496. g: float;
  1497. b: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector4Like {
  1503. x: float;
  1504. y: float;
  1505. z: float;
  1506. w: float;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IVector3Like {
  1512. x: float;
  1513. y: float;
  1514. z: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IVector2Like {
  1520. x: float;
  1521. y: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IMatrixLike {
  1527. toArray(): DeepImmutable<Float32Array>;
  1528. updateFlag: int;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IViewportLike {
  1534. x: float;
  1535. y: float;
  1536. width: float;
  1537. height: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IPlaneLike {
  1543. normal: IVector3Like;
  1544. d: float;
  1545. normalize(): void;
  1546. }
  1547. }
  1548. declare module "babylonjs/Materials/iEffectFallbacks" {
  1549. import { Effect } from "babylonjs/Materials/effect";
  1550. /**
  1551. * Interface used to define common properties for effect fallbacks
  1552. */
  1553. export interface IEffectFallbacks {
  1554. /**
  1555. * Removes the defines that should be removed when falling back.
  1556. * @param currentDefines defines the current define statements for the shader.
  1557. * @param effect defines the current effect we try to compile
  1558. * @returns The resulting defines with defines of the current rank removed.
  1559. */
  1560. reduce(currentDefines: string, effect: Effect): string;
  1561. /**
  1562. * Removes the fallback from the bound mesh.
  1563. */
  1564. unBindMesh(): void;
  1565. /**
  1566. * Checks to see if more fallbacks are still availible.
  1567. */
  1568. hasMoreFallbacks: boolean;
  1569. }
  1570. }
  1571. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1572. /**
  1573. * Class used to evalaute queries containing `and` and `or` operators
  1574. */
  1575. export class AndOrNotEvaluator {
  1576. /**
  1577. * Evaluate a query
  1578. * @param query defines the query to evaluate
  1579. * @param evaluateCallback defines the callback used to filter result
  1580. * @returns true if the query matches
  1581. */
  1582. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1583. private static _HandleParenthesisContent;
  1584. private static _SimplifyNegation;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/tags" {
  1588. /**
  1589. * Class used to store custom tags
  1590. */
  1591. export class Tags {
  1592. /**
  1593. * Adds support for tags on the given object
  1594. * @param obj defines the object to use
  1595. */
  1596. static EnableFor(obj: any): void;
  1597. /**
  1598. * Removes tags support
  1599. * @param obj defines the object to use
  1600. */
  1601. static DisableFor(obj: any): void;
  1602. /**
  1603. * Gets a boolean indicating if the given object has tags
  1604. * @param obj defines the object to use
  1605. * @returns a boolean
  1606. */
  1607. static HasTags(obj: any): boolean;
  1608. /**
  1609. * Gets the tags available on a given object
  1610. * @param obj defines the object to use
  1611. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1612. * @returns the tags
  1613. */
  1614. static GetTags(obj: any, asString?: boolean): any;
  1615. /**
  1616. * Adds tags to an object
  1617. * @param obj defines the object to use
  1618. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1619. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1620. */
  1621. static AddTagsTo(obj: any, tagsString: string): void;
  1622. /**
  1623. * @hidden
  1624. */
  1625. static _AddTagTo(obj: any, tag: string): void;
  1626. /**
  1627. * Removes specific tags from a specific object
  1628. * @param obj defines the object to use
  1629. * @param tagsString defines the tags to remove
  1630. */
  1631. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1632. /**
  1633. * @hidden
  1634. */
  1635. static _RemoveTagFrom(obj: any, tag: string): void;
  1636. /**
  1637. * Defines if tags hosted on an object match a given query
  1638. * @param obj defines the object to use
  1639. * @param tagsQuery defines the tag query
  1640. * @returns a boolean
  1641. */
  1642. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1643. }
  1644. }
  1645. declare module "babylonjs/Maths/math.scalar" {
  1646. /**
  1647. * Scalar computation library
  1648. */
  1649. export class Scalar {
  1650. /**
  1651. * Two pi constants convenient for computation.
  1652. */
  1653. static TwoPi: number;
  1654. /**
  1655. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. * @param a number
  1657. * @param b number
  1658. * @param epsilon (default = 1.401298E-45)
  1659. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1660. */
  1661. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1662. /**
  1663. * Returns a string : the upper case translation of the number i to hexadecimal.
  1664. * @param i number
  1665. * @returns the upper case translation of the number i to hexadecimal.
  1666. */
  1667. static ToHex(i: number): string;
  1668. /**
  1669. * Returns -1 if value is negative and +1 is value is positive.
  1670. * @param value the value
  1671. * @returns the value itself if it's equal to zero.
  1672. */
  1673. static Sign(value: number): number;
  1674. /**
  1675. * Returns the value itself if it's between min and max.
  1676. * Returns min if the value is lower than min.
  1677. * Returns max if the value is greater than max.
  1678. * @param value the value to clmap
  1679. * @param min the min value to clamp to (default: 0)
  1680. * @param max the max value to clamp to (default: 1)
  1681. * @returns the clamped value
  1682. */
  1683. static Clamp(value: number, min?: number, max?: number): number;
  1684. /**
  1685. * the log2 of value.
  1686. * @param value the value to compute log2 of
  1687. * @returns the log2 of value.
  1688. */
  1689. static Log2(value: number): number;
  1690. /**
  1691. * Loops the value, so that it is never larger than length and never smaller than 0.
  1692. *
  1693. * This is similar to the modulo operator but it works with floating point numbers.
  1694. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1695. * With t = 5 and length = 2.5, the result would be 0.0.
  1696. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1697. * @param value the value
  1698. * @param length the length
  1699. * @returns the looped value
  1700. */
  1701. static Repeat(value: number, length: number): number;
  1702. /**
  1703. * Normalize the value between 0.0 and 1.0 using min and max values
  1704. * @param value value to normalize
  1705. * @param min max to normalize between
  1706. * @param max min to normalize between
  1707. * @returns the normalized value
  1708. */
  1709. static Normalize(value: number, min: number, max: number): number;
  1710. /**
  1711. * Denormalize the value from 0.0 and 1.0 using min and max values
  1712. * @param normalized value to denormalize
  1713. * @param min max to denormalize between
  1714. * @param max min to denormalize between
  1715. * @returns the denormalized value
  1716. */
  1717. static Denormalize(normalized: number, min: number, max: number): number;
  1718. /**
  1719. * Calculates the shortest difference between two given angles given in degrees.
  1720. * @param current current angle in degrees
  1721. * @param target target angle in degrees
  1722. * @returns the delta
  1723. */
  1724. static DeltaAngle(current: number, target: number): number;
  1725. /**
  1726. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1727. * @param tx value
  1728. * @param length length
  1729. * @returns The returned value will move back and forth between 0 and length
  1730. */
  1731. static PingPong(tx: number, length: number): number;
  1732. /**
  1733. * Interpolates between min and max with smoothing at the limits.
  1734. *
  1735. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1736. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1737. * @param from from
  1738. * @param to to
  1739. * @param tx value
  1740. * @returns the smooth stepped value
  1741. */
  1742. static SmoothStep(from: number, to: number, tx: number): number;
  1743. /**
  1744. * Moves a value current towards target.
  1745. *
  1746. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1747. * Negative values of maxDelta pushes the value away from target.
  1748. * @param current current value
  1749. * @param target target value
  1750. * @param maxDelta max distance to move
  1751. * @returns resulting value
  1752. */
  1753. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1754. /**
  1755. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1756. *
  1757. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1758. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1759. * @param current current value
  1760. * @param target target value
  1761. * @param maxDelta max distance to move
  1762. * @returns resulting angle
  1763. */
  1764. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1765. /**
  1766. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1767. * @param start start value
  1768. * @param end target value
  1769. * @param amount amount to lerp between
  1770. * @returns the lerped value
  1771. */
  1772. static Lerp(start: number, end: number, amount: number): number;
  1773. /**
  1774. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1775. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1776. * @param start start value
  1777. * @param end target value
  1778. * @param amount amount to lerp between
  1779. * @returns the lerped value
  1780. */
  1781. static LerpAngle(start: number, end: number, amount: number): number;
  1782. /**
  1783. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1784. * @param a start value
  1785. * @param b target value
  1786. * @param value value between a and b
  1787. * @returns the inverseLerp value
  1788. */
  1789. static InverseLerp(a: number, b: number, value: number): number;
  1790. /**
  1791. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1792. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1793. * @param value1 spline value
  1794. * @param tangent1 spline value
  1795. * @param value2 spline value
  1796. * @param tangent2 spline value
  1797. * @param amount input value
  1798. * @returns hermite result
  1799. */
  1800. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1801. /**
  1802. * Returns a random float number between and min and max values
  1803. * @param min min value of random
  1804. * @param max max value of random
  1805. * @returns random value
  1806. */
  1807. static RandomRange(min: number, max: number): number;
  1808. /**
  1809. * This function returns percentage of a number in a given range.
  1810. *
  1811. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1812. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1813. * @param number to convert to percentage
  1814. * @param min min range
  1815. * @param max max range
  1816. * @returns the percentage
  1817. */
  1818. static RangeToPercent(number: number, min: number, max: number): number;
  1819. /**
  1820. * This function returns number that corresponds to the percentage in a given range.
  1821. *
  1822. * PercentToRange(0.34,0,100) will return 34.
  1823. * @param percent to convert to number
  1824. * @param min min range
  1825. * @param max max range
  1826. * @returns the number
  1827. */
  1828. static PercentToRange(percent: number, min: number, max: number): number;
  1829. /**
  1830. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1831. * @param angle The angle to normalize in radian.
  1832. * @return The converted angle.
  1833. */
  1834. static NormalizeRadians(angle: number): number;
  1835. }
  1836. }
  1837. declare module "babylonjs/Maths/math.constants" {
  1838. /**
  1839. * Constant used to convert a value to gamma space
  1840. * @ignorenaming
  1841. */
  1842. export const ToGammaSpace: number;
  1843. /**
  1844. * Constant used to convert a value to linear space
  1845. * @ignorenaming
  1846. */
  1847. export const ToLinearSpace = 2.2;
  1848. /**
  1849. * Constant used to define the minimal number value in Babylon.js
  1850. * @ignorenaming
  1851. */
  1852. let Epsilon: number;
  1853. export { Epsilon };
  1854. }
  1855. declare module "babylonjs/Maths/math.viewport" {
  1856. /**
  1857. * Class used to represent a viewport on screen
  1858. */
  1859. export class Viewport {
  1860. /** viewport left coordinate */
  1861. x: number;
  1862. /** viewport top coordinate */
  1863. y: number;
  1864. /**viewport width */
  1865. width: number;
  1866. /** viewport height */
  1867. height: number;
  1868. /**
  1869. * Creates a Viewport object located at (x, y) and sized (width, height)
  1870. * @param x defines viewport left coordinate
  1871. * @param y defines viewport top coordinate
  1872. * @param width defines the viewport width
  1873. * @param height defines the viewport height
  1874. */
  1875. constructor(
  1876. /** viewport left coordinate */
  1877. x: number,
  1878. /** viewport top coordinate */
  1879. y: number,
  1880. /**viewport width */
  1881. width: number,
  1882. /** viewport height */
  1883. height: number);
  1884. /**
  1885. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1886. * @param renderWidth defines the rendering width
  1887. * @param renderHeight defines the rendering height
  1888. * @returns a new Viewport
  1889. */
  1890. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1891. /**
  1892. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @param ref defines the target viewport
  1896. * @returns the current viewport
  1897. */
  1898. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1899. /**
  1900. * Returns a new Viewport copied from the current one
  1901. * @returns a new Viewport
  1902. */
  1903. clone(): Viewport;
  1904. }
  1905. }
  1906. declare module "babylonjs/Misc/arrayTools" {
  1907. /**
  1908. * Class containing a set of static utilities functions for arrays.
  1909. */
  1910. export class ArrayTools {
  1911. /**
  1912. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1913. * @param size the number of element to construct and put in the array
  1914. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1915. * @returns a new array filled with new objects
  1916. */
  1917. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1918. }
  1919. }
  1920. declare module "babylonjs/Maths/math.vector" {
  1921. import { Viewport } from "babylonjs/Maths/math.viewport";
  1922. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1923. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1924. /**
  1925. * Class representing a vector containing 2 coordinates
  1926. */
  1927. export class Vector2 {
  1928. /** defines the first coordinate */
  1929. x: number;
  1930. /** defines the second coordinate */
  1931. y: number;
  1932. /**
  1933. * Creates a new Vector2 from the given x and y coordinates
  1934. * @param x defines the first coordinate
  1935. * @param y defines the second coordinate
  1936. */
  1937. constructor(
  1938. /** defines the first coordinate */
  1939. x?: number,
  1940. /** defines the second coordinate */
  1941. y?: number);
  1942. /**
  1943. * Gets a string with the Vector2 coordinates
  1944. * @returns a string with the Vector2 coordinates
  1945. */
  1946. toString(): string;
  1947. /**
  1948. * Gets class name
  1949. * @returns the string "Vector2"
  1950. */
  1951. getClassName(): string;
  1952. /**
  1953. * Gets current vector hash code
  1954. * @returns the Vector2 hash code as a number
  1955. */
  1956. getHashCode(): number;
  1957. /**
  1958. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1959. * @param array defines the source array
  1960. * @param index defines the offset in source array
  1961. * @returns the current Vector2
  1962. */
  1963. toArray(array: FloatArray, index?: number): Vector2;
  1964. /**
  1965. * Copy the current vector to an array
  1966. * @returns a new array with 2 elements: the Vector2 coordinates.
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1971. * @param source defines the source Vector2
  1972. * @returns the current updated Vector2
  1973. */
  1974. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1975. /**
  1976. * Sets the Vector2 coordinates with the given floats
  1977. * @param x defines the first coordinate
  1978. * @param y defines the second coordinate
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFromFloats(x: number, y: number): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. set(x: number, y: number): Vector2;
  1989. /**
  1990. * Add another vector with the current one
  1991. * @param otherVector defines the other vector
  1992. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1993. */
  1994. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1995. /**
  1996. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1997. * @param otherVector defines the other vector
  1998. * @param result defines the target vector
  1999. * @returns the unmodified current Vector2
  2000. */
  2001. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2002. /**
  2003. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2004. * @param otherVector defines the other vector
  2005. * @returns the current updated Vector2
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2008. /**
  2009. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns a new Vector2
  2012. */
  2013. addVector3(otherVector: Vector3): Vector2;
  2014. /**
  2015. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2016. * @param otherVector defines the other vector
  2017. * @returns a new Vector2
  2018. */
  2019. subtract(otherVector: Vector2): Vector2;
  2020. /**
  2021. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2022. * @param otherVector defines the other vector
  2023. * @param result defines the target vector
  2024. * @returns the unmodified current Vector2
  2025. */
  2026. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2027. /**
  2028. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2029. * @param otherVector defines the other vector
  2030. * @returns the current updated Vector2
  2031. */
  2032. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2033. /**
  2034. * Multiplies in place the current Vector2 coordinates by the given ones
  2035. * @param otherVector defines the other vector
  2036. * @returns the current updated Vector2
  2037. */
  2038. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2039. /**
  2040. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @returns a new Vector2
  2043. */
  2044. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2045. /**
  2046. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2047. * @param otherVector defines the other vector
  2048. * @param result defines the target vector
  2049. * @returns the unmodified current Vector2
  2050. */
  2051. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2052. /**
  2053. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2054. * @param x defines the first coordinate
  2055. * @param y defines the second coordinate
  2056. * @returns a new Vector2
  2057. */
  2058. multiplyByFloats(x: number, y: number): Vector2;
  2059. /**
  2060. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2061. * @param otherVector defines the other vector
  2062. * @returns a new Vector2
  2063. */
  2064. divide(otherVector: Vector2): Vector2;
  2065. /**
  2066. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @param result defines the target vector
  2069. * @returns the unmodified current Vector2
  2070. */
  2071. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2072. /**
  2073. * Divides the current Vector2 coordinates by the given ones
  2074. * @param otherVector defines the other vector
  2075. * @returns the current updated Vector2
  2076. */
  2077. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2078. /**
  2079. * Gets a new Vector2 with current Vector2 negated coordinates
  2080. * @returns a new Vector2
  2081. */
  2082. negate(): Vector2;
  2083. /**
  2084. * Negate this vector in place
  2085. * @returns this
  2086. */
  2087. negateInPlace(): Vector2;
  2088. /**
  2089. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2090. * @param result defines the Vector3 object where to store the result
  2091. * @returns the current Vector2
  2092. */
  2093. negateToRef(result: Vector2): Vector2;
  2094. /**
  2095. * Multiply the Vector2 coordinates by scale
  2096. * @param scale defines the scaling factor
  2097. * @returns the current updated Vector2
  2098. */
  2099. scaleInPlace(scale: number): Vector2;
  2100. /**
  2101. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2102. * @param scale defines the scaling factor
  2103. * @returns a new Vector2
  2104. */
  2105. scale(scale: number): Vector2;
  2106. /**
  2107. * Scale the current Vector2 values by a factor to a given Vector2
  2108. * @param scale defines the scale factor
  2109. * @param result defines the Vector2 object where to store the result
  2110. * @returns the unmodified current Vector2
  2111. */
  2112. scaleToRef(scale: number, result: Vector2): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Gets a boolean if two vectors are equals
  2122. * @param otherVector defines the other vector
  2123. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2124. */
  2125. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2126. /**
  2127. * Gets a boolean if two vectors are equals (using an epsilon value)
  2128. * @param otherVector defines the other vector
  2129. * @param epsilon defines the minimal distance to consider equality
  2130. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2131. */
  2132. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2133. /**
  2134. * Gets a new Vector2 from current Vector2 floored values
  2135. * @returns a new Vector2
  2136. */
  2137. floor(): Vector2;
  2138. /**
  2139. * Gets a new Vector2 from current Vector2 floored values
  2140. * @returns a new Vector2
  2141. */
  2142. fract(): Vector2;
  2143. /**
  2144. * Gets the length of the vector
  2145. * @returns the vector length (float)
  2146. */
  2147. length(): number;
  2148. /**
  2149. * Gets the vector squared length
  2150. * @returns the vector squared length (float)
  2151. */
  2152. lengthSquared(): number;
  2153. /**
  2154. * Normalize the vector
  2155. * @returns the current updated Vector2
  2156. */
  2157. normalize(): Vector2;
  2158. /**
  2159. * Gets a new Vector2 copied from the Vector2
  2160. * @returns a new Vector2
  2161. */
  2162. clone(): Vector2;
  2163. /**
  2164. * Gets a new Vector2(0, 0)
  2165. * @returns a new Vector2
  2166. */
  2167. static Zero(): Vector2;
  2168. /**
  2169. * Gets a new Vector2(1, 1)
  2170. * @returns a new Vector2
  2171. */
  2172. static One(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 set from the given index element of the given array
  2175. * @param array defines the data source
  2176. * @param offset defines the offset in the data source
  2177. * @returns a new Vector2
  2178. */
  2179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2180. /**
  2181. * Sets "result" from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @param result defines the target vector
  2185. */
  2186. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2187. /**
  2188. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2189. * @param value1 defines 1st point of control
  2190. * @param value2 defines 2nd point of control
  2191. * @param value3 defines 3rd point of control
  2192. * @param value4 defines 4th point of control
  2193. * @param amount defines the interpolation factor
  2194. * @returns a new Vector2
  2195. */
  2196. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2197. /**
  2198. * 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".
  2199. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2200. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2201. * @param value defines the value to clamp
  2202. * @param min defines the lower limit
  2203. * @param max defines the upper limit
  2204. * @returns a new Vector2
  2205. */
  2206. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2209. * @param value1 defines the 1st control point
  2210. * @param tangent1 defines the outgoing tangent
  2211. * @param value2 defines the 2nd control point
  2212. * @param tangent2 defines the incoming tangent
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2219. * @param start defines the start vector
  2220. * @param end defines the end vector
  2221. * @param amount defines the interpolation factor
  2222. * @returns a new Vector2
  2223. */
  2224. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2225. /**
  2226. * Gets the dot product of the vector "left" and the vector "right"
  2227. * @param left defines first vector
  2228. * @param right defines second vector
  2229. * @returns the dot product (float)
  2230. */
  2231. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2232. /**
  2233. * Returns a new Vector2 equal to the normalized given vector
  2234. * @param vector defines the vector to normalize
  2235. * @returns a new Vector2
  2236. */
  2237. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2240. * @param left defines 1st vector
  2241. * @param right defines 2nd vector
  2242. * @returns a new Vector2
  2243. */
  2244. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2254. * @param vector defines the vector to transform
  2255. * @param transformation defines the matrix to apply
  2256. * @returns a new Vector2
  2257. */
  2258. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2259. /**
  2260. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @param result defines the target vector
  2264. */
  2265. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2266. /**
  2267. * Determines if a given vector is included in a triangle
  2268. * @param p defines the vector to test
  2269. * @param p0 defines 1st triangle point
  2270. * @param p1 defines 2nd triangle point
  2271. * @param p2 defines 3rd triangle point
  2272. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2273. */
  2274. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2275. /**
  2276. * Gets the distance between the vectors "value1" and "value2"
  2277. * @param value1 defines first vector
  2278. * @param value2 defines second vector
  2279. * @returns the distance between vectors
  2280. */
  2281. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2282. /**
  2283. * Returns the squared distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the squared distance between vectors
  2287. */
  2288. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns a new Vector2
  2294. */
  2295. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2296. /**
  2297. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2298. * @param p defines the middle point
  2299. * @param segA defines one point of the segment
  2300. * @param segB defines the other point of the segment
  2301. * @returns the shortest distance
  2302. */
  2303. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2304. }
  2305. /**
  2306. * Class used to store (x,y,z) vector representation
  2307. * A Vector3 is the main object used in 3D geometry
  2308. * It can represent etiher the coordinates of a point the space, either a direction
  2309. * Reminder: js uses a left handed forward facing system
  2310. */
  2311. export class Vector3 {
  2312. /**
  2313. * Defines the first coordinates (on X axis)
  2314. */
  2315. x: number;
  2316. /**
  2317. * Defines the second coordinates (on Y axis)
  2318. */
  2319. y: number;
  2320. /**
  2321. * Defines the third coordinates (on Z axis)
  2322. */
  2323. z: number;
  2324. private static _UpReadOnly;
  2325. private static _ZeroReadOnly;
  2326. /**
  2327. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2328. * @param x defines the first coordinates (on X axis)
  2329. * @param y defines the second coordinates (on Y axis)
  2330. * @param z defines the third coordinates (on Z axis)
  2331. */
  2332. constructor(
  2333. /**
  2334. * Defines the first coordinates (on X axis)
  2335. */
  2336. x?: number,
  2337. /**
  2338. * Defines the second coordinates (on Y axis)
  2339. */
  2340. y?: number,
  2341. /**
  2342. * Defines the third coordinates (on Z axis)
  2343. */
  2344. z?: number);
  2345. /**
  2346. * Creates a string representation of the Vector3
  2347. * @returns a string with the Vector3 coordinates.
  2348. */
  2349. toString(): string;
  2350. /**
  2351. * Gets the class name
  2352. * @returns the string "Vector3"
  2353. */
  2354. getClassName(): string;
  2355. /**
  2356. * Creates the Vector3 hash code
  2357. * @returns a number which tends to be unique between Vector3 instances
  2358. */
  2359. getHashCode(): number;
  2360. /**
  2361. * Creates an array containing three elements : the coordinates of the Vector3
  2362. * @returns a new array of numbers
  2363. */
  2364. asArray(): number[];
  2365. /**
  2366. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2367. * @param array defines the destination array
  2368. * @param index defines the offset in the destination array
  2369. * @returns the current Vector3
  2370. */
  2371. toArray(array: FloatArray, index?: number): Vector3;
  2372. /**
  2373. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2374. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2375. */
  2376. toQuaternion(): Quaternion;
  2377. /**
  2378. * Adds the given vector to the current Vector3
  2379. * @param otherVector defines the second operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2383. /**
  2384. * Adds the given coordinates to the current Vector3
  2385. * @param x defines the x coordinate of the operand
  2386. * @param y defines the y coordinate of the operand
  2387. * @param z defines the z coordinate of the operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2391. /**
  2392. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Subtract the given vector from the current Vector3
  2406. * @param otherVector defines the second operand
  2407. * @returns the current updated Vector3
  2408. */
  2409. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2410. /**
  2411. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2412. * @param otherVector defines the second operand
  2413. * @returns the resulting Vector3
  2414. */
  2415. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2416. /**
  2417. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2418. * @param otherVector defines the second operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2423. /**
  2424. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2431. /**
  2432. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2433. * @param x defines the x coordinate of the operand
  2434. * @param y defines the y coordinate of the operand
  2435. * @param z defines the z coordinate of the operand
  2436. * @param result defines the Vector3 object where to store the result
  2437. * @returns the current Vector3
  2438. */
  2439. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2440. /**
  2441. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2442. * @returns a new Vector3
  2443. */
  2444. negate(): Vector3;
  2445. /**
  2446. * Negate this vector in place
  2447. * @returns this
  2448. */
  2449. negateInPlace(): Vector3;
  2450. /**
  2451. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. negateToRef(result: Vector3): Vector3;
  2456. /**
  2457. * Multiplies the Vector3 coordinates by the float "scale"
  2458. * @param scale defines the multiplier factor
  2459. * @returns the current updated Vector3
  2460. */
  2461. scaleInPlace(scale: number): Vector3;
  2462. /**
  2463. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2464. * @param scale defines the multiplier factor
  2465. * @returns a new Vector3
  2466. */
  2467. scale(scale: number): Vector3;
  2468. /**
  2469. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2470. * @param scale defines the multiplier factor
  2471. * @param result defines the Vector3 object where to store the result
  2472. * @returns the current Vector3
  2473. */
  2474. scaleToRef(scale: number, result: Vector3): Vector3;
  2475. /**
  2476. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2477. * @param scale defines the scale factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the unmodified current Vector3
  2480. */
  2481. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2484. * @param otherVector defines the second operand
  2485. * @returns true if both vectors are equals
  2486. */
  2487. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2488. /**
  2489. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2490. * @param otherVector defines the second operand
  2491. * @param epsilon defines the minimal distance to define values as equals
  2492. * @returns true if both vectors are distant less than epsilon
  2493. */
  2494. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 coordinates equals the given floats
  2497. * @param x defines the x coordinate of the operand
  2498. * @param y defines the y coordinate of the operand
  2499. * @param z defines the z coordinate of the operand
  2500. * @returns true if both vectors are equals
  2501. */
  2502. equalsToFloats(x: number, y: number, z: number): boolean;
  2503. /**
  2504. * Multiplies the current Vector3 coordinates by the given ones
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2511. * @param otherVector defines the second operand
  2512. * @returns the new Vector3
  2513. */
  2514. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the new Vector3
  2528. */
  2529. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2532. * @param otherVector defines the second operand
  2533. * @returns the new Vector3
  2534. */
  2535. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2538. * @param otherVector defines the second operand
  2539. * @param result defines the Vector3 object where to store the result
  2540. * @returns the current Vector3
  2541. */
  2542. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones.
  2545. * @param otherVector defines the second operand
  2546. * @returns the current updated Vector3
  2547. */
  2548. divideInPlace(otherVector: Vector3): Vector3;
  2549. /**
  2550. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2551. * @param other defines the second operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2555. /**
  2556. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2557. * @param other defines the second operand
  2558. * @returns the current updated Vector3
  2559. */
  2560. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2561. /**
  2562. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2577. /**
  2578. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2579. * Check if is non uniform within a certain amount of decimal places to account for this
  2580. * @param epsilon the amount the values can differ
  2581. * @returns if the the vector is non uniform to a certain number of decimal places
  2582. */
  2583. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2584. /**
  2585. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2586. */
  2587. get isNonUniform(): boolean;
  2588. /**
  2589. * Gets a new Vector3 from current Vector3 floored values
  2590. * @returns a new Vector3
  2591. */
  2592. floor(): Vector3;
  2593. /**
  2594. * Gets a new Vector3 from current Vector3 floored values
  2595. * @returns a new Vector3
  2596. */
  2597. fract(): Vector3;
  2598. /**
  2599. * Gets the length of the Vector3
  2600. * @returns the length of the Vector3
  2601. */
  2602. length(): number;
  2603. /**
  2604. * Gets the squared length of the Vector3
  2605. * @returns squared length of the Vector3
  2606. */
  2607. lengthSquared(): number;
  2608. /**
  2609. * Normalize the current Vector3.
  2610. * Please note that this is an in place operation.
  2611. * @returns the current updated Vector3
  2612. */
  2613. normalize(): Vector3;
  2614. /**
  2615. * Reorders the x y z properties of the vector in place
  2616. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2617. * @returns the current updated vector
  2618. */
  2619. reorderInPlace(order: string): this;
  2620. /**
  2621. * Rotates the vector around 0,0,0 by a quaternion
  2622. * @param quaternion the rotation quaternion
  2623. * @param result vector to store the result
  2624. * @returns the resulting vector
  2625. */
  2626. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2627. /**
  2628. * Rotates a vector around a given point
  2629. * @param quaternion the rotation quaternion
  2630. * @param point the point to rotate around
  2631. * @param result vector to store the result
  2632. * @returns the resulting vector
  2633. */
  2634. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2637. * The cross product is then orthogonal to both current and "other"
  2638. * @param other defines the right operand
  2639. * @returns the cross product
  2640. */
  2641. cross(other: Vector3): Vector3;
  2642. /**
  2643. * Normalize the current Vector3 with the given input length.
  2644. * Please note that this is an in place operation.
  2645. * @param len the length of the vector
  2646. * @returns the current updated Vector3
  2647. */
  2648. normalizeFromLength(len: number): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 to a new vector
  2651. * @returns the new Vector3
  2652. */
  2653. normalizeToNew(): Vector3;
  2654. /**
  2655. * Normalize the current Vector3 to the reference
  2656. * @param reference define the Vector3 to update
  2657. * @returns the updated Vector3
  2658. */
  2659. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2660. /**
  2661. * Creates a new Vector3 copied from the current Vector3
  2662. * @returns the new Vector3
  2663. */
  2664. clone(): Vector3;
  2665. /**
  2666. * Copies the given vector coordinates to the current Vector3 ones
  2667. * @param source defines the source Vector3
  2668. * @returns the current updated Vector3
  2669. */
  2670. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2671. /**
  2672. * Copies the given floats to the current Vector3 coordinates
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the current updated Vector3
  2677. */
  2678. copyFromFloats(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Copies the given floats to the current Vector3 coordinates
  2681. * @param x defines the x coordinate of the operand
  2682. * @param y defines the y coordinate of the operand
  2683. * @param z defines the z coordinate of the operand
  2684. * @returns the current updated Vector3
  2685. */
  2686. set(x: number, y: number, z: number): Vector3;
  2687. /**
  2688. * Copies the given float to the current Vector3 coordinates
  2689. * @param v defines the x, y and z coordinates of the operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. setAll(v: number): Vector3;
  2693. /**
  2694. * Get the clip factor between two vectors
  2695. * @param vector0 defines the first operand
  2696. * @param vector1 defines the second operand
  2697. * @param axis defines the axis to use
  2698. * @param size defines the size along the axis
  2699. * @returns the clip factor
  2700. */
  2701. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2702. /**
  2703. * Get angle between two vectors
  2704. * @param vector0 angle between vector0 and vector1
  2705. * @param vector1 angle between vector0 and vector1
  2706. * @param normal direction of the normal
  2707. * @return the angle between vector0 and vector1
  2708. */
  2709. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2710. /**
  2711. * Returns a new Vector3 set from the index "offset" of the given array
  2712. * @param array defines the source array
  2713. * @param offset defines the offset in the source array
  2714. * @returns the new Vector3
  2715. */
  2716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. * @deprecated Please use FromArray instead.
  2723. */
  2724. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2725. /**
  2726. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2727. * @param array defines the source array
  2728. * @param offset defines the offset in the source array
  2729. * @param result defines the Vector3 where to store the result
  2730. */
  2731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. * @deprecated Please use FromArrayToRef instead.
  2738. */
  2739. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2740. /**
  2741. * Sets the given vector "result" with the given floats.
  2742. * @param x defines the x coordinate of the source
  2743. * @param y defines the y coordinate of the source
  2744. * @param z defines the z coordinate of the source
  2745. * @param result defines the Vector3 where to store the result
  2746. */
  2747. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2748. /**
  2749. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2750. * @returns a new empty Vector3
  2751. */
  2752. static Zero(): Vector3;
  2753. /**
  2754. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2755. * @returns a new unit Vector3
  2756. */
  2757. static One(): Vector3;
  2758. /**
  2759. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2760. * @returns a new up Vector3
  2761. */
  2762. static Up(): Vector3;
  2763. /**
  2764. * Gets a up Vector3 that must not be updated
  2765. */
  2766. static get UpReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Gets a zero Vector3 that must not be updated
  2769. */
  2770. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2771. /**
  2772. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2773. * @returns a new down Vector3
  2774. */
  2775. static Down(): Vector3;
  2776. /**
  2777. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2778. * @returns a new forward Vector3
  2779. */
  2780. static Forward(): Vector3;
  2781. /**
  2782. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2783. * @returns a new forward Vector3
  2784. */
  2785. static Backward(): Vector3;
  2786. /**
  2787. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2788. * @returns a new right Vector3
  2789. */
  2790. static Right(): Vector3;
  2791. /**
  2792. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2793. * @returns a new left Vector3
  2794. */
  2795. static Left(): Vector3;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2798. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the transformed Vector3
  2802. */
  2803. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2806. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2814. * This method computes tranformed coordinates only, not transformed direction vectors
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2824. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2825. * @param vector defines the Vector3 to transform
  2826. * @param transformation defines the transformation matrix
  2827. * @returns the new Vector3
  2828. */
  2829. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2832. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2833. * @param vector defines the Vector3 to transform
  2834. * @param transformation defines the transformation matrix
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2840. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2841. * @param x define the x coordinate of the source vector
  2842. * @param y define the y coordinate of the source vector
  2843. * @param z define the z coordinate of the source vector
  2844. * @param transformation defines the transformation matrix
  2845. * @param result defines the Vector3 where to store the result
  2846. */
  2847. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2848. /**
  2849. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2850. * @param value1 defines the first control point
  2851. * @param value2 defines the second control point
  2852. * @param value3 defines the third control point
  2853. * @param value4 defines the fourth control point
  2854. * @param amount defines the amount on the spline to use
  2855. * @returns the new Vector3
  2856. */
  2857. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2858. /**
  2859. * 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"
  2860. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2861. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2862. * @param value defines the current value
  2863. * @param min defines the lower range value
  2864. * @param max defines the upper range value
  2865. * @returns the new Vector3
  2866. */
  2867. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2868. /**
  2869. * 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"
  2870. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2871. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2872. * @param value defines the current value
  2873. * @param min defines the lower range value
  2874. * @param max defines the upper range value
  2875. * @param result defines the Vector3 where to store the result
  2876. */
  2877. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2878. /**
  2879. * Checks if a given vector is inside a specific range
  2880. * @param v defines the vector to test
  2881. * @param min defines the minimum range
  2882. * @param max defines the maximum range
  2883. */
  2884. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2887. * @param value1 defines the first control point
  2888. * @param tangent1 defines the first tangent vector
  2889. * @param value2 defines the second control point
  2890. * @param tangent2 defines the second tangent vector
  2891. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2892. * @returns the new Vector3
  2893. */
  2894. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2895. /**
  2896. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2897. * @param start defines the start value
  2898. * @param end defines the end value
  2899. * @param amount max defines amount between both (between 0 and 1)
  2900. * @returns the new Vector3
  2901. */
  2902. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2903. /**
  2904. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2905. * @param start defines the start value
  2906. * @param end defines the end value
  2907. * @param amount max defines amount between both (between 0 and 1)
  2908. * @param result defines the Vector3 where to store the result
  2909. */
  2910. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2911. /**
  2912. * Returns the dot product (float) between the vectors "left" and "right"
  2913. * @param left defines the left operand
  2914. * @param right defines the right operand
  2915. * @returns the dot product
  2916. */
  2917. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2918. /**
  2919. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2920. * The cross product is then orthogonal to both "left" and "right"
  2921. * @param left defines the left operand
  2922. * @param right defines the right operand
  2923. * @returns the cross product
  2924. */
  2925. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2926. /**
  2927. * Sets the given vector "result" with the cross product of "left" and "right"
  2928. * The cross product is then orthogonal to both "left" and "right"
  2929. * @param left defines the left operand
  2930. * @param right defines the right operand
  2931. * @param result defines the Vector3 where to store the result
  2932. */
  2933. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2934. /**
  2935. * Returns a new Vector3 as the normalization of the given vector
  2936. * @param vector defines the Vector3 to normalize
  2937. * @returns the new Vector3
  2938. */
  2939. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2940. /**
  2941. * Sets the given vector "result" with the normalization of the given first vector
  2942. * @param vector defines the Vector3 to normalize
  2943. * @param result defines the Vector3 where to store the result
  2944. */
  2945. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2946. /**
  2947. * Project a Vector3 onto screen space
  2948. * @param vector defines the Vector3 to project
  2949. * @param world defines the world matrix to use
  2950. * @param transform defines the transform (view x projection) matrix to use
  2951. * @param viewport defines the screen viewport to use
  2952. * @returns the new Vector3
  2953. */
  2954. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2955. /** @hidden */
  2956. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2957. /**
  2958. * Unproject from screen space to object space
  2959. * @param source defines the screen space Vector3 to use
  2960. * @param viewportWidth defines the current width of the viewport
  2961. * @param viewportHeight defines the current height of the viewport
  2962. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2963. * @param transform defines the transform (view x projection) matrix to use
  2964. * @returns the new Vector3
  2965. */
  2966. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2967. /**
  2968. * Unproject from screen space to object space
  2969. * @param source defines the screen space Vector3 to use
  2970. * @param viewportWidth defines the current width of the viewport
  2971. * @param viewportHeight defines the current height of the viewport
  2972. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2973. * @param view defines the view matrix to use
  2974. * @param projection defines the projection matrix to use
  2975. * @returns the new Vector3
  2976. */
  2977. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2978. /**
  2979. * Unproject from screen space to object space
  2980. * @param source defines the screen space Vector3 to use
  2981. * @param viewportWidth defines the current width of the viewport
  2982. * @param viewportHeight defines the current height of the viewport
  2983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2984. * @param view defines the view matrix to use
  2985. * @param projection defines the projection matrix to use
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Unproject from screen space to object space
  2991. * @param sourceX defines the screen space x coordinate to use
  2992. * @param sourceY defines the screen space y coordinate to use
  2993. * @param sourceZ defines the screen space z coordinate to use
  2994. * @param viewportWidth defines the current width of the viewport
  2995. * @param viewportHeight defines the current height of the viewport
  2996. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2997. * @param view defines the view matrix to use
  2998. * @param projection defines the projection matrix to use
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Gets the minimal coordinate values between two Vector3
  3004. * @param left defines the first operand
  3005. * @param right defines the second operand
  3006. * @returns the new Vector3
  3007. */
  3008. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3009. /**
  3010. * Gets the maximal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Returns the distance between the vectors "value1" and "value2"
  3018. * @param value1 defines the first operand
  3019. * @param value2 defines the second operand
  3020. * @returns the distance
  3021. */
  3022. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3023. /**
  3024. * Returns the squared distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the squared distance
  3028. */
  3029. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns a new Vector3 located at the center between "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the new Vector3
  3035. */
  3036. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3037. /**
  3038. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3039. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3040. * to something in order to rotate it from its local system to the given target system
  3041. * Note: axis1, axis2 and axis3 are normalized during this operation
  3042. * @param axis1 defines the first axis
  3043. * @param axis2 defines the second axis
  3044. * @param axis3 defines the third axis
  3045. * @returns a new Vector3
  3046. */
  3047. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3050. * @param axis1 defines the first axis
  3051. * @param axis2 defines the second axis
  3052. * @param axis3 defines the third axis
  3053. * @param ref defines the Vector3 where to store the result
  3054. */
  3055. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3056. }
  3057. /**
  3058. * Vector4 class created for EulerAngle class conversion to Quaternion
  3059. */
  3060. export class Vector4 {
  3061. /** x value of the vector */
  3062. x: number;
  3063. /** y value of the vector */
  3064. y: number;
  3065. /** z value of the vector */
  3066. z: number;
  3067. /** w value of the vector */
  3068. w: number;
  3069. /**
  3070. * Creates a Vector4 object from the given floats.
  3071. * @param x x value of the vector
  3072. * @param y y value of the vector
  3073. * @param z z value of the vector
  3074. * @param w w value of the vector
  3075. */
  3076. constructor(
  3077. /** x value of the vector */
  3078. x: number,
  3079. /** y value of the vector */
  3080. y: number,
  3081. /** z value of the vector */
  3082. z: number,
  3083. /** w value of the vector */
  3084. w: number);
  3085. /**
  3086. * Returns the string with the Vector4 coordinates.
  3087. * @returns a string containing all the vector values
  3088. */
  3089. toString(): string;
  3090. /**
  3091. * Returns the string "Vector4".
  3092. * @returns "Vector4"
  3093. */
  3094. getClassName(): string;
  3095. /**
  3096. * Returns the Vector4 hash code.
  3097. * @returns a unique hash code
  3098. */
  3099. getHashCode(): number;
  3100. /**
  3101. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3102. * @returns the resulting array
  3103. */
  3104. asArray(): number[];
  3105. /**
  3106. * Populates the given array from the given index with the Vector4 coordinates.
  3107. * @param array array to populate
  3108. * @param index index of the array to start at (default: 0)
  3109. * @returns the Vector4.
  3110. */
  3111. toArray(array: FloatArray, index?: number): Vector4;
  3112. /**
  3113. * Adds the given vector to the current Vector4.
  3114. * @param otherVector the vector to add
  3115. * @returns the updated Vector4.
  3116. */
  3117. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3120. * @param otherVector the vector to add
  3121. * @returns the resulting vector
  3122. */
  3123. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3126. * @param otherVector the vector to add
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Subtract in place the given vector from the current Vector4.
  3133. * @param otherVector the vector to subtract
  3134. * @returns the updated Vector4.
  3135. */
  3136. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3137. /**
  3138. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3139. * @param otherVector the vector to add
  3140. * @returns the new vector with the result
  3141. */
  3142. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3143. /**
  3144. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3145. * @param otherVector the vector to subtract
  3146. * @param result the vector to store the result
  3147. * @returns the current Vector4.
  3148. */
  3149. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3150. /**
  3151. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3152. */
  3153. /**
  3154. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3155. * @param x value to subtract
  3156. * @param y value to subtract
  3157. * @param z value to subtract
  3158. * @param w value to subtract
  3159. * @returns new vector containing the result
  3160. */
  3161. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3162. /**
  3163. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3164. * @param x value to subtract
  3165. * @param y value to subtract
  3166. * @param z value to subtract
  3167. * @param w value to subtract
  3168. * @param result the vector to store the result in
  3169. * @returns the current Vector4.
  3170. */
  3171. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3172. /**
  3173. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3174. * @returns a new vector with the negated values
  3175. */
  3176. negate(): Vector4;
  3177. /**
  3178. * Negate this vector in place
  3179. * @returns this
  3180. */
  3181. negateInPlace(): Vector4;
  3182. /**
  3183. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3184. * @param result defines the Vector3 object where to store the result
  3185. * @returns the current Vector4
  3186. */
  3187. negateToRef(result: Vector4): Vector4;
  3188. /**
  3189. * Multiplies the current Vector4 coordinates by scale (float).
  3190. * @param scale the number to scale with
  3191. * @returns the updated Vector4.
  3192. */
  3193. scaleInPlace(scale: number): Vector4;
  3194. /**
  3195. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3196. * @param scale the number to scale with
  3197. * @returns a new vector with the result
  3198. */
  3199. scale(scale: number): Vector4;
  3200. /**
  3201. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3202. * @param scale the number to scale with
  3203. * @param result a vector to store the result in
  3204. * @returns the current Vector4.
  3205. */
  3206. scaleToRef(scale: number, result: Vector4): Vector4;
  3207. /**
  3208. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3209. * @param scale defines the scale factor
  3210. * @param result defines the Vector4 object where to store the result
  3211. * @returns the unmodified current Vector4
  3212. */
  3213. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3216. * @param otherVector the vector to compare against
  3217. * @returns true if they are equal
  3218. */
  3219. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3220. /**
  3221. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3222. * @param otherVector vector to compare against
  3223. * @param epsilon (Default: very small number)
  3224. * @returns true if they are equal
  3225. */
  3226. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3227. /**
  3228. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3229. * @param x x value to compare against
  3230. * @param y y value to compare against
  3231. * @param z z value to compare against
  3232. * @param w w value to compare against
  3233. * @returns true if equal
  3234. */
  3235. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3236. /**
  3237. * Multiplies in place the current Vector4 by the given one.
  3238. * @param otherVector vector to multiple with
  3239. * @returns the updated Vector4.
  3240. */
  3241. multiplyInPlace(otherVector: Vector4): Vector4;
  3242. /**
  3243. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3244. * @param otherVector vector to multiple with
  3245. * @returns resulting new vector
  3246. */
  3247. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3250. * @param otherVector vector to multiple with
  3251. * @param result vector to store the result
  3252. * @returns the current Vector4.
  3253. */
  3254. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3255. /**
  3256. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3257. * @param x x value multiply with
  3258. * @param y y value multiply with
  3259. * @param z z value multiply with
  3260. * @param w w value multiply with
  3261. * @returns resulting new vector
  3262. */
  3263. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3264. /**
  3265. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3266. * @param otherVector vector to devide with
  3267. * @returns resulting new vector
  3268. */
  3269. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3272. * @param otherVector vector to devide with
  3273. * @param result vector to store the result
  3274. * @returns the current Vector4.
  3275. */
  3276. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3277. /**
  3278. * Divides the current Vector3 coordinates by the given ones.
  3279. * @param otherVector vector to devide with
  3280. * @returns the updated Vector3.
  3281. */
  3282. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3283. /**
  3284. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3285. * @param other defines the second operand
  3286. * @returns the current updated Vector4
  3287. */
  3288. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3289. /**
  3290. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3291. * @param other defines the second operand
  3292. * @returns the current updated Vector4
  3293. */
  3294. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3295. /**
  3296. * Gets a new Vector4 from current Vector4 floored values
  3297. * @returns a new Vector4
  3298. */
  3299. floor(): Vector4;
  3300. /**
  3301. * Gets a new Vector4 from current Vector3 floored values
  3302. * @returns a new Vector4
  3303. */
  3304. fract(): Vector4;
  3305. /**
  3306. * Returns the Vector4 length (float).
  3307. * @returns the length
  3308. */
  3309. length(): number;
  3310. /**
  3311. * Returns the Vector4 squared length (float).
  3312. * @returns the length squared
  3313. */
  3314. lengthSquared(): number;
  3315. /**
  3316. * Normalizes in place the Vector4.
  3317. * @returns the updated Vector4.
  3318. */
  3319. normalize(): Vector4;
  3320. /**
  3321. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3322. * @returns this converted to a new vector3
  3323. */
  3324. toVector3(): Vector3;
  3325. /**
  3326. * Returns a new Vector4 copied from the current one.
  3327. * @returns the new cloned vector
  3328. */
  3329. clone(): Vector4;
  3330. /**
  3331. * Updates the current Vector4 with the given one coordinates.
  3332. * @param source the source vector to copy from
  3333. * @returns the updated Vector4.
  3334. */
  3335. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3336. /**
  3337. * Updates the current Vector4 coordinates with the given floats.
  3338. * @param x float to copy from
  3339. * @param y float to copy from
  3340. * @param z float to copy from
  3341. * @param w float to copy from
  3342. * @returns the updated Vector4.
  3343. */
  3344. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3345. /**
  3346. * Updates the current Vector4 coordinates with the given floats.
  3347. * @param x float to set from
  3348. * @param y float to set from
  3349. * @param z float to set from
  3350. * @param w float to set from
  3351. * @returns the updated Vector4.
  3352. */
  3353. set(x: number, y: number, z: number, w: number): Vector4;
  3354. /**
  3355. * Copies the given float to the current Vector3 coordinates
  3356. * @param v defines the x, y, z and w coordinates of the operand
  3357. * @returns the current updated Vector3
  3358. */
  3359. setAll(v: number): Vector4;
  3360. /**
  3361. * Returns a new Vector4 set from the starting index of the given array.
  3362. * @param array the array to pull values from
  3363. * @param offset the offset into the array to start at
  3364. * @returns the new vector
  3365. */
  3366. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3367. /**
  3368. * Updates the given vector "result" from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @param result the vector to store the result in
  3372. */
  3373. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3374. /**
  3375. * Updates the given vector "result" from the starting index of the given Float32Array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @param result the vector to store the result in
  3379. */
  3380. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" coordinates from the given floats.
  3383. * @param x float to set from
  3384. * @param y float to set from
  3385. * @param z float to set from
  3386. * @param w float to set from
  3387. * @param result the vector to the floats in
  3388. */
  3389. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3390. /**
  3391. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3392. * @returns the new vector
  3393. */
  3394. static Zero(): Vector4;
  3395. /**
  3396. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3397. * @returns the new vector
  3398. */
  3399. static One(): Vector4;
  3400. /**
  3401. * Returns a new normalized Vector4 from the given one.
  3402. * @param vector the vector to normalize
  3403. * @returns the vector
  3404. */
  3405. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3406. /**
  3407. * Updates the given vector "result" from the normalization of the given one.
  3408. * @param vector the vector to normalize
  3409. * @param result the vector to store the result in
  3410. */
  3411. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3412. /**
  3413. * Returns a vector with the minimum values from the left and right vectors
  3414. * @param left left vector to minimize
  3415. * @param right right vector to minimize
  3416. * @returns a new vector with the minimum of the left and right vector values
  3417. */
  3418. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3419. /**
  3420. * Returns a vector with the maximum values from the left and right vectors
  3421. * @param left left vector to maximize
  3422. * @param right right vector to maximize
  3423. * @returns a new vector with the maximum of the left and right vector values
  3424. */
  3425. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns the distance (float) between the vectors "value1" and "value2".
  3428. * @param value1 value to calulate the distance between
  3429. * @param value2 value to calulate the distance between
  3430. * @return the distance between the two vectors
  3431. */
  3432. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3433. /**
  3434. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors squared
  3438. */
  3439. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the center between
  3443. * @param value2 value to calulate the center between
  3444. * @return the center between the two vectors
  3445. */
  3446. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3447. /**
  3448. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3449. * This methods computes transformed normalized direction vectors only.
  3450. * @param vector the vector to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @returns the new vector
  3453. */
  3454. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3455. /**
  3456. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3457. * This methods computes transformed normalized direction vectors only.
  3458. * @param vector the vector to transform
  3459. * @param transformation the transformation matrix to apply
  3460. * @param result the vector to store the result in
  3461. */
  3462. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3463. /**
  3464. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3465. * This methods computes transformed normalized direction vectors only.
  3466. * @param x value to transform
  3467. * @param y value to transform
  3468. * @param z value to transform
  3469. * @param w value to transform
  3470. * @param transformation the transformation matrix to apply
  3471. * @param result the vector to store the results in
  3472. */
  3473. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3474. /**
  3475. * Creates a new Vector4 from a Vector3
  3476. * @param source defines the source data
  3477. * @param w defines the 4th component (default is 0)
  3478. * @returns a new Vector4
  3479. */
  3480. static FromVector3(source: Vector3, w?: number): Vector4;
  3481. }
  3482. /**
  3483. * Class used to store quaternion data
  3484. * @see https://en.wikipedia.org/wiki/Quaternion
  3485. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3486. */
  3487. export class Quaternion {
  3488. /** defines the first component (0 by default) */
  3489. x: number;
  3490. /** defines the second component (0 by default) */
  3491. y: number;
  3492. /** defines the third component (0 by default) */
  3493. z: number;
  3494. /** defines the fourth component (1.0 by default) */
  3495. w: number;
  3496. /**
  3497. * Creates a new Quaternion from the given floats
  3498. * @param x defines the first component (0 by default)
  3499. * @param y defines the second component (0 by default)
  3500. * @param z defines the third component (0 by default)
  3501. * @param w defines the fourth component (1.0 by default)
  3502. */
  3503. constructor(
  3504. /** defines the first component (0 by default) */
  3505. x?: number,
  3506. /** defines the second component (0 by default) */
  3507. y?: number,
  3508. /** defines the third component (0 by default) */
  3509. z?: number,
  3510. /** defines the fourth component (1.0 by default) */
  3511. w?: number);
  3512. /**
  3513. * Gets a string representation for the current quaternion
  3514. * @returns a string with the Quaternion coordinates
  3515. */
  3516. toString(): string;
  3517. /**
  3518. * Gets the class name of the quaternion
  3519. * @returns the string "Quaternion"
  3520. */
  3521. getClassName(): string;
  3522. /**
  3523. * Gets a hash code for this quaternion
  3524. * @returns the quaternion hash code
  3525. */
  3526. getHashCode(): number;
  3527. /**
  3528. * Copy the quaternion to an array
  3529. * @returns a new array populated with 4 elements from the quaternion coordinates
  3530. */
  3531. asArray(): number[];
  3532. /**
  3533. * Check if two quaternions are equals
  3534. * @param otherQuaternion defines the second operand
  3535. * @return true if the current quaternion and the given one coordinates are strictly equals
  3536. */
  3537. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3538. /**
  3539. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3540. * @param otherQuaternion defines the other quaternion
  3541. * @param epsilon defines the minimal distance to consider equality
  3542. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3543. */
  3544. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3545. /**
  3546. * Clone the current quaternion
  3547. * @returns a new quaternion copied from the current one
  3548. */
  3549. clone(): Quaternion;
  3550. /**
  3551. * Copy a quaternion to the current one
  3552. * @param other defines the other quaternion
  3553. * @returns the updated current quaternion
  3554. */
  3555. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3556. /**
  3557. * Updates the current quaternion with the given float coordinates
  3558. * @param x defines the x coordinate
  3559. * @param y defines the y coordinate
  3560. * @param z defines the z coordinate
  3561. * @param w defines the w coordinate
  3562. * @returns the updated current quaternion
  3563. */
  3564. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3565. /**
  3566. * Updates the current quaternion from the given float coordinates
  3567. * @param x defines the x coordinate
  3568. * @param y defines the y coordinate
  3569. * @param z defines the z coordinate
  3570. * @param w defines the w coordinate
  3571. * @returns the updated current quaternion
  3572. */
  3573. set(x: number, y: number, z: number, w: number): Quaternion;
  3574. /**
  3575. * Adds two quaternions
  3576. * @param other defines the second operand
  3577. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3578. */
  3579. add(other: DeepImmutable<Quaternion>): Quaternion;
  3580. /**
  3581. * Add a quaternion to the current one
  3582. * @param other defines the quaternion to add
  3583. * @returns the current quaternion
  3584. */
  3585. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3586. /**
  3587. * Subtract two quaternions
  3588. * @param other defines the second operand
  3589. * @returns a new quaternion as the subtraction result of the given one from the current one
  3590. */
  3591. subtract(other: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies the current quaternion by a scale factor
  3594. * @param value defines the scale factor
  3595. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3596. */
  3597. scale(value: number): Quaternion;
  3598. /**
  3599. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3600. * @param scale defines the scale factor
  3601. * @param result defines the Quaternion object where to store the result
  3602. * @returns the unmodified current quaternion
  3603. */
  3604. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3605. /**
  3606. * Multiplies in place the current quaternion by a scale factor
  3607. * @param value defines the scale factor
  3608. * @returns the current modified quaternion
  3609. */
  3610. scaleInPlace(value: number): Quaternion;
  3611. /**
  3612. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3613. * @param scale defines the scale factor
  3614. * @param result defines the Quaternion object where to store the result
  3615. * @returns the unmodified current quaternion
  3616. */
  3617. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3618. /**
  3619. * Multiplies two quaternions
  3620. * @param q1 defines the second operand
  3621. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3622. */
  3623. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3624. /**
  3625. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3626. * @param q1 defines the second operand
  3627. * @param result defines the target quaternion
  3628. * @returns the current quaternion
  3629. */
  3630. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3631. /**
  3632. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @returns the currentupdated quaternion
  3635. */
  3636. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3637. /**
  3638. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3639. * @param ref defines the target quaternion
  3640. * @returns the current quaternion
  3641. */
  3642. conjugateToRef(ref: Quaternion): Quaternion;
  3643. /**
  3644. * Conjugates in place (1-q) the current quaternion
  3645. * @returns the current updated quaternion
  3646. */
  3647. conjugateInPlace(): Quaternion;
  3648. /**
  3649. * Conjugates in place (1-q) the current quaternion
  3650. * @returns a new quaternion
  3651. */
  3652. conjugate(): Quaternion;
  3653. /**
  3654. * Gets length of current quaternion
  3655. * @returns the quaternion length (float)
  3656. */
  3657. length(): number;
  3658. /**
  3659. * Normalize in place the current quaternion
  3660. * @returns the current updated quaternion
  3661. */
  3662. normalize(): Quaternion;
  3663. /**
  3664. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3665. * @param order is a reserved parameter and is ignore for now
  3666. * @returns a new Vector3 containing the Euler angles
  3667. */
  3668. toEulerAngles(order?: string): Vector3;
  3669. /**
  3670. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3671. * @param result defines the vector which will be filled with the Euler angles
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns the current unchanged quaternion
  3674. */
  3675. toEulerAnglesToRef(result: Vector3): Quaternion;
  3676. /**
  3677. * Updates the given rotation matrix with the current quaternion values
  3678. * @param result defines the target matrix
  3679. * @returns the current unchanged quaternion
  3680. */
  3681. toRotationMatrix(result: Matrix): Quaternion;
  3682. /**
  3683. * Updates the current quaternion from the given rotation matrix values
  3684. * @param matrix defines the source matrix
  3685. * @returns the current updated quaternion
  3686. */
  3687. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3688. /**
  3689. * Creates a new quaternion from a rotation matrix
  3690. * @param matrix defines the source matrix
  3691. * @returns a new quaternion created from the given rotation matrix values
  3692. */
  3693. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3694. /**
  3695. * Updates the given quaternion with the given rotation matrix values
  3696. * @param matrix defines the source matrix
  3697. * @param result defines the target quaternion
  3698. */
  3699. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3700. /**
  3701. * Returns the dot product (float) between the quaternions "left" and "right"
  3702. * @param left defines the left operand
  3703. * @param right defines the right operand
  3704. * @returns the dot product
  3705. */
  3706. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3707. /**
  3708. * Checks if the two quaternions are close to each other
  3709. * @param quat0 defines the first quaternion to check
  3710. * @param quat1 defines the second quaternion to check
  3711. * @returns true if the two quaternions are close to each other
  3712. */
  3713. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3714. /**
  3715. * Creates an empty quaternion
  3716. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3717. */
  3718. static Zero(): Quaternion;
  3719. /**
  3720. * Inverse a given quaternion
  3721. * @param q defines the source quaternion
  3722. * @returns a new quaternion as the inverted current quaternion
  3723. */
  3724. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3725. /**
  3726. * Inverse a given quaternion
  3727. * @param q defines the source quaternion
  3728. * @param result the quaternion the result will be stored in
  3729. * @returns the result quaternion
  3730. */
  3731. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates an identity quaternion
  3734. * @returns the identity quaternion
  3735. */
  3736. static Identity(): Quaternion;
  3737. /**
  3738. * Gets a boolean indicating if the given quaternion is identity
  3739. * @param quaternion defines the quaternion to check
  3740. * @returns true if the quaternion is identity
  3741. */
  3742. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3743. /**
  3744. * Creates a quaternion from a rotation around an axis
  3745. * @param axis defines the axis to use
  3746. * @param angle defines the angle to use
  3747. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3748. */
  3749. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3750. /**
  3751. * Creates a rotation around an axis and stores it into the given quaternion
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @param result defines the target quaternion
  3755. * @returns the target quaternion
  3756. */
  3757. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from data stored into an array
  3760. * @param array defines the data source
  3761. * @param offset defines the offset in the source array where the data starts
  3762. * @returns a new quaternion
  3763. */
  3764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3765. /**
  3766. * Create a quaternion from Euler rotation angles
  3767. * @param x Pitch
  3768. * @param y Yaw
  3769. * @param z Roll
  3770. * @returns the new Quaternion
  3771. */
  3772. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3773. /**
  3774. * Updates a quaternion from Euler rotation angles
  3775. * @param x Pitch
  3776. * @param y Yaw
  3777. * @param z Roll
  3778. * @param result the quaternion to store the result
  3779. * @returns the updated quaternion
  3780. */
  3781. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3782. /**
  3783. * Create a quaternion from Euler rotation vector
  3784. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3785. * @returns the new Quaternion
  3786. */
  3787. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3788. /**
  3789. * Updates a quaternion from Euler rotation vector
  3790. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3791. * @param result the quaternion to store the result
  3792. * @returns the updated quaternion
  3793. */
  3794. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3795. /**
  3796. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3797. * @param yaw defines the rotation around Y axis
  3798. * @param pitch defines the rotation around X axis
  3799. * @param roll defines the rotation around Z axis
  3800. * @returns the new quaternion
  3801. */
  3802. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3803. /**
  3804. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3805. * @param yaw defines the rotation around Y axis
  3806. * @param pitch defines the rotation around X axis
  3807. * @param roll defines the rotation around Z axis
  3808. * @param result defines the target quaternion
  3809. */
  3810. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3811. /**
  3812. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3813. * @param alpha defines the rotation around first axis
  3814. * @param beta defines the rotation around second axis
  3815. * @param gamma defines the rotation around third axis
  3816. * @returns the new quaternion
  3817. */
  3818. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3819. /**
  3820. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3821. * @param alpha defines the rotation around first axis
  3822. * @param beta defines the rotation around second axis
  3823. * @param gamma defines the rotation around third axis
  3824. * @param result defines the target quaternion
  3825. */
  3826. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3827. /**
  3828. * 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)
  3829. * @param axis1 defines the first axis
  3830. * @param axis2 defines the second axis
  3831. * @param axis3 defines the third axis
  3832. * @returns the new quaternion
  3833. */
  3834. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3835. /**
  3836. * 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
  3837. * @param axis1 defines the first axis
  3838. * @param axis2 defines the second axis
  3839. * @param axis3 defines the third axis
  3840. * @param ref defines the target quaternion
  3841. */
  3842. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3843. /**
  3844. * Interpolates between two quaternions
  3845. * @param left defines first quaternion
  3846. * @param right defines second quaternion
  3847. * @param amount defines the gradient to use
  3848. * @returns the new interpolated quaternion
  3849. */
  3850. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3851. /**
  3852. * Interpolates between two quaternions and stores it into a target quaternion
  3853. * @param left defines first quaternion
  3854. * @param right defines second quaternion
  3855. * @param amount defines the gradient to use
  3856. * @param result defines the target quaternion
  3857. */
  3858. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3859. /**
  3860. * Interpolate between two quaternions using Hermite interpolation
  3861. * @param value1 defines first quaternion
  3862. * @param tangent1 defines the incoming tangent
  3863. * @param value2 defines second quaternion
  3864. * @param tangent2 defines the outgoing tangent
  3865. * @param amount defines the target quaternion
  3866. * @returns the new interpolated quaternion
  3867. */
  3868. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3869. }
  3870. /**
  3871. * Class used to store matrix data (4x4)
  3872. */
  3873. export class Matrix {
  3874. private static _updateFlagSeed;
  3875. private static _identityReadOnly;
  3876. private _isIdentity;
  3877. private _isIdentityDirty;
  3878. private _isIdentity3x2;
  3879. private _isIdentity3x2Dirty;
  3880. /**
  3881. * Gets the update flag of the matrix which is an unique number for the matrix.
  3882. * It will be incremented every time the matrix data change.
  3883. * You can use it to speed the comparison between two versions of the same matrix.
  3884. */
  3885. updateFlag: number;
  3886. private readonly _m;
  3887. /**
  3888. * Gets the internal data of the matrix
  3889. */
  3890. get m(): DeepImmutable<Float32Array>;
  3891. /** @hidden */
  3892. _markAsUpdated(): void;
  3893. /** @hidden */
  3894. private _updateIdentityStatus;
  3895. /**
  3896. * Creates an empty matrix (filled with zeros)
  3897. */
  3898. constructor();
  3899. /**
  3900. * Check if the current matrix is identity
  3901. * @returns true is the matrix is the identity matrix
  3902. */
  3903. isIdentity(): boolean;
  3904. /**
  3905. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3906. * @returns true is the matrix is the identity matrix
  3907. */
  3908. isIdentityAs3x2(): boolean;
  3909. /**
  3910. * Gets the determinant of the matrix
  3911. * @returns the matrix determinant
  3912. */
  3913. determinant(): number;
  3914. /**
  3915. * Returns the matrix as a Float32Array
  3916. * @returns the matrix underlying array
  3917. */
  3918. toArray(): DeepImmutable<Float32Array>;
  3919. /**
  3920. * Returns the matrix as a Float32Array
  3921. * @returns the matrix underlying array.
  3922. */
  3923. asArray(): DeepImmutable<Float32Array>;
  3924. /**
  3925. * Inverts the current matrix in place
  3926. * @returns the current inverted matrix
  3927. */
  3928. invert(): Matrix;
  3929. /**
  3930. * Sets all the matrix elements to zero
  3931. * @returns the current matrix
  3932. */
  3933. reset(): Matrix;
  3934. /**
  3935. * Adds the current matrix with a second one
  3936. * @param other defines the matrix to add
  3937. * @returns a new matrix as the addition of the current matrix and the given one
  3938. */
  3939. add(other: DeepImmutable<Matrix>): Matrix;
  3940. /**
  3941. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3942. * @param other defines the matrix to add
  3943. * @param result defines the target matrix
  3944. * @returns the current matrix
  3945. */
  3946. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3947. /**
  3948. * Adds in place the given matrix to the current matrix
  3949. * @param other defines the second operand
  3950. * @returns the current updated matrix
  3951. */
  3952. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3953. /**
  3954. * Sets the given matrix to the current inverted Matrix
  3955. * @param other defines the target matrix
  3956. * @returns the unmodified current matrix
  3957. */
  3958. invertToRef(other: Matrix): Matrix;
  3959. /**
  3960. * add a value at the specified position in the current Matrix
  3961. * @param index the index of the value within the matrix. between 0 and 15.
  3962. * @param value the value to be added
  3963. * @returns the current updated matrix
  3964. */
  3965. addAtIndex(index: number, value: number): Matrix;
  3966. /**
  3967. * mutiply the specified position in the current Matrix by a value
  3968. * @param index the index of the value within the matrix. between 0 and 15.
  3969. * @param value the value to be added
  3970. * @returns the current updated matrix
  3971. */
  3972. multiplyAtIndex(index: number, value: number): Matrix;
  3973. /**
  3974. * Inserts the translation vector (using 3 floats) in the current matrix
  3975. * @param x defines the 1st component of the translation
  3976. * @param y defines the 2nd component of the translation
  3977. * @param z defines the 3rd component of the translation
  3978. * @returns the current updated matrix
  3979. */
  3980. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3981. /**
  3982. * Adds the translation vector (using 3 floats) in the current matrix
  3983. * @param x defines the 1st component of the translation
  3984. * @param y defines the 2nd component of the translation
  3985. * @param z defines the 3rd component of the translation
  3986. * @returns the current updated matrix
  3987. */
  3988. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3989. /**
  3990. * Inserts the translation vector in the current matrix
  3991. * @param vector3 defines the translation to insert
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3995. /**
  3996. * Gets the translation value of the current matrix
  3997. * @returns a new Vector3 as the extracted translation from the matrix
  3998. */
  3999. getTranslation(): Vector3;
  4000. /**
  4001. * Fill a Vector3 with the extracted translation from the matrix
  4002. * @param result defines the Vector3 where to store the translation
  4003. * @returns the current matrix
  4004. */
  4005. getTranslationToRef(result: Vector3): Matrix;
  4006. /**
  4007. * Remove rotation and scaling part from the matrix
  4008. * @returns the updated matrix
  4009. */
  4010. removeRotationAndScaling(): Matrix;
  4011. /**
  4012. * Multiply two matrices
  4013. * @param other defines the second operand
  4014. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4015. */
  4016. multiply(other: DeepImmutable<Matrix>): Matrix;
  4017. /**
  4018. * Copy the current matrix from the given one
  4019. * @param other defines the source matrix
  4020. * @returns the current updated matrix
  4021. */
  4022. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4023. /**
  4024. * Populates the given array from the starting index with the current matrix values
  4025. * @param array defines the target array
  4026. * @param offset defines the offset in the target array where to start storing values
  4027. * @returns the current matrix
  4028. */
  4029. copyToArray(array: Float32Array, offset?: number): Matrix;
  4030. /**
  4031. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4032. * @param other defines the second operand
  4033. * @param result defines the matrix where to store the multiplication
  4034. * @returns the current matrix
  4035. */
  4036. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4037. /**
  4038. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4039. * @param other defines the second operand
  4040. * @param result defines the array where to store the multiplication
  4041. * @param offset defines the offset in the target array where to start storing values
  4042. * @returns the current matrix
  4043. */
  4044. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4045. /**
  4046. * Check equality between this matrix and a second one
  4047. * @param value defines the second matrix to compare
  4048. * @returns true is the current matrix and the given one values are strictly equal
  4049. */
  4050. equals(value: DeepImmutable<Matrix>): boolean;
  4051. /**
  4052. * Clone the current matrix
  4053. * @returns a new matrix from the current matrix
  4054. */
  4055. clone(): Matrix;
  4056. /**
  4057. * Returns the name of the current matrix class
  4058. * @returns the string "Matrix"
  4059. */
  4060. getClassName(): string;
  4061. /**
  4062. * Gets the hash code of the current matrix
  4063. * @returns the hash code
  4064. */
  4065. getHashCode(): number;
  4066. /**
  4067. * Decomposes the current Matrix into a translation, rotation and scaling components
  4068. * @param scale defines the scale vector3 given as a reference to update
  4069. * @param rotation defines the rotation quaternion given as a reference to update
  4070. * @param translation defines the translation vector3 given as a reference to update
  4071. * @returns true if operation was successful
  4072. */
  4073. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4074. /**
  4075. * Gets specific row of the matrix
  4076. * @param index defines the number of the row to get
  4077. * @returns the index-th row of the current matrix as a new Vector4
  4078. */
  4079. getRow(index: number): Nullable<Vector4>;
  4080. /**
  4081. * Sets the index-th row of the current matrix to the vector4 values
  4082. * @param index defines the number of the row to set
  4083. * @param row defines the target vector4
  4084. * @returns the updated current matrix
  4085. */
  4086. setRow(index: number, row: Vector4): Matrix;
  4087. /**
  4088. * Compute the transpose of the matrix
  4089. * @returns the new transposed matrix
  4090. */
  4091. transpose(): Matrix;
  4092. /**
  4093. * Compute the transpose of the matrix and store it in a given matrix
  4094. * @param result defines the target matrix
  4095. * @returns the current matrix
  4096. */
  4097. transposeToRef(result: Matrix): Matrix;
  4098. /**
  4099. * Sets the index-th row of the current matrix with the given 4 x float values
  4100. * @param index defines the row index
  4101. * @param x defines the x component to set
  4102. * @param y defines the y component to set
  4103. * @param z defines the z component to set
  4104. * @param w defines the w component to set
  4105. * @returns the updated current matrix
  4106. */
  4107. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4108. /**
  4109. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4110. * @param scale defines the scale factor
  4111. * @returns a new matrix
  4112. */
  4113. scale(scale: number): Matrix;
  4114. /**
  4115. * Scale the current matrix values by a factor to a given result matrix
  4116. * @param scale defines the scale factor
  4117. * @param result defines the matrix to store the result
  4118. * @returns the current matrix
  4119. */
  4120. scaleToRef(scale: number, result: Matrix): Matrix;
  4121. /**
  4122. * Scale the current matrix values by a factor and add the result to a given matrix
  4123. * @param scale defines the scale factor
  4124. * @param result defines the Matrix to store the result
  4125. * @returns the current matrix
  4126. */
  4127. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4128. /**
  4129. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4130. * @param ref matrix to store the result
  4131. */
  4132. toNormalMatrix(ref: Matrix): void;
  4133. /**
  4134. * Gets only rotation part of the current matrix
  4135. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4136. */
  4137. getRotationMatrix(): Matrix;
  4138. /**
  4139. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4140. * @param result defines the target matrix to store data to
  4141. * @returns the current matrix
  4142. */
  4143. getRotationMatrixToRef(result: Matrix): Matrix;
  4144. /**
  4145. * Toggles model matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleModelMatrixHandInPlace(): void;
  4148. /**
  4149. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4150. */
  4151. toggleProjectionMatrixHandInPlace(): void;
  4152. /**
  4153. * Creates a matrix from an array
  4154. * @param array defines the source array
  4155. * @param offset defines an offset in the source array
  4156. * @returns a new Matrix set from the starting index of the given array
  4157. */
  4158. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4159. /**
  4160. * Copy the content of an array into a given matrix
  4161. * @param array defines the source array
  4162. * @param offset defines an offset in the source array
  4163. * @param result defines the target matrix
  4164. */
  4165. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4166. /**
  4167. * Stores an array into a matrix after having multiplied each component by a given factor
  4168. * @param array defines the source array
  4169. * @param offset defines the offset in the source array
  4170. * @param scale defines the scaling factor
  4171. * @param result defines the target matrix
  4172. */
  4173. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4174. /**
  4175. * Gets an identity matrix that must not be updated
  4176. */
  4177. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4178. /**
  4179. * Stores a list of values (16) inside a given matrix
  4180. * @param initialM11 defines 1st value of 1st row
  4181. * @param initialM12 defines 2nd value of 1st row
  4182. * @param initialM13 defines 3rd value of 1st row
  4183. * @param initialM14 defines 4th value of 1st row
  4184. * @param initialM21 defines 1st value of 2nd row
  4185. * @param initialM22 defines 2nd value of 2nd row
  4186. * @param initialM23 defines 3rd value of 2nd row
  4187. * @param initialM24 defines 4th value of 2nd row
  4188. * @param initialM31 defines 1st value of 3rd row
  4189. * @param initialM32 defines 2nd value of 3rd row
  4190. * @param initialM33 defines 3rd value of 3rd row
  4191. * @param initialM34 defines 4th value of 3rd row
  4192. * @param initialM41 defines 1st value of 4th row
  4193. * @param initialM42 defines 2nd value of 4th row
  4194. * @param initialM43 defines 3rd value of 4th row
  4195. * @param initialM44 defines 4th value of 4th row
  4196. * @param result defines the target matrix
  4197. */
  4198. 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;
  4199. /**
  4200. * Creates new matrix from a list of values (16)
  4201. * @param initialM11 defines 1st value of 1st row
  4202. * @param initialM12 defines 2nd value of 1st row
  4203. * @param initialM13 defines 3rd value of 1st row
  4204. * @param initialM14 defines 4th value of 1st row
  4205. * @param initialM21 defines 1st value of 2nd row
  4206. * @param initialM22 defines 2nd value of 2nd row
  4207. * @param initialM23 defines 3rd value of 2nd row
  4208. * @param initialM24 defines 4th value of 2nd row
  4209. * @param initialM31 defines 1st value of 3rd row
  4210. * @param initialM32 defines 2nd value of 3rd row
  4211. * @param initialM33 defines 3rd value of 3rd row
  4212. * @param initialM34 defines 4th value of 3rd row
  4213. * @param initialM41 defines 1st value of 4th row
  4214. * @param initialM42 defines 2nd value of 4th row
  4215. * @param initialM43 defines 3rd value of 4th row
  4216. * @param initialM44 defines 4th value of 4th row
  4217. * @returns the new matrix
  4218. */
  4219. 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;
  4220. /**
  4221. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4222. * @param scale defines the scale vector3
  4223. * @param rotation defines the rotation quaternion
  4224. * @param translation defines the translation vector3
  4225. * @returns a new matrix
  4226. */
  4227. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4228. /**
  4229. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4230. * @param scale defines the scale vector3
  4231. * @param rotation defines the rotation quaternion
  4232. * @param translation defines the translation vector3
  4233. * @param result defines the target matrix
  4234. */
  4235. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4236. /**
  4237. * Creates a new identity matrix
  4238. * @returns a new identity matrix
  4239. */
  4240. static Identity(): Matrix;
  4241. /**
  4242. * Creates a new identity matrix and stores the result in a given matrix
  4243. * @param result defines the target matrix
  4244. */
  4245. static IdentityToRef(result: Matrix): void;
  4246. /**
  4247. * Creates a new zero matrix
  4248. * @returns a new zero matrix
  4249. */
  4250. static Zero(): Matrix;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the X axis
  4253. * @param angle defines the angle (in radians) to use
  4254. * @return the new matrix
  4255. */
  4256. static RotationX(angle: number): Matrix;
  4257. /**
  4258. * Creates a new matrix as the invert of a given matrix
  4259. * @param source defines the source matrix
  4260. * @returns the new matrix
  4261. */
  4262. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4265. * @param angle defines the angle (in radians) to use
  4266. * @param result defines the target matrix
  4267. */
  4268. static RotationXToRef(angle: number, result: Matrix): void;
  4269. /**
  4270. * Creates a new rotation matrix for "angle" radians around the Y axis
  4271. * @param angle defines the angle (in radians) to use
  4272. * @return the new matrix
  4273. */
  4274. static RotationY(angle: number): Matrix;
  4275. /**
  4276. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4277. * @param angle defines the angle (in radians) to use
  4278. * @param result defines the target matrix
  4279. */
  4280. static RotationYToRef(angle: number, result: Matrix): void;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the Z axis
  4283. * @param angle defines the angle (in radians) to use
  4284. * @return the new matrix
  4285. */
  4286. static RotationZ(angle: number): Matrix;
  4287. /**
  4288. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4289. * @param angle defines the angle (in radians) to use
  4290. * @param result defines the target matrix
  4291. */
  4292. static RotationZToRef(angle: number, result: Matrix): void;
  4293. /**
  4294. * Creates a new rotation matrix for "angle" radians around the given axis
  4295. * @param axis defines the axis to use
  4296. * @param angle defines the angle (in radians) to use
  4297. * @return the new matrix
  4298. */
  4299. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4300. /**
  4301. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4302. * @param axis defines the axis to use
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4307. /**
  4308. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4309. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4310. * @param from defines the vector to align
  4311. * @param to defines the vector to align to
  4312. * @param result defines the target matrix
  4313. */
  4314. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4315. /**
  4316. * Creates a rotation matrix
  4317. * @param yaw defines the yaw angle in radians (Y axis)
  4318. * @param pitch defines the pitch angle in radians (X axis)
  4319. * @param roll defines the roll angle in radians (X axis)
  4320. * @returns the new rotation matrix
  4321. */
  4322. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4323. /**
  4324. * Creates a rotation matrix and stores it in a given matrix
  4325. * @param yaw defines the yaw angle in radians (Y axis)
  4326. * @param pitch defines the pitch angle in radians (X axis)
  4327. * @param roll defines the roll angle in radians (X axis)
  4328. * @param result defines the target matrix
  4329. */
  4330. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4331. /**
  4332. * Creates a scaling matrix
  4333. * @param x defines the scale factor on X axis
  4334. * @param y defines the scale factor on Y axis
  4335. * @param z defines the scale factor on Z axis
  4336. * @returns the new matrix
  4337. */
  4338. static Scaling(x: number, y: number, z: number): Matrix;
  4339. /**
  4340. * Creates a scaling matrix and stores it in a given matrix
  4341. * @param x defines the scale factor on X axis
  4342. * @param y defines the scale factor on Y axis
  4343. * @param z defines the scale factor on Z axis
  4344. * @param result defines the target matrix
  4345. */
  4346. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4347. /**
  4348. * Creates a translation matrix
  4349. * @param x defines the translation on X axis
  4350. * @param y defines the translation on Y axis
  4351. * @param z defines the translationon Z axis
  4352. * @returns the new matrix
  4353. */
  4354. static Translation(x: number, y: number, z: number): Matrix;
  4355. /**
  4356. * Creates a translation matrix and stores it in a given matrix
  4357. * @param x defines the translation on X axis
  4358. * @param y defines the translation on Y axis
  4359. * @param z defines the translationon Z axis
  4360. * @param result defines the target matrix
  4361. */
  4362. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4363. /**
  4364. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4365. * @param startValue defines the start value
  4366. * @param endValue defines the end value
  4367. * @param gradient defines the gradient factor
  4368. * @returns the new matrix
  4369. */
  4370. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4373. * @param startValue defines the start value
  4374. * @param endValue defines the end value
  4375. * @param gradient defines the gradient factor
  4376. * @param result defines the Matrix object where to store data
  4377. */
  4378. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4379. /**
  4380. * Builds a new matrix whose values are computed by:
  4381. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4382. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4383. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4384. * @param startValue defines the first matrix
  4385. * @param endValue defines the second matrix
  4386. * @param gradient defines the gradient between the two matrices
  4387. * @returns the new matrix
  4388. */
  4389. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4390. /**
  4391. * Update a matrix to values which are computed by:
  4392. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4393. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4394. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4395. * @param startValue defines the first matrix
  4396. * @param endValue defines the second matrix
  4397. * @param gradient defines the gradient between the two matrices
  4398. * @param result defines the target matrix
  4399. */
  4400. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4401. /**
  4402. * 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"
  4403. * This function works in left handed mode
  4404. * @param eye defines the final position of the entity
  4405. * @param target defines where the entity should look at
  4406. * @param up defines the up vector for the entity
  4407. * @returns the new matrix
  4408. */
  4409. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4410. /**
  4411. * 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".
  4412. * This function works in left handed mode
  4413. * @param eye defines the final position of the entity
  4414. * @param target defines where the entity should look at
  4415. * @param up defines the up vector for the entity
  4416. * @param result defines the target matrix
  4417. */
  4418. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4419. /**
  4420. * 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"
  4421. * This function works in right handed mode
  4422. * @param eye defines the final position of the entity
  4423. * @param target defines where the entity should look at
  4424. * @param up defines the up vector for the entity
  4425. * @returns the new matrix
  4426. */
  4427. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4428. /**
  4429. * 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".
  4430. * This function works in right handed mode
  4431. * @param eye defines the final position of the entity
  4432. * @param target defines where the entity should look at
  4433. * @param up defines the up vector for the entity
  4434. * @param result defines the target matrix
  4435. */
  4436. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Create a left-handed orthographic projection matrix
  4439. * @param width defines the viewport width
  4440. * @param height defines the viewport height
  4441. * @param znear defines the near clip plane
  4442. * @param zfar defines the far clip plane
  4443. * @returns a new matrix as a left-handed orthographic projection matrix
  4444. */
  4445. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4446. /**
  4447. * Store a left-handed orthographic projection to a given matrix
  4448. * @param width defines the viewport width
  4449. * @param height defines the viewport height
  4450. * @param znear defines the near clip plane
  4451. * @param zfar defines the far clip plane
  4452. * @param result defines the target matrix
  4453. */
  4454. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4455. /**
  4456. * Create a left-handed orthographic projection matrix
  4457. * @param left defines the viewport left coordinate
  4458. * @param right defines the viewport right coordinate
  4459. * @param bottom defines the viewport bottom coordinate
  4460. * @param top defines the viewport top coordinate
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @returns a new matrix as a left-handed orthographic projection matrix
  4464. */
  4465. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4466. /**
  4467. * Stores a left-handed orthographic projection into a given matrix
  4468. * @param left defines the viewport left coordinate
  4469. * @param right defines the viewport right coordinate
  4470. * @param bottom defines the viewport bottom coordinate
  4471. * @param top defines the viewport top coordinate
  4472. * @param znear defines the near clip plane
  4473. * @param zfar defines the far clip plane
  4474. * @param result defines the target matrix
  4475. */
  4476. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4477. /**
  4478. * Creates a right-handed orthographic projection matrix
  4479. * @param left defines the viewport left coordinate
  4480. * @param right defines the viewport right coordinate
  4481. * @param bottom defines the viewport bottom coordinate
  4482. * @param top defines the viewport top coordinate
  4483. * @param znear defines the near clip plane
  4484. * @param zfar defines the far clip plane
  4485. * @returns a new matrix as a right-handed orthographic projection matrix
  4486. */
  4487. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4488. /**
  4489. * Stores a right-handed orthographic projection into a given matrix
  4490. * @param left defines the viewport left coordinate
  4491. * @param right defines the viewport right coordinate
  4492. * @param bottom defines the viewport bottom coordinate
  4493. * @param top defines the viewport top coordinate
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @param result defines the target matrix
  4497. */
  4498. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4499. /**
  4500. * Creates a left-handed perspective projection matrix
  4501. * @param width defines the viewport width
  4502. * @param height defines the viewport height
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @returns a new matrix as a left-handed perspective projection matrix
  4506. */
  4507. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4508. /**
  4509. * Creates a left-handed perspective projection matrix
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @returns a new matrix as a left-handed perspective projection matrix
  4515. */
  4516. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar defines the far clip plane
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar not used as infinity is used as far clip
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Creates a right-handed perspective projection matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar defines the far clip plane
  4543. * @returns a new matrix as a right-handed perspective projection matrix
  4544. */
  4545. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a right-handed perspective projection into a given matrix
  4558. * @param fov defines the horizontal field of view
  4559. * @param aspect defines the aspect ratio
  4560. * @param znear defines the near clip plane
  4561. * @param zfar not used as infinity is used as far clip
  4562. * @param result defines the target matrix
  4563. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4564. */
  4565. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4566. /**
  4567. * Stores a perspective projection for WebVR info a given matrix
  4568. * @param fov defines the field of view
  4569. * @param znear defines the near clip plane
  4570. * @param zfar defines the far clip plane
  4571. * @param result defines the target matrix
  4572. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4573. */
  4574. static PerspectiveFovWebVRToRef(fov: {
  4575. upDegrees: number;
  4576. downDegrees: number;
  4577. leftDegrees: number;
  4578. rightDegrees: number;
  4579. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4580. /**
  4581. * Computes a complete transformation matrix
  4582. * @param viewport defines the viewport to use
  4583. * @param world defines the world matrix
  4584. * @param view defines the view matrix
  4585. * @param projection defines the projection matrix
  4586. * @param zmin defines the near clip plane
  4587. * @param zmax defines the far clip plane
  4588. * @returns the transformation matrix
  4589. */
  4590. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4591. /**
  4592. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4593. * @param matrix defines the matrix to use
  4594. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4595. */
  4596. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4597. /**
  4598. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4599. * @param matrix defines the matrix to use
  4600. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4601. */
  4602. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4603. /**
  4604. * Compute the transpose of a given matrix
  4605. * @param matrix defines the matrix to transpose
  4606. * @returns the new matrix
  4607. */
  4608. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4609. /**
  4610. * Compute the transpose of a matrix and store it in a target matrix
  4611. * @param matrix defines the matrix to transpose
  4612. * @param result defines the target matrix
  4613. */
  4614. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4615. /**
  4616. * Computes a reflection matrix from a plane
  4617. * @param plane defines the reflection plane
  4618. * @returns a new matrix
  4619. */
  4620. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4621. /**
  4622. * Computes a reflection matrix from a plane
  4623. * @param plane defines the reflection plane
  4624. * @param result defines the target matrix
  4625. */
  4626. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4627. /**
  4628. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4629. * @param xaxis defines the value of the 1st axis
  4630. * @param yaxis defines the value of the 2nd axis
  4631. * @param zaxis defines the value of the 3rd axis
  4632. * @param result defines the target matrix
  4633. */
  4634. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4635. /**
  4636. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4637. * @param quat defines the quaternion to use
  4638. * @param result defines the target matrix
  4639. */
  4640. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4641. }
  4642. /**
  4643. * @hidden
  4644. */
  4645. export class TmpVectors {
  4646. static Vector2: Vector2[];
  4647. static Vector3: Vector3[];
  4648. static Vector4: Vector4[];
  4649. static Quaternion: Quaternion[];
  4650. static Matrix: Matrix[];
  4651. }
  4652. }
  4653. declare module "babylonjs/Maths/math.path" {
  4654. import { DeepImmutable, Nullable } from "babylonjs/types";
  4655. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4656. /**
  4657. * Defines potential orientation for back face culling
  4658. */
  4659. export enum Orientation {
  4660. /**
  4661. * Clockwise
  4662. */
  4663. CW = 0,
  4664. /** Counter clockwise */
  4665. CCW = 1
  4666. }
  4667. /** Class used to represent a Bezier curve */
  4668. export class BezierCurve {
  4669. /**
  4670. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4671. * @param t defines the time
  4672. * @param x1 defines the left coordinate on X axis
  4673. * @param y1 defines the left coordinate on Y axis
  4674. * @param x2 defines the right coordinate on X axis
  4675. * @param y2 defines the right coordinate on Y axis
  4676. * @returns the interpolated value
  4677. */
  4678. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4679. }
  4680. /**
  4681. * Defines angle representation
  4682. */
  4683. export class Angle {
  4684. private _radians;
  4685. /**
  4686. * Creates an Angle object of "radians" radians (float).
  4687. * @param radians the angle in radians
  4688. */
  4689. constructor(radians: number);
  4690. /**
  4691. * Get value in degrees
  4692. * @returns the Angle value in degrees (float)
  4693. */
  4694. degrees(): number;
  4695. /**
  4696. * Get value in radians
  4697. * @returns the Angle value in radians (float)
  4698. */
  4699. radians(): number;
  4700. /**
  4701. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4702. * @param a defines first vector
  4703. * @param b defines second vector
  4704. * @returns a new Angle
  4705. */
  4706. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4707. /**
  4708. * Gets a new Angle object from the given float in radians
  4709. * @param radians defines the angle value in radians
  4710. * @returns a new Angle
  4711. */
  4712. static FromRadians(radians: number): Angle;
  4713. /**
  4714. * Gets a new Angle object from the given float in degrees
  4715. * @param degrees defines the angle value in degrees
  4716. * @returns a new Angle
  4717. */
  4718. static FromDegrees(degrees: number): Angle;
  4719. }
  4720. /**
  4721. * This represents an arc in a 2d space.
  4722. */
  4723. export class Arc2 {
  4724. /** Defines the start point of the arc */
  4725. startPoint: Vector2;
  4726. /** Defines the mid point of the arc */
  4727. midPoint: Vector2;
  4728. /** Defines the end point of the arc */
  4729. endPoint: Vector2;
  4730. /**
  4731. * Defines the center point of the arc.
  4732. */
  4733. centerPoint: Vector2;
  4734. /**
  4735. * Defines the radius of the arc.
  4736. */
  4737. radius: number;
  4738. /**
  4739. * Defines the angle of the arc (from mid point to end point).
  4740. */
  4741. angle: Angle;
  4742. /**
  4743. * Defines the start angle of the arc (from start point to middle point).
  4744. */
  4745. startAngle: Angle;
  4746. /**
  4747. * Defines the orientation of the arc (clock wise/counter clock wise).
  4748. */
  4749. orientation: Orientation;
  4750. /**
  4751. * Creates an Arc object from the three given points : start, middle and end.
  4752. * @param startPoint Defines the start point of the arc
  4753. * @param midPoint Defines the midlle point of the arc
  4754. * @param endPoint Defines the end point of the arc
  4755. */
  4756. constructor(
  4757. /** Defines the start point of the arc */
  4758. startPoint: Vector2,
  4759. /** Defines the mid point of the arc */
  4760. midPoint: Vector2,
  4761. /** Defines the end point of the arc */
  4762. endPoint: Vector2);
  4763. }
  4764. /**
  4765. * Represents a 2D path made up of multiple 2D points
  4766. */
  4767. export class Path2 {
  4768. private _points;
  4769. private _length;
  4770. /**
  4771. * If the path start and end point are the same
  4772. */
  4773. closed: boolean;
  4774. /**
  4775. * Creates a Path2 object from the starting 2D coordinates x and y.
  4776. * @param x the starting points x value
  4777. * @param y the starting points y value
  4778. */
  4779. constructor(x: number, y: number);
  4780. /**
  4781. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4782. * @param x the added points x value
  4783. * @param y the added points y value
  4784. * @returns the updated Path2.
  4785. */
  4786. addLineTo(x: number, y: number): Path2;
  4787. /**
  4788. * 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.
  4789. * @param midX middle point x value
  4790. * @param midY middle point y value
  4791. * @param endX end point x value
  4792. * @param endY end point y value
  4793. * @param numberOfSegments (default: 36)
  4794. * @returns the updated Path2.
  4795. */
  4796. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4797. /**
  4798. * Closes the Path2.
  4799. * @returns the Path2.
  4800. */
  4801. close(): Path2;
  4802. /**
  4803. * Gets the sum of the distance between each sequential point in the path
  4804. * @returns the Path2 total length (float).
  4805. */
  4806. length(): number;
  4807. /**
  4808. * Gets the points which construct the path
  4809. * @returns the Path2 internal array of points.
  4810. */
  4811. getPoints(): Vector2[];
  4812. /**
  4813. * Retreives the point at the distance aways from the starting point
  4814. * @param normalizedLengthPosition the length along the path to retreive the point from
  4815. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4816. */
  4817. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4818. /**
  4819. * Creates a new path starting from an x and y position
  4820. * @param x starting x value
  4821. * @param y starting y value
  4822. * @returns a new Path2 starting at the coordinates (x, y).
  4823. */
  4824. static StartingAt(x: number, y: number): Path2;
  4825. }
  4826. /**
  4827. * Represents a 3D path made up of multiple 3D points
  4828. */
  4829. export class Path3D {
  4830. /**
  4831. * an array of Vector3, the curve axis of the Path3D
  4832. */
  4833. path: Vector3[];
  4834. private _curve;
  4835. private _distances;
  4836. private _tangents;
  4837. private _normals;
  4838. private _binormals;
  4839. private _raw;
  4840. private _alignTangentsWithPath;
  4841. private readonly _pointAtData;
  4842. /**
  4843. * new Path3D(path, normal, raw)
  4844. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4845. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4846. * @param path an array of Vector3, the curve axis of the Path3D
  4847. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4848. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4849. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4850. */
  4851. constructor(
  4852. /**
  4853. * an array of Vector3, the curve axis of the Path3D
  4854. */
  4855. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4856. /**
  4857. * Returns the Path3D array of successive Vector3 designing its curve.
  4858. * @returns the Path3D array of successive Vector3 designing its curve.
  4859. */
  4860. getCurve(): Vector3[];
  4861. /**
  4862. * Returns the Path3D array of successive Vector3 designing its curve.
  4863. * @returns the Path3D array of successive Vector3 designing its curve.
  4864. */
  4865. getPoints(): Vector3[];
  4866. /**
  4867. * @returns the computed length (float) of the path.
  4868. */
  4869. length(): number;
  4870. /**
  4871. * Returns an array populated with tangent vectors on each Path3D curve point.
  4872. * @returns an array populated with tangent vectors on each Path3D curve point.
  4873. */
  4874. getTangents(): Vector3[];
  4875. /**
  4876. * Returns an array populated with normal vectors on each Path3D curve point.
  4877. * @returns an array populated with normal vectors on each Path3D curve point.
  4878. */
  4879. getNormals(): Vector3[];
  4880. /**
  4881. * Returns an array populated with binormal vectors on each Path3D curve point.
  4882. * @returns an array populated with binormal vectors on each Path3D curve point.
  4883. */
  4884. getBinormals(): Vector3[];
  4885. /**
  4886. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4887. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4888. */
  4889. getDistances(): number[];
  4890. /**
  4891. * Returns an interpolated point along this path
  4892. * @param position the position of the point along this path, from 0.0 to 1.0
  4893. * @returns a new Vector3 as the point
  4894. */
  4895. getPointAt(position: number): Vector3;
  4896. /**
  4897. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4900. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4901. */
  4902. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4903. /**
  4904. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4905. * @param position the position of the point along this path, from 0.0 to 1.0
  4906. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4907. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4908. */
  4909. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4910. /**
  4911. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4914. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4915. */
  4916. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4921. */
  4922. getDistanceAt(position: number): number;
  4923. /**
  4924. * Returns the array index of the previous point of an interpolated point along this path
  4925. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4926. * @returns the array index
  4927. */
  4928. getPreviousPointIndexAt(position: number): number;
  4929. /**
  4930. * 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)
  4931. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4932. * @returns the sub position
  4933. */
  4934. getSubPositionAt(position: number): number;
  4935. /**
  4936. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4937. * @param target the vector of which to get the closest position to
  4938. * @returns the position of the closest virtual point on this path to the target vector
  4939. */
  4940. getClosestPositionTo(target: Vector3): number;
  4941. /**
  4942. * Returns a sub path (slice) of this path
  4943. * @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
  4944. * @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
  4945. * @returns a sub path (slice) of this path
  4946. */
  4947. slice(start?: number, end?: number): Path3D;
  4948. /**
  4949. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4950. * @param path path which all values are copied into the curves points
  4951. * @param firstNormal which should be projected onto the curve
  4952. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4953. * @returns the same object updated.
  4954. */
  4955. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4956. private _compute;
  4957. private _getFirstNonNullVector;
  4958. private _getLastNonNullVector;
  4959. private _normalVector;
  4960. /**
  4961. * Updates the point at data for an interpolated point along this curve
  4962. * @param position the position of the point along this curve, from 0.0 to 1.0
  4963. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4964. * @returns the (updated) point at data
  4965. */
  4966. private _updatePointAtData;
  4967. /**
  4968. * Updates the point at data from the specified parameters
  4969. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4970. * @param point the interpolated point
  4971. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4972. */
  4973. private _setPointAtData;
  4974. /**
  4975. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4976. */
  4977. private _updateInterpolationMatrix;
  4978. }
  4979. /**
  4980. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4981. * A Curve3 is designed from a series of successive Vector3.
  4982. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4983. */
  4984. export class Curve3 {
  4985. private _points;
  4986. private _length;
  4987. /**
  4988. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4989. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4990. * @param v1 (Vector3) the control point
  4991. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4992. * @param nbPoints (integer) the wanted number of points in the curve
  4993. * @returns the created Curve3
  4994. */
  4995. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4996. /**
  4997. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4998. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4999. * @param v1 (Vector3) the first control point
  5000. * @param v2 (Vector3) the second control point
  5001. * @param v3 (Vector3) the end point of the Cubic Bezier
  5002. * @param nbPoints (integer) the wanted number of points in the curve
  5003. * @returns the created Curve3
  5004. */
  5005. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5006. /**
  5007. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5008. * @param p1 (Vector3) the origin point of the Hermite Spline
  5009. * @param t1 (Vector3) the tangent vector at the origin point
  5010. * @param p2 (Vector3) the end point of the Hermite Spline
  5011. * @param t2 (Vector3) the tangent vector at the end point
  5012. * @param nbPoints (integer) the wanted number of points in the curve
  5013. * @returns the created Curve3
  5014. */
  5015. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5016. /**
  5017. * Returns a Curve3 object along a CatmullRom Spline curve :
  5018. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5019. * @param nbPoints (integer) the wanted number of points between each curve control points
  5020. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5021. * @returns the created Curve3
  5022. */
  5023. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5024. /**
  5025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5026. * A Curve3 is designed from a series of successive Vector3.
  5027. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5028. * @param points points which make up the curve
  5029. */
  5030. constructor(points: Vector3[]);
  5031. /**
  5032. * @returns the Curve3 stored array of successive Vector3
  5033. */
  5034. getPoints(): Vector3[];
  5035. /**
  5036. * @returns the computed length (float) of the curve.
  5037. */
  5038. length(): number;
  5039. /**
  5040. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5041. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5042. * curveA and curveB keep unchanged.
  5043. * @param curve the curve to continue from this curve
  5044. * @returns the newly constructed curve
  5045. */
  5046. continue(curve: DeepImmutable<Curve3>): Curve3;
  5047. private _computeLength;
  5048. }
  5049. }
  5050. declare module "babylonjs/Animations/easing" {
  5051. /**
  5052. * This represents the main contract an easing function should follow.
  5053. * Easing functions are used throughout the animation system.
  5054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5055. */
  5056. export interface IEasingFunction {
  5057. /**
  5058. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5059. * of the easing function.
  5060. * The link below provides some of the most common examples of easing functions.
  5061. * @see https://easings.net/
  5062. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5063. * @returns the corresponding value on the curve defined by the easing function
  5064. */
  5065. ease(gradient: number): number;
  5066. }
  5067. /**
  5068. * Base class used for every default easing function.
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class EasingFunction implements IEasingFunction {
  5072. /**
  5073. * Interpolation follows the mathematical formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEIN: number;
  5076. /**
  5077. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5078. */
  5079. static readonly EASINGMODE_EASEOUT: number;
  5080. /**
  5081. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5082. */
  5083. static readonly EASINGMODE_EASEINOUT: number;
  5084. private _easingMode;
  5085. /**
  5086. * Sets the easing mode of the current function.
  5087. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5088. */
  5089. setEasingMode(easingMode: number): void;
  5090. /**
  5091. * Gets the current easing mode.
  5092. * @returns the easing mode
  5093. */
  5094. getEasingMode(): number;
  5095. /**
  5096. * @hidden
  5097. */
  5098. easeInCore(gradient: number): number;
  5099. /**
  5100. * Given an input gradient between 0 and 1, this returns the corresponding value
  5101. * of the easing function.
  5102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5103. * @returns the corresponding value on the curve defined by the easing function
  5104. */
  5105. ease(gradient: number): number;
  5106. }
  5107. /**
  5108. * Easing function with a circle shape (see link below).
  5109. * @see https://easings.net/#easeInCirc
  5110. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5111. */
  5112. export class CircleEase extends EasingFunction implements IEasingFunction {
  5113. /** @hidden */
  5114. easeInCore(gradient: number): number;
  5115. }
  5116. /**
  5117. * Easing function with a ease back shape (see link below).
  5118. * @see https://easings.net/#easeInBack
  5119. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5120. */
  5121. export class BackEase extends EasingFunction implements IEasingFunction {
  5122. /** Defines the amplitude of the function */
  5123. amplitude: number;
  5124. /**
  5125. * Instantiates a back ease easing
  5126. * @see https://easings.net/#easeInBack
  5127. * @param amplitude Defines the amplitude of the function
  5128. */
  5129. constructor(
  5130. /** Defines the amplitude of the function */
  5131. amplitude?: number);
  5132. /** @hidden */
  5133. easeInCore(gradient: number): number;
  5134. }
  5135. /**
  5136. * Easing function with a bouncing shape (see link below).
  5137. * @see https://easings.net/#easeInBounce
  5138. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5139. */
  5140. export class BounceEase extends EasingFunction implements IEasingFunction {
  5141. /** Defines the number of bounces */
  5142. bounces: number;
  5143. /** Defines the amplitude of the bounce */
  5144. bounciness: number;
  5145. /**
  5146. * Instantiates a bounce easing
  5147. * @see https://easings.net/#easeInBounce
  5148. * @param bounces Defines the number of bounces
  5149. * @param bounciness Defines the amplitude of the bounce
  5150. */
  5151. constructor(
  5152. /** Defines the number of bounces */
  5153. bounces?: number,
  5154. /** Defines the amplitude of the bounce */
  5155. bounciness?: number);
  5156. /** @hidden */
  5157. easeInCore(gradient: number): number;
  5158. }
  5159. /**
  5160. * Easing function with a power of 3 shape (see link below).
  5161. * @see https://easings.net/#easeInCubic
  5162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5163. */
  5164. export class CubicEase extends EasingFunction implements IEasingFunction {
  5165. /** @hidden */
  5166. easeInCore(gradient: number): number;
  5167. }
  5168. /**
  5169. * Easing function with an elastic shape (see link below).
  5170. * @see https://easings.net/#easeInElastic
  5171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5172. */
  5173. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5174. /** Defines the number of oscillations*/
  5175. oscillations: number;
  5176. /** Defines the amplitude of the oscillations*/
  5177. springiness: number;
  5178. /**
  5179. * Instantiates an elastic easing function
  5180. * @see https://easings.net/#easeInElastic
  5181. * @param oscillations Defines the number of oscillations
  5182. * @param springiness Defines the amplitude of the oscillations
  5183. */
  5184. constructor(
  5185. /** Defines the number of oscillations*/
  5186. oscillations?: number,
  5187. /** Defines the amplitude of the oscillations*/
  5188. springiness?: number);
  5189. /** @hidden */
  5190. easeInCore(gradient: number): number;
  5191. }
  5192. /**
  5193. * Easing function with an exponential shape (see link below).
  5194. * @see https://easings.net/#easeInExpo
  5195. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5196. */
  5197. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5198. /** Defines the exponent of the function */
  5199. exponent: number;
  5200. /**
  5201. * Instantiates an exponential easing function
  5202. * @see https://easings.net/#easeInExpo
  5203. * @param exponent Defines the exponent of the function
  5204. */
  5205. constructor(
  5206. /** Defines the exponent of the function */
  5207. exponent?: number);
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power shape (see link below).
  5213. * @see https://easings.net/#easeInQuad
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class PowerEase extends EasingFunction implements IEasingFunction {
  5217. /** Defines the power of the function */
  5218. power: number;
  5219. /**
  5220. * Instantiates an power base easing function
  5221. * @see https://easings.net/#easeInQuad
  5222. * @param power Defines the power of the function
  5223. */
  5224. constructor(
  5225. /** Defines the power of the function */
  5226. power?: number);
  5227. /** @hidden */
  5228. easeInCore(gradient: number): number;
  5229. }
  5230. /**
  5231. * Easing function with a power of 2 shape (see link below).
  5232. * @see https://easings.net/#easeInQuad
  5233. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5234. */
  5235. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5236. /** @hidden */
  5237. easeInCore(gradient: number): number;
  5238. }
  5239. /**
  5240. * Easing function with a power of 4 shape (see link below).
  5241. * @see https://easings.net/#easeInQuart
  5242. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5243. */
  5244. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5245. /** @hidden */
  5246. easeInCore(gradient: number): number;
  5247. }
  5248. /**
  5249. * Easing function with a power of 5 shape (see link below).
  5250. * @see https://easings.net/#easeInQuint
  5251. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5252. */
  5253. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5254. /** @hidden */
  5255. easeInCore(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a sin shape (see link below).
  5259. * @see https://easings.net/#easeInSine
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class SineEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a bezier shape (see link below).
  5268. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5272. /** Defines the x component of the start tangent in the bezier curve */
  5273. x1: number;
  5274. /** Defines the y component of the start tangent in the bezier curve */
  5275. y1: number;
  5276. /** Defines the x component of the end tangent in the bezier curve */
  5277. x2: number;
  5278. /** Defines the y component of the end tangent in the bezier curve */
  5279. y2: number;
  5280. /**
  5281. * Instantiates a bezier function
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @param x1 Defines the x component of the start tangent in the bezier curve
  5284. * @param y1 Defines the y component of the start tangent in the bezier curve
  5285. * @param x2 Defines the x component of the end tangent in the bezier curve
  5286. * @param y2 Defines the y component of the end tangent in the bezier curve
  5287. */
  5288. constructor(
  5289. /** Defines the x component of the start tangent in the bezier curve */
  5290. x1?: number,
  5291. /** Defines the y component of the start tangent in the bezier curve */
  5292. y1?: number,
  5293. /** Defines the x component of the end tangent in the bezier curve */
  5294. x2?: number,
  5295. /** Defines the y component of the end tangent in the bezier curve */
  5296. y2?: number);
  5297. /** @hidden */
  5298. easeInCore(gradient: number): number;
  5299. }
  5300. }
  5301. declare module "babylonjs/Maths/math.color" {
  5302. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5303. /**
  5304. * Class used to hold a RBG color
  5305. */
  5306. export class Color3 {
  5307. /**
  5308. * Defines the red component (between 0 and 1, default is 0)
  5309. */
  5310. r: number;
  5311. /**
  5312. * Defines the green component (between 0 and 1, default is 0)
  5313. */
  5314. g: number;
  5315. /**
  5316. * Defines the blue component (between 0 and 1, default is 0)
  5317. */
  5318. b: number;
  5319. /**
  5320. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5321. * @param r defines the red component (between 0 and 1, default is 0)
  5322. * @param g defines the green component (between 0 and 1, default is 0)
  5323. * @param b defines the blue component (between 0 and 1, default is 0)
  5324. */
  5325. constructor(
  5326. /**
  5327. * Defines the red component (between 0 and 1, default is 0)
  5328. */
  5329. r?: number,
  5330. /**
  5331. * Defines the green component (between 0 and 1, default is 0)
  5332. */
  5333. g?: number,
  5334. /**
  5335. * Defines the blue component (between 0 and 1, default is 0)
  5336. */
  5337. b?: number);
  5338. /**
  5339. * Creates a string with the Color3 current values
  5340. * @returns the string representation of the Color3 object
  5341. */
  5342. toString(): string;
  5343. /**
  5344. * Returns the string "Color3"
  5345. * @returns "Color3"
  5346. */
  5347. getClassName(): string;
  5348. /**
  5349. * Compute the Color3 hash code
  5350. * @returns an unique number that can be used to hash Color3 objects
  5351. */
  5352. getHashCode(): number;
  5353. /**
  5354. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5355. * @param array defines the array where to store the r,g,b components
  5356. * @param index defines an optional index in the target array to define where to start storing values
  5357. * @returns the current Color3 object
  5358. */
  5359. toArray(array: FloatArray, index?: number): Color3;
  5360. /**
  5361. * Returns a new Color4 object from the current Color3 and the given alpha
  5362. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5363. * @returns a new Color4 object
  5364. */
  5365. toColor4(alpha?: number): Color4;
  5366. /**
  5367. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5368. * @returns the new array
  5369. */
  5370. asArray(): number[];
  5371. /**
  5372. * Returns the luminance value
  5373. * @returns a float value
  5374. */
  5375. toLuminance(): number;
  5376. /**
  5377. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5378. * @param otherColor defines the second operand
  5379. * @returns the new Color3 object
  5380. */
  5381. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5382. /**
  5383. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5384. * @param otherColor defines the second operand
  5385. * @param result defines the Color3 object where to store the result
  5386. * @returns the current Color3
  5387. */
  5388. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5389. /**
  5390. * Determines equality between Color3 objects
  5391. * @param otherColor defines the second operand
  5392. * @returns true if the rgb values are equal to the given ones
  5393. */
  5394. equals(otherColor: DeepImmutable<Color3>): boolean;
  5395. /**
  5396. * Determines equality between the current Color3 object and a set of r,b,g values
  5397. * @param r defines the red component to check
  5398. * @param g defines the green component to check
  5399. * @param b defines the blue component to check
  5400. * @returns true if the rgb values are equal to the given ones
  5401. */
  5402. equalsFloats(r: number, g: number, b: number): boolean;
  5403. /**
  5404. * Multiplies in place each rgb value by scale
  5405. * @param scale defines the scaling factor
  5406. * @returns the updated Color3
  5407. */
  5408. scale(scale: number): Color3;
  5409. /**
  5410. * Multiplies the rgb values by scale and stores the result into "result"
  5411. * @param scale defines the scaling factor
  5412. * @param result defines the Color3 object where to store the result
  5413. * @returns the unmodified current Color3
  5414. */
  5415. scaleToRef(scale: number, result: Color3): Color3;
  5416. /**
  5417. * Scale the current Color3 values by a factor and add the result to a given Color3
  5418. * @param scale defines the scale factor
  5419. * @param result defines color to store the result into
  5420. * @returns the unmodified current Color3
  5421. */
  5422. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5423. /**
  5424. * Clamps the rgb values by the min and max values and stores the result into "result"
  5425. * @param min defines minimum clamping value (default is 0)
  5426. * @param max defines maximum clamping value (default is 1)
  5427. * @param result defines color to store the result into
  5428. * @returns the original Color3
  5429. */
  5430. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5431. /**
  5432. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. add(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5446. * @param otherColor defines the second operand
  5447. * @returns the new Color3
  5448. */
  5449. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5450. /**
  5451. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5452. * @param otherColor defines the second operand
  5453. * @param result defines Color3 object to store the result into
  5454. * @returns the unmodified current Color3
  5455. */
  5456. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5457. /**
  5458. * Copy the current object
  5459. * @returns a new Color3 copied the current one
  5460. */
  5461. clone(): Color3;
  5462. /**
  5463. * Copies the rgb values from the source in the current Color3
  5464. * @param source defines the source Color3 object
  5465. * @returns the updated Color3 object
  5466. */
  5467. copyFrom(source: DeepImmutable<Color3>): Color3;
  5468. /**
  5469. * Updates the Color3 rgb values from the given floats
  5470. * @param r defines the red component to read from
  5471. * @param g defines the green component to read from
  5472. * @param b defines the blue component to read from
  5473. * @returns the current Color3 object
  5474. */
  5475. copyFromFloats(r: number, g: number, b: number): Color3;
  5476. /**
  5477. * Updates the Color3 rgb values from the given floats
  5478. * @param r defines the red component to read from
  5479. * @param g defines the green component to read from
  5480. * @param b defines the blue component to read from
  5481. * @returns the current Color3 object
  5482. */
  5483. set(r: number, g: number, b: number): Color3;
  5484. /**
  5485. * Compute the Color3 hexadecimal code as a string
  5486. * @returns a string containing the hexadecimal representation of the Color3 object
  5487. */
  5488. toHexString(): string;
  5489. /**
  5490. * Computes a new Color3 converted from the current one to linear space
  5491. * @returns a new Color3 object
  5492. */
  5493. toLinearSpace(): Color3;
  5494. /**
  5495. * Converts current color in rgb space to HSV values
  5496. * @returns a new color3 representing the HSV values
  5497. */
  5498. toHSV(): Color3;
  5499. /**
  5500. * Converts current color in rgb space to HSV values
  5501. * @param result defines the Color3 where to store the HSV values
  5502. */
  5503. toHSVToRef(result: Color3): void;
  5504. /**
  5505. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5506. * @param convertedColor defines the Color3 object where to store the linear space version
  5507. * @returns the unmodified Color3
  5508. */
  5509. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5510. /**
  5511. * Computes a new Color3 converted from the current one to gamma space
  5512. * @returns a new Color3 object
  5513. */
  5514. toGammaSpace(): Color3;
  5515. /**
  5516. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5517. * @param convertedColor defines the Color3 object where to store the gamma space version
  5518. * @returns the unmodified Color3
  5519. */
  5520. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5521. private static _BlackReadOnly;
  5522. /**
  5523. * Convert Hue, saturation and value to a Color3 (RGB)
  5524. * @param hue defines the hue
  5525. * @param saturation defines the saturation
  5526. * @param value defines the value
  5527. * @param result defines the Color3 where to store the RGB values
  5528. */
  5529. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5530. /**
  5531. * Creates a new Color3 from the string containing valid hexadecimal values
  5532. * @param hex defines a string containing valid hexadecimal values
  5533. * @returns a new Color3 object
  5534. */
  5535. static FromHexString(hex: string): Color3;
  5536. /**
  5537. * Creates a new Color3 from the starting index of the given array
  5538. * @param array defines the source array
  5539. * @param offset defines an offset in the source array
  5540. * @returns a new Color3 object
  5541. */
  5542. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5543. /**
  5544. * Creates a new Color3 from integer values (< 256)
  5545. * @param r defines the red component to read from (value between 0 and 255)
  5546. * @param g defines the green component to read from (value between 0 and 255)
  5547. * @param b defines the blue component to read from (value between 0 and 255)
  5548. * @returns a new Color3 object
  5549. */
  5550. static FromInts(r: number, g: number, b: number): Color3;
  5551. /**
  5552. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5553. * @param start defines the start Color3 value
  5554. * @param end defines the end Color3 value
  5555. * @param amount defines the gradient value between start and end
  5556. * @returns a new Color3 object
  5557. */
  5558. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5559. /**
  5560. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5561. * @param left defines the start value
  5562. * @param right defines the end value
  5563. * @param amount defines the gradient factor
  5564. * @param result defines the Color3 object where to store the result
  5565. */
  5566. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5567. /**
  5568. * Returns a Color3 value containing a red color
  5569. * @returns a new Color3 object
  5570. */
  5571. static Red(): Color3;
  5572. /**
  5573. * Returns a Color3 value containing a green color
  5574. * @returns a new Color3 object
  5575. */
  5576. static Green(): Color3;
  5577. /**
  5578. * Returns a Color3 value containing a blue color
  5579. * @returns a new Color3 object
  5580. */
  5581. static Blue(): Color3;
  5582. /**
  5583. * Returns a Color3 value containing a black color
  5584. * @returns a new Color3 object
  5585. */
  5586. static Black(): Color3;
  5587. /**
  5588. * Gets a Color3 value containing a black color that must not be updated
  5589. */
  5590. static get BlackReadOnly(): DeepImmutable<Color3>;
  5591. /**
  5592. * Returns a Color3 value containing a white color
  5593. * @returns a new Color3 object
  5594. */
  5595. static White(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a purple color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Purple(): Color3;
  5601. /**
  5602. * Returns a Color3 value containing a magenta color
  5603. * @returns a new Color3 object
  5604. */
  5605. static Magenta(): Color3;
  5606. /**
  5607. * Returns a Color3 value containing a yellow color
  5608. * @returns a new Color3 object
  5609. */
  5610. static Yellow(): Color3;
  5611. /**
  5612. * Returns a Color3 value containing a gray color
  5613. * @returns a new Color3 object
  5614. */
  5615. static Gray(): Color3;
  5616. /**
  5617. * Returns a Color3 value containing a teal color
  5618. * @returns a new Color3 object
  5619. */
  5620. static Teal(): Color3;
  5621. /**
  5622. * Returns a Color3 value containing a random color
  5623. * @returns a new Color3 object
  5624. */
  5625. static Random(): Color3;
  5626. }
  5627. /**
  5628. * Class used to hold a RBGA color
  5629. */
  5630. export class Color4 {
  5631. /**
  5632. * Defines the red component (between 0 and 1, default is 0)
  5633. */
  5634. r: number;
  5635. /**
  5636. * Defines the green component (between 0 and 1, default is 0)
  5637. */
  5638. g: number;
  5639. /**
  5640. * Defines the blue component (between 0 and 1, default is 0)
  5641. */
  5642. b: number;
  5643. /**
  5644. * Defines the alpha component (between 0 and 1, default is 1)
  5645. */
  5646. a: number;
  5647. /**
  5648. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5649. * @param r defines the red component (between 0 and 1, default is 0)
  5650. * @param g defines the green component (between 0 and 1, default is 0)
  5651. * @param b defines the blue component (between 0 and 1, default is 0)
  5652. * @param a defines the alpha component (between 0 and 1, default is 1)
  5653. */
  5654. constructor(
  5655. /**
  5656. * Defines the red component (between 0 and 1, default is 0)
  5657. */
  5658. r?: number,
  5659. /**
  5660. * Defines the green component (between 0 and 1, default is 0)
  5661. */
  5662. g?: number,
  5663. /**
  5664. * Defines the blue component (between 0 and 1, default is 0)
  5665. */
  5666. b?: number,
  5667. /**
  5668. * Defines the alpha component (between 0 and 1, default is 1)
  5669. */
  5670. a?: number);
  5671. /**
  5672. * Adds in place the given Color4 values to the current Color4 object
  5673. * @param right defines the second operand
  5674. * @returns the current updated Color4 object
  5675. */
  5676. addInPlace(right: DeepImmutable<Color4>): Color4;
  5677. /**
  5678. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5679. * @returns the new array
  5680. */
  5681. asArray(): number[];
  5682. /**
  5683. * Stores from the starting index in the given array the Color4 successive values
  5684. * @param array defines the array where to store the r,g,b components
  5685. * @param index defines an optional index in the target array to define where to start storing values
  5686. * @returns the current Color4 object
  5687. */
  5688. toArray(array: number[], index?: number): Color4;
  5689. /**
  5690. * Determines equality between Color4 objects
  5691. * @param otherColor defines the second operand
  5692. * @returns true if the rgba values are equal to the given ones
  5693. */
  5694. equals(otherColor: DeepImmutable<Color4>): boolean;
  5695. /**
  5696. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5697. * @param right defines the second operand
  5698. * @returns a new Color4 object
  5699. */
  5700. add(right: DeepImmutable<Color4>): Color4;
  5701. /**
  5702. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5703. * @param right defines the second operand
  5704. * @returns a new Color4 object
  5705. */
  5706. subtract(right: DeepImmutable<Color4>): Color4;
  5707. /**
  5708. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5709. * @param right defines the second operand
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current Color4 object
  5712. */
  5713. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5714. /**
  5715. * Creates a new Color4 with the current Color4 values multiplied by scale
  5716. * @param scale defines the scaling factor to apply
  5717. * @returns a new Color4 object
  5718. */
  5719. scale(scale: number): Color4;
  5720. /**
  5721. * Multiplies the current Color4 values by scale and stores the result in "result"
  5722. * @param scale defines the scaling factor to apply
  5723. * @param result defines the Color4 object where to store the result
  5724. * @returns the current unmodified Color4
  5725. */
  5726. scaleToRef(scale: number, result: Color4): Color4;
  5727. /**
  5728. * Scale the current Color4 values by a factor and add the result to a given Color4
  5729. * @param scale defines the scale factor
  5730. * @param result defines the Color4 object where to store the result
  5731. * @returns the unmodified current Color4
  5732. */
  5733. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5734. /**
  5735. * Clamps the rgb values by the min and max values and stores the result into "result"
  5736. * @param min defines minimum clamping value (default is 0)
  5737. * @param max defines maximum clamping value (default is 1)
  5738. * @param result defines color to store the result into.
  5739. * @returns the cuurent Color4
  5740. */
  5741. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5742. /**
  5743. * Multipy an Color4 value by another and return a new Color4 object
  5744. * @param color defines the Color4 value to multiply by
  5745. * @returns a new Color4 object
  5746. */
  5747. multiply(color: Color4): Color4;
  5748. /**
  5749. * Multipy a Color4 value by another and push the result in a reference value
  5750. * @param color defines the Color4 value to multiply by
  5751. * @param result defines the Color4 to fill the result in
  5752. * @returns the result Color4
  5753. */
  5754. multiplyToRef(color: Color4, result: Color4): Color4;
  5755. /**
  5756. * Creates a string with the Color4 current values
  5757. * @returns the string representation of the Color4 object
  5758. */
  5759. toString(): string;
  5760. /**
  5761. * Returns the string "Color4"
  5762. * @returns "Color4"
  5763. */
  5764. getClassName(): string;
  5765. /**
  5766. * Compute the Color4 hash code
  5767. * @returns an unique number that can be used to hash Color4 objects
  5768. */
  5769. getHashCode(): number;
  5770. /**
  5771. * Creates a new Color4 copied from the current one
  5772. * @returns a new Color4 object
  5773. */
  5774. clone(): Color4;
  5775. /**
  5776. * Copies the given Color4 values into the current one
  5777. * @param source defines the source Color4 object
  5778. * @returns the current updated Color4 object
  5779. */
  5780. copyFrom(source: Color4): Color4;
  5781. /**
  5782. * Copies the given float values into the current one
  5783. * @param r defines the red component to read from
  5784. * @param g defines the green component to read from
  5785. * @param b defines the blue component to read from
  5786. * @param a defines the alpha component to read from
  5787. * @returns the current updated Color4 object
  5788. */
  5789. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5790. /**
  5791. * Copies the given float values into the current one
  5792. * @param r defines the red component to read from
  5793. * @param g defines the green component to read from
  5794. * @param b defines the blue component to read from
  5795. * @param a defines the alpha component to read from
  5796. * @returns the current updated Color4 object
  5797. */
  5798. set(r: number, g: number, b: number, a: number): Color4;
  5799. /**
  5800. * Compute the Color4 hexadecimal code as a string
  5801. * @returns a string containing the hexadecimal representation of the Color4 object
  5802. */
  5803. toHexString(): string;
  5804. /**
  5805. * Computes a new Color4 converted from the current one to linear space
  5806. * @returns a new Color4 object
  5807. */
  5808. toLinearSpace(): Color4;
  5809. /**
  5810. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5811. * @param convertedColor defines the Color4 object where to store the linear space version
  5812. * @returns the unmodified Color4
  5813. */
  5814. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5815. /**
  5816. * Computes a new Color4 converted from the current one to gamma space
  5817. * @returns a new Color4 object
  5818. */
  5819. toGammaSpace(): Color4;
  5820. /**
  5821. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5822. * @param convertedColor defines the Color4 object where to store the gamma space version
  5823. * @returns the unmodified Color4
  5824. */
  5825. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5826. /**
  5827. * Creates a new Color4 from the string containing valid hexadecimal values
  5828. * @param hex defines a string containing valid hexadecimal values
  5829. * @returns a new Color4 object
  5830. */
  5831. static FromHexString(hex: string): Color4;
  5832. /**
  5833. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5834. * @param left defines the start value
  5835. * @param right defines the end value
  5836. * @param amount defines the gradient factor
  5837. * @returns a new Color4 object
  5838. */
  5839. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5840. /**
  5841. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5842. * @param left defines the start value
  5843. * @param right defines the end value
  5844. * @param amount defines the gradient factor
  5845. * @param result defines the Color4 object where to store data
  5846. */
  5847. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5848. /**
  5849. * Creates a new Color4 from a Color3 and an alpha value
  5850. * @param color3 defines the source Color3 to read from
  5851. * @param alpha defines the alpha component (1.0 by default)
  5852. * @returns a new Color4 object
  5853. */
  5854. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5855. /**
  5856. * Creates a new Color4 from the starting index element of the given array
  5857. * @param array defines the source array to read from
  5858. * @param offset defines the offset in the source array
  5859. * @returns a new Color4 object
  5860. */
  5861. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5862. /**
  5863. * Creates a new Color3 from integer values (< 256)
  5864. * @param r defines the red component to read from (value between 0 and 255)
  5865. * @param g defines the green component to read from (value between 0 and 255)
  5866. * @param b defines the blue component to read from (value between 0 and 255)
  5867. * @param a defines the alpha component to read from (value between 0 and 255)
  5868. * @returns a new Color3 object
  5869. */
  5870. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5871. /**
  5872. * Check the content of a given array and convert it to an array containing RGBA data
  5873. * If the original array was already containing count * 4 values then it is returned directly
  5874. * @param colors defines the array to check
  5875. * @param count defines the number of RGBA data to expect
  5876. * @returns an array containing count * 4 values (RGBA)
  5877. */
  5878. static CheckColors4(colors: number[], count: number): number[];
  5879. }
  5880. /**
  5881. * @hidden
  5882. */
  5883. export class TmpColors {
  5884. static Color3: Color3[];
  5885. static Color4: Color4[];
  5886. }
  5887. }
  5888. declare module "babylonjs/Animations/animationKey" {
  5889. /**
  5890. * Defines an interface which represents an animation key frame
  5891. */
  5892. export interface IAnimationKey {
  5893. /**
  5894. * Frame of the key frame
  5895. */
  5896. frame: number;
  5897. /**
  5898. * Value at the specifies key frame
  5899. */
  5900. value: any;
  5901. /**
  5902. * The input tangent for the cubic hermite spline
  5903. */
  5904. inTangent?: any;
  5905. /**
  5906. * The output tangent for the cubic hermite spline
  5907. */
  5908. outTangent?: any;
  5909. /**
  5910. * The animation interpolation type
  5911. */
  5912. interpolation?: AnimationKeyInterpolation;
  5913. }
  5914. /**
  5915. * Enum for the animation key frame interpolation type
  5916. */
  5917. export enum AnimationKeyInterpolation {
  5918. /**
  5919. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5920. */
  5921. STEP = 1
  5922. }
  5923. }
  5924. declare module "babylonjs/Animations/animationRange" {
  5925. /**
  5926. * Represents the range of an animation
  5927. */
  5928. export class AnimationRange {
  5929. /**The name of the animation range**/
  5930. name: string;
  5931. /**The starting frame of the animation */
  5932. from: number;
  5933. /**The ending frame of the animation*/
  5934. to: number;
  5935. /**
  5936. * Initializes the range of an animation
  5937. * @param name The name of the animation range
  5938. * @param from The starting frame of the animation
  5939. * @param to The ending frame of the animation
  5940. */
  5941. constructor(
  5942. /**The name of the animation range**/
  5943. name: string,
  5944. /**The starting frame of the animation */
  5945. from: number,
  5946. /**The ending frame of the animation*/
  5947. to: number);
  5948. /**
  5949. * Makes a copy of the animation range
  5950. * @returns A copy of the animation range
  5951. */
  5952. clone(): AnimationRange;
  5953. }
  5954. }
  5955. declare module "babylonjs/Animations/animationEvent" {
  5956. /**
  5957. * Composed of a frame, and an action function
  5958. */
  5959. export class AnimationEvent {
  5960. /** The frame for which the event is triggered **/
  5961. frame: number;
  5962. /** The event to perform when triggered **/
  5963. action: (currentFrame: number) => void;
  5964. /** Specifies if the event should be triggered only once**/
  5965. onlyOnce?: boolean | undefined;
  5966. /**
  5967. * Specifies if the animation event is done
  5968. */
  5969. isDone: boolean;
  5970. /**
  5971. * Initializes the animation event
  5972. * @param frame The frame for which the event is triggered
  5973. * @param action The event to perform when triggered
  5974. * @param onlyOnce Specifies if the event should be triggered only once
  5975. */
  5976. constructor(
  5977. /** The frame for which the event is triggered **/
  5978. frame: number,
  5979. /** The event to perform when triggered **/
  5980. action: (currentFrame: number) => void,
  5981. /** Specifies if the event should be triggered only once**/
  5982. onlyOnce?: boolean | undefined);
  5983. /** @hidden */
  5984. _clone(): AnimationEvent;
  5985. }
  5986. }
  5987. declare module "babylonjs/Behaviors/behavior" {
  5988. import { Nullable } from "babylonjs/types";
  5989. /**
  5990. * Interface used to define a behavior
  5991. */
  5992. export interface Behavior<T> {
  5993. /** gets or sets behavior's name */
  5994. name: string;
  5995. /**
  5996. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5997. */
  5998. init(): void;
  5999. /**
  6000. * Called when the behavior is attached to a target
  6001. * @param target defines the target where the behavior is attached to
  6002. */
  6003. attach(target: T): void;
  6004. /**
  6005. * Called when the behavior is detached from its target
  6006. */
  6007. detach(): void;
  6008. }
  6009. /**
  6010. * Interface implemented by classes supporting behaviors
  6011. */
  6012. export interface IBehaviorAware<T> {
  6013. /**
  6014. * Attach a behavior
  6015. * @param behavior defines the behavior to attach
  6016. * @returns the current host
  6017. */
  6018. addBehavior(behavior: Behavior<T>): T;
  6019. /**
  6020. * Remove a behavior from the current object
  6021. * @param behavior defines the behavior to detach
  6022. * @returns the current host
  6023. */
  6024. removeBehavior(behavior: Behavior<T>): T;
  6025. /**
  6026. * Gets a behavior using its name to search
  6027. * @param name defines the name to search
  6028. * @returns the behavior or null if not found
  6029. */
  6030. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6031. }
  6032. }
  6033. declare module "babylonjs/Misc/smartArray" {
  6034. /**
  6035. * Defines an array and its length.
  6036. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6037. */
  6038. export interface ISmartArrayLike<T> {
  6039. /**
  6040. * The data of the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. }
  6048. /**
  6049. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6050. */
  6051. export class SmartArray<T> implements ISmartArrayLike<T> {
  6052. /**
  6053. * The full set of data from the array.
  6054. */
  6055. data: Array<T>;
  6056. /**
  6057. * The active length of the array.
  6058. */
  6059. length: number;
  6060. protected _id: number;
  6061. /**
  6062. * Instantiates a Smart Array.
  6063. * @param capacity defines the default capacity of the array.
  6064. */
  6065. constructor(capacity: number);
  6066. /**
  6067. * Pushes a value at the end of the active data.
  6068. * @param value defines the object to push in the array.
  6069. */
  6070. push(value: T): void;
  6071. /**
  6072. * Iterates over the active data and apply the lambda to them.
  6073. * @param func defines the action to apply on each value.
  6074. */
  6075. forEach(func: (content: T) => void): void;
  6076. /**
  6077. * Sorts the full sets of data.
  6078. * @param compareFn defines the comparison function to apply.
  6079. */
  6080. sort(compareFn: (a: T, b: T) => number): void;
  6081. /**
  6082. * Resets the active data to an empty array.
  6083. */
  6084. reset(): void;
  6085. /**
  6086. * Releases all the data from the array as well as the array.
  6087. */
  6088. dispose(): void;
  6089. /**
  6090. * Concats the active data with a given array.
  6091. * @param array defines the data to concatenate with.
  6092. */
  6093. concat(array: any): void;
  6094. /**
  6095. * Returns the position of a value in the active data.
  6096. * @param value defines the value to find the index for
  6097. * @returns the index if found in the active data otherwise -1
  6098. */
  6099. indexOf(value: T): number;
  6100. /**
  6101. * Returns whether an element is part of the active data.
  6102. * @param value defines the value to look for
  6103. * @returns true if found in the active data otherwise false
  6104. */
  6105. contains(value: T): boolean;
  6106. private static _GlobalId;
  6107. }
  6108. /**
  6109. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6110. * The data in this array can only be present once
  6111. */
  6112. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6113. private _duplicateId;
  6114. /**
  6115. * Pushes a value at the end of the active data.
  6116. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6117. * @param value defines the object to push in the array.
  6118. */
  6119. push(value: T): void;
  6120. /**
  6121. * Pushes a value at the end of the active data.
  6122. * If the data is already present, it won t be added again
  6123. * @param value defines the object to push in the array.
  6124. * @returns true if added false if it was already present
  6125. */
  6126. pushNoDuplicate(value: T): boolean;
  6127. /**
  6128. * Resets the active data to an empty array.
  6129. */
  6130. reset(): void;
  6131. /**
  6132. * Concats the active data with a given array.
  6133. * This ensures no dupplicate will be present in the result.
  6134. * @param array defines the data to concatenate with.
  6135. */
  6136. concatWithNoDuplicate(array: any): void;
  6137. }
  6138. }
  6139. declare module "babylonjs/Cameras/cameraInputsManager" {
  6140. import { Nullable } from "babylonjs/types";
  6141. import { Camera } from "babylonjs/Cameras/camera";
  6142. /**
  6143. * @ignore
  6144. * This is a list of all the different input types that are available in the application.
  6145. * Fo instance: ArcRotateCameraGamepadInput...
  6146. */
  6147. export var CameraInputTypes: {};
  6148. /**
  6149. * This is the contract to implement in order to create a new input class.
  6150. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6151. */
  6152. export interface ICameraInput<TCamera extends Camera> {
  6153. /**
  6154. * Defines the camera the input is attached to.
  6155. */
  6156. camera: Nullable<TCamera>;
  6157. /**
  6158. * Gets the class name of the current intput.
  6159. * @returns the class name
  6160. */
  6161. getClassName(): string;
  6162. /**
  6163. * Get the friendly name associated with the input class.
  6164. * @returns the input friendly name
  6165. */
  6166. getSimpleName(): string;
  6167. /**
  6168. * Attach the input controls to a specific dom element to get the input from.
  6169. * @param element Defines the element the controls should be listened from
  6170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6173. /**
  6174. * Detach the current controls from the specified dom element.
  6175. * @param element Defines the element to stop listening the inputs from
  6176. */
  6177. detachControl(element: Nullable<HTMLElement>): void;
  6178. /**
  6179. * Update the current camera state depending on the inputs that have been used this frame.
  6180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6181. */
  6182. checkInputs?: () => void;
  6183. }
  6184. /**
  6185. * Represents a map of input types to input instance or input index to input instance.
  6186. */
  6187. export interface CameraInputsMap<TCamera extends Camera> {
  6188. /**
  6189. * Accessor to the input by input type.
  6190. */
  6191. [name: string]: ICameraInput<TCamera>;
  6192. /**
  6193. * Accessor to the input by input index.
  6194. */
  6195. [idx: number]: ICameraInput<TCamera>;
  6196. }
  6197. /**
  6198. * This represents the input manager used within a camera.
  6199. * It helps dealing with all the different kind of input attached to a camera.
  6200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6201. */
  6202. export class CameraInputsManager<TCamera extends Camera> {
  6203. /**
  6204. * Defines the list of inputs attahed to the camera.
  6205. */
  6206. attached: CameraInputsMap<TCamera>;
  6207. /**
  6208. * Defines the dom element the camera is collecting inputs from.
  6209. * This is null if the controls have not been attached.
  6210. */
  6211. attachedElement: Nullable<HTMLElement>;
  6212. /**
  6213. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6214. */
  6215. noPreventDefault: boolean;
  6216. /**
  6217. * Defined the camera the input manager belongs to.
  6218. */
  6219. camera: TCamera;
  6220. /**
  6221. * Update the current camera state depending on the inputs that have been used this frame.
  6222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6223. */
  6224. checkInputs: () => void;
  6225. /**
  6226. * Instantiate a new Camera Input Manager.
  6227. * @param camera Defines the camera the input manager blongs to
  6228. */
  6229. constructor(camera: TCamera);
  6230. /**
  6231. * Add an input method to a camera
  6232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6233. * @param input camera input method
  6234. */
  6235. add(input: ICameraInput<TCamera>): void;
  6236. /**
  6237. * Remove a specific input method from a camera
  6238. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6239. * @param inputToRemove camera input method
  6240. */
  6241. remove(inputToRemove: ICameraInput<TCamera>): void;
  6242. /**
  6243. * Remove a specific input type from a camera
  6244. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6245. * @param inputType the type of the input to remove
  6246. */
  6247. removeByType(inputType: string): void;
  6248. private _addCheckInputs;
  6249. /**
  6250. * Attach the input controls to the currently attached dom element to listen the events from.
  6251. * @param input Defines the input to attach
  6252. */
  6253. attachInput(input: ICameraInput<TCamera>): void;
  6254. /**
  6255. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6256. * @param element Defines the dom element to collect the events from
  6257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6258. */
  6259. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6260. /**
  6261. * Detach the current manager inputs controls from a specific dom element.
  6262. * @param element Defines the dom element to collect the events from
  6263. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6264. */
  6265. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6266. /**
  6267. * Rebuild the dynamic inputCheck function from the current list of
  6268. * defined inputs in the manager.
  6269. */
  6270. rebuildInputCheck(): void;
  6271. /**
  6272. * Remove all attached input methods from a camera
  6273. */
  6274. clear(): void;
  6275. /**
  6276. * Serialize the current input manager attached to a camera.
  6277. * This ensures than once parsed,
  6278. * the input associated to the camera will be identical to the current ones
  6279. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6280. */
  6281. serialize(serializedCamera: any): void;
  6282. /**
  6283. * Parses an input manager serialized JSON to restore the previous list of inputs
  6284. * and states associated to a camera.
  6285. * @param parsedCamera Defines the JSON to parse
  6286. */
  6287. parse(parsedCamera: any): void;
  6288. }
  6289. }
  6290. declare module "babylonjs/Meshes/buffer" {
  6291. import { Nullable, DataArray } from "babylonjs/types";
  6292. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6293. /**
  6294. * Class used to store data that will be store in GPU memory
  6295. */
  6296. export class Buffer {
  6297. private _engine;
  6298. private _buffer;
  6299. /** @hidden */
  6300. _data: Nullable<DataArray>;
  6301. private _updatable;
  6302. private _instanced;
  6303. private _divisor;
  6304. /**
  6305. * Gets the byte stride.
  6306. */
  6307. readonly byteStride: number;
  6308. /**
  6309. * Constructor
  6310. * @param engine the engine
  6311. * @param data the data to use for this buffer
  6312. * @param updatable whether the data is updatable
  6313. * @param stride the stride (optional)
  6314. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6315. * @param instanced whether the buffer is instanced (optional)
  6316. * @param useBytes set to true if the stride in in bytes (optional)
  6317. * @param divisor sets an optional divisor for instances (1 by default)
  6318. */
  6319. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6320. /**
  6321. * Create a new VertexBuffer based on the current buffer
  6322. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6323. * @param offset defines offset in the buffer (0 by default)
  6324. * @param size defines the size in floats of attributes (position is 3 for instance)
  6325. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6326. * @param instanced defines if the vertex buffer contains indexed data
  6327. * @param useBytes defines if the offset and stride are in bytes *
  6328. * @param divisor sets an optional divisor for instances (1 by default)
  6329. * @returns the new vertex buffer
  6330. */
  6331. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6332. /**
  6333. * Gets a boolean indicating if the Buffer is updatable?
  6334. * @returns true if the buffer is updatable
  6335. */
  6336. isUpdatable(): boolean;
  6337. /**
  6338. * Gets current buffer's data
  6339. * @returns a DataArray or null
  6340. */
  6341. getData(): Nullable<DataArray>;
  6342. /**
  6343. * Gets underlying native buffer
  6344. * @returns underlying native buffer
  6345. */
  6346. getBuffer(): Nullable<DataBuffer>;
  6347. /**
  6348. * Gets the stride in float32 units (i.e. byte stride / 4).
  6349. * May not be an integer if the byte stride is not divisible by 4.
  6350. * @returns the stride in float32 units
  6351. * @deprecated Please use byteStride instead.
  6352. */
  6353. getStrideSize(): number;
  6354. /**
  6355. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6356. * @param data defines the data to store
  6357. */
  6358. create(data?: Nullable<DataArray>): void;
  6359. /** @hidden */
  6360. _rebuild(): void;
  6361. /**
  6362. * Update current buffer data
  6363. * @param data defines the data to store
  6364. */
  6365. update(data: DataArray): void;
  6366. /**
  6367. * Updates the data directly.
  6368. * @param data the new data
  6369. * @param offset the new offset
  6370. * @param vertexCount the vertex count (optional)
  6371. * @param useBytes set to true if the offset is in bytes
  6372. */
  6373. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6374. /**
  6375. * Release all resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. /**
  6380. * Specialized buffer used to store vertex data
  6381. */
  6382. export class VertexBuffer {
  6383. /** @hidden */
  6384. _buffer: Buffer;
  6385. private _kind;
  6386. private _size;
  6387. private _ownsBuffer;
  6388. private _instanced;
  6389. private _instanceDivisor;
  6390. /**
  6391. * The byte type.
  6392. */
  6393. static readonly BYTE: number;
  6394. /**
  6395. * The unsigned byte type.
  6396. */
  6397. static readonly UNSIGNED_BYTE: number;
  6398. /**
  6399. * The short type.
  6400. */
  6401. static readonly SHORT: number;
  6402. /**
  6403. * The unsigned short type.
  6404. */
  6405. static readonly UNSIGNED_SHORT: number;
  6406. /**
  6407. * The integer type.
  6408. */
  6409. static readonly INT: number;
  6410. /**
  6411. * The unsigned integer type.
  6412. */
  6413. static readonly UNSIGNED_INT: number;
  6414. /**
  6415. * The float type.
  6416. */
  6417. static readonly FLOAT: number;
  6418. /**
  6419. * Gets or sets the instance divisor when in instanced mode
  6420. */
  6421. get instanceDivisor(): number;
  6422. set instanceDivisor(value: number);
  6423. /**
  6424. * Gets the byte stride.
  6425. */
  6426. readonly byteStride: number;
  6427. /**
  6428. * Gets the byte offset.
  6429. */
  6430. readonly byteOffset: number;
  6431. /**
  6432. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6433. */
  6434. readonly normalized: boolean;
  6435. /**
  6436. * Gets the data type of each component in the array.
  6437. */
  6438. readonly type: number;
  6439. /**
  6440. * Constructor
  6441. * @param engine the engine
  6442. * @param data the data to use for this vertex buffer
  6443. * @param kind the vertex buffer kind
  6444. * @param updatable whether the data is updatable
  6445. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6446. * @param stride the stride (optional)
  6447. * @param instanced whether the buffer is instanced (optional)
  6448. * @param offset the offset of the data (optional)
  6449. * @param size the number of components (optional)
  6450. * @param type the type of the component (optional)
  6451. * @param normalized whether the data contains normalized data (optional)
  6452. * @param useBytes set to true if stride and offset are in bytes (optional)
  6453. * @param divisor defines the instance divisor to use (1 by default)
  6454. */
  6455. 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);
  6456. /** @hidden */
  6457. _rebuild(): void;
  6458. /**
  6459. * Returns the kind of the VertexBuffer (string)
  6460. * @returns a string
  6461. */
  6462. getKind(): string;
  6463. /**
  6464. * Gets a boolean indicating if the VertexBuffer is updatable?
  6465. * @returns true if the buffer is updatable
  6466. */
  6467. isUpdatable(): boolean;
  6468. /**
  6469. * Gets current buffer's data
  6470. * @returns a DataArray or null
  6471. */
  6472. getData(): Nullable<DataArray>;
  6473. /**
  6474. * Gets underlying native buffer
  6475. * @returns underlying native buffer
  6476. */
  6477. getBuffer(): Nullable<DataBuffer>;
  6478. /**
  6479. * Gets the stride in float32 units (i.e. byte stride / 4).
  6480. * May not be an integer if the byte stride is not divisible by 4.
  6481. * @returns the stride in float32 units
  6482. * @deprecated Please use byteStride instead.
  6483. */
  6484. getStrideSize(): number;
  6485. /**
  6486. * Returns the offset as a multiple of the type byte length.
  6487. * @returns the offset in bytes
  6488. * @deprecated Please use byteOffset instead.
  6489. */
  6490. getOffset(): number;
  6491. /**
  6492. * Returns the number of components per vertex attribute (integer)
  6493. * @returns the size in float
  6494. */
  6495. getSize(): number;
  6496. /**
  6497. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6498. * @returns true if this buffer is instanced
  6499. */
  6500. getIsInstanced(): boolean;
  6501. /**
  6502. * Returns the instancing divisor, zero for non-instanced (integer).
  6503. * @returns a number
  6504. */
  6505. getInstanceDivisor(): number;
  6506. /**
  6507. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6508. * @param data defines the data to store
  6509. */
  6510. create(data?: DataArray): void;
  6511. /**
  6512. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6513. * This function will create a new buffer if the current one is not updatable
  6514. * @param data defines the data to store
  6515. */
  6516. update(data: DataArray): void;
  6517. /**
  6518. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6519. * Returns the directly updated WebGLBuffer.
  6520. * @param data the new data
  6521. * @param offset the new offset
  6522. * @param useBytes set to true if the offset is in bytes
  6523. */
  6524. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6525. /**
  6526. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6527. */
  6528. dispose(): void;
  6529. /**
  6530. * Enumerates each value of this vertex buffer as numbers.
  6531. * @param count the number of values to enumerate
  6532. * @param callback the callback function called for each value
  6533. */
  6534. forEach(count: number, callback: (value: number, index: number) => void): void;
  6535. /**
  6536. * Positions
  6537. */
  6538. static readonly PositionKind: string;
  6539. /**
  6540. * Normals
  6541. */
  6542. static readonly NormalKind: string;
  6543. /**
  6544. * Tangents
  6545. */
  6546. static readonly TangentKind: string;
  6547. /**
  6548. * Texture coordinates
  6549. */
  6550. static readonly UVKind: string;
  6551. /**
  6552. * Texture coordinates 2
  6553. */
  6554. static readonly UV2Kind: string;
  6555. /**
  6556. * Texture coordinates 3
  6557. */
  6558. static readonly UV3Kind: string;
  6559. /**
  6560. * Texture coordinates 4
  6561. */
  6562. static readonly UV4Kind: string;
  6563. /**
  6564. * Texture coordinates 5
  6565. */
  6566. static readonly UV5Kind: string;
  6567. /**
  6568. * Texture coordinates 6
  6569. */
  6570. static readonly UV6Kind: string;
  6571. /**
  6572. * Colors
  6573. */
  6574. static readonly ColorKind: string;
  6575. /**
  6576. * Matrix indices (for bones)
  6577. */
  6578. static readonly MatricesIndicesKind: string;
  6579. /**
  6580. * Matrix weights (for bones)
  6581. */
  6582. static readonly MatricesWeightsKind: string;
  6583. /**
  6584. * Additional matrix indices (for bones)
  6585. */
  6586. static readonly MatricesIndicesExtraKind: string;
  6587. /**
  6588. * Additional matrix weights (for bones)
  6589. */
  6590. static readonly MatricesWeightsExtraKind: string;
  6591. /**
  6592. * Deduces the stride given a kind.
  6593. * @param kind The kind string to deduce
  6594. * @returns The deduced stride
  6595. */
  6596. static DeduceStride(kind: string): number;
  6597. /**
  6598. * Gets the byte length of the given type.
  6599. * @param type the type
  6600. * @returns the number of bytes
  6601. */
  6602. static GetTypeByteLength(type: number): number;
  6603. /**
  6604. * Enumerates each value of the given parameters as numbers.
  6605. * @param data the data to enumerate
  6606. * @param byteOffset the byte offset of the data
  6607. * @param byteStride the byte stride of the data
  6608. * @param componentCount the number of components per element
  6609. * @param componentType the type of the component
  6610. * @param count the number of values to enumerate
  6611. * @param normalized whether the data is normalized
  6612. * @param callback the callback function called for each value
  6613. */
  6614. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6615. private static _GetFloatValue;
  6616. }
  6617. }
  6618. declare module "babylonjs/Collisions/intersectionInfo" {
  6619. import { Nullable } from "babylonjs/types";
  6620. /**
  6621. * @hidden
  6622. */
  6623. export class IntersectionInfo {
  6624. bu: Nullable<number>;
  6625. bv: Nullable<number>;
  6626. distance: number;
  6627. faceId: number;
  6628. subMeshId: number;
  6629. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6630. }
  6631. }
  6632. declare module "babylonjs/Maths/math.plane" {
  6633. import { DeepImmutable } from "babylonjs/types";
  6634. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6635. /**
  6636. * Represens a plane by the equation ax + by + cz + d = 0
  6637. */
  6638. export class Plane {
  6639. private static _TmpMatrix;
  6640. /**
  6641. * Normal of the plane (a,b,c)
  6642. */
  6643. normal: Vector3;
  6644. /**
  6645. * d component of the plane
  6646. */
  6647. d: number;
  6648. /**
  6649. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6650. * @param a a component of the plane
  6651. * @param b b component of the plane
  6652. * @param c c component of the plane
  6653. * @param d d component of the plane
  6654. */
  6655. constructor(a: number, b: number, c: number, d: number);
  6656. /**
  6657. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6658. */
  6659. asArray(): number[];
  6660. /**
  6661. * @returns a new plane copied from the current Plane.
  6662. */
  6663. clone(): Plane;
  6664. /**
  6665. * @returns the string "Plane".
  6666. */
  6667. getClassName(): string;
  6668. /**
  6669. * @returns the Plane hash code.
  6670. */
  6671. getHashCode(): number;
  6672. /**
  6673. * Normalize the current Plane in place.
  6674. * @returns the updated Plane.
  6675. */
  6676. normalize(): Plane;
  6677. /**
  6678. * Applies a transformation the plane and returns the result
  6679. * @param transformation the transformation matrix to be applied to the plane
  6680. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6681. */
  6682. transform(transformation: DeepImmutable<Matrix>): Plane;
  6683. /**
  6684. * Calcualtte the dot product between the point and the plane normal
  6685. * @param point point to calculate the dot product with
  6686. * @returns the dot product (float) of the point coordinates and the plane normal.
  6687. */
  6688. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6689. /**
  6690. * Updates the current Plane from the plane defined by the three given points.
  6691. * @param point1 one of the points used to contruct the plane
  6692. * @param point2 one of the points used to contruct the plane
  6693. * @param point3 one of the points used to contruct the plane
  6694. * @returns the updated Plane.
  6695. */
  6696. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6697. /**
  6698. * Checks if the plane is facing a given direction
  6699. * @param direction the direction to check if the plane is facing
  6700. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6701. * @returns True is the vector "direction" is the same side than the plane normal.
  6702. */
  6703. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6704. /**
  6705. * Calculates the distance to a point
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance (float) from the given point to the Plane.
  6708. */
  6709. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6710. /**
  6711. * Creates a plane from an array
  6712. * @param array the array to create a plane from
  6713. * @returns a new Plane from the given array.
  6714. */
  6715. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6716. /**
  6717. * Creates a plane from three points
  6718. * @param point1 point used to create the plane
  6719. * @param point2 point used to create the plane
  6720. * @param point3 point used to create the plane
  6721. * @returns a new Plane defined by the three given points.
  6722. */
  6723. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6724. /**
  6725. * Creates a plane from an origin point and a normal
  6726. * @param origin origin of the plane to be constructed
  6727. * @param normal normal of the plane to be constructed
  6728. * @returns a new Plane the normal vector to this plane at the given origin point.
  6729. * Note : the vector "normal" is updated because normalized.
  6730. */
  6731. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6732. /**
  6733. * Calculates the distance from a plane and a point
  6734. * @param origin origin of the plane to be constructed
  6735. * @param normal normal of the plane to be constructed
  6736. * @param point point to calculate distance to
  6737. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6738. */
  6739. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6740. }
  6741. }
  6742. declare module "babylonjs/Culling/boundingSphere" {
  6743. import { DeepImmutable } from "babylonjs/types";
  6744. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6745. import { Plane } from "babylonjs/Maths/math.plane";
  6746. /**
  6747. * Class used to store bounding sphere information
  6748. */
  6749. export class BoundingSphere {
  6750. /**
  6751. * Gets the center of the bounding sphere in local space
  6752. */
  6753. readonly center: Vector3;
  6754. /**
  6755. * Radius of the bounding sphere in local space
  6756. */
  6757. radius: number;
  6758. /**
  6759. * Gets the center of the bounding sphere in world space
  6760. */
  6761. readonly centerWorld: Vector3;
  6762. /**
  6763. * Radius of the bounding sphere in world space
  6764. */
  6765. radiusWorld: number;
  6766. /**
  6767. * Gets the minimum vector in local space
  6768. */
  6769. readonly minimum: Vector3;
  6770. /**
  6771. * Gets the maximum vector in local space
  6772. */
  6773. readonly maximum: Vector3;
  6774. private _worldMatrix;
  6775. private static readonly TmpVector3;
  6776. /**
  6777. * Creates a new bounding sphere
  6778. * @param min defines the minimum vector (in local space)
  6779. * @param max defines the maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6783. /**
  6784. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6785. * @param min defines the new minimum vector (in local space)
  6786. * @param max defines the new maximum vector (in local space)
  6787. * @param worldMatrix defines the new world matrix
  6788. */
  6789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6790. /**
  6791. * Scale the current bounding sphere by applying a scale factor
  6792. * @param factor defines the scale factor to apply
  6793. * @returns the current bounding box
  6794. */
  6795. scale(factor: number): BoundingSphere;
  6796. /**
  6797. * Gets the world matrix of the bounding box
  6798. * @returns a matrix
  6799. */
  6800. getWorldMatrix(): DeepImmutable<Matrix>;
  6801. /** @hidden */
  6802. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6803. /**
  6804. * Tests if the bounding sphere is intersecting the frustum planes
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if the bounding sphere center is in between the frustum planes.
  6811. * Used for optimistic fast inclusion.
  6812. * @param frustumPlanes defines the frustum planes to test
  6813. * @returns true if the sphere center is in between the frustum planes
  6814. */
  6815. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6816. /**
  6817. * Tests if a point is inside the bounding sphere
  6818. * @param point defines the point to test
  6819. * @returns true if the point is inside the bounding sphere
  6820. */
  6821. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6822. /**
  6823. * Checks if two sphere intersct
  6824. * @param sphere0 sphere 0
  6825. * @param sphere1 sphere 1
  6826. * @returns true if the speres intersect
  6827. */
  6828. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6829. }
  6830. }
  6831. declare module "babylonjs/Culling/boundingBox" {
  6832. import { DeepImmutable } from "babylonjs/types";
  6833. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6834. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6835. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6836. import { Plane } from "babylonjs/Maths/math.plane";
  6837. /**
  6838. * Class used to store bounding box information
  6839. */
  6840. export class BoundingBox implements ICullable {
  6841. /**
  6842. * Gets the 8 vectors representing the bounding box in local space
  6843. */
  6844. readonly vectors: Vector3[];
  6845. /**
  6846. * Gets the center of the bounding box in local space
  6847. */
  6848. readonly center: Vector3;
  6849. /**
  6850. * Gets the center of the bounding box in world space
  6851. */
  6852. readonly centerWorld: Vector3;
  6853. /**
  6854. * Gets the extend size in local space
  6855. */
  6856. readonly extendSize: Vector3;
  6857. /**
  6858. * Gets the extend size in world space
  6859. */
  6860. readonly extendSizeWorld: Vector3;
  6861. /**
  6862. * Gets the OBB (object bounding box) directions
  6863. */
  6864. readonly directions: Vector3[];
  6865. /**
  6866. * Gets the 8 vectors representing the bounding box in world space
  6867. */
  6868. readonly vectorsWorld: Vector3[];
  6869. /**
  6870. * Gets the minimum vector in world space
  6871. */
  6872. readonly minimumWorld: Vector3;
  6873. /**
  6874. * Gets the maximum vector in world space
  6875. */
  6876. readonly maximumWorld: Vector3;
  6877. /**
  6878. * Gets the minimum vector in local space
  6879. */
  6880. readonly minimum: Vector3;
  6881. /**
  6882. * Gets the maximum vector in local space
  6883. */
  6884. readonly maximum: Vector3;
  6885. private _worldMatrix;
  6886. private static readonly TmpVector3;
  6887. /**
  6888. * @hidden
  6889. */
  6890. _tag: number;
  6891. /**
  6892. * Creates a new bounding box
  6893. * @param min defines the minimum vector (in local space)
  6894. * @param max defines the maximum vector (in local space)
  6895. * @param worldMatrix defines the new world matrix
  6896. */
  6897. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6898. /**
  6899. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6900. * @param min defines the new minimum vector (in local space)
  6901. * @param max defines the new maximum vector (in local space)
  6902. * @param worldMatrix defines the new world matrix
  6903. */
  6904. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6905. /**
  6906. * Scale the current bounding box by applying a scale factor
  6907. * @param factor defines the scale factor to apply
  6908. * @returns the current bounding box
  6909. */
  6910. scale(factor: number): BoundingBox;
  6911. /**
  6912. * Gets the world matrix of the bounding box
  6913. * @returns a matrix
  6914. */
  6915. getWorldMatrix(): DeepImmutable<Matrix>;
  6916. /** @hidden */
  6917. _update(world: DeepImmutable<Matrix>): void;
  6918. /**
  6919. * Tests if the bounding box is intersecting the frustum planes
  6920. * @param frustumPlanes defines the frustum planes to test
  6921. * @returns true if there is an intersection
  6922. */
  6923. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6924. /**
  6925. * Tests if the bounding box is entirely inside the frustum planes
  6926. * @param frustumPlanes defines the frustum planes to test
  6927. * @returns true if there is an inclusion
  6928. */
  6929. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6930. /**
  6931. * Tests if a point is inside the bounding box
  6932. * @param point defines the point to test
  6933. * @returns true if the point is inside the bounding box
  6934. */
  6935. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6936. /**
  6937. * Tests if the bounding box intersects with a bounding sphere
  6938. * @param sphere defines the sphere to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6942. /**
  6943. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6944. * @param min defines the min vector to use
  6945. * @param max defines the max vector to use
  6946. * @returns true if there is an intersection
  6947. */
  6948. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6949. /**
  6950. * Tests if two bounding boxes are intersections
  6951. * @param box0 defines the first box to test
  6952. * @param box1 defines the second box to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6956. /**
  6957. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6958. * @param minPoint defines the minimum vector of the bounding box
  6959. * @param maxPoint defines the maximum vector of the bounding box
  6960. * @param sphereCenter defines the sphere center
  6961. * @param sphereRadius defines the sphere radius
  6962. * @returns true if there is an intersection
  6963. */
  6964. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6965. /**
  6966. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6967. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @return true if there is an inclusion
  6970. */
  6971. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6974. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @return true if there is an intersection
  6977. */
  6978. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. }
  6980. }
  6981. declare module "babylonjs/Collisions/collider" {
  6982. import { Nullable, IndicesArray } from "babylonjs/types";
  6983. import { Vector3 } from "babylonjs/Maths/math.vector";
  6984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6985. import { Plane } from "babylonjs/Maths/math.plane";
  6986. /** @hidden */
  6987. export class Collider {
  6988. /** Define if a collision was found */
  6989. collisionFound: boolean;
  6990. /**
  6991. * Define last intersection point in local space
  6992. */
  6993. intersectionPoint: Vector3;
  6994. /**
  6995. * Define last collided mesh
  6996. */
  6997. collidedMesh: Nullable<AbstractMesh>;
  6998. private _collisionPoint;
  6999. private _planeIntersectionPoint;
  7000. private _tempVector;
  7001. private _tempVector2;
  7002. private _tempVector3;
  7003. private _tempVector4;
  7004. private _edge;
  7005. private _baseToVertex;
  7006. private _destinationPoint;
  7007. private _slidePlaneNormal;
  7008. private _displacementVector;
  7009. /** @hidden */
  7010. _radius: Vector3;
  7011. /** @hidden */
  7012. _retry: number;
  7013. private _velocity;
  7014. private _basePoint;
  7015. private _epsilon;
  7016. /** @hidden */
  7017. _velocityWorldLength: number;
  7018. /** @hidden */
  7019. _basePointWorld: Vector3;
  7020. private _velocityWorld;
  7021. private _normalizedVelocity;
  7022. /** @hidden */
  7023. _initialVelocity: Vector3;
  7024. /** @hidden */
  7025. _initialPosition: Vector3;
  7026. private _nearestDistance;
  7027. private _collisionMask;
  7028. get collisionMask(): number;
  7029. set collisionMask(mask: number);
  7030. /**
  7031. * Gets the plane normal used to compute the sliding response (in local space)
  7032. */
  7033. get slidePlaneNormal(): Vector3;
  7034. /** @hidden */
  7035. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7036. /** @hidden */
  7037. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7038. /** @hidden */
  7039. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7040. /** @hidden */
  7041. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7042. /** @hidden */
  7043. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7044. /** @hidden */
  7045. _getResponse(pos: Vector3, vel: Vector3): void;
  7046. }
  7047. }
  7048. declare module "babylonjs/Culling/boundingInfo" {
  7049. import { DeepImmutable } from "babylonjs/types";
  7050. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7051. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7052. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7053. import { Plane } from "babylonjs/Maths/math.plane";
  7054. import { Collider } from "babylonjs/Collisions/collider";
  7055. /**
  7056. * Interface for cullable objects
  7057. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7058. */
  7059. export interface ICullable {
  7060. /**
  7061. * Checks if the object or part of the object is in the frustum
  7062. * @param frustumPlanes Camera near/planes
  7063. * @returns true if the object is in frustum otherwise false
  7064. */
  7065. isInFrustum(frustumPlanes: Plane[]): boolean;
  7066. /**
  7067. * Checks if a cullable object (mesh...) is in the camera frustum
  7068. * Unlike isInFrustum this cheks the full bounding box
  7069. * @param frustumPlanes Camera near/planes
  7070. * @returns true if the object is in frustum otherwise false
  7071. */
  7072. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7073. }
  7074. /**
  7075. * Info for a bounding data of a mesh
  7076. */
  7077. export class BoundingInfo implements ICullable {
  7078. /**
  7079. * Bounding box for the mesh
  7080. */
  7081. readonly boundingBox: BoundingBox;
  7082. /**
  7083. * Bounding sphere for the mesh
  7084. */
  7085. readonly boundingSphere: BoundingSphere;
  7086. private _isLocked;
  7087. private static readonly TmpVector3;
  7088. /**
  7089. * Constructs bounding info
  7090. * @param minimum min vector of the bounding box/sphere
  7091. * @param maximum max vector of the bounding box/sphere
  7092. * @param worldMatrix defines the new world matrix
  7093. */
  7094. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7095. /**
  7096. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7097. * @param min defines the new minimum vector (in local space)
  7098. * @param max defines the new maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7102. /**
  7103. * min vector of the bounding box/sphere
  7104. */
  7105. get minimum(): Vector3;
  7106. /**
  7107. * max vector of the bounding box/sphere
  7108. */
  7109. get maximum(): Vector3;
  7110. /**
  7111. * If the info is locked and won't be updated to avoid perf overhead
  7112. */
  7113. get isLocked(): boolean;
  7114. set isLocked(value: boolean);
  7115. /**
  7116. * Updates the bounding sphere and box
  7117. * @param world world matrix to be used to update
  7118. */
  7119. update(world: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7122. * @param center New center of the bounding info
  7123. * @param extend New extend of the bounding info
  7124. * @returns the current bounding info
  7125. */
  7126. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7127. /**
  7128. * Scale the current bounding info by applying a scale factor
  7129. * @param factor defines the scale factor to apply
  7130. * @returns the current bounding info
  7131. */
  7132. scale(factor: number): BoundingInfo;
  7133. /**
  7134. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7135. * @param frustumPlanes defines the frustum to test
  7136. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7137. * @returns true if the bounding info is in the frustum planes
  7138. */
  7139. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7140. /**
  7141. * Gets the world distance between the min and max points of the bounding box
  7142. */
  7143. get diagonalLength(): number;
  7144. /**
  7145. * Checks if a cullable object (mesh...) is in the camera frustum
  7146. * Unlike isInFrustum this cheks the full bounding box
  7147. * @param frustumPlanes Camera near/planes
  7148. * @returns true if the object is in frustum otherwise false
  7149. */
  7150. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7151. /** @hidden */
  7152. _checkCollision(collider: Collider): boolean;
  7153. /**
  7154. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7155. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7156. * @param point the point to check intersection with
  7157. * @returns if the point intersects
  7158. */
  7159. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7160. /**
  7161. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7162. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7163. * @param boundingInfo the bounding info to check intersection with
  7164. * @param precise if the intersection should be done using OBB
  7165. * @returns if the bounding info intersects
  7166. */
  7167. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7168. }
  7169. }
  7170. declare module "babylonjs/Maths/math.functions" {
  7171. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7172. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7173. /**
  7174. * Extracts minimum and maximum values from a list of indexed positions
  7175. * @param positions defines the positions to use
  7176. * @param indices defines the indices to the positions
  7177. * @param indexStart defines the start index
  7178. * @param indexCount defines the end index
  7179. * @param bias defines bias value to add to the result
  7180. * @return minimum and maximum values
  7181. */
  7182. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7183. minimum: Vector3;
  7184. maximum: Vector3;
  7185. };
  7186. /**
  7187. * Extracts minimum and maximum values from a list of positions
  7188. * @param positions defines the positions to use
  7189. * @param start defines the start index in the positions array
  7190. * @param count defines the number of positions to handle
  7191. * @param bias defines bias value to add to the result
  7192. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7193. * @return minimum and maximum values
  7194. */
  7195. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7196. minimum: Vector3;
  7197. maximum: Vector3;
  7198. };
  7199. }
  7200. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7201. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7202. /** @hidden */
  7203. export class WebGLDataBuffer extends DataBuffer {
  7204. private _buffer;
  7205. constructor(resource: WebGLBuffer);
  7206. get underlyingResource(): any;
  7207. }
  7208. }
  7209. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7210. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7211. import { Nullable } from "babylonjs/types";
  7212. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7213. /** @hidden */
  7214. export class WebGLPipelineContext implements IPipelineContext {
  7215. engine: ThinEngine;
  7216. program: Nullable<WebGLProgram>;
  7217. context?: WebGLRenderingContext;
  7218. vertexShader?: WebGLShader;
  7219. fragmentShader?: WebGLShader;
  7220. isParallelCompiled: boolean;
  7221. onCompiled?: () => void;
  7222. transformFeedback?: WebGLTransformFeedback | null;
  7223. vertexCompilationError: Nullable<string>;
  7224. fragmentCompilationError: Nullable<string>;
  7225. programLinkError: Nullable<string>;
  7226. programValidationError: Nullable<string>;
  7227. get isAsync(): boolean;
  7228. get isReady(): boolean;
  7229. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7230. _getVertexShaderCode(): string | null;
  7231. _getFragmentShaderCode(): string | null;
  7232. }
  7233. }
  7234. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7235. import { FloatArray, Nullable } from "babylonjs/types";
  7236. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7237. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7238. module "babylonjs/Engines/thinEngine" {
  7239. interface ThinEngine {
  7240. /**
  7241. * Create an uniform buffer
  7242. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7243. * @param elements defines the content of the uniform buffer
  7244. * @returns the webGL uniform buffer
  7245. */
  7246. createUniformBuffer(elements: FloatArray): DataBuffer;
  7247. /**
  7248. * Create a dynamic uniform buffer
  7249. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7250. * @param elements defines the content of the uniform buffer
  7251. * @returns the webGL uniform buffer
  7252. */
  7253. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7254. /**
  7255. * Update an existing uniform buffer
  7256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7257. * @param uniformBuffer defines the target uniform buffer
  7258. * @param elements defines the content to update
  7259. * @param offset defines the offset in the uniform buffer where update should start
  7260. * @param count defines the size of the data to update
  7261. */
  7262. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7263. /**
  7264. * Bind an uniform buffer to the current webGL context
  7265. * @param buffer defines the buffer to bind
  7266. */
  7267. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7268. /**
  7269. * Bind a buffer to the current webGL context at a given location
  7270. * @param buffer defines the buffer to bind
  7271. * @param location defines the index where to bind the buffer
  7272. */
  7273. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7274. /**
  7275. * Bind a specific block at a given index in a specific shader program
  7276. * @param pipelineContext defines the pipeline context to use
  7277. * @param blockName defines the block name
  7278. * @param index defines the index where to bind the block
  7279. */
  7280. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7281. }
  7282. }
  7283. }
  7284. declare module "babylonjs/Materials/uniformBuffer" {
  7285. import { Nullable, FloatArray } from "babylonjs/types";
  7286. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7287. import { Engine } from "babylonjs/Engines/engine";
  7288. import { Effect } from "babylonjs/Materials/effect";
  7289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7291. import { Color3 } from "babylonjs/Maths/math.color";
  7292. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7293. /**
  7294. * Uniform buffer objects.
  7295. *
  7296. * Handles blocks of uniform on the GPU.
  7297. *
  7298. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7299. *
  7300. * For more information, please refer to :
  7301. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7302. */
  7303. export class UniformBuffer {
  7304. private _engine;
  7305. private _buffer;
  7306. private _data;
  7307. private _bufferData;
  7308. private _dynamic?;
  7309. private _uniformLocations;
  7310. private _uniformSizes;
  7311. private _uniformLocationPointer;
  7312. private _needSync;
  7313. private _noUBO;
  7314. private _currentEffect;
  7315. /** @hidden */
  7316. _alreadyBound: boolean;
  7317. private static _MAX_UNIFORM_SIZE;
  7318. private static _tempBuffer;
  7319. /**
  7320. * Lambda to Update a 3x3 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7331. /**
  7332. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7337. /**
  7338. * Lambda to Update a vec2 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec3 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7355. /**
  7356. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7361. /**
  7362. * Lambda to Update vec3 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. updateVector3: (name: string, vector: Vector3) => void;
  7367. /**
  7368. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7373. /**
  7374. * Lambda to Update vec3 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7379. /**
  7380. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7385. /**
  7386. * Instantiates a new Uniform buffer objects.
  7387. *
  7388. * Handles blocks of uniform on the GPU.
  7389. *
  7390. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7391. *
  7392. * For more information, please refer to :
  7393. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7394. * @param engine Define the engine the buffer is associated with
  7395. * @param data Define the data contained in the buffer
  7396. * @param dynamic Define if the buffer is updatable
  7397. */
  7398. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7399. /**
  7400. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7401. * or just falling back on setUniformXXX calls.
  7402. */
  7403. get useUbo(): boolean;
  7404. /**
  7405. * Indicates if the WebGL underlying uniform buffer is in sync
  7406. * with the javascript cache data.
  7407. */
  7408. get isSync(): boolean;
  7409. /**
  7410. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7411. * Also, a dynamic UniformBuffer will disable cache verification and always
  7412. * update the underlying WebGL uniform buffer to the GPU.
  7413. * @returns if Dynamic, otherwise false
  7414. */
  7415. isDynamic(): boolean;
  7416. /**
  7417. * The data cache on JS side.
  7418. * @returns the underlying data as a float array
  7419. */
  7420. getData(): Float32Array;
  7421. /**
  7422. * The underlying WebGL Uniform buffer.
  7423. * @returns the webgl buffer
  7424. */
  7425. getBuffer(): Nullable<DataBuffer>;
  7426. /**
  7427. * std140 layout specifies how to align data within an UBO structure.
  7428. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7429. * for specs.
  7430. */
  7431. private _fillAlignment;
  7432. /**
  7433. * Adds an uniform in the buffer.
  7434. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7435. * for the layout to be correct !
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param size Data size, or data directly.
  7438. */
  7439. addUniform(name: string, size: number | number[]): void;
  7440. /**
  7441. * Adds a Matrix 4x4 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param mat A 4x4 matrix.
  7444. */
  7445. addMatrix(name: string, mat: Matrix): void;
  7446. /**
  7447. * Adds a vec2 to the uniform buffer.
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. * @param x Define the x component value of the vec2
  7450. * @param y Define the y component value of the vec2
  7451. */
  7452. addFloat2(name: string, x: number, y: number): void;
  7453. /**
  7454. * Adds a vec3 to the uniform buffer.
  7455. * @param name Name of the uniform, as used in the uniform block in the shader.
  7456. * @param x Define the x component value of the vec3
  7457. * @param y Define the y component value of the vec3
  7458. * @param z Define the z component value of the vec3
  7459. */
  7460. addFloat3(name: string, x: number, y: number, z: number): void;
  7461. /**
  7462. * Adds a vec3 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 vec3 from a Color
  7465. */
  7466. addColor3(name: string, color: Color3): void;
  7467. /**
  7468. * Adds a vec4 to the uniform buffer.
  7469. * @param name Name of the uniform, as used in the uniform block in the shader.
  7470. * @param color Define the rgb components from a Color
  7471. * @param alpha Define the a component of the vec4
  7472. */
  7473. addColor4(name: string, color: Color3, alpha: number): void;
  7474. /**
  7475. * Adds a vec3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. * @param vector Define the vec3 components from a Vector
  7478. */
  7479. addVector3(name: string, vector: Vector3): void;
  7480. /**
  7481. * Adds a Matrix 3x3 to the uniform buffer.
  7482. * @param name Name of the uniform, as used in the uniform block in the shader.
  7483. */
  7484. addMatrix3x3(name: string): void;
  7485. /**
  7486. * Adds a Matrix 2x2 to the uniform buffer.
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. */
  7489. addMatrix2x2(name: string): void;
  7490. /**
  7491. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7492. */
  7493. create(): void;
  7494. /** @hidden */
  7495. _rebuild(): void;
  7496. /**
  7497. * Updates the WebGL Uniform Buffer on the GPU.
  7498. * If the `dynamic` flag is set to true, no cache comparison is done.
  7499. * Otherwise, the buffer will be updated only if the cache differs.
  7500. */
  7501. update(): void;
  7502. /**
  7503. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7504. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7505. * @param data Define the flattened data
  7506. * @param size Define the size of the data.
  7507. */
  7508. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7509. private _valueCache;
  7510. private _cacheMatrix;
  7511. private _updateMatrix3x3ForUniform;
  7512. private _updateMatrix3x3ForEffect;
  7513. private _updateMatrix2x2ForEffect;
  7514. private _updateMatrix2x2ForUniform;
  7515. private _updateFloatForEffect;
  7516. private _updateFloatForUniform;
  7517. private _updateFloat2ForEffect;
  7518. private _updateFloat2ForUniform;
  7519. private _updateFloat3ForEffect;
  7520. private _updateFloat3ForUniform;
  7521. private _updateFloat4ForEffect;
  7522. private _updateFloat4ForUniform;
  7523. private _updateMatrixForEffect;
  7524. private _updateMatrixForUniform;
  7525. private _updateVector3ForEffect;
  7526. private _updateVector3ForUniform;
  7527. private _updateVector4ForEffect;
  7528. private _updateVector4ForUniform;
  7529. private _updateColor3ForEffect;
  7530. private _updateColor3ForUniform;
  7531. private _updateColor4ForEffect;
  7532. private _updateColor4ForUniform;
  7533. /**
  7534. * Sets a sampler uniform on the effect.
  7535. * @param name Define the name of the sampler.
  7536. * @param texture Define the texture to set in the sampler
  7537. */
  7538. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7539. /**
  7540. * Directly updates the value of the uniform in the cache AND on the GPU.
  7541. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7542. * @param data Define the flattened data
  7543. */
  7544. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7545. /**
  7546. * Binds this uniform buffer to an effect.
  7547. * @param effect Define the effect to bind the buffer to
  7548. * @param name Name of the uniform block in the shader.
  7549. */
  7550. bindToEffect(effect: Effect, name: string): void;
  7551. /**
  7552. * Disposes the uniform buffer.
  7553. */
  7554. dispose(): void;
  7555. }
  7556. }
  7557. declare module "babylonjs/Misc/iInspectable" {
  7558. /**
  7559. * Enum that determines the text-wrapping mode to use.
  7560. */
  7561. export enum InspectableType {
  7562. /**
  7563. * Checkbox for booleans
  7564. */
  7565. Checkbox = 0,
  7566. /**
  7567. * Sliders for numbers
  7568. */
  7569. Slider = 1,
  7570. /**
  7571. * Vector3
  7572. */
  7573. Vector3 = 2,
  7574. /**
  7575. * Quaternions
  7576. */
  7577. Quaternion = 3,
  7578. /**
  7579. * Color3
  7580. */
  7581. Color3 = 4,
  7582. /**
  7583. * String
  7584. */
  7585. String = 5
  7586. }
  7587. /**
  7588. * Interface used to define custom inspectable properties.
  7589. * This interface is used by the inspector to display custom property grids
  7590. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7591. */
  7592. export interface IInspectable {
  7593. /**
  7594. * Gets the label to display
  7595. */
  7596. label: string;
  7597. /**
  7598. * Gets the name of the property to edit
  7599. */
  7600. propertyName: string;
  7601. /**
  7602. * Gets the type of the editor to use
  7603. */
  7604. type: InspectableType;
  7605. /**
  7606. * Gets the minimum value of the property when using in "slider" mode
  7607. */
  7608. min?: number;
  7609. /**
  7610. * Gets the maximum value of the property when using in "slider" mode
  7611. */
  7612. max?: number;
  7613. /**
  7614. * Gets the setp to use when using in "slider" mode
  7615. */
  7616. step?: number;
  7617. }
  7618. }
  7619. declare module "babylonjs/Misc/timingTools" {
  7620. /**
  7621. * Class used to provide helper for timing
  7622. */
  7623. export class TimingTools {
  7624. /**
  7625. * Polyfill for setImmediate
  7626. * @param action defines the action to execute after the current execution block
  7627. */
  7628. static SetImmediate(action: () => void): void;
  7629. }
  7630. }
  7631. declare module "babylonjs/Misc/instantiationTools" {
  7632. /**
  7633. * Class used to enable instatition of objects by class name
  7634. */
  7635. export class InstantiationTools {
  7636. /**
  7637. * Use this object to register external classes like custom textures or material
  7638. * to allow the laoders to instantiate them
  7639. */
  7640. static RegisteredExternalClasses: {
  7641. [key: string]: Object;
  7642. };
  7643. /**
  7644. * Tries to instantiate a new object from a given class name
  7645. * @param className defines the class name to instantiate
  7646. * @returns the new object or null if the system was not able to do the instantiation
  7647. */
  7648. static Instantiate(className: string): any;
  7649. }
  7650. }
  7651. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7652. /**
  7653. * Define options used to create a depth texture
  7654. */
  7655. export class DepthTextureCreationOptions {
  7656. /** Specifies whether or not a stencil should be allocated in the texture */
  7657. generateStencil?: boolean;
  7658. /** Specifies whether or not bilinear filtering is enable on the texture */
  7659. bilinearFiltering?: boolean;
  7660. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7661. comparisonFunction?: number;
  7662. /** Specifies if the created texture is a cube texture */
  7663. isCube?: boolean;
  7664. }
  7665. }
  7666. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7667. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7668. import { Nullable } from "babylonjs/types";
  7669. import { Scene } from "babylonjs/scene";
  7670. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7671. module "babylonjs/Engines/thinEngine" {
  7672. interface ThinEngine {
  7673. /**
  7674. * Creates a depth stencil cube texture.
  7675. * This is only available in WebGL 2.
  7676. * @param size The size of face edge in the cube texture.
  7677. * @param options The options defining the cube texture.
  7678. * @returns The cube texture
  7679. */
  7680. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7681. /**
  7682. * Creates a cube texture
  7683. * @param rootUrl defines the url where the files to load is located
  7684. * @param scene defines the current scene
  7685. * @param files defines the list of files to load (1 per face)
  7686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7687. * @param onLoad defines an optional callback raised when the texture is loaded
  7688. * @param onError defines an optional callback raised if there is an issue to load the texture
  7689. * @param format defines the format of the data
  7690. * @param forcedExtension defines the extension to use to pick the right loader
  7691. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7694. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7695. * @returns the cube texture as an InternalTexture
  7696. */
  7697. 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;
  7698. /**
  7699. * Creates a cube texture
  7700. * @param rootUrl defines the url where the files to load is located
  7701. * @param scene defines the current scene
  7702. * @param files defines the list of files to load (1 per face)
  7703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7704. * @param onLoad defines an optional callback raised when the texture is loaded
  7705. * @param onError defines an optional callback raised if there is an issue to load the texture
  7706. * @param format defines the format of the data
  7707. * @param forcedExtension defines the extension to use to pick the right loader
  7708. * @returns the cube texture as an InternalTexture
  7709. */
  7710. 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;
  7711. /**
  7712. * Creates a cube texture
  7713. * @param rootUrl defines the url where the files to load is located
  7714. * @param scene defines the current scene
  7715. * @param files defines the list of files to load (1 per face)
  7716. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7717. * @param onLoad defines an optional callback raised when the texture is loaded
  7718. * @param onError defines an optional callback raised if there is an issue to load the texture
  7719. * @param format defines the format of the data
  7720. * @param forcedExtension defines the extension to use to pick the right loader
  7721. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7722. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7723. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7724. * @returns the cube texture as an InternalTexture
  7725. */
  7726. 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;
  7727. /** @hidden */
  7728. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7729. /** @hidden */
  7730. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7731. /** @hidden */
  7732. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7733. /** @hidden */
  7734. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7735. /**
  7736. * @hidden
  7737. */
  7738. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7739. }
  7740. }
  7741. }
  7742. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7743. import { Nullable } from "babylonjs/types";
  7744. import { Scene } from "babylonjs/scene";
  7745. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7747. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7748. import { Observable } from "babylonjs/Misc/observable";
  7749. /**
  7750. * Class for creating a cube texture
  7751. */
  7752. export class CubeTexture extends BaseTexture {
  7753. private _delayedOnLoad;
  7754. /**
  7755. * Observable triggered once the texture has been loaded.
  7756. */
  7757. onLoadObservable: Observable<CubeTexture>;
  7758. /**
  7759. * The url of the texture
  7760. */
  7761. url: string;
  7762. /**
  7763. * Gets or sets the center of the bounding box associated with the cube texture.
  7764. * It must define where the camera used to render the texture was set
  7765. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7766. */
  7767. boundingBoxPosition: Vector3;
  7768. private _boundingBoxSize;
  7769. /**
  7770. * Gets or sets the size of the bounding box associated with the cube texture
  7771. * When defined, the cubemap will switch to local mode
  7772. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7773. * @example https://www.babylonjs-playground.com/#RNASML
  7774. */
  7775. set boundingBoxSize(value: Vector3);
  7776. /**
  7777. * Returns the bounding box size
  7778. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7779. */
  7780. get boundingBoxSize(): Vector3;
  7781. protected _rotationY: number;
  7782. /**
  7783. * Sets texture matrix rotation angle around Y axis in radians.
  7784. */
  7785. set rotationY(value: number);
  7786. /**
  7787. * Gets texture matrix rotation angle around Y axis radians.
  7788. */
  7789. get rotationY(): number;
  7790. /**
  7791. * Are mip maps generated for this texture or not.
  7792. */
  7793. get noMipmap(): boolean;
  7794. private _noMipmap;
  7795. private _files;
  7796. protected _forcedExtension: Nullable<string>;
  7797. private _extensions;
  7798. private _textureMatrix;
  7799. private _format;
  7800. private _createPolynomials;
  7801. /** @hidden */
  7802. _prefiltered: boolean;
  7803. /**
  7804. * Creates a cube texture from an array of image urls
  7805. * @param files defines an array of image urls
  7806. * @param scene defines the hosting scene
  7807. * @param noMipmap specifies if mip maps are not used
  7808. * @returns a cube texture
  7809. */
  7810. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7811. /**
  7812. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7813. * @param url defines the url of the prefiltered texture
  7814. * @param scene defines the scene the texture is attached to
  7815. * @param forcedExtension defines the extension of the file if different from the url
  7816. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7817. * @return the prefiltered texture
  7818. */
  7819. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7820. /**
  7821. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7822. * as prefiltered data.
  7823. * @param rootUrl defines the url of the texture or the root name of the six images
  7824. * @param scene defines the scene the texture is attached to
  7825. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7826. * @param noMipmap defines if mipmaps should be created or not
  7827. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7828. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7829. * @param onError defines a callback triggered in case of error during load
  7830. * @param format defines the internal format to use for the texture once loaded
  7831. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7832. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7833. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7834. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7835. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7836. * @return the cube texture
  7837. */
  7838. 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);
  7839. /**
  7840. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7841. */
  7842. get isPrefiltered(): boolean;
  7843. /**
  7844. * Get the current class name of the texture useful for serialization or dynamic coding.
  7845. * @returns "CubeTexture"
  7846. */
  7847. getClassName(): string;
  7848. /**
  7849. * Update the url (and optional buffer) of this texture if url was null during construction.
  7850. * @param url the url of the texture
  7851. * @param forcedExtension defines the extension to use
  7852. * @param onLoad callback called when the texture is loaded (defaults to null)
  7853. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7854. */
  7855. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7856. /**
  7857. * Delays loading of the cube texture
  7858. * @param forcedExtension defines the extension to use
  7859. */
  7860. delayLoad(forcedExtension?: string): void;
  7861. /**
  7862. * Returns the reflection texture matrix
  7863. * @returns the reflection texture matrix
  7864. */
  7865. getReflectionTextureMatrix(): Matrix;
  7866. /**
  7867. * Sets the reflection texture matrix
  7868. * @param value Reflection texture matrix
  7869. */
  7870. setReflectionTextureMatrix(value: Matrix): void;
  7871. /**
  7872. * Parses text to create a cube texture
  7873. * @param parsedTexture define the serialized text to read from
  7874. * @param scene defines the hosting scene
  7875. * @param rootUrl defines the root url of the cube texture
  7876. * @returns a cube texture
  7877. */
  7878. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7879. /**
  7880. * Makes a clone, or deep copy, of the cube texture
  7881. * @returns a new cube texture
  7882. */
  7883. clone(): CubeTexture;
  7884. }
  7885. }
  7886. declare module "babylonjs/Materials/materialDefines" {
  7887. /**
  7888. * Manages the defines for the Material
  7889. */
  7890. export class MaterialDefines {
  7891. /** @hidden */
  7892. protected _keys: string[];
  7893. private _isDirty;
  7894. /** @hidden */
  7895. _renderId: number;
  7896. /** @hidden */
  7897. _areLightsDirty: boolean;
  7898. /** @hidden */
  7899. _areLightsDisposed: boolean;
  7900. /** @hidden */
  7901. _areAttributesDirty: boolean;
  7902. /** @hidden */
  7903. _areTexturesDirty: boolean;
  7904. /** @hidden */
  7905. _areFresnelDirty: boolean;
  7906. /** @hidden */
  7907. _areMiscDirty: boolean;
  7908. /** @hidden */
  7909. _areImageProcessingDirty: boolean;
  7910. /** @hidden */
  7911. _normals: boolean;
  7912. /** @hidden */
  7913. _uvs: boolean;
  7914. /** @hidden */
  7915. _needNormals: boolean;
  7916. /** @hidden */
  7917. _needUVs: boolean;
  7918. [id: string]: any;
  7919. /**
  7920. * Specifies if the material needs to be re-calculated
  7921. */
  7922. get isDirty(): boolean;
  7923. /**
  7924. * Marks the material to indicate that it has been re-calculated
  7925. */
  7926. markAsProcessed(): void;
  7927. /**
  7928. * Marks the material to indicate that it needs to be re-calculated
  7929. */
  7930. markAsUnprocessed(): void;
  7931. /**
  7932. * Marks the material to indicate all of its defines need to be re-calculated
  7933. */
  7934. markAllAsDirty(): void;
  7935. /**
  7936. * Marks the material to indicate that image processing needs to be re-calculated
  7937. */
  7938. markAsImageProcessingDirty(): void;
  7939. /**
  7940. * Marks the material to indicate the lights need to be re-calculated
  7941. * @param disposed Defines whether the light is dirty due to dispose or not
  7942. */
  7943. markAsLightDirty(disposed?: boolean): void;
  7944. /**
  7945. * Marks the attribute state as changed
  7946. */
  7947. markAsAttributesDirty(): void;
  7948. /**
  7949. * Marks the texture state as changed
  7950. */
  7951. markAsTexturesDirty(): void;
  7952. /**
  7953. * Marks the fresnel state as changed
  7954. */
  7955. markAsFresnelDirty(): void;
  7956. /**
  7957. * Marks the misc state as changed
  7958. */
  7959. markAsMiscDirty(): void;
  7960. /**
  7961. * Rebuilds the material defines
  7962. */
  7963. rebuild(): void;
  7964. /**
  7965. * Specifies if two material defines are equal
  7966. * @param other - A material define instance to compare to
  7967. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7968. */
  7969. isEqual(other: MaterialDefines): boolean;
  7970. /**
  7971. * Clones this instance's defines to another instance
  7972. * @param other - material defines to clone values to
  7973. */
  7974. cloneTo(other: MaterialDefines): void;
  7975. /**
  7976. * Resets the material define values
  7977. */
  7978. reset(): void;
  7979. /**
  7980. * Converts the material define values to a string
  7981. * @returns - String of material define information
  7982. */
  7983. toString(): string;
  7984. }
  7985. }
  7986. declare module "babylonjs/Materials/colorCurves" {
  7987. import { Effect } from "babylonjs/Materials/effect";
  7988. /**
  7989. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7990. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7991. * 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;
  7992. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7993. */
  7994. export class ColorCurves {
  7995. private _dirty;
  7996. private _tempColor;
  7997. private _globalCurve;
  7998. private _highlightsCurve;
  7999. private _midtonesCurve;
  8000. private _shadowsCurve;
  8001. private _positiveCurve;
  8002. private _negativeCurve;
  8003. private _globalHue;
  8004. private _globalDensity;
  8005. private _globalSaturation;
  8006. private _globalExposure;
  8007. /**
  8008. * Gets the global Hue value.
  8009. * 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).
  8010. */
  8011. get globalHue(): number;
  8012. /**
  8013. * Sets the global Hue value.
  8014. * 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).
  8015. */
  8016. set globalHue(value: number);
  8017. /**
  8018. * Gets 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. get globalDensity(): number;
  8023. /**
  8024. * Sets the global Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. set globalDensity(value: number);
  8029. /**
  8030. * Gets the global Saturation value.
  8031. * 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.
  8032. */
  8033. get globalSaturation(): number;
  8034. /**
  8035. * Sets the global Saturation value.
  8036. * 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.
  8037. */
  8038. set globalSaturation(value: number);
  8039. /**
  8040. * Gets the global Exposure value.
  8041. * 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.
  8042. */
  8043. get globalExposure(): number;
  8044. /**
  8045. * Sets the global Exposure value.
  8046. * 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.
  8047. */
  8048. set globalExposure(value: number);
  8049. private _highlightsHue;
  8050. private _highlightsDensity;
  8051. private _highlightsSaturation;
  8052. private _highlightsExposure;
  8053. /**
  8054. * Gets the highlights Hue value.
  8055. * 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).
  8056. */
  8057. get highlightsHue(): number;
  8058. /**
  8059. * Sets the highlights Hue value.
  8060. * 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).
  8061. */
  8062. set highlightsHue(value: number);
  8063. /**
  8064. * Gets 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. get highlightsDensity(): number;
  8069. /**
  8070. * Sets the highlights Density value.
  8071. * 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.
  8072. * Values less than zero provide a filter of opposite hue.
  8073. */
  8074. set highlightsDensity(value: number);
  8075. /**
  8076. * Gets the highlights Saturation value.
  8077. * 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.
  8078. */
  8079. get highlightsSaturation(): number;
  8080. /**
  8081. * Sets the highlights Saturation value.
  8082. * 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.
  8083. */
  8084. set highlightsSaturation(value: number);
  8085. /**
  8086. * Gets the highlights Exposure value.
  8087. * 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.
  8088. */
  8089. get highlightsExposure(): number;
  8090. /**
  8091. * Sets the highlights Exposure value.
  8092. * 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.
  8093. */
  8094. set highlightsExposure(value: number);
  8095. private _midtonesHue;
  8096. private _midtonesDensity;
  8097. private _midtonesSaturation;
  8098. private _midtonesExposure;
  8099. /**
  8100. * Gets the midtones Hue value.
  8101. * 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).
  8102. */
  8103. get midtonesHue(): number;
  8104. /**
  8105. * Sets the midtones Hue value.
  8106. * 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).
  8107. */
  8108. set midtonesHue(value: number);
  8109. /**
  8110. * Gets 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. get midtonesDensity(): number;
  8115. /**
  8116. * Sets the midtones Density value.
  8117. * 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.
  8118. * Values less than zero provide a filter of opposite hue.
  8119. */
  8120. set midtonesDensity(value: number);
  8121. /**
  8122. * Gets the midtones Saturation value.
  8123. * 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.
  8124. */
  8125. get midtonesSaturation(): number;
  8126. /**
  8127. * Sets the midtones Saturation value.
  8128. * 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.
  8129. */
  8130. set midtonesSaturation(value: number);
  8131. /**
  8132. * Gets the midtones Exposure value.
  8133. * 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.
  8134. */
  8135. get midtonesExposure(): number;
  8136. /**
  8137. * Sets the midtones Exposure value.
  8138. * 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.
  8139. */
  8140. set midtonesExposure(value: number);
  8141. private _shadowsHue;
  8142. private _shadowsDensity;
  8143. private _shadowsSaturation;
  8144. private _shadowsExposure;
  8145. /**
  8146. * Gets the shadows Hue value.
  8147. * 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).
  8148. */
  8149. get shadowsHue(): number;
  8150. /**
  8151. * Sets the shadows Hue value.
  8152. * 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).
  8153. */
  8154. set shadowsHue(value: number);
  8155. /**
  8156. * Gets 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. get shadowsDensity(): number;
  8161. /**
  8162. * Sets the shadows Density value.
  8163. * 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.
  8164. * Values less than zero provide a filter of opposite hue.
  8165. */
  8166. set shadowsDensity(value: number);
  8167. /**
  8168. * Gets the shadows Saturation value.
  8169. * 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.
  8170. */
  8171. get shadowsSaturation(): number;
  8172. /**
  8173. * Sets the shadows Saturation value.
  8174. * 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.
  8175. */
  8176. set shadowsSaturation(value: number);
  8177. /**
  8178. * Gets the shadows Exposure value.
  8179. * 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.
  8180. */
  8181. get shadowsExposure(): number;
  8182. /**
  8183. * Sets the shadows Exposure value.
  8184. * 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.
  8185. */
  8186. set shadowsExposure(value: number);
  8187. /**
  8188. * Returns the class name
  8189. * @returns The class name
  8190. */
  8191. getClassName(): string;
  8192. /**
  8193. * Binds the color curves to the shader.
  8194. * @param colorCurves The color curve to bind
  8195. * @param effect The effect to bind to
  8196. * @param positiveUniform The positive uniform shader parameter
  8197. * @param neutralUniform The neutral uniform shader parameter
  8198. * @param negativeUniform The negative uniform shader parameter
  8199. */
  8200. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8201. /**
  8202. * Prepare the list of uniforms associated with the ColorCurves effects.
  8203. * @param uniformsList The list of uniforms used in the effect
  8204. */
  8205. static PrepareUniforms(uniformsList: string[]): void;
  8206. /**
  8207. * Returns color grading data based on a hue, density, saturation and exposure value.
  8208. * @param filterHue The hue of the color filter.
  8209. * @param filterDensity The density of the color filter.
  8210. * @param saturation The saturation.
  8211. * @param exposure The exposure.
  8212. * @param result The result data container.
  8213. */
  8214. private getColorGradingDataToRef;
  8215. /**
  8216. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8217. * @param value The input slider value in range [-100,100].
  8218. * @returns Adjusted value.
  8219. */
  8220. private static applyColorGradingSliderNonlinear;
  8221. /**
  8222. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8223. * @param hue The hue (H) input.
  8224. * @param saturation The saturation (S) input.
  8225. * @param brightness The brightness (B) input.
  8226. * @result An RGBA color represented as Vector4.
  8227. */
  8228. private static fromHSBToRef;
  8229. /**
  8230. * Returns a value clamped between min and max
  8231. * @param value The value to clamp
  8232. * @param min The minimum of value
  8233. * @param max The maximum of value
  8234. * @returns The clamped value.
  8235. */
  8236. private static clamp;
  8237. /**
  8238. * Clones the current color curve instance.
  8239. * @return The cloned curves
  8240. */
  8241. clone(): ColorCurves;
  8242. /**
  8243. * Serializes the current color curve instance to a json representation.
  8244. * @return a JSON representation
  8245. */
  8246. serialize(): any;
  8247. /**
  8248. * Parses the color curve from a json representation.
  8249. * @param source the JSON source to parse
  8250. * @return The parsed curves
  8251. */
  8252. static Parse(source: any): ColorCurves;
  8253. }
  8254. }
  8255. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8256. import { Observable } from "babylonjs/Misc/observable";
  8257. import { Nullable } from "babylonjs/types";
  8258. import { Color4 } from "babylonjs/Maths/math.color";
  8259. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8260. import { Effect } from "babylonjs/Materials/effect";
  8261. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8262. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8263. /**
  8264. * Interface to follow in your material defines to integrate easily the
  8265. * Image proccessing functions.
  8266. * @hidden
  8267. */
  8268. export interface IImageProcessingConfigurationDefines {
  8269. IMAGEPROCESSING: boolean;
  8270. VIGNETTE: boolean;
  8271. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8272. VIGNETTEBLENDMODEOPAQUE: boolean;
  8273. TONEMAPPING: boolean;
  8274. TONEMAPPING_ACES: boolean;
  8275. CONTRAST: boolean;
  8276. EXPOSURE: boolean;
  8277. COLORCURVES: boolean;
  8278. COLORGRADING: boolean;
  8279. COLORGRADING3D: boolean;
  8280. SAMPLER3DGREENDEPTH: boolean;
  8281. SAMPLER3DBGRMAP: boolean;
  8282. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8283. }
  8284. /**
  8285. * @hidden
  8286. */
  8287. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8288. IMAGEPROCESSING: boolean;
  8289. VIGNETTE: boolean;
  8290. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8291. VIGNETTEBLENDMODEOPAQUE: boolean;
  8292. TONEMAPPING: boolean;
  8293. TONEMAPPING_ACES: boolean;
  8294. CONTRAST: boolean;
  8295. COLORCURVES: boolean;
  8296. COLORGRADING: boolean;
  8297. COLORGRADING3D: boolean;
  8298. SAMPLER3DGREENDEPTH: boolean;
  8299. SAMPLER3DBGRMAP: boolean;
  8300. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8301. EXPOSURE: boolean;
  8302. constructor();
  8303. }
  8304. /**
  8305. * This groups together the common properties used for image processing either in direct forward pass
  8306. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8307. * or not.
  8308. */
  8309. export class ImageProcessingConfiguration {
  8310. /**
  8311. * Default tone mapping applied in BabylonJS.
  8312. */
  8313. static readonly TONEMAPPING_STANDARD: number;
  8314. /**
  8315. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8316. * to other engines rendering to increase portability.
  8317. */
  8318. static readonly TONEMAPPING_ACES: number;
  8319. /**
  8320. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8321. */
  8322. colorCurves: Nullable<ColorCurves>;
  8323. private _colorCurvesEnabled;
  8324. /**
  8325. * Gets wether the color curves effect is enabled.
  8326. */
  8327. get colorCurvesEnabled(): boolean;
  8328. /**
  8329. * Sets wether the color curves effect is enabled.
  8330. */
  8331. set colorCurvesEnabled(value: boolean);
  8332. private _colorGradingTexture;
  8333. /**
  8334. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8335. */
  8336. get colorGradingTexture(): Nullable<BaseTexture>;
  8337. /**
  8338. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8339. */
  8340. set colorGradingTexture(value: Nullable<BaseTexture>);
  8341. private _colorGradingEnabled;
  8342. /**
  8343. * Gets wether the color grading effect is enabled.
  8344. */
  8345. get colorGradingEnabled(): boolean;
  8346. /**
  8347. * Sets wether the color grading effect is enabled.
  8348. */
  8349. set colorGradingEnabled(value: boolean);
  8350. private _colorGradingWithGreenDepth;
  8351. /**
  8352. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8353. */
  8354. get colorGradingWithGreenDepth(): boolean;
  8355. /**
  8356. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8357. */
  8358. set colorGradingWithGreenDepth(value: boolean);
  8359. private _colorGradingBGR;
  8360. /**
  8361. * Gets wether the color grading texture contains BGR values.
  8362. */
  8363. get colorGradingBGR(): boolean;
  8364. /**
  8365. * Sets wether the color grading texture contains BGR values.
  8366. */
  8367. set colorGradingBGR(value: boolean);
  8368. /** @hidden */
  8369. _exposure: number;
  8370. /**
  8371. * Gets the Exposure used in the effect.
  8372. */
  8373. get exposure(): number;
  8374. /**
  8375. * Sets the Exposure used in the effect.
  8376. */
  8377. set exposure(value: number);
  8378. private _toneMappingEnabled;
  8379. /**
  8380. * Gets wether the tone mapping effect is enabled.
  8381. */
  8382. get toneMappingEnabled(): boolean;
  8383. /**
  8384. * Sets wether the tone mapping effect is enabled.
  8385. */
  8386. set toneMappingEnabled(value: boolean);
  8387. private _toneMappingType;
  8388. /**
  8389. * Gets the type of tone mapping effect.
  8390. */
  8391. get toneMappingType(): number;
  8392. /**
  8393. * Sets the type of tone mapping effect used in BabylonJS.
  8394. */
  8395. set toneMappingType(value: number);
  8396. protected _contrast: number;
  8397. /**
  8398. * Gets the contrast used in the effect.
  8399. */
  8400. get contrast(): number;
  8401. /**
  8402. * Sets the contrast used in the effect.
  8403. */
  8404. set contrast(value: number);
  8405. /**
  8406. * Vignette stretch size.
  8407. */
  8408. vignetteStretch: number;
  8409. /**
  8410. * Vignette centre X Offset.
  8411. */
  8412. vignetteCentreX: number;
  8413. /**
  8414. * Vignette centre Y Offset.
  8415. */
  8416. vignetteCentreY: number;
  8417. /**
  8418. * Vignette weight or intensity of the vignette effect.
  8419. */
  8420. vignetteWeight: number;
  8421. /**
  8422. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8423. * if vignetteEnabled is set to true.
  8424. */
  8425. vignetteColor: Color4;
  8426. /**
  8427. * Camera field of view used by the Vignette effect.
  8428. */
  8429. vignetteCameraFov: number;
  8430. private _vignetteBlendMode;
  8431. /**
  8432. * Gets the vignette blend mode allowing different kind of effect.
  8433. */
  8434. get vignetteBlendMode(): number;
  8435. /**
  8436. * Sets the vignette blend mode allowing different kind of effect.
  8437. */
  8438. set vignetteBlendMode(value: number);
  8439. private _vignetteEnabled;
  8440. /**
  8441. * Gets wether the vignette effect is enabled.
  8442. */
  8443. get vignetteEnabled(): boolean;
  8444. /**
  8445. * Sets wether the vignette effect is enabled.
  8446. */
  8447. set vignetteEnabled(value: boolean);
  8448. private _applyByPostProcess;
  8449. /**
  8450. * Gets wether the image processing is applied through a post process or not.
  8451. */
  8452. get applyByPostProcess(): boolean;
  8453. /**
  8454. * Sets wether the image processing is applied through a post process or not.
  8455. */
  8456. set applyByPostProcess(value: boolean);
  8457. private _isEnabled;
  8458. /**
  8459. * Gets wether the image processing is enabled or not.
  8460. */
  8461. get isEnabled(): boolean;
  8462. /**
  8463. * Sets wether the image processing is enabled or not.
  8464. */
  8465. set isEnabled(value: boolean);
  8466. /**
  8467. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8468. */
  8469. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8470. /**
  8471. * Method called each time the image processing information changes requires to recompile the effect.
  8472. */
  8473. protected _updateParameters(): void;
  8474. /**
  8475. * Gets the current class name.
  8476. * @return "ImageProcessingConfiguration"
  8477. */
  8478. getClassName(): string;
  8479. /**
  8480. * Prepare the list of uniforms associated with the Image Processing effects.
  8481. * @param uniforms The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of samplers associated with the Image Processing effects.
  8487. * @param samplersList The list of uniforms used in the effect
  8488. * @param defines the list of defines currently in use
  8489. */
  8490. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8491. /**
  8492. * Prepare the list of defines associated to the shader.
  8493. * @param defines the list of defines to complete
  8494. * @param forPostProcess Define if we are currently in post process mode or not
  8495. */
  8496. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8497. /**
  8498. * Returns true if all the image processing information are ready.
  8499. * @returns True if ready, otherwise, false
  8500. */
  8501. isReady(): boolean;
  8502. /**
  8503. * Binds the image processing to the shader.
  8504. * @param effect The effect to bind to
  8505. * @param overrideAspectRatio Override the aspect ratio of the effect
  8506. */
  8507. bind(effect: Effect, overrideAspectRatio?: number): void;
  8508. /**
  8509. * Clones the current image processing instance.
  8510. * @return The cloned image processing
  8511. */
  8512. clone(): ImageProcessingConfiguration;
  8513. /**
  8514. * Serializes the current image processing instance to a json representation.
  8515. * @return a JSON representation
  8516. */
  8517. serialize(): any;
  8518. /**
  8519. * Parses the image processing from a json representation.
  8520. * @param source the JSON source to parse
  8521. * @return The parsed image processing
  8522. */
  8523. static Parse(source: any): ImageProcessingConfiguration;
  8524. private static _VIGNETTEMODE_MULTIPLY;
  8525. private static _VIGNETTEMODE_OPAQUE;
  8526. /**
  8527. * Used to apply the vignette as a mix with the pixel color.
  8528. */
  8529. static get VIGNETTEMODE_MULTIPLY(): number;
  8530. /**
  8531. * Used to apply the vignette as a replacement of the pixel color.
  8532. */
  8533. static get VIGNETTEMODE_OPAQUE(): number;
  8534. }
  8535. }
  8536. declare module "babylonjs/Shaders/postprocess.vertex" {
  8537. /** @hidden */
  8538. export var postprocessVertexShader: {
  8539. name: string;
  8540. shader: string;
  8541. };
  8542. }
  8543. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8545. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8546. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8547. module "babylonjs/Engines/thinEngine" {
  8548. interface ThinEngine {
  8549. /**
  8550. * Creates a new render target texture
  8551. * @param size defines the size of the texture
  8552. * @param options defines the options used to create the texture
  8553. * @returns a new render target texture stored in an InternalTexture
  8554. */
  8555. createRenderTargetTexture(size: number | {
  8556. width: number;
  8557. height: number;
  8558. layers?: number;
  8559. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8560. /**
  8561. * Creates a depth stencil texture.
  8562. * This is only available in WebGL 2 or with the depth texture extension available.
  8563. * @param size The size of face edge in the texture.
  8564. * @param options The options defining the texture.
  8565. * @returns The texture
  8566. */
  8567. createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. /** @hidden */
  8573. _createDepthStencilTexture(size: number | {
  8574. width: number;
  8575. height: number;
  8576. layers?: number;
  8577. }, options: DepthTextureCreationOptions): InternalTexture;
  8578. }
  8579. }
  8580. }
  8581. declare module "babylonjs/Maths/math.axis" {
  8582. import { Vector3 } from "babylonjs/Maths/math.vector";
  8583. /** Defines supported spaces */
  8584. export enum Space {
  8585. /** Local (object) space */
  8586. LOCAL = 0,
  8587. /** World space */
  8588. WORLD = 1,
  8589. /** Bone space */
  8590. BONE = 2
  8591. }
  8592. /** Defines the 3 main axes */
  8593. export class Axis {
  8594. /** X axis */
  8595. static X: Vector3;
  8596. /** Y axis */
  8597. static Y: Vector3;
  8598. /** Z axis */
  8599. static Z: Vector3;
  8600. }
  8601. }
  8602. declare module "babylonjs/Cameras/targetCamera" {
  8603. import { Nullable } from "babylonjs/types";
  8604. import { Camera } from "babylonjs/Cameras/camera";
  8605. import { Scene } from "babylonjs/scene";
  8606. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8607. /**
  8608. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8609. * This is the base of the follow, arc rotate cameras and Free camera
  8610. * @see http://doc.babylonjs.com/features/cameras
  8611. */
  8612. export class TargetCamera extends Camera {
  8613. private static _RigCamTransformMatrix;
  8614. private static _TargetTransformMatrix;
  8615. private static _TargetFocalPoint;
  8616. /**
  8617. * Define the current direction the camera is moving to
  8618. */
  8619. cameraDirection: Vector3;
  8620. /**
  8621. * Define the current rotation the camera is rotating to
  8622. */
  8623. cameraRotation: Vector2;
  8624. /**
  8625. * When set, the up vector of the camera will be updated by the rotation of the camera
  8626. */
  8627. updateUpVectorFromRotation: boolean;
  8628. private _tmpQuaternion;
  8629. /**
  8630. * Define the current rotation of the camera
  8631. */
  8632. rotation: Vector3;
  8633. /**
  8634. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8635. */
  8636. rotationQuaternion: Quaternion;
  8637. /**
  8638. * Define the current speed of the camera
  8639. */
  8640. speed: number;
  8641. /**
  8642. * Add constraint to the camera to prevent it to move freely in all directions and
  8643. * around all axis.
  8644. */
  8645. noRotationConstraint: boolean;
  8646. /**
  8647. * Define the current target of the camera as an object or a position.
  8648. */
  8649. lockedTarget: any;
  8650. /** @hidden */
  8651. _currentTarget: Vector3;
  8652. /** @hidden */
  8653. _initialFocalDistance: number;
  8654. /** @hidden */
  8655. _viewMatrix: Matrix;
  8656. /** @hidden */
  8657. _camMatrix: Matrix;
  8658. /** @hidden */
  8659. _cameraTransformMatrix: Matrix;
  8660. /** @hidden */
  8661. _cameraRotationMatrix: Matrix;
  8662. /** @hidden */
  8663. _referencePoint: Vector3;
  8664. /** @hidden */
  8665. _transformedReferencePoint: Vector3;
  8666. protected _globalCurrentTarget: Vector3;
  8667. protected _globalCurrentUpVector: Vector3;
  8668. /** @hidden */
  8669. _reset: () => void;
  8670. private _defaultUp;
  8671. /**
  8672. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8673. * This is the base of the follow, arc rotate cameras and Free camera
  8674. * @see http://doc.babylonjs.com/features/cameras
  8675. * @param name Defines the name of the camera in the scene
  8676. * @param position Defines the start position of the camera in the scene
  8677. * @param scene Defines the scene the camera belongs to
  8678. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8679. */
  8680. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8681. /**
  8682. * Gets the position in front of the camera at a given distance.
  8683. * @param distance The distance from the camera we want the position to be
  8684. * @returns the position
  8685. */
  8686. getFrontPosition(distance: number): Vector3;
  8687. /** @hidden */
  8688. _getLockedTargetPosition(): Nullable<Vector3>;
  8689. private _storedPosition;
  8690. private _storedRotation;
  8691. private _storedRotationQuaternion;
  8692. /**
  8693. * Store current camera state of the camera (fov, position, rotation, etc..)
  8694. * @returns the camera
  8695. */
  8696. storeState(): Camera;
  8697. /**
  8698. * Restored camera state. You must call storeState() first
  8699. * @returns whether it was successful or not
  8700. * @hidden
  8701. */
  8702. _restoreStateValues(): boolean;
  8703. /** @hidden */
  8704. _initCache(): void;
  8705. /** @hidden */
  8706. _updateCache(ignoreParentClass?: boolean): void;
  8707. /** @hidden */
  8708. _isSynchronizedViewMatrix(): boolean;
  8709. /** @hidden */
  8710. _computeLocalCameraSpeed(): number;
  8711. /**
  8712. * Defines the target the camera should look at.
  8713. * @param target Defines the new target as a Vector or a mesh
  8714. */
  8715. setTarget(target: Vector3): void;
  8716. /**
  8717. * Return the current target position of the camera. This value is expressed in local space.
  8718. * @returns the target position
  8719. */
  8720. getTarget(): Vector3;
  8721. /** @hidden */
  8722. _decideIfNeedsToMove(): boolean;
  8723. /** @hidden */
  8724. _updatePosition(): void;
  8725. /** @hidden */
  8726. _checkInputs(): void;
  8727. protected _updateCameraRotationMatrix(): void;
  8728. /**
  8729. * 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)
  8730. * @returns the current camera
  8731. */
  8732. private _rotateUpVectorWithCameraRotationMatrix;
  8733. private _cachedRotationZ;
  8734. private _cachedQuaternionRotationZ;
  8735. /** @hidden */
  8736. _getViewMatrix(): Matrix;
  8737. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8738. /**
  8739. * @hidden
  8740. */
  8741. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8742. /**
  8743. * @hidden
  8744. */
  8745. _updateRigCameras(): void;
  8746. private _getRigCamPositionAndTarget;
  8747. /**
  8748. * Gets the current object class name.
  8749. * @return the class name
  8750. */
  8751. getClassName(): string;
  8752. }
  8753. }
  8754. declare module "babylonjs/Events/keyboardEvents" {
  8755. /**
  8756. * Gather the list of keyboard event types as constants.
  8757. */
  8758. export class KeyboardEventTypes {
  8759. /**
  8760. * The keydown event is fired when a key becomes active (pressed).
  8761. */
  8762. static readonly KEYDOWN: number;
  8763. /**
  8764. * The keyup event is fired when a key has been released.
  8765. */
  8766. static readonly KEYUP: number;
  8767. }
  8768. /**
  8769. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8770. */
  8771. export class KeyboardInfo {
  8772. /**
  8773. * Defines the type of event (KeyboardEventTypes)
  8774. */
  8775. type: number;
  8776. /**
  8777. * Defines the related dom event
  8778. */
  8779. event: KeyboardEvent;
  8780. /**
  8781. * Instantiates a new keyboard info.
  8782. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8783. * @param type Defines the type of event (KeyboardEventTypes)
  8784. * @param event Defines the related dom event
  8785. */
  8786. constructor(
  8787. /**
  8788. * Defines the type of event (KeyboardEventTypes)
  8789. */
  8790. type: number,
  8791. /**
  8792. * Defines the related dom event
  8793. */
  8794. event: KeyboardEvent);
  8795. }
  8796. /**
  8797. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8798. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8799. */
  8800. export class KeyboardInfoPre extends KeyboardInfo {
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number;
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent;
  8809. /**
  8810. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8811. */
  8812. skipOnPointerObservable: boolean;
  8813. /**
  8814. * Instantiates a new keyboard pre info.
  8815. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8816. * @param type Defines the type of event (KeyboardEventTypes)
  8817. * @param event Defines the related dom event
  8818. */
  8819. constructor(
  8820. /**
  8821. * Defines the type of event (KeyboardEventTypes)
  8822. */
  8823. type: number,
  8824. /**
  8825. * Defines the related dom event
  8826. */
  8827. event: KeyboardEvent);
  8828. }
  8829. }
  8830. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8831. import { Nullable } from "babylonjs/types";
  8832. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8834. /**
  8835. * Manage the keyboard inputs to control the movement of a free camera.
  8836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8837. */
  8838. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8839. /**
  8840. * Defines the camera the input is attached to.
  8841. */
  8842. camera: FreeCamera;
  8843. /**
  8844. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8845. */
  8846. keysUp: number[];
  8847. /**
  8848. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8849. */
  8850. keysDown: number[];
  8851. /**
  8852. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8853. */
  8854. keysLeft: number[];
  8855. /**
  8856. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8857. */
  8858. keysRight: number[];
  8859. private _keys;
  8860. private _onCanvasBlurObserver;
  8861. private _onKeyboardObserver;
  8862. private _engine;
  8863. private _scene;
  8864. /**
  8865. * Attach the input controls to a specific dom element to get the input from.
  8866. * @param element Defines the element the controls should be listened from
  8867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8868. */
  8869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8870. /**
  8871. * Detach the current controls from the specified dom element.
  8872. * @param element Defines the element to stop listening the inputs from
  8873. */
  8874. detachControl(element: Nullable<HTMLElement>): void;
  8875. /**
  8876. * Update the current camera state depending on the inputs that have been used this frame.
  8877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8878. */
  8879. checkInputs(): void;
  8880. /**
  8881. * Gets the class name of the current intput.
  8882. * @returns the class name
  8883. */
  8884. getClassName(): string;
  8885. /** @hidden */
  8886. _onLostFocus(): void;
  8887. /**
  8888. * Get the friendly name associated with the input class.
  8889. * @returns the input friendly name
  8890. */
  8891. getSimpleName(): string;
  8892. }
  8893. }
  8894. declare module "babylonjs/Lights/shadowLight" {
  8895. import { Camera } from "babylonjs/Cameras/camera";
  8896. import { Scene } from "babylonjs/scene";
  8897. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8899. import { Light } from "babylonjs/Lights/light";
  8900. /**
  8901. * Interface describing all the common properties and methods a shadow light needs to implement.
  8902. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8903. * as well as binding the different shadow properties to the effects.
  8904. */
  8905. export interface IShadowLight extends Light {
  8906. /**
  8907. * The light id in the scene (used in scene.findLighById for instance)
  8908. */
  8909. id: string;
  8910. /**
  8911. * The position the shdow will be casted from.
  8912. */
  8913. position: Vector3;
  8914. /**
  8915. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8916. */
  8917. direction: Vector3;
  8918. /**
  8919. * The transformed position. Position of the light in world space taking parenting in account.
  8920. */
  8921. transformedPosition: Vector3;
  8922. /**
  8923. * The transformed direction. Direction of the light in world space taking parenting in account.
  8924. */
  8925. transformedDirection: Vector3;
  8926. /**
  8927. * The friendly name of the light in the scene.
  8928. */
  8929. name: string;
  8930. /**
  8931. * Defines the shadow projection clipping minimum z value.
  8932. */
  8933. shadowMinZ: number;
  8934. /**
  8935. * Defines the shadow projection clipping maximum z value.
  8936. */
  8937. shadowMaxZ: number;
  8938. /**
  8939. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8940. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8941. */
  8942. computeTransformedInformation(): boolean;
  8943. /**
  8944. * Gets the scene the light belongs to.
  8945. * @returns The scene
  8946. */
  8947. getScene(): Scene;
  8948. /**
  8949. * Callback defining a custom Projection Matrix Builder.
  8950. * This can be used to override the default projection matrix computation.
  8951. */
  8952. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8953. /**
  8954. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8955. * @param matrix The materix to updated with the projection information
  8956. * @param viewMatrix The transform matrix of the light
  8957. * @param renderList The list of mesh to render in the map
  8958. * @returns The current light
  8959. */
  8960. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8961. /**
  8962. * Gets the current depth scale used in ESM.
  8963. * @returns The scale
  8964. */
  8965. getDepthScale(): number;
  8966. /**
  8967. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8968. * @returns true if a cube texture needs to be use
  8969. */
  8970. needCube(): boolean;
  8971. /**
  8972. * Detects if the projection matrix requires to be recomputed this frame.
  8973. * @returns true if it requires to be recomputed otherwise, false.
  8974. */
  8975. needProjectionMatrixCompute(): boolean;
  8976. /**
  8977. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8978. */
  8979. forceProjectionMatrixCompute(): void;
  8980. /**
  8981. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8982. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8983. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8984. */
  8985. getShadowDirection(faceIndex?: number): Vector3;
  8986. /**
  8987. * Gets the minZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the min for
  8989. * @returns the depth min z
  8990. */
  8991. getDepthMinZ(activeCamera: Camera): number;
  8992. /**
  8993. * Gets the maxZ used for shadow according to both the scene and the light.
  8994. * @param activeCamera The camera we are returning the max for
  8995. * @returns the depth max z
  8996. */
  8997. getDepthMaxZ(activeCamera: Camera): number;
  8998. }
  8999. /**
  9000. * Base implementation IShadowLight
  9001. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9002. */
  9003. export abstract class ShadowLight extends Light implements IShadowLight {
  9004. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9005. protected _position: Vector3;
  9006. protected _setPosition(value: Vector3): void;
  9007. /**
  9008. * Sets the position the shadow will be casted from. Also use as the light position for both
  9009. * point and spot lights.
  9010. */
  9011. get position(): Vector3;
  9012. /**
  9013. * Sets the position the shadow will be casted from. Also use as the light position for both
  9014. * point and spot lights.
  9015. */
  9016. set position(value: Vector3);
  9017. protected _direction: Vector3;
  9018. protected _setDirection(value: Vector3): void;
  9019. /**
  9020. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9021. * Also use as the light direction on spot and directional lights.
  9022. */
  9023. get direction(): Vector3;
  9024. /**
  9025. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9026. * Also use as the light direction on spot and directional lights.
  9027. */
  9028. set direction(value: Vector3);
  9029. protected _shadowMinZ: number;
  9030. /**
  9031. * Gets the shadow projection clipping minimum z value.
  9032. */
  9033. get shadowMinZ(): number;
  9034. /**
  9035. * Sets the shadow projection clipping minimum z value.
  9036. */
  9037. set shadowMinZ(value: number);
  9038. protected _shadowMaxZ: number;
  9039. /**
  9040. * Sets the shadow projection clipping maximum z value.
  9041. */
  9042. get shadowMaxZ(): number;
  9043. /**
  9044. * Gets the shadow projection clipping maximum z value.
  9045. */
  9046. set shadowMaxZ(value: number);
  9047. /**
  9048. * Callback defining a custom Projection Matrix Builder.
  9049. * This can be used to override the default projection matrix computation.
  9050. */
  9051. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9052. /**
  9053. * The transformed position. Position of the light in world space taking parenting in account.
  9054. */
  9055. transformedPosition: Vector3;
  9056. /**
  9057. * The transformed direction. Direction of the light in world space taking parenting in account.
  9058. */
  9059. transformedDirection: Vector3;
  9060. private _needProjectionMatrixCompute;
  9061. /**
  9062. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9063. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9064. */
  9065. computeTransformedInformation(): boolean;
  9066. /**
  9067. * Return the depth scale used for the shadow map.
  9068. * @returns the depth scale.
  9069. */
  9070. getDepthScale(): number;
  9071. /**
  9072. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9073. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9074. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9075. */
  9076. getShadowDirection(faceIndex?: number): Vector3;
  9077. /**
  9078. * Returns the ShadowLight absolute position in the World.
  9079. * @returns the position vector in world space
  9080. */
  9081. getAbsolutePosition(): Vector3;
  9082. /**
  9083. * Sets the ShadowLight direction toward the passed target.
  9084. * @param target The point to target in local space
  9085. * @returns the updated ShadowLight direction
  9086. */
  9087. setDirectionToTarget(target: Vector3): Vector3;
  9088. /**
  9089. * Returns the light rotation in euler definition.
  9090. * @returns the x y z rotation in local space.
  9091. */
  9092. getRotation(): Vector3;
  9093. /**
  9094. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9095. * @returns true if a cube texture needs to be use
  9096. */
  9097. needCube(): boolean;
  9098. /**
  9099. * Detects if the projection matrix requires to be recomputed this frame.
  9100. * @returns true if it requires to be recomputed otherwise, false.
  9101. */
  9102. needProjectionMatrixCompute(): boolean;
  9103. /**
  9104. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9105. */
  9106. forceProjectionMatrixCompute(): void;
  9107. /** @hidden */
  9108. _initCache(): void;
  9109. /** @hidden */
  9110. _isSynchronized(): boolean;
  9111. /**
  9112. * Computes the world matrix of the node
  9113. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9114. * @returns the world matrix
  9115. */
  9116. computeWorldMatrix(force?: boolean): Matrix;
  9117. /**
  9118. * Gets the minZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the min for
  9120. * @returns the depth min z
  9121. */
  9122. getDepthMinZ(activeCamera: Camera): number;
  9123. /**
  9124. * Gets the maxZ used for shadow according to both the scene and the light.
  9125. * @param activeCamera The camera we are returning the max for
  9126. * @returns the depth max z
  9127. */
  9128. getDepthMaxZ(activeCamera: Camera): number;
  9129. /**
  9130. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9131. * @param matrix The materix to updated with the projection information
  9132. * @param viewMatrix The transform matrix of the light
  9133. * @param renderList The list of mesh to render in the map
  9134. * @returns The current light
  9135. */
  9136. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9137. }
  9138. }
  9139. declare module "babylonjs/Materials/effectFallbacks" {
  9140. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9141. import { Effect } from "babylonjs/Materials/effect";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. /**
  9144. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9145. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9146. */
  9147. export class EffectFallbacks implements IEffectFallbacks {
  9148. private _defines;
  9149. private _currentRank;
  9150. private _maxRank;
  9151. private _mesh;
  9152. /**
  9153. * Removes the fallback from the bound mesh.
  9154. */
  9155. unBindMesh(): void;
  9156. /**
  9157. * Adds a fallback on the specified property.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param define The name of the define in the shader
  9160. */
  9161. addFallback(rank: number, define: string): void;
  9162. /**
  9163. * Sets the mesh to use CPU skinning when needing to fallback.
  9164. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9165. * @param mesh The mesh to use the fallbacks.
  9166. */
  9167. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9168. /**
  9169. * Checks to see if more fallbacks are still availible.
  9170. */
  9171. get hasMoreFallbacks(): boolean;
  9172. /**
  9173. * Removes the defines that should be removed when falling back.
  9174. * @param currentDefines defines the current define statements for the shader.
  9175. * @param effect defines the current effect we try to compile
  9176. * @returns The resulting defines with defines of the current rank removed.
  9177. */
  9178. reduce(currentDefines: string, effect: Effect): string;
  9179. }
  9180. }
  9181. declare module "babylonjs/Materials/materialHelper" {
  9182. import { Nullable } from "babylonjs/types";
  9183. import { Scene } from "babylonjs/scene";
  9184. import { Engine } from "babylonjs/Engines/engine";
  9185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9186. import { Light } from "babylonjs/Lights/light";
  9187. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9188. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9190. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9191. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9192. /**
  9193. * "Static Class" containing the most commonly used helper while dealing with material for
  9194. * rendering purpose.
  9195. *
  9196. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9197. *
  9198. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9199. */
  9200. export class MaterialHelper {
  9201. /**
  9202. * Bind the current view position to an effect.
  9203. * @param effect The effect to be bound
  9204. * @param scene The scene the eyes position is used from
  9205. */
  9206. static BindEyePosition(effect: Effect, scene: Scene): void;
  9207. /**
  9208. * Helps preparing the defines values about the UVs in used in the effect.
  9209. * UVs are shared as much as we can accross channels in the shaders.
  9210. * @param texture The texture we are preparing the UVs for
  9211. * @param defines The defines to update
  9212. * @param key The channel key "diffuse", "specular"... used in the shader
  9213. */
  9214. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9215. /**
  9216. * Binds a texture matrix value to its corrsponding uniform
  9217. * @param texture The texture to bind the matrix for
  9218. * @param uniformBuffer The uniform buffer receivin the data
  9219. * @param key The channel key "diffuse", "specular"... used in the shader
  9220. */
  9221. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9222. /**
  9223. * Gets the current status of the fog (should it be enabled?)
  9224. * @param mesh defines the mesh to evaluate for fog support
  9225. * @param scene defines the hosting scene
  9226. * @returns true if fog must be enabled
  9227. */
  9228. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9229. /**
  9230. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9231. * @param mesh defines the current mesh
  9232. * @param scene defines the current scene
  9233. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9234. * @param pointsCloud defines if point cloud rendering has to be turned on
  9235. * @param fogEnabled defines if fog has to be turned on
  9236. * @param alphaTest defines if alpha testing has to be turned on
  9237. * @param defines defines the current list of defines
  9238. */
  9239. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9240. /**
  9241. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9242. * @param scene defines the current scene
  9243. * @param engine defines the current engine
  9244. * @param defines specifies the list of active defines
  9245. * @param useInstances defines if instances have to be turned on
  9246. * @param useClipPlane defines if clip plane have to be turned on
  9247. */
  9248. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9249. /**
  9250. * Prepares the defines for bones
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines for morph targets
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. */
  9260. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9261. /**
  9262. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9263. * @param mesh The mesh containing the geometry data we will draw
  9264. * @param defines The defines to update
  9265. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9266. * @param useBones Precise whether bones should be used or not (override mesh info)
  9267. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9268. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9269. * @returns false if defines are considered not dirty and have not been checked
  9270. */
  9271. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9272. /**
  9273. * Prepares the defines related to multiview
  9274. * @param scene The scene we are intending to draw
  9275. * @param defines The defines to update
  9276. */
  9277. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9278. /**
  9279. * Prepares the defines related to the light information passed in parameter
  9280. * @param scene The scene we are intending to draw
  9281. * @param mesh The mesh the effect is compiling for
  9282. * @param light The light the effect is compiling for
  9283. * @param lightIndex The index of the light
  9284. * @param defines The defines to update
  9285. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9286. * @param state Defines the current state regarding what is needed (normals, etc...)
  9287. */
  9288. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9289. needNormals: boolean;
  9290. needRebuild: boolean;
  9291. shadowEnabled: boolean;
  9292. specularEnabled: boolean;
  9293. lightmapMode: boolean;
  9294. }): void;
  9295. /**
  9296. * Prepares the defines related to the light information passed in parameter
  9297. * @param scene The scene we are intending to draw
  9298. * @param mesh The mesh the effect is compiling for
  9299. * @param defines The defines to update
  9300. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9301. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9302. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9303. * @returns true if normals will be required for the rest of the effect
  9304. */
  9305. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9306. /**
  9307. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9308. * @param lightIndex defines the light index
  9309. * @param uniformsList The uniform list
  9310. * @param samplersList The sampler list
  9311. * @param projectedLightTexture defines if projected texture must be used
  9312. * @param uniformBuffersList defines an optional list of uniform buffers
  9313. */
  9314. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9315. /**
  9316. * Prepares the uniforms and samplers list to be used in the effect
  9317. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9318. * @param samplersList The sampler list
  9319. * @param defines The defines helping in the list generation
  9320. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9321. */
  9322. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9323. /**
  9324. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9325. * @param defines The defines to update while falling back
  9326. * @param fallbacks The authorized effect fallbacks
  9327. * @param maxSimultaneousLights The maximum number of lights allowed
  9328. * @param rank the current rank of the Effect
  9329. * @returns The newly affected rank
  9330. */
  9331. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9332. private static _TmpMorphInfluencers;
  9333. /**
  9334. * Prepares the list of attributes required for morph targets according to the effect defines.
  9335. * @param attribs The current list of supported attribs
  9336. * @param mesh The mesh to prepare the morph targets attributes for
  9337. * @param influencers The number of influencers
  9338. */
  9339. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9340. /**
  9341. * Prepares the list of attributes required for morph targets according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param mesh The mesh to prepare the morph targets attributes for
  9344. * @param defines The current Defines of the effect
  9345. */
  9346. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9347. /**
  9348. * Prepares the list of attributes required for bones according to the effect defines.
  9349. * @param attribs The current list of supported attribs
  9350. * @param mesh The mesh to prepare the bones attributes for
  9351. * @param defines The current Defines of the effect
  9352. * @param fallbacks The current efffect fallback strategy
  9353. */
  9354. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9355. /**
  9356. * Check and prepare the list of attributes required for instances according to the effect defines.
  9357. * @param attribs The current list of supported attribs
  9358. * @param defines The current MaterialDefines of the effect
  9359. */
  9360. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9361. /**
  9362. * Add the list of attributes required for instances to the attribs array.
  9363. * @param attribs The current list of supported attribs
  9364. */
  9365. static PushAttributesForInstances(attribs: string[]): void;
  9366. /**
  9367. * Binds the light information to the effect.
  9368. * @param light The light containing the generator
  9369. * @param effect The effect we are binding the data to
  9370. * @param lightIndex The light index in the effect used to render
  9371. */
  9372. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9373. /**
  9374. * Binds the lights information from the scene to the effect for the given mesh.
  9375. * @param light Light to bind
  9376. * @param lightIndex Light index
  9377. * @param scene The scene where the light belongs to
  9378. * @param effect The effect we are binding the data to
  9379. * @param useSpecular Defines if specular is supported
  9380. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9381. */
  9382. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9383. /**
  9384. * Binds the lights information from the scene to the effect for the given mesh.
  9385. * @param scene The scene the lights belongs to
  9386. * @param mesh The mesh we are binding the information to render
  9387. * @param effect The effect we are binding the data to
  9388. * @param defines The generated defines for the effect
  9389. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9390. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9391. */
  9392. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9393. private static _tempFogColor;
  9394. /**
  9395. * Binds the fog information from the scene to the effect for the given mesh.
  9396. * @param scene The scene the lights belongs to
  9397. * @param mesh The mesh we are binding the information to render
  9398. * @param effect The effect we are binding the data to
  9399. * @param linearSpace Defines if the fog effect is applied in linear space
  9400. */
  9401. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9402. /**
  9403. * Binds the bones information from the mesh to the effect.
  9404. * @param mesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9408. /**
  9409. * Binds the morph targets information from the mesh to the effect.
  9410. * @param abstractMesh The mesh we are binding the information to render
  9411. * @param effect The effect we are binding the data to
  9412. */
  9413. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9414. /**
  9415. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9416. * @param defines The generated defines used in the effect
  9417. * @param effect The effect we are binding the data to
  9418. * @param scene The scene we are willing to render with logarithmic scale for
  9419. */
  9420. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9421. /**
  9422. * Binds the clip plane information from the scene to the effect.
  9423. * @param scene The scene the clip plane information are extracted from
  9424. * @param effect The effect we are binding the data to
  9425. */
  9426. static BindClipPlane(effect: Effect, scene: Scene): void;
  9427. }
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9430. /** @hidden */
  9431. export var packingFunctions: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9437. /** @hidden */
  9438. export var clipPlaneFragmentDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9444. /** @hidden */
  9445. export var clipPlaneFragment: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9451. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9452. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9453. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9454. /** @hidden */
  9455. export var shadowMapPixelShader: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9461. /** @hidden */
  9462. export var bonesDeclaration: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9468. /** @hidden */
  9469. export var morphTargetsVertexGlobalDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9475. /** @hidden */
  9476. export var morphTargetsVertexDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9482. /** @hidden */
  9483. export var instancesDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9489. /** @hidden */
  9490. export var helperFunctions: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9496. /** @hidden */
  9497. export var clipPlaneVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9503. /** @hidden */
  9504. export var morphTargetsVertex: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9510. /** @hidden */
  9511. export var instancesVertex: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9517. /** @hidden */
  9518. export var bonesVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9524. /** @hidden */
  9525. export var clipPlaneVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9531. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9533. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9534. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9535. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9538. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9539. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9540. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9541. /** @hidden */
  9542. export var shadowMapVertexShader: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9548. /** @hidden */
  9549. export var depthBoxBlurPixelShader: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module "babylonjs/Culling/ray" {
  9555. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9556. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9558. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9559. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9560. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9561. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9562. import { Plane } from "babylonjs/Maths/math.plane";
  9563. /**
  9564. * Class representing a ray with position and direction
  9565. */
  9566. export class Ray {
  9567. /** origin point */
  9568. origin: Vector3;
  9569. /** direction */
  9570. direction: Vector3;
  9571. /** length of the ray */
  9572. length: number;
  9573. private static readonly TmpVector3;
  9574. private _tmpRay;
  9575. /**
  9576. * Creates a new ray
  9577. * @param origin origin point
  9578. * @param direction direction
  9579. * @param length length of the ray
  9580. */
  9581. constructor(
  9582. /** origin point */
  9583. origin: Vector3,
  9584. /** direction */
  9585. direction: Vector3,
  9586. /** length of the ray */
  9587. length?: number);
  9588. /**
  9589. * Checks if the ray intersects a box
  9590. * @param minimum bound of the box
  9591. * @param maximum bound of the box
  9592. * @param intersectionTreshold extra extend to be added to the box in all direction
  9593. * @returns if the box was hit
  9594. */
  9595. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9596. /**
  9597. * Checks if the ray intersects a box
  9598. * @param box the bounding box to check
  9599. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9600. * @returns if the box was hit
  9601. */
  9602. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9603. /**
  9604. * If the ray hits a sphere
  9605. * @param sphere the bounding sphere to check
  9606. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9607. * @returns true if it hits the sphere
  9608. */
  9609. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9610. /**
  9611. * If the ray hits a triange
  9612. * @param vertex0 triangle vertex
  9613. * @param vertex1 triangle vertex
  9614. * @param vertex2 triangle vertex
  9615. * @returns intersection information if hit
  9616. */
  9617. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9618. /**
  9619. * Checks if ray intersects a plane
  9620. * @param plane the plane to check
  9621. * @returns the distance away it was hit
  9622. */
  9623. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9624. /**
  9625. * Calculate the intercept of a ray on a given axis
  9626. * @param axis to check 'x' | 'y' | 'z'
  9627. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9628. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9629. */
  9630. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9631. /**
  9632. * Checks if ray intersects a mesh
  9633. * @param mesh the mesh to check
  9634. * @param fastCheck if only the bounding box should checked
  9635. * @returns picking info of the intersecton
  9636. */
  9637. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9638. /**
  9639. * Checks if ray intersects a mesh
  9640. * @param meshes the meshes to check
  9641. * @param fastCheck if only the bounding box should checked
  9642. * @param results array to store result in
  9643. * @returns Array of picking infos
  9644. */
  9645. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9646. private _comparePickingInfo;
  9647. private static smallnum;
  9648. private static rayl;
  9649. /**
  9650. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9651. * @param sega the first point of the segment to test the intersection against
  9652. * @param segb the second point of the segment to test the intersection against
  9653. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9654. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9655. */
  9656. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9657. /**
  9658. * Update the ray from viewport position
  9659. * @param x position
  9660. * @param y y position
  9661. * @param viewportWidth viewport width
  9662. * @param viewportHeight viewport height
  9663. * @param world world matrix
  9664. * @param view view matrix
  9665. * @param projection projection matrix
  9666. * @returns this ray updated
  9667. */
  9668. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9669. /**
  9670. * Creates a ray with origin and direction of 0,0,0
  9671. * @returns the new ray
  9672. */
  9673. static Zero(): Ray;
  9674. /**
  9675. * Creates a new ray from screen space and viewport
  9676. * @param x position
  9677. * @param y y position
  9678. * @param viewportWidth viewport width
  9679. * @param viewportHeight viewport height
  9680. * @param world world matrix
  9681. * @param view view matrix
  9682. * @param projection projection matrix
  9683. * @returns new ray
  9684. */
  9685. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9686. /**
  9687. * 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
  9688. * transformed to the given world matrix.
  9689. * @param origin The origin point
  9690. * @param end The end point
  9691. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9692. * @returns the new ray
  9693. */
  9694. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9695. /**
  9696. * Transforms a ray by a matrix
  9697. * @param ray ray to transform
  9698. * @param matrix matrix to apply
  9699. * @returns the resulting new ray
  9700. */
  9701. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9702. /**
  9703. * Transforms a ray by a matrix
  9704. * @param ray ray to transform
  9705. * @param matrix matrix to apply
  9706. * @param result ray to store result in
  9707. */
  9708. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9709. /**
  9710. * Unproject a ray from screen space to object space
  9711. * @param sourceX defines the screen space x coordinate to use
  9712. * @param sourceY defines the screen space y coordinate to use
  9713. * @param viewportWidth defines the current width of the viewport
  9714. * @param viewportHeight defines the current height of the viewport
  9715. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9716. * @param view defines the view matrix to use
  9717. * @param projection defines the projection matrix to use
  9718. */
  9719. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9720. }
  9721. /**
  9722. * Type used to define predicate used to select faces when a mesh intersection is detected
  9723. */
  9724. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9725. module "babylonjs/scene" {
  9726. interface Scene {
  9727. /** @hidden */
  9728. _tempPickingRay: Nullable<Ray>;
  9729. /** @hidden */
  9730. _cachedRayForTransform: Ray;
  9731. /** @hidden */
  9732. _pickWithRayInverseMatrix: Matrix;
  9733. /** @hidden */
  9734. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9735. /** @hidden */
  9736. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9737. }
  9738. }
  9739. }
  9740. declare module "babylonjs/sceneComponent" {
  9741. import { Scene } from "babylonjs/scene";
  9742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9743. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9744. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9745. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9746. import { Nullable } from "babylonjs/types";
  9747. import { Camera } from "babylonjs/Cameras/camera";
  9748. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9749. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9750. import { AbstractScene } from "babylonjs/abstractScene";
  9751. import { Mesh } from "babylonjs/Meshes/mesh";
  9752. /**
  9753. * Groups all the scene component constants in one place to ease maintenance.
  9754. * @hidden
  9755. */
  9756. export class SceneComponentConstants {
  9757. static readonly NAME_EFFECTLAYER: string;
  9758. static readonly NAME_LAYER: string;
  9759. static readonly NAME_LENSFLARESYSTEM: string;
  9760. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9761. static readonly NAME_PARTICLESYSTEM: string;
  9762. static readonly NAME_GAMEPAD: string;
  9763. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9764. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9765. static readonly NAME_DEPTHRENDERER: string;
  9766. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9767. static readonly NAME_SPRITE: string;
  9768. static readonly NAME_OUTLINERENDERER: string;
  9769. static readonly NAME_PROCEDURALTEXTURE: string;
  9770. static readonly NAME_SHADOWGENERATOR: string;
  9771. static readonly NAME_OCTREE: string;
  9772. static readonly NAME_PHYSICSENGINE: string;
  9773. static readonly NAME_AUDIO: string;
  9774. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9775. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9776. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9777. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9778. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9779. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9780. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9781. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9782. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9783. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9784. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9785. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9786. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9787. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9788. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9789. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9790. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9791. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9792. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9793. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9794. static readonly STEP_AFTERRENDER_AUDIO: number;
  9795. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9796. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9797. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9798. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9799. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9800. static readonly STEP_POINTERMOVE_SPRITE: number;
  9801. static readonly STEP_POINTERDOWN_SPRITE: number;
  9802. static readonly STEP_POINTERUP_SPRITE: number;
  9803. }
  9804. /**
  9805. * This represents a scene component.
  9806. *
  9807. * This is used to decouple the dependency the scene is having on the different workloads like
  9808. * layers, post processes...
  9809. */
  9810. export interface ISceneComponent {
  9811. /**
  9812. * The name of the component. Each component must have a unique name.
  9813. */
  9814. name: string;
  9815. /**
  9816. * The scene the component belongs to.
  9817. */
  9818. scene: Scene;
  9819. /**
  9820. * Register the component to one instance of a scene.
  9821. */
  9822. register(): void;
  9823. /**
  9824. * Rebuilds the elements related to this component in case of
  9825. * context lost for instance.
  9826. */
  9827. rebuild(): void;
  9828. /**
  9829. * Disposes the component and the associated ressources.
  9830. */
  9831. dispose(): void;
  9832. }
  9833. /**
  9834. * This represents a SERIALIZABLE scene component.
  9835. *
  9836. * This extends Scene Component to add Serialization methods on top.
  9837. */
  9838. export interface ISceneSerializableComponent extends ISceneComponent {
  9839. /**
  9840. * Adds all the elements from the container to the scene
  9841. * @param container the container holding the elements
  9842. */
  9843. addFromContainer(container: AbstractScene): void;
  9844. /**
  9845. * Removes all the elements in the container from the scene
  9846. * @param container contains the elements to remove
  9847. * @param dispose if the removed element should be disposed (default: false)
  9848. */
  9849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9850. /**
  9851. * Serializes the component data to the specified json object
  9852. * @param serializationObject The object to serialize to
  9853. */
  9854. serialize(serializationObject: any): void;
  9855. }
  9856. /**
  9857. * Strong typing of a Mesh related stage step action
  9858. */
  9859. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9860. /**
  9861. * Strong typing of a Evaluate Sub Mesh related stage step action
  9862. */
  9863. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9864. /**
  9865. * Strong typing of a Active Mesh related stage step action
  9866. */
  9867. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9868. /**
  9869. * Strong typing of a Camera related stage step action
  9870. */
  9871. export type CameraStageAction = (camera: Camera) => void;
  9872. /**
  9873. * Strong typing of a Camera Frame buffer related stage step action
  9874. */
  9875. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9876. /**
  9877. * Strong typing of a Render Target related stage step action
  9878. */
  9879. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9880. /**
  9881. * Strong typing of a RenderingGroup related stage step action
  9882. */
  9883. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9884. /**
  9885. * Strong typing of a Mesh Render related stage step action
  9886. */
  9887. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9888. /**
  9889. * Strong typing of a simple stage step action
  9890. */
  9891. export type SimpleStageAction = () => void;
  9892. /**
  9893. * Strong typing of a render target action.
  9894. */
  9895. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9896. /**
  9897. * Strong typing of a pointer move action.
  9898. */
  9899. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9900. /**
  9901. * Strong typing of a pointer up/down action.
  9902. */
  9903. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9904. /**
  9905. * Representation of a stage in the scene (Basically a list of ordered steps)
  9906. * @hidden
  9907. */
  9908. export class Stage<T extends Function> extends Array<{
  9909. index: number;
  9910. component: ISceneComponent;
  9911. action: T;
  9912. }> {
  9913. /**
  9914. * Hide ctor from the rest of the world.
  9915. * @param items The items to add.
  9916. */
  9917. private constructor();
  9918. /**
  9919. * Creates a new Stage.
  9920. * @returns A new instance of a Stage
  9921. */
  9922. static Create<T extends Function>(): Stage<T>;
  9923. /**
  9924. * Registers a step in an ordered way in the targeted stage.
  9925. * @param index Defines the position to register the step in
  9926. * @param component Defines the component attached to the step
  9927. * @param action Defines the action to launch during the step
  9928. */
  9929. registerStep(index: number, component: ISceneComponent, action: T): void;
  9930. /**
  9931. * Clears all the steps from the stage.
  9932. */
  9933. clear(): void;
  9934. }
  9935. }
  9936. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9937. import { Nullable } from "babylonjs/types";
  9938. import { Observable } from "babylonjs/Misc/observable";
  9939. import { Scene } from "babylonjs/scene";
  9940. import { Sprite } from "babylonjs/Sprites/sprite";
  9941. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9942. import { Ray } from "babylonjs/Culling/ray";
  9943. import { Camera } from "babylonjs/Cameras/camera";
  9944. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9945. import { ISceneComponent } from "babylonjs/sceneComponent";
  9946. module "babylonjs/scene" {
  9947. interface Scene {
  9948. /** @hidden */
  9949. _pointerOverSprite: Nullable<Sprite>;
  9950. /** @hidden */
  9951. _pickedDownSprite: Nullable<Sprite>;
  9952. /** @hidden */
  9953. _tempSpritePickingRay: Nullable<Ray>;
  9954. /**
  9955. * All of the sprite managers added to this scene
  9956. * @see http://doc.babylonjs.com/babylon101/sprites
  9957. */
  9958. spriteManagers: Array<ISpriteManager>;
  9959. /**
  9960. * An event triggered when sprites rendering is about to start
  9961. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9962. */
  9963. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9964. /**
  9965. * An event triggered when sprites rendering is done
  9966. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9967. */
  9968. onAfterSpritesRenderingObservable: Observable<Scene>;
  9969. /** @hidden */
  9970. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9971. /** Launch a ray to try to pick a sprite in the scene
  9972. * @param x position on screen
  9973. * @param y position on screen
  9974. * @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
  9975. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9976. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9977. * @returns a PickingInfo
  9978. */
  9979. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9980. /** Use the given ray to pick a sprite in the scene
  9981. * @param ray The ray (in world space) to use to pick meshes
  9982. * @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
  9983. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9984. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9985. * @returns a PickingInfo
  9986. */
  9987. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9988. /** @hidden */
  9989. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9990. /** Launch a ray to try to pick sprites in the scene
  9991. * @param x position on screen
  9992. * @param y position on screen
  9993. * @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
  9994. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9995. * @returns a PickingInfo array
  9996. */
  9997. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9998. /** Use the given ray to pick sprites in the scene
  9999. * @param ray The ray (in world space) to use to pick meshes
  10000. * @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
  10001. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10002. * @returns a PickingInfo array
  10003. */
  10004. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10005. /**
  10006. * Force the sprite under the pointer
  10007. * @param sprite defines the sprite to use
  10008. */
  10009. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10010. /**
  10011. * Gets the sprite under the pointer
  10012. * @returns a Sprite or null if no sprite is under the pointer
  10013. */
  10014. getPointerOverSprite(): Nullable<Sprite>;
  10015. }
  10016. }
  10017. /**
  10018. * Defines the sprite scene component responsible to manage sprites
  10019. * in a given scene.
  10020. */
  10021. export class SpriteSceneComponent implements ISceneComponent {
  10022. /**
  10023. * The component name helpfull to identify the component in the list of scene components.
  10024. */
  10025. readonly name: string;
  10026. /**
  10027. * The scene the component belongs to.
  10028. */
  10029. scene: Scene;
  10030. /** @hidden */
  10031. private _spritePredicate;
  10032. /**
  10033. * Creates a new instance of the component for the given scene
  10034. * @param scene Defines the scene to register the component in
  10035. */
  10036. constructor(scene: Scene);
  10037. /**
  10038. * Registers the component in a given scene
  10039. */
  10040. register(): void;
  10041. /**
  10042. * Rebuilds the elements related to this component in case of
  10043. * context lost for instance.
  10044. */
  10045. rebuild(): void;
  10046. /**
  10047. * Disposes the component and the associated ressources.
  10048. */
  10049. dispose(): void;
  10050. private _pickSpriteButKeepRay;
  10051. private _pointerMove;
  10052. private _pointerDown;
  10053. private _pointerUp;
  10054. }
  10055. }
  10056. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10057. /** @hidden */
  10058. export var fogFragmentDeclaration: {
  10059. name: string;
  10060. shader: string;
  10061. };
  10062. }
  10063. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10064. /** @hidden */
  10065. export var fogFragment: {
  10066. name: string;
  10067. shader: string;
  10068. };
  10069. }
  10070. declare module "babylonjs/Shaders/sprites.fragment" {
  10071. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10072. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10073. /** @hidden */
  10074. export var spritesPixelShader: {
  10075. name: string;
  10076. shader: string;
  10077. };
  10078. }
  10079. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10080. /** @hidden */
  10081. export var fogVertexDeclaration: {
  10082. name: string;
  10083. shader: string;
  10084. };
  10085. }
  10086. declare module "babylonjs/Shaders/sprites.vertex" {
  10087. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10088. /** @hidden */
  10089. export var spritesVertexShader: {
  10090. name: string;
  10091. shader: string;
  10092. };
  10093. }
  10094. declare module "babylonjs/Sprites/spriteManager" {
  10095. import { IDisposable, Scene } from "babylonjs/scene";
  10096. import { Nullable } from "babylonjs/types";
  10097. import { Observable } from "babylonjs/Misc/observable";
  10098. import { Sprite } from "babylonjs/Sprites/sprite";
  10099. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10100. import { Camera } from "babylonjs/Cameras/camera";
  10101. import { Texture } from "babylonjs/Materials/Textures/texture";
  10102. import "babylonjs/Shaders/sprites.fragment";
  10103. import "babylonjs/Shaders/sprites.vertex";
  10104. import { Ray } from "babylonjs/Culling/ray";
  10105. /**
  10106. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10107. */
  10108. export interface ISpriteManager extends IDisposable {
  10109. /**
  10110. * Restricts the camera to viewing objects with the same layerMask.
  10111. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10112. */
  10113. layerMask: number;
  10114. /**
  10115. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10116. */
  10117. isPickable: boolean;
  10118. /**
  10119. * Specifies the rendering group id for this mesh (0 by default)
  10120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10121. */
  10122. renderingGroupId: number;
  10123. /**
  10124. * Defines the list of sprites managed by the manager.
  10125. */
  10126. sprites: Array<Sprite>;
  10127. /**
  10128. * Tests the intersection of a sprite with a specific ray.
  10129. * @param ray The ray we are sending to test the collision
  10130. * @param camera The camera space we are sending rays in
  10131. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10132. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10133. * @returns picking info or null.
  10134. */
  10135. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10136. /**
  10137. * Intersects the sprites with a ray
  10138. * @param ray defines the ray to intersect with
  10139. * @param camera defines the current active camera
  10140. * @param predicate defines a predicate used to select candidate sprites
  10141. * @returns null if no hit or a PickingInfo array
  10142. */
  10143. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10144. /**
  10145. * Renders the list of sprites on screen.
  10146. */
  10147. render(): void;
  10148. }
  10149. /**
  10150. * Class used to manage multiple sprites on the same spritesheet
  10151. * @see http://doc.babylonjs.com/babylon101/sprites
  10152. */
  10153. export class SpriteManager implements ISpriteManager {
  10154. /** defines the manager's name */
  10155. name: string;
  10156. /** Gets the list of sprites */
  10157. sprites: Sprite[];
  10158. /** Gets or sets the rendering group id (0 by default) */
  10159. renderingGroupId: number;
  10160. /** Gets or sets camera layer mask */
  10161. layerMask: number;
  10162. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10163. fogEnabled: boolean;
  10164. /** Gets or sets a boolean indicating if the sprites are pickable */
  10165. isPickable: boolean;
  10166. /** Defines the default width of a cell in the spritesheet */
  10167. cellWidth: number;
  10168. /** Defines the default height of a cell in the spritesheet */
  10169. cellHeight: number;
  10170. /** Associative array from JSON sprite data file */
  10171. private _cellData;
  10172. /** Array of sprite names from JSON sprite data file */
  10173. private _spriteMap;
  10174. /** True when packed cell data from JSON file is ready*/
  10175. private _packedAndReady;
  10176. /**
  10177. * An event triggered when the manager is disposed.
  10178. */
  10179. onDisposeObservable: Observable<SpriteManager>;
  10180. private _onDisposeObserver;
  10181. /**
  10182. * Callback called when the manager is disposed
  10183. */
  10184. set onDispose(callback: () => void);
  10185. private _capacity;
  10186. private _fromPacked;
  10187. private _spriteTexture;
  10188. private _epsilon;
  10189. private _scene;
  10190. private _vertexData;
  10191. private _buffer;
  10192. private _vertexBuffers;
  10193. private _indexBuffer;
  10194. private _effectBase;
  10195. private _effectFog;
  10196. /**
  10197. * Gets or sets the spritesheet texture
  10198. */
  10199. get texture(): Texture;
  10200. set texture(value: Texture);
  10201. private _blendMode;
  10202. /**
  10203. * Blend mode use to render the particle, it can be any of
  10204. * the static Constants.ALPHA_x properties provided in this class.
  10205. * Default value is Constants.ALPHA_COMBINE
  10206. */
  10207. get blendMode(): number;
  10208. set blendMode(blendMode: number);
  10209. /** Disables writing to the depth buffer when rendering the sprites.
  10210. * It can be handy to disable depth writing when using textures without alpha channel
  10211. * and setting some specific blend modes.
  10212. */
  10213. disableDepthWrite: boolean;
  10214. /**
  10215. * Creates a new sprite manager
  10216. * @param name defines the manager's name
  10217. * @param imgUrl defines the sprite sheet url
  10218. * @param capacity defines the maximum allowed number of sprites
  10219. * @param cellSize defines the size of a sprite cell
  10220. * @param scene defines the hosting scene
  10221. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10222. * @param samplingMode defines the smapling mode to use with spritesheet
  10223. * @param fromPacked set to false; do not alter
  10224. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10225. */
  10226. constructor(
  10227. /** defines the manager's name */
  10228. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10229. private _makePacked;
  10230. private _appendSpriteVertex;
  10231. /**
  10232. * Intersects the sprites with a ray
  10233. * @param ray defines the ray to intersect with
  10234. * @param camera defines the current active camera
  10235. * @param predicate defines a predicate used to select candidate sprites
  10236. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10237. * @returns null if no hit or a PickingInfo
  10238. */
  10239. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10240. /**
  10241. * Intersects the sprites with a ray
  10242. * @param ray defines the ray to intersect with
  10243. * @param camera defines the current active camera
  10244. * @param predicate defines a predicate used to select candidate sprites
  10245. * @returns null if no hit or a PickingInfo array
  10246. */
  10247. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10248. /**
  10249. * Render all child sprites
  10250. */
  10251. render(): void;
  10252. /**
  10253. * Release associated resources
  10254. */
  10255. dispose(): void;
  10256. }
  10257. }
  10258. declare module "babylonjs/Misc/gradients" {
  10259. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10260. /** Interface used by value gradients (color, factor, ...) */
  10261. export interface IValueGradient {
  10262. /**
  10263. * Gets or sets the gradient value (between 0 and 1)
  10264. */
  10265. gradient: number;
  10266. }
  10267. /** Class used to store color4 gradient */
  10268. export class ColorGradient implements IValueGradient {
  10269. /**
  10270. * Gets or sets the gradient value (between 0 and 1)
  10271. */
  10272. gradient: number;
  10273. /**
  10274. * Gets or sets first associated color
  10275. */
  10276. color1: Color4;
  10277. /**
  10278. * Gets or sets second associated color
  10279. */
  10280. color2?: Color4;
  10281. /**
  10282. * Will get a color picked randomly between color1 and color2.
  10283. * If color2 is undefined then color1 will be used
  10284. * @param result defines the target Color4 to store the result in
  10285. */
  10286. getColorToRef(result: Color4): void;
  10287. }
  10288. /** Class used to store color 3 gradient */
  10289. export class Color3Gradient implements IValueGradient {
  10290. /**
  10291. * Gets or sets the gradient value (between 0 and 1)
  10292. */
  10293. gradient: number;
  10294. /**
  10295. * Gets or sets the associated color
  10296. */
  10297. color: Color3;
  10298. }
  10299. /** Class used to store factor gradient */
  10300. export class FactorGradient implements IValueGradient {
  10301. /**
  10302. * Gets or sets the gradient value (between 0 and 1)
  10303. */
  10304. gradient: number;
  10305. /**
  10306. * Gets or sets first associated factor
  10307. */
  10308. factor1: number;
  10309. /**
  10310. * Gets or sets second associated factor
  10311. */
  10312. factor2?: number;
  10313. /**
  10314. * Will get a number picked randomly between factor1 and factor2.
  10315. * If factor2 is undefined then factor1 will be used
  10316. * @returns the picked number
  10317. */
  10318. getFactor(): number;
  10319. }
  10320. /**
  10321. * Helper used to simplify some generic gradient tasks
  10322. */
  10323. export class GradientHelper {
  10324. /**
  10325. * Gets the current gradient from an array of IValueGradient
  10326. * @param ratio defines the current ratio to get
  10327. * @param gradients defines the array of IValueGradient
  10328. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10329. */
  10330. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10331. }
  10332. }
  10333. declare module "babylonjs/Maths/math.size" {
  10334. /**
  10335. * Interface for the size containing width and height
  10336. */
  10337. export interface ISize {
  10338. /**
  10339. * Width
  10340. */
  10341. width: number;
  10342. /**
  10343. * Heighht
  10344. */
  10345. height: number;
  10346. }
  10347. /**
  10348. * Size containing widht and height
  10349. */
  10350. export class Size implements ISize {
  10351. /**
  10352. * Width
  10353. */
  10354. width: number;
  10355. /**
  10356. * Height
  10357. */
  10358. height: number;
  10359. /**
  10360. * Creates a Size object from the given width and height (floats).
  10361. * @param width width of the new size
  10362. * @param height height of the new size
  10363. */
  10364. constructor(width: number, height: number);
  10365. /**
  10366. * Returns a string with the Size width and height
  10367. * @returns a string with the Size width and height
  10368. */
  10369. toString(): string;
  10370. /**
  10371. * "Size"
  10372. * @returns the string "Size"
  10373. */
  10374. getClassName(): string;
  10375. /**
  10376. * Returns the Size hash code.
  10377. * @returns a hash code for a unique width and height
  10378. */
  10379. getHashCode(): number;
  10380. /**
  10381. * Updates the current size from the given one.
  10382. * @param src the given size
  10383. */
  10384. copyFrom(src: Size): void;
  10385. /**
  10386. * Updates in place the current Size from the given floats.
  10387. * @param width width of the new size
  10388. * @param height height of the new size
  10389. * @returns the updated Size.
  10390. */
  10391. copyFromFloats(width: number, height: number): Size;
  10392. /**
  10393. * Updates in place the current Size from the given floats.
  10394. * @param width width to set
  10395. * @param height height to set
  10396. * @returns the updated Size.
  10397. */
  10398. set(width: number, height: number): Size;
  10399. /**
  10400. * Multiplies the width and height by numbers
  10401. * @param w factor to multiple the width by
  10402. * @param h factor to multiple the height by
  10403. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10404. */
  10405. multiplyByFloats(w: number, h: number): Size;
  10406. /**
  10407. * Clones the size
  10408. * @returns a new Size copied from the given one.
  10409. */
  10410. clone(): Size;
  10411. /**
  10412. * True if the current Size and the given one width and height are strictly equal.
  10413. * @param other the other size to compare against
  10414. * @returns True if the current Size and the given one width and height are strictly equal.
  10415. */
  10416. equals(other: Size): boolean;
  10417. /**
  10418. * The surface of the Size : width * height (float).
  10419. */
  10420. get surface(): number;
  10421. /**
  10422. * Create a new size of zero
  10423. * @returns a new Size set to (0.0, 0.0)
  10424. */
  10425. static Zero(): Size;
  10426. /**
  10427. * Sums the width and height of two sizes
  10428. * @param otherSize size to add to this size
  10429. * @returns a new Size set as the addition result of the current Size and the given one.
  10430. */
  10431. add(otherSize: Size): Size;
  10432. /**
  10433. * Subtracts the width and height of two
  10434. * @param otherSize size to subtract to this size
  10435. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10436. */
  10437. subtract(otherSize: Size): Size;
  10438. /**
  10439. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10440. * @param start starting size to lerp between
  10441. * @param end end size to lerp between
  10442. * @param amount amount to lerp between the start and end values
  10443. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10444. */
  10445. static Lerp(start: Size, end: Size, amount: number): Size;
  10446. }
  10447. }
  10448. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10450. import { Nullable } from "babylonjs/types";
  10451. module "babylonjs/Engines/thinEngine" {
  10452. interface ThinEngine {
  10453. /**
  10454. * Creates a dynamic texture
  10455. * @param width defines the width of the texture
  10456. * @param height defines the height of the texture
  10457. * @param generateMipMaps defines if the engine should generate the mip levels
  10458. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10459. * @returns the dynamic texture inside an InternalTexture
  10460. */
  10461. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10462. /**
  10463. * Update the content of a dynamic texture
  10464. * @param texture defines the texture to update
  10465. * @param canvas defines the canvas containing the source
  10466. * @param invertY defines if data must be stored with Y axis inverted
  10467. * @param premulAlpha defines if alpha is stored as premultiplied
  10468. * @param format defines the format of the data
  10469. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10470. */
  10471. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10472. }
  10473. }
  10474. }
  10475. declare module "babylonjs/Misc/canvasGenerator" {
  10476. /**
  10477. * Helper class used to generate a canvas to manipulate images
  10478. */
  10479. export class CanvasGenerator {
  10480. /**
  10481. * Create a new canvas (or offscreen canvas depending on the context)
  10482. * @param width defines the expected width
  10483. * @param height defines the expected height
  10484. * @return a new canvas or offscreen canvas
  10485. */
  10486. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10487. }
  10488. }
  10489. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10490. import { Scene } from "babylonjs/scene";
  10491. import { Texture } from "babylonjs/Materials/Textures/texture";
  10492. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10493. /**
  10494. * A class extending Texture allowing drawing on a texture
  10495. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10496. */
  10497. export class DynamicTexture extends Texture {
  10498. private _generateMipMaps;
  10499. private _canvas;
  10500. private _context;
  10501. private _engine;
  10502. /**
  10503. * Creates a DynamicTexture
  10504. * @param name defines the name of the texture
  10505. * @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
  10506. * @param scene defines the scene where you want the texture
  10507. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10508. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10509. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10510. */
  10511. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10512. /**
  10513. * Get the current class name of the texture useful for serialization or dynamic coding.
  10514. * @returns "DynamicTexture"
  10515. */
  10516. getClassName(): string;
  10517. /**
  10518. * Gets the current state of canRescale
  10519. */
  10520. get canRescale(): boolean;
  10521. private _recreate;
  10522. /**
  10523. * Scales the texture
  10524. * @param ratio the scale factor to apply to both width and height
  10525. */
  10526. scale(ratio: number): void;
  10527. /**
  10528. * Resizes the texture
  10529. * @param width the new width
  10530. * @param height the new height
  10531. */
  10532. scaleTo(width: number, height: number): void;
  10533. /**
  10534. * Gets the context of the canvas used by the texture
  10535. * @returns the canvas context of the dynamic texture
  10536. */
  10537. getContext(): CanvasRenderingContext2D;
  10538. /**
  10539. * Clears the texture
  10540. */
  10541. clear(): void;
  10542. /**
  10543. * Updates the texture
  10544. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10545. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10546. */
  10547. update(invertY?: boolean, premulAlpha?: boolean): void;
  10548. /**
  10549. * Draws text onto the texture
  10550. * @param text defines the text to be drawn
  10551. * @param x defines the placement of the text from the left
  10552. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10553. * @param font defines the font to be used with font-style, font-size, font-name
  10554. * @param color defines the color used for the text
  10555. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10556. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10557. * @param update defines whether texture is immediately update (default is true)
  10558. */
  10559. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10560. /**
  10561. * Clones the texture
  10562. * @returns the clone of the texture.
  10563. */
  10564. clone(): DynamicTexture;
  10565. /**
  10566. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10567. * @returns a serialized dynamic texture object
  10568. */
  10569. serialize(): any;
  10570. /** @hidden */
  10571. _rebuild(): void;
  10572. }
  10573. }
  10574. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10575. import { Nullable } from "babylonjs/types";
  10576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10577. import { Scene } from "babylonjs/scene";
  10578. module "babylonjs/Engines/engine" {
  10579. interface Engine {
  10580. /**
  10581. * Creates a raw texture
  10582. * @param data defines the data to store in the texture
  10583. * @param width defines the width of the texture
  10584. * @param height defines the height of the texture
  10585. * @param format defines the format of the data
  10586. * @param generateMipMaps defines if the engine should generate the mip levels
  10587. * @param invertY defines if data must be stored with Y axis inverted
  10588. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10589. * @param compression defines the compression used (null by default)
  10590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10591. * @returns the raw texture inside an InternalTexture
  10592. */
  10593. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10594. /**
  10595. * Update a raw texture
  10596. * @param texture defines the texture to update
  10597. * @param data defines the data to store in the texture
  10598. * @param format defines the format of the data
  10599. * @param invertY defines if data must be stored with Y axis inverted
  10600. */
  10601. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10602. /**
  10603. * Update a raw texture
  10604. * @param texture defines the texture to update
  10605. * @param data defines the data to store in the texture
  10606. * @param format defines the format of the data
  10607. * @param invertY defines if data must be stored with Y axis inverted
  10608. * @param compression defines the compression used (null by default)
  10609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10610. */
  10611. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10612. /**
  10613. * Creates a new raw cube texture
  10614. * @param data defines the array of data to use to create each face
  10615. * @param size defines the size of the textures
  10616. * @param format defines the format of the data
  10617. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10618. * @param generateMipMaps defines if the engine should generate the mip levels
  10619. * @param invertY defines if data must be stored with Y axis inverted
  10620. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10621. * @param compression defines the compression used (null by default)
  10622. * @returns the cube texture as an InternalTexture
  10623. */
  10624. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10625. /**
  10626. * Update a raw cube texture
  10627. * @param texture defines the texture to udpdate
  10628. * @param data defines the data to store
  10629. * @param format defines the data format
  10630. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10631. * @param invertY defines if data must be stored with Y axis inverted
  10632. */
  10633. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10634. /**
  10635. * Update a raw cube texture
  10636. * @param texture defines the texture to udpdate
  10637. * @param data defines the data to store
  10638. * @param format defines the data format
  10639. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10640. * @param invertY defines if data must be stored with Y axis inverted
  10641. * @param compression defines the compression used (null by default)
  10642. */
  10643. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10644. /**
  10645. * Update a raw cube texture
  10646. * @param texture defines the texture to udpdate
  10647. * @param data defines the data to store
  10648. * @param format defines the data format
  10649. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10650. * @param invertY defines if data must be stored with Y axis inverted
  10651. * @param compression defines the compression used (null by default)
  10652. * @param level defines which level of the texture to update
  10653. */
  10654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10655. /**
  10656. * Creates a new raw cube texture from a specified url
  10657. * @param url defines the url where the data is located
  10658. * @param scene defines the current scene
  10659. * @param size defines the size of the textures
  10660. * @param format defines the format of the data
  10661. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10662. * @param noMipmap defines if the engine should avoid generating the mip levels
  10663. * @param callback defines a callback used to extract texture data from loaded data
  10664. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10665. * @param onLoad defines a callback called when texture is loaded
  10666. * @param onError defines a callback called if there is an error
  10667. * @returns the cube texture as an InternalTexture
  10668. */
  10669. 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;
  10670. /**
  10671. * Creates a new raw cube texture from a specified url
  10672. * @param url defines the url where the data is located
  10673. * @param scene defines the current scene
  10674. * @param size defines the size of the textures
  10675. * @param format defines the format of the data
  10676. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10677. * @param noMipmap defines if the engine should avoid generating the mip levels
  10678. * @param callback defines a callback used to extract texture data from loaded data
  10679. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10680. * @param onLoad defines a callback called when texture is loaded
  10681. * @param onError defines a callback called if there is an error
  10682. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10683. * @param invertY defines if data must be stored with Y axis inverted
  10684. * @returns the cube texture as an InternalTexture
  10685. */
  10686. 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;
  10687. /**
  10688. * Creates a new raw 3D texture
  10689. * @param data defines the data used to create the texture
  10690. * @param width defines the width of the texture
  10691. * @param height defines the height of the texture
  10692. * @param depth defines the depth of the texture
  10693. * @param format defines the format of the texture
  10694. * @param generateMipMaps defines if the engine must generate mip levels
  10695. * @param invertY defines if data must be stored with Y axis inverted
  10696. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10697. * @param compression defines the compressed used (can be null)
  10698. * @param textureType defines the compressed used (can be null)
  10699. * @returns a new raw 3D texture (stored in an InternalTexture)
  10700. */
  10701. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10702. /**
  10703. * Update a raw 3D texture
  10704. * @param texture defines the texture to update
  10705. * @param data defines the data to store
  10706. * @param format defines the data format
  10707. * @param invertY defines if data must be stored with Y axis inverted
  10708. */
  10709. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10710. /**
  10711. * Update a raw 3D texture
  10712. * @param texture defines the texture to update
  10713. * @param data defines the data to store
  10714. * @param format defines the data format
  10715. * @param invertY defines if data must be stored with Y axis inverted
  10716. * @param compression defines the used compression (can be null)
  10717. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10718. */
  10719. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10720. /**
  10721. * Creates a new raw 2D array texture
  10722. * @param data defines the data used to create the texture
  10723. * @param width defines the width of the texture
  10724. * @param height defines the height of the texture
  10725. * @param depth defines the number of layers of the texture
  10726. * @param format defines the format of the texture
  10727. * @param generateMipMaps defines if the engine must generate mip levels
  10728. * @param invertY defines if data must be stored with Y axis inverted
  10729. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10730. * @param compression defines the compressed used (can be null)
  10731. * @param textureType defines the compressed used (can be null)
  10732. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10733. */
  10734. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10735. /**
  10736. * Update a raw 2D array texture
  10737. * @param texture defines the texture to update
  10738. * @param data defines the data to store
  10739. * @param format defines the data format
  10740. * @param invertY defines if data must be stored with Y axis inverted
  10741. */
  10742. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10743. /**
  10744. * Update a raw 2D array texture
  10745. * @param texture defines the texture to update
  10746. * @param data defines the data to store
  10747. * @param format defines the data format
  10748. * @param invertY defines if data must be stored with Y axis inverted
  10749. * @param compression defines the used compression (can be null)
  10750. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10751. */
  10752. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10753. }
  10754. }
  10755. }
  10756. declare module "babylonjs/Materials/Textures/rawTexture" {
  10757. import { Scene } from "babylonjs/scene";
  10758. import { Texture } from "babylonjs/Materials/Textures/texture";
  10759. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10760. /**
  10761. * Raw texture can help creating a texture directly from an array of data.
  10762. * This can be super useful if you either get the data from an uncompressed source or
  10763. * if you wish to create your texture pixel by pixel.
  10764. */
  10765. export class RawTexture extends Texture {
  10766. /**
  10767. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10768. */
  10769. format: number;
  10770. private _engine;
  10771. /**
  10772. * Instantiates a new RawTexture.
  10773. * Raw texture can help creating a texture directly from an array of data.
  10774. * This can be super useful if you either get the data from an uncompressed source or
  10775. * if you wish to create your texture pixel by pixel.
  10776. * @param data define the array of data to use to create the texture
  10777. * @param width define the width of the texture
  10778. * @param height define the height of the texture
  10779. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10780. * @param scene define the scene the texture belongs to
  10781. * @param generateMipMaps define whether mip maps should be generated or not
  10782. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10783. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10784. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10785. */
  10786. constructor(data: ArrayBufferView, width: number, height: number,
  10787. /**
  10788. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10789. */
  10790. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10791. /**
  10792. * Updates the texture underlying data.
  10793. * @param data Define the new data of the texture
  10794. */
  10795. update(data: ArrayBufferView): void;
  10796. /**
  10797. * Creates a luminance texture from some data.
  10798. * @param data Define the texture data
  10799. * @param width Define the width of the texture
  10800. * @param height Define the height of the texture
  10801. * @param scene Define the scene the texture belongs to
  10802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10805. * @returns the luminance texture
  10806. */
  10807. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10808. /**
  10809. * Creates a luminance alpha texture from some data.
  10810. * @param data Define the texture data
  10811. * @param width Define the width of the texture
  10812. * @param height Define the height of the texture
  10813. * @param scene Define the scene the texture belongs to
  10814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10817. * @returns the luminance alpha texture
  10818. */
  10819. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10820. /**
  10821. * Creates an alpha texture from some data.
  10822. * @param data Define the texture data
  10823. * @param width Define the width of the texture
  10824. * @param height Define the height of the texture
  10825. * @param scene Define the scene the texture belongs to
  10826. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10827. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10828. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10829. * @returns the alpha texture
  10830. */
  10831. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10832. /**
  10833. * Creates a RGB texture from some data.
  10834. * @param data Define the texture data
  10835. * @param width Define the width of the texture
  10836. * @param height Define the height of the texture
  10837. * @param scene Define the scene the texture belongs to
  10838. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10839. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10840. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10841. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10842. * @returns the RGB alpha texture
  10843. */
  10844. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10845. /**
  10846. * Creates a RGBA texture from some data.
  10847. * @param data Define the texture data
  10848. * @param width Define the width of the texture
  10849. * @param height Define the height of the texture
  10850. * @param scene Define the scene the texture belongs to
  10851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10855. * @returns the RGBA texture
  10856. */
  10857. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10858. /**
  10859. * Creates a R texture from some data.
  10860. * @param data Define the texture data
  10861. * @param width Define the width of the texture
  10862. * @param height Define the height of the texture
  10863. * @param scene Define the scene the texture belongs to
  10864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10867. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10868. * @returns the R texture
  10869. */
  10870. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10871. }
  10872. }
  10873. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10874. import { Scene } from "babylonjs/scene";
  10875. import { ISceneComponent } from "babylonjs/sceneComponent";
  10876. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10877. module "babylonjs/abstractScene" {
  10878. interface AbstractScene {
  10879. /**
  10880. * The list of procedural textures added to the scene
  10881. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10882. */
  10883. proceduralTextures: Array<ProceduralTexture>;
  10884. }
  10885. }
  10886. /**
  10887. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10888. * in a given scene.
  10889. */
  10890. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10891. /**
  10892. * The component name helpfull to identify the component in the list of scene components.
  10893. */
  10894. readonly name: string;
  10895. /**
  10896. * The scene the component belongs to.
  10897. */
  10898. scene: Scene;
  10899. /**
  10900. * Creates a new instance of the component for the given scene
  10901. * @param scene Defines the scene to register the component in
  10902. */
  10903. constructor(scene: Scene);
  10904. /**
  10905. * Registers the component in a given scene
  10906. */
  10907. register(): void;
  10908. /**
  10909. * Rebuilds the elements related to this component in case of
  10910. * context lost for instance.
  10911. */
  10912. rebuild(): void;
  10913. /**
  10914. * Disposes the component and the associated ressources.
  10915. */
  10916. dispose(): void;
  10917. private _beforeClear;
  10918. }
  10919. }
  10920. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10921. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10922. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10923. module "babylonjs/Engines/thinEngine" {
  10924. interface ThinEngine {
  10925. /**
  10926. * Creates a new render target cube texture
  10927. * @param size defines the size of the texture
  10928. * @param options defines the options used to create the texture
  10929. * @returns a new render target cube texture stored in an InternalTexture
  10930. */
  10931. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10932. }
  10933. }
  10934. }
  10935. declare module "babylonjs/Shaders/procedural.vertex" {
  10936. /** @hidden */
  10937. export var proceduralVertexShader: {
  10938. name: string;
  10939. shader: string;
  10940. };
  10941. }
  10942. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10943. import { Observable } from "babylonjs/Misc/observable";
  10944. import { Nullable } from "babylonjs/types";
  10945. import { Scene } from "babylonjs/scene";
  10946. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10947. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10948. import { Effect } from "babylonjs/Materials/effect";
  10949. import { Texture } from "babylonjs/Materials/Textures/texture";
  10950. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10951. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10952. import "babylonjs/Shaders/procedural.vertex";
  10953. /**
  10954. * 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.
  10955. * This is the base class of any Procedural texture and contains most of the shareable code.
  10956. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10957. */
  10958. export class ProceduralTexture extends Texture {
  10959. isCube: boolean;
  10960. /**
  10961. * Define if the texture is enabled or not (disabled texture will not render)
  10962. */
  10963. isEnabled: boolean;
  10964. /**
  10965. * Define if the texture must be cleared before rendering (default is true)
  10966. */
  10967. autoClear: boolean;
  10968. /**
  10969. * Callback called when the texture is generated
  10970. */
  10971. onGenerated: () => void;
  10972. /**
  10973. * Event raised when the texture is generated
  10974. */
  10975. onGeneratedObservable: Observable<ProceduralTexture>;
  10976. /** @hidden */
  10977. _generateMipMaps: boolean;
  10978. /** @hidden **/
  10979. _effect: Effect;
  10980. /** @hidden */
  10981. _textures: {
  10982. [key: string]: Texture;
  10983. };
  10984. private _size;
  10985. private _currentRefreshId;
  10986. private _frameId;
  10987. private _refreshRate;
  10988. private _vertexBuffers;
  10989. private _indexBuffer;
  10990. private _uniforms;
  10991. private _samplers;
  10992. private _fragment;
  10993. private _floats;
  10994. private _ints;
  10995. private _floatsArrays;
  10996. private _colors3;
  10997. private _colors4;
  10998. private _vectors2;
  10999. private _vectors3;
  11000. private _matrices;
  11001. private _fallbackTexture;
  11002. private _fallbackTextureUsed;
  11003. private _engine;
  11004. private _cachedDefines;
  11005. private _contentUpdateId;
  11006. private _contentData;
  11007. /**
  11008. * Instantiates a new procedural texture.
  11009. * 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.
  11010. * This is the base class of any Procedural texture and contains most of the shareable code.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11012. * @param name Define the name of the texture
  11013. * @param size Define the size of the texture to create
  11014. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11015. * @param scene Define the scene the texture belongs to
  11016. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11017. * @param generateMipMaps Define if the texture should creates mip maps or not
  11018. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11019. */
  11020. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11021. /**
  11022. * The effect that is created when initializing the post process.
  11023. * @returns The created effect corresponding the the postprocess.
  11024. */
  11025. getEffect(): Effect;
  11026. /**
  11027. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11028. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11029. */
  11030. getContent(): Nullable<ArrayBufferView>;
  11031. private _createIndexBuffer;
  11032. /** @hidden */
  11033. _rebuild(): void;
  11034. /**
  11035. * Resets the texture in order to recreate its associated resources.
  11036. * This can be called in case of context loss
  11037. */
  11038. reset(): void;
  11039. protected _getDefines(): string;
  11040. /**
  11041. * Is the texture ready to be used ? (rendered at least once)
  11042. * @returns true if ready, otherwise, false.
  11043. */
  11044. isReady(): boolean;
  11045. /**
  11046. * Resets the refresh counter of the texture and start bak from scratch.
  11047. * Could be useful to regenerate the texture if it is setup to render only once.
  11048. */
  11049. resetRefreshCounter(): void;
  11050. /**
  11051. * Set the fragment shader to use in order to render the texture.
  11052. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11053. */
  11054. setFragment(fragment: any): void;
  11055. /**
  11056. * Define the refresh rate of the texture or the rendering frequency.
  11057. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11058. */
  11059. get refreshRate(): number;
  11060. set refreshRate(value: number);
  11061. /** @hidden */
  11062. _shouldRender(): boolean;
  11063. /**
  11064. * Get the size the texture is rendering at.
  11065. * @returns the size (texture is always squared)
  11066. */
  11067. getRenderSize(): number;
  11068. /**
  11069. * Resize the texture to new value.
  11070. * @param size Define the new size the texture should have
  11071. * @param generateMipMaps Define whether the new texture should create mip maps
  11072. */
  11073. resize(size: number, generateMipMaps: boolean): void;
  11074. private _checkUniform;
  11075. /**
  11076. * Set a texture in the shader program used to render.
  11077. * @param name Define the name of the uniform samplers as defined in the shader
  11078. * @param texture Define the texture to bind to this sampler
  11079. * @return the texture itself allowing "fluent" like uniform updates
  11080. */
  11081. setTexture(name: string, texture: Texture): ProceduralTexture;
  11082. /**
  11083. * Set a float in the shader.
  11084. * @param name Define the name of the uniform as defined in the shader
  11085. * @param value Define the value to give to the uniform
  11086. * @return the texture itself allowing "fluent" like uniform updates
  11087. */
  11088. setFloat(name: string, value: number): ProceduralTexture;
  11089. /**
  11090. * Set a int in the shader.
  11091. * @param name Define the name of the uniform as defined in the shader
  11092. * @param value Define the value to give to the uniform
  11093. * @return the texture itself allowing "fluent" like uniform updates
  11094. */
  11095. setInt(name: string, value: number): ProceduralTexture;
  11096. /**
  11097. * Set an array of floats in the shader.
  11098. * @param name Define the name of the uniform as defined in the shader
  11099. * @param value Define the value to give to the uniform
  11100. * @return the texture itself allowing "fluent" like uniform updates
  11101. */
  11102. setFloats(name: string, value: number[]): ProceduralTexture;
  11103. /**
  11104. * Set a vec3 in the shader from a Color3.
  11105. * @param name Define the name of the uniform as defined in the shader
  11106. * @param value Define the value to give to the uniform
  11107. * @return the texture itself allowing "fluent" like uniform updates
  11108. */
  11109. setColor3(name: string, value: Color3): ProceduralTexture;
  11110. /**
  11111. * Set a vec4 in the shader from a Color4.
  11112. * @param name Define the name of the uniform as defined in the shader
  11113. * @param value Define the value to give to the uniform
  11114. * @return the texture itself allowing "fluent" like uniform updates
  11115. */
  11116. setColor4(name: string, value: Color4): ProceduralTexture;
  11117. /**
  11118. * Set a vec2 in the shader from a Vector2.
  11119. * @param name Define the name of the uniform as defined in the shader
  11120. * @param value Define the value to give to the uniform
  11121. * @return the texture itself allowing "fluent" like uniform updates
  11122. */
  11123. setVector2(name: string, value: Vector2): ProceduralTexture;
  11124. /**
  11125. * Set a vec3 in the shader from a Vector3.
  11126. * @param name Define the name of the uniform as defined in the shader
  11127. * @param value Define the value to give to the uniform
  11128. * @return the texture itself allowing "fluent" like uniform updates
  11129. */
  11130. setVector3(name: string, value: Vector3): ProceduralTexture;
  11131. /**
  11132. * Set a mat4 in the shader from a MAtrix.
  11133. * @param name Define the name of the uniform as defined in the shader
  11134. * @param value Define the value to give to the uniform
  11135. * @return the texture itself allowing "fluent" like uniform updates
  11136. */
  11137. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11138. /**
  11139. * Render the texture to its associated render target.
  11140. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11141. */
  11142. render(useCameraPostProcess?: boolean): void;
  11143. /**
  11144. * Clone the texture.
  11145. * @returns the cloned texture
  11146. */
  11147. clone(): ProceduralTexture;
  11148. /**
  11149. * Dispose the texture and release its asoociated resources.
  11150. */
  11151. dispose(): void;
  11152. }
  11153. }
  11154. declare module "babylonjs/Particles/baseParticleSystem" {
  11155. import { Nullable } from "babylonjs/types";
  11156. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11158. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11159. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11160. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11161. import { Scene } from "babylonjs/scene";
  11162. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11163. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11164. import { Texture } from "babylonjs/Materials/Textures/texture";
  11165. import { Color4 } from "babylonjs/Maths/math.color";
  11166. import { Animation } from "babylonjs/Animations/animation";
  11167. /**
  11168. * This represents the base class for particle system in Babylon.
  11169. * 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.
  11170. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11171. * @example https://doc.babylonjs.com/babylon101/particles
  11172. */
  11173. export class BaseParticleSystem {
  11174. /**
  11175. * Source color is added to the destination color without alpha affecting the result
  11176. */
  11177. static BLENDMODE_ONEONE: number;
  11178. /**
  11179. * Blend current color and particle color using particle’s alpha
  11180. */
  11181. static BLENDMODE_STANDARD: number;
  11182. /**
  11183. * Add current color and particle color multiplied by particle’s alpha
  11184. */
  11185. static BLENDMODE_ADD: number;
  11186. /**
  11187. * Multiply current color with particle color
  11188. */
  11189. static BLENDMODE_MULTIPLY: number;
  11190. /**
  11191. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11192. */
  11193. static BLENDMODE_MULTIPLYADD: number;
  11194. /**
  11195. * List of animations used by the particle system.
  11196. */
  11197. animations: Animation[];
  11198. /**
  11199. * The id of the Particle system.
  11200. */
  11201. id: string;
  11202. /**
  11203. * The friendly name of the Particle system.
  11204. */
  11205. name: string;
  11206. /**
  11207. * The rendering group used by the Particle system to chose when to render.
  11208. */
  11209. renderingGroupId: number;
  11210. /**
  11211. * The emitter represents the Mesh or position we are attaching the particle system to.
  11212. */
  11213. emitter: Nullable<AbstractMesh | Vector3>;
  11214. /**
  11215. * The maximum number of particles to emit per frame
  11216. */
  11217. emitRate: number;
  11218. /**
  11219. * If you want to launch only a few particles at once, that can be done, as well.
  11220. */
  11221. manualEmitCount: number;
  11222. /**
  11223. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11224. */
  11225. updateSpeed: number;
  11226. /**
  11227. * The amount of time the particle system is running (depends of the overall update speed).
  11228. */
  11229. targetStopDuration: number;
  11230. /**
  11231. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11232. */
  11233. disposeOnStop: boolean;
  11234. /**
  11235. * Minimum power of emitting particles.
  11236. */
  11237. minEmitPower: number;
  11238. /**
  11239. * Maximum power of emitting particles.
  11240. */
  11241. maxEmitPower: number;
  11242. /**
  11243. * Minimum life time of emitting particles.
  11244. */
  11245. minLifeTime: number;
  11246. /**
  11247. * Maximum life time of emitting particles.
  11248. */
  11249. maxLifeTime: number;
  11250. /**
  11251. * Minimum Size of emitting particles.
  11252. */
  11253. minSize: number;
  11254. /**
  11255. * Maximum Size of emitting particles.
  11256. */
  11257. maxSize: number;
  11258. /**
  11259. * Minimum scale of emitting particles on X axis.
  11260. */
  11261. minScaleX: number;
  11262. /**
  11263. * Maximum scale of emitting particles on X axis.
  11264. */
  11265. maxScaleX: number;
  11266. /**
  11267. * Minimum scale of emitting particles on Y axis.
  11268. */
  11269. minScaleY: number;
  11270. /**
  11271. * Maximum scale of emitting particles on Y axis.
  11272. */
  11273. maxScaleY: number;
  11274. /**
  11275. * Gets or sets the minimal initial rotation in radians.
  11276. */
  11277. minInitialRotation: number;
  11278. /**
  11279. * Gets or sets the maximal initial rotation in radians.
  11280. */
  11281. maxInitialRotation: number;
  11282. /**
  11283. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11284. */
  11285. minAngularSpeed: number;
  11286. /**
  11287. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11288. */
  11289. maxAngularSpeed: number;
  11290. /**
  11291. * The texture used to render each particle. (this can be a spritesheet)
  11292. */
  11293. particleTexture: Nullable<Texture>;
  11294. /**
  11295. * The layer mask we are rendering the particles through.
  11296. */
  11297. layerMask: number;
  11298. /**
  11299. * This can help using your own shader to render the particle system.
  11300. * The according effect will be created
  11301. */
  11302. customShader: any;
  11303. /**
  11304. * By default particle system starts as soon as they are created. This prevents the
  11305. * automatic start to happen and let you decide when to start emitting particles.
  11306. */
  11307. preventAutoStart: boolean;
  11308. private _noiseTexture;
  11309. /**
  11310. * Gets or sets a texture used to add random noise to particle positions
  11311. */
  11312. get noiseTexture(): Nullable<ProceduralTexture>;
  11313. set noiseTexture(value: Nullable<ProceduralTexture>);
  11314. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11315. noiseStrength: Vector3;
  11316. /**
  11317. * Callback triggered when the particle animation is ending.
  11318. */
  11319. onAnimationEnd: Nullable<() => void>;
  11320. /**
  11321. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11322. */
  11323. blendMode: number;
  11324. /**
  11325. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11326. * to override the particles.
  11327. */
  11328. forceDepthWrite: boolean;
  11329. /** 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 */
  11330. preWarmCycles: number;
  11331. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11332. preWarmStepOffset: number;
  11333. /**
  11334. * 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)
  11335. */
  11336. spriteCellChangeSpeed: number;
  11337. /**
  11338. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11339. */
  11340. startSpriteCellID: number;
  11341. /**
  11342. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11343. */
  11344. endSpriteCellID: number;
  11345. /**
  11346. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11347. */
  11348. spriteCellWidth: number;
  11349. /**
  11350. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11351. */
  11352. spriteCellHeight: number;
  11353. /**
  11354. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11355. */
  11356. spriteRandomStartCell: boolean;
  11357. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11358. translationPivot: Vector2;
  11359. /** @hidden */
  11360. protected _isAnimationSheetEnabled: boolean;
  11361. /**
  11362. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11363. */
  11364. beginAnimationOnStart: boolean;
  11365. /**
  11366. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11367. */
  11368. beginAnimationFrom: number;
  11369. /**
  11370. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11371. */
  11372. beginAnimationTo: number;
  11373. /**
  11374. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11375. */
  11376. beginAnimationLoop: boolean;
  11377. /**
  11378. * Gets or sets a world offset applied to all particles
  11379. */
  11380. worldOffset: Vector3;
  11381. /**
  11382. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11383. */
  11384. get isAnimationSheetEnabled(): boolean;
  11385. set isAnimationSheetEnabled(value: boolean);
  11386. /**
  11387. * Get hosting scene
  11388. * @returns the scene
  11389. */
  11390. getScene(): Scene;
  11391. /**
  11392. * You can use gravity if you want to give an orientation to your particles.
  11393. */
  11394. gravity: Vector3;
  11395. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11396. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11397. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11399. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11400. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11401. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11402. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11403. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11404. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11405. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11406. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11407. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11408. /**
  11409. * Defines the delay in milliseconds before starting the system (0 by default)
  11410. */
  11411. startDelay: number;
  11412. /**
  11413. * Gets the current list of drag gradients.
  11414. * You must use addDragGradient and removeDragGradient to udpate this list
  11415. * @returns the list of drag gradients
  11416. */
  11417. getDragGradients(): Nullable<Array<FactorGradient>>;
  11418. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11419. limitVelocityDamping: number;
  11420. /**
  11421. * Gets the current list of limit velocity gradients.
  11422. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11423. * @returns the list of limit velocity gradients
  11424. */
  11425. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11426. /**
  11427. * Gets the current list of color gradients.
  11428. * You must use addColorGradient and removeColorGradient to udpate this list
  11429. * @returns the list of color gradients
  11430. */
  11431. getColorGradients(): Nullable<Array<ColorGradient>>;
  11432. /**
  11433. * Gets the current list of size gradients.
  11434. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11435. * @returns the list of size gradients
  11436. */
  11437. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of color remap gradients.
  11440. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11441. * @returns the list of color remap gradients
  11442. */
  11443. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of alpha remap gradients.
  11446. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11447. * @returns the list of alpha remap gradients
  11448. */
  11449. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of life time gradients.
  11452. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11453. * @returns the list of life time gradients
  11454. */
  11455. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of angular speed gradients.
  11458. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11459. * @returns the list of angular speed gradients
  11460. */
  11461. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of velocity gradients.
  11464. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11465. * @returns the list of velocity gradients
  11466. */
  11467. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of start size gradients.
  11470. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11471. * @returns the list of start size gradients
  11472. */
  11473. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Gets the current list of emit rate gradients.
  11476. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11477. * @returns the list of emit rate gradients
  11478. */
  11479. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  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 direction1(): Vector3;
  11485. set direction1(value: Vector3);
  11486. /**
  11487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get direction2(): Vector3;
  11491. set direction2(value: Vector3);
  11492. /**
  11493. * 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.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get minEmitBox(): Vector3;
  11497. set minEmitBox(value: Vector3);
  11498. /**
  11499. * 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.
  11500. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11501. */
  11502. get maxEmitBox(): Vector3;
  11503. set maxEmitBox(value: Vector3);
  11504. /**
  11505. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11506. */
  11507. color1: Color4;
  11508. /**
  11509. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11510. */
  11511. color2: Color4;
  11512. /**
  11513. * Color the particle will have at the end of its lifetime
  11514. */
  11515. colorDead: Color4;
  11516. /**
  11517. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11518. */
  11519. textureMask: Color4;
  11520. /**
  11521. * The particle emitter type defines the emitter used by the particle system.
  11522. * It can be for example box, sphere, or cone...
  11523. */
  11524. particleEmitterType: IParticleEmitterType;
  11525. /** @hidden */
  11526. _isSubEmitter: boolean;
  11527. /**
  11528. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11529. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11530. */
  11531. billboardMode: number;
  11532. protected _isBillboardBased: boolean;
  11533. /**
  11534. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11535. */
  11536. get isBillboardBased(): boolean;
  11537. set isBillboardBased(value: boolean);
  11538. /**
  11539. * The scene the particle system belongs to.
  11540. */
  11541. protected _scene: Scene;
  11542. /**
  11543. * Local cache of defines for image processing.
  11544. */
  11545. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11546. /**
  11547. * Default configuration related to image processing available in the standard Material.
  11548. */
  11549. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11550. /**
  11551. * Gets the image processing configuration used either in this material.
  11552. */
  11553. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11554. /**
  11555. * Sets the Default image processing configuration used either in the this material.
  11556. *
  11557. * If sets to null, the scene one is in use.
  11558. */
  11559. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11560. /**
  11561. * Attaches a new image processing configuration to the Standard Material.
  11562. * @param configuration
  11563. */
  11564. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11565. /** @hidden */
  11566. protected _reset(): void;
  11567. /** @hidden */
  11568. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11569. /**
  11570. * Instantiates a particle system.
  11571. * 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.
  11572. * @param name The name of the particle system
  11573. */
  11574. constructor(name: string);
  11575. /**
  11576. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11579. * @returns the emitter
  11580. */
  11581. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11582. /**
  11583. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11584. * @param radius The radius of the hemisphere to emit from
  11585. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11586. * @returns the emitter
  11587. */
  11588. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11589. /**
  11590. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11591. * @param radius The radius of the sphere to emit from
  11592. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11593. * @returns the emitter
  11594. */
  11595. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11596. /**
  11597. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11598. * @param radius The radius of the sphere to emit from
  11599. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11600. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11601. * @returns the emitter
  11602. */
  11603. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11604. /**
  11605. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11606. * @param radius The radius of the emission cylinder
  11607. * @param height The height of the emission cylinder
  11608. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11609. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11610. * @returns the emitter
  11611. */
  11612. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11613. /**
  11614. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11615. * @param radius The radius of the cylinder to emit from
  11616. * @param height The height of the emission cylinder
  11617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11618. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11619. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11620. * @returns the emitter
  11621. */
  11622. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11623. /**
  11624. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11625. * @param radius The radius of the cone to emit from
  11626. * @param angle The base angle of the cone
  11627. * @returns the emitter
  11628. */
  11629. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11630. /**
  11631. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11634. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11635. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11636. * @returns the emitter
  11637. */
  11638. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11639. }
  11640. }
  11641. declare module "babylonjs/Particles/subEmitter" {
  11642. import { Scene } from "babylonjs/scene";
  11643. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11644. /**
  11645. * Type of sub emitter
  11646. */
  11647. export enum SubEmitterType {
  11648. /**
  11649. * Attached to the particle over it's lifetime
  11650. */
  11651. ATTACHED = 0,
  11652. /**
  11653. * Created when the particle dies
  11654. */
  11655. END = 1
  11656. }
  11657. /**
  11658. * Sub emitter class used to emit particles from an existing particle
  11659. */
  11660. export class SubEmitter {
  11661. /**
  11662. * the particle system to be used by the sub emitter
  11663. */
  11664. particleSystem: ParticleSystem;
  11665. /**
  11666. * Type of the submitter (Default: END)
  11667. */
  11668. type: SubEmitterType;
  11669. /**
  11670. * 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)
  11671. * Note: This only is supported when using an emitter of type Mesh
  11672. */
  11673. inheritDirection: boolean;
  11674. /**
  11675. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11676. */
  11677. inheritedVelocityAmount: number;
  11678. /**
  11679. * Creates a sub emitter
  11680. * @param particleSystem the particle system to be used by the sub emitter
  11681. */
  11682. constructor(
  11683. /**
  11684. * the particle system to be used by the sub emitter
  11685. */
  11686. particleSystem: ParticleSystem);
  11687. /**
  11688. * Clones the sub emitter
  11689. * @returns the cloned sub emitter
  11690. */
  11691. clone(): SubEmitter;
  11692. /**
  11693. * Serialize current object to a JSON object
  11694. * @returns the serialized object
  11695. */
  11696. serialize(): any;
  11697. /** @hidden */
  11698. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11699. /**
  11700. * Creates a new SubEmitter from a serialized JSON version
  11701. * @param serializationObject defines the JSON object to read from
  11702. * @param scene defines the hosting scene
  11703. * @param rootUrl defines the rootUrl for data loading
  11704. * @returns a new SubEmitter
  11705. */
  11706. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11707. /** Release associated resources */
  11708. dispose(): void;
  11709. }
  11710. }
  11711. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11712. /** @hidden */
  11713. export var imageProcessingDeclaration: {
  11714. name: string;
  11715. shader: string;
  11716. };
  11717. }
  11718. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11719. /** @hidden */
  11720. export var imageProcessingFunctions: {
  11721. name: string;
  11722. shader: string;
  11723. };
  11724. }
  11725. declare module "babylonjs/Shaders/particles.fragment" {
  11726. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11727. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11728. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11729. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11730. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11731. /** @hidden */
  11732. export var particlesPixelShader: {
  11733. name: string;
  11734. shader: string;
  11735. };
  11736. }
  11737. declare module "babylonjs/Shaders/particles.vertex" {
  11738. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11739. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11740. /** @hidden */
  11741. export var particlesVertexShader: {
  11742. name: string;
  11743. shader: string;
  11744. };
  11745. }
  11746. declare module "babylonjs/Particles/particleSystem" {
  11747. import { Nullable } from "babylonjs/types";
  11748. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11749. import { Observable } from "babylonjs/Misc/observable";
  11750. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11751. import { Effect } from "babylonjs/Materials/effect";
  11752. import { Scene, IDisposable } from "babylonjs/scene";
  11753. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11754. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11755. import { Particle } from "babylonjs/Particles/particle";
  11756. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11757. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11758. import "babylonjs/Shaders/particles.fragment";
  11759. import "babylonjs/Shaders/particles.vertex";
  11760. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11761. /**
  11762. * This represents a particle system in Babylon.
  11763. * 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.
  11764. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11765. * @example https://doc.babylonjs.com/babylon101/particles
  11766. */
  11767. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11768. /**
  11769. * Billboard mode will only apply to Y axis
  11770. */
  11771. static readonly BILLBOARDMODE_Y: number;
  11772. /**
  11773. * Billboard mode will apply to all axes
  11774. */
  11775. static readonly BILLBOARDMODE_ALL: number;
  11776. /**
  11777. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11778. */
  11779. static readonly BILLBOARDMODE_STRETCHED: number;
  11780. /**
  11781. * This function can be defined to provide custom update for active particles.
  11782. * This function will be called instead of regular update (age, position, color, etc.).
  11783. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11784. */
  11785. updateFunction: (particles: Particle[]) => void;
  11786. private _emitterWorldMatrix;
  11787. /**
  11788. * This function can be defined to specify initial direction for every new particle.
  11789. * It by default use the emitterType defined function
  11790. */
  11791. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11792. /**
  11793. * This function can be defined to specify initial position for every new particle.
  11794. * It by default use the emitterType defined function
  11795. */
  11796. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11797. /**
  11798. * @hidden
  11799. */
  11800. _inheritedVelocityOffset: Vector3;
  11801. /**
  11802. * An event triggered when the system is disposed
  11803. */
  11804. onDisposeObservable: Observable<ParticleSystem>;
  11805. private _onDisposeObserver;
  11806. /**
  11807. * Sets a callback that will be triggered when the system is disposed
  11808. */
  11809. set onDispose(callback: () => void);
  11810. private _particles;
  11811. private _epsilon;
  11812. private _capacity;
  11813. private _stockParticles;
  11814. private _newPartsExcess;
  11815. private _vertexData;
  11816. private _vertexBuffer;
  11817. private _vertexBuffers;
  11818. private _spriteBuffer;
  11819. private _indexBuffer;
  11820. private _effect;
  11821. private _customEffect;
  11822. private _cachedDefines;
  11823. private _scaledColorStep;
  11824. private _colorDiff;
  11825. private _scaledDirection;
  11826. private _scaledGravity;
  11827. private _currentRenderId;
  11828. private _alive;
  11829. private _useInstancing;
  11830. private _started;
  11831. private _stopped;
  11832. private _actualFrame;
  11833. private _scaledUpdateSpeed;
  11834. private _vertexBufferSize;
  11835. /** @hidden */
  11836. _currentEmitRateGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentEmitRate1: number;
  11839. /** @hidden */
  11840. _currentEmitRate2: number;
  11841. /** @hidden */
  11842. _currentStartSizeGradient: Nullable<FactorGradient>;
  11843. /** @hidden */
  11844. _currentStartSize1: number;
  11845. /** @hidden */
  11846. _currentStartSize2: number;
  11847. private readonly _rawTextureWidth;
  11848. private _rampGradientsTexture;
  11849. private _useRampGradients;
  11850. /** Gets or sets a boolean indicating that ramp gradients must be used
  11851. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11852. */
  11853. get useRampGradients(): boolean;
  11854. set useRampGradients(value: boolean);
  11855. /**
  11856. * 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.
  11857. * 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: [])
  11858. */
  11859. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11860. private _subEmitters;
  11861. /**
  11862. * @hidden
  11863. * If the particle systems emitter should be disposed when the particle system is disposed
  11864. */
  11865. _disposeEmitterOnDispose: boolean;
  11866. /**
  11867. * The current active Sub-systems, this property is used by the root particle system only.
  11868. */
  11869. activeSubSystems: Array<ParticleSystem>;
  11870. /**
  11871. * Specifies if the particles are updated in emitter local space or world space
  11872. */
  11873. isLocal: boolean;
  11874. private _rootParticleSystem;
  11875. /**
  11876. * Gets the current list of active particles
  11877. */
  11878. get particles(): Particle[];
  11879. /**
  11880. * Returns the string "ParticleSystem"
  11881. * @returns a string containing the class name
  11882. */
  11883. getClassName(): string;
  11884. /**
  11885. * Instantiates a particle system.
  11886. * 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.
  11887. * @param name The name of the particle system
  11888. * @param capacity The max number of particles alive at the same time
  11889. * @param scene The scene the particle system belongs to
  11890. * @param customEffect a custom effect used to change the way particles are rendered by default
  11891. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11892. * @param epsilon Offset used to render the particles
  11893. */
  11894. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11895. private _addFactorGradient;
  11896. private _removeFactorGradient;
  11897. /**
  11898. * Adds a new life time gradient
  11899. * @param gradient defines the gradient to use (between 0 and 1)
  11900. * @param factor defines the life time factor to affect to the specified gradient
  11901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11902. * @returns the current particle system
  11903. */
  11904. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11905. /**
  11906. * Remove a specific life time gradient
  11907. * @param gradient defines the gradient to remove
  11908. * @returns the current particle system
  11909. */
  11910. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11911. /**
  11912. * Adds a new size gradient
  11913. * @param gradient defines the gradient to use (between 0 and 1)
  11914. * @param factor defines the size factor to affect to the specified gradient
  11915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11916. * @returns the current particle system
  11917. */
  11918. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11919. /**
  11920. * Remove a specific size gradient
  11921. * @param gradient defines the gradient to remove
  11922. * @returns the current particle system
  11923. */
  11924. removeSizeGradient(gradient: number): IParticleSystem;
  11925. /**
  11926. * Adds a new color remap gradient
  11927. * @param gradient defines the gradient to use (between 0 and 1)
  11928. * @param min defines the color remap minimal range
  11929. * @param max defines the color remap maximal range
  11930. * @returns the current particle system
  11931. */
  11932. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11933. /**
  11934. * Remove a specific color remap gradient
  11935. * @param gradient defines the gradient to remove
  11936. * @returns the current particle system
  11937. */
  11938. removeColorRemapGradient(gradient: number): IParticleSystem;
  11939. /**
  11940. * Adds a new alpha remap gradient
  11941. * @param gradient defines the gradient to use (between 0 and 1)
  11942. * @param min defines the alpha remap minimal range
  11943. * @param max defines the alpha remap maximal range
  11944. * @returns the current particle system
  11945. */
  11946. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11947. /**
  11948. * Remove a specific alpha remap gradient
  11949. * @param gradient defines the gradient to remove
  11950. * @returns the current particle system
  11951. */
  11952. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11953. /**
  11954. * Adds a new angular speed gradient
  11955. * @param gradient defines the gradient to use (between 0 and 1)
  11956. * @param factor defines the angular speed to affect to the specified gradient
  11957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11958. * @returns the current particle system
  11959. */
  11960. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11961. /**
  11962. * Remove a specific angular speed gradient
  11963. * @param gradient defines the gradient to remove
  11964. * @returns the current particle system
  11965. */
  11966. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11967. /**
  11968. * Adds a new velocity gradient
  11969. * @param gradient defines the gradient to use (between 0 and 1)
  11970. * @param factor defines the velocity to affect to the specified gradient
  11971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11972. * @returns the current particle system
  11973. */
  11974. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11975. /**
  11976. * Remove a specific velocity gradient
  11977. * @param gradient defines the gradient to remove
  11978. * @returns the current particle system
  11979. */
  11980. removeVelocityGradient(gradient: number): IParticleSystem;
  11981. /**
  11982. * Adds a new limit velocity gradient
  11983. * @param gradient defines the gradient to use (between 0 and 1)
  11984. * @param factor defines the limit velocity value to affect to the specified gradient
  11985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11986. * @returns the current particle system
  11987. */
  11988. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11989. /**
  11990. * Remove a specific limit velocity gradient
  11991. * @param gradient defines the gradient to remove
  11992. * @returns the current particle system
  11993. */
  11994. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11995. /**
  11996. * Adds a new drag gradient
  11997. * @param gradient defines the gradient to use (between 0 and 1)
  11998. * @param factor defines the drag value to affect to the specified gradient
  11999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12000. * @returns the current particle system
  12001. */
  12002. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12003. /**
  12004. * Remove a specific drag gradient
  12005. * @param gradient defines the gradient to remove
  12006. * @returns the current particle system
  12007. */
  12008. removeDragGradient(gradient: number): IParticleSystem;
  12009. /**
  12010. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12011. * @param gradient defines the gradient to use (between 0 and 1)
  12012. * @param factor defines the emit rate value to affect to the specified gradient
  12013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12014. * @returns the current particle system
  12015. */
  12016. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12017. /**
  12018. * Remove a specific emit rate gradient
  12019. * @param gradient defines the gradient to remove
  12020. * @returns the current particle system
  12021. */
  12022. removeEmitRateGradient(gradient: number): IParticleSystem;
  12023. /**
  12024. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12025. * @param gradient defines the gradient to use (between 0 and 1)
  12026. * @param factor defines the start size value to affect to the specified gradient
  12027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12028. * @returns the current particle system
  12029. */
  12030. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12031. /**
  12032. * Remove a specific start size gradient
  12033. * @param gradient defines the gradient to remove
  12034. * @returns the current particle system
  12035. */
  12036. removeStartSizeGradient(gradient: number): IParticleSystem;
  12037. private _createRampGradientTexture;
  12038. /**
  12039. * Gets the current list of ramp gradients.
  12040. * You must use addRampGradient and removeRampGradient to udpate this list
  12041. * @returns the list of ramp gradients
  12042. */
  12043. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12044. /**
  12045. * Adds a new ramp gradient used to remap particle colors
  12046. * @param gradient defines the gradient to use (between 0 and 1)
  12047. * @param color defines the color to affect to the specified gradient
  12048. * @returns the current particle system
  12049. */
  12050. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12051. /**
  12052. * Remove a specific ramp gradient
  12053. * @param gradient defines the gradient to remove
  12054. * @returns the current particle system
  12055. */
  12056. removeRampGradient(gradient: number): ParticleSystem;
  12057. /**
  12058. * Adds a new color gradient
  12059. * @param gradient defines the gradient to use (between 0 and 1)
  12060. * @param color1 defines the color to affect to the specified gradient
  12061. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12062. * @returns this particle system
  12063. */
  12064. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12065. /**
  12066. * Remove a specific color gradient
  12067. * @param gradient defines the gradient to remove
  12068. * @returns this particle system
  12069. */
  12070. removeColorGradient(gradient: number): IParticleSystem;
  12071. private _fetchR;
  12072. protected _reset(): void;
  12073. private _resetEffect;
  12074. private _createVertexBuffers;
  12075. private _createIndexBuffer;
  12076. /**
  12077. * Gets the maximum number of particles active at the same time.
  12078. * @returns The max number of active particles.
  12079. */
  12080. getCapacity(): number;
  12081. /**
  12082. * Gets whether there are still active particles in the system.
  12083. * @returns True if it is alive, otherwise false.
  12084. */
  12085. isAlive(): boolean;
  12086. /**
  12087. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12088. * @returns True if it has been started, otherwise false.
  12089. */
  12090. isStarted(): boolean;
  12091. private _prepareSubEmitterInternalArray;
  12092. /**
  12093. * Starts the particle system and begins to emit
  12094. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12095. */
  12096. start(delay?: number): void;
  12097. /**
  12098. * Stops the particle system.
  12099. * @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.
  12100. */
  12101. stop(stopSubEmitters?: boolean): void;
  12102. /**
  12103. * Remove all active particles
  12104. */
  12105. reset(): void;
  12106. /**
  12107. * @hidden (for internal use only)
  12108. */
  12109. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12110. /**
  12111. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12112. * Its lifetime will start back at 0.
  12113. */
  12114. recycleParticle: (particle: Particle) => void;
  12115. private _stopSubEmitters;
  12116. private _createParticle;
  12117. private _removeFromRoot;
  12118. private _emitFromParticle;
  12119. private _update;
  12120. /** @hidden */
  12121. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12122. /** @hidden */
  12123. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12124. /** @hidden */
  12125. private _getEffect;
  12126. /**
  12127. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12128. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12129. */
  12130. animate(preWarmOnly?: boolean): void;
  12131. private _appendParticleVertices;
  12132. /**
  12133. * Rebuilds the particle system.
  12134. */
  12135. rebuild(): void;
  12136. /**
  12137. * Is this system ready to be used/rendered
  12138. * @return true if the system is ready
  12139. */
  12140. isReady(): boolean;
  12141. private _render;
  12142. /**
  12143. * Renders the particle system in its current state.
  12144. * @returns the current number of particles
  12145. */
  12146. render(): number;
  12147. /**
  12148. * Disposes the particle system and free the associated resources
  12149. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12150. */
  12151. dispose(disposeTexture?: boolean): void;
  12152. /**
  12153. * Clones the particle system.
  12154. * @param name The name of the cloned object
  12155. * @param newEmitter The new emitter to use
  12156. * @returns the cloned particle system
  12157. */
  12158. clone(name: string, newEmitter: any): ParticleSystem;
  12159. /**
  12160. * Serializes the particle system to a JSON object.
  12161. * @returns the JSON object
  12162. */
  12163. serialize(): any;
  12164. /** @hidden */
  12165. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12166. /** @hidden */
  12167. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12168. /**
  12169. * Parses a JSON object to create a particle system.
  12170. * @param parsedParticleSystem The JSON object to parse
  12171. * @param scene The scene to create the particle system in
  12172. * @param rootUrl The root url to use to load external dependencies like texture
  12173. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12174. * @returns the Parsed particle system
  12175. */
  12176. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12177. }
  12178. }
  12179. declare module "babylonjs/Particles/particle" {
  12180. import { Nullable } from "babylonjs/types";
  12181. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12182. import { Color4 } from "babylonjs/Maths/math.color";
  12183. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12184. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12185. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12186. /**
  12187. * A particle represents one of the element emitted by a particle system.
  12188. * This is mainly define by its coordinates, direction, velocity and age.
  12189. */
  12190. export class Particle {
  12191. /**
  12192. * The particle system the particle belongs to.
  12193. */
  12194. particleSystem: ParticleSystem;
  12195. private static _Count;
  12196. /**
  12197. * Unique ID of the particle
  12198. */
  12199. id: number;
  12200. /**
  12201. * The world position of the particle in the scene.
  12202. */
  12203. position: Vector3;
  12204. /**
  12205. * The world direction of the particle in the scene.
  12206. */
  12207. direction: Vector3;
  12208. /**
  12209. * The color of the particle.
  12210. */
  12211. color: Color4;
  12212. /**
  12213. * The color change of the particle per step.
  12214. */
  12215. colorStep: Color4;
  12216. /**
  12217. * Defines how long will the life of the particle be.
  12218. */
  12219. lifeTime: number;
  12220. /**
  12221. * The current age of the particle.
  12222. */
  12223. age: number;
  12224. /**
  12225. * The current size of the particle.
  12226. */
  12227. size: number;
  12228. /**
  12229. * The current scale of the particle.
  12230. */
  12231. scale: Vector2;
  12232. /**
  12233. * The current angle of the particle.
  12234. */
  12235. angle: number;
  12236. /**
  12237. * Defines how fast is the angle changing.
  12238. */
  12239. angularSpeed: number;
  12240. /**
  12241. * Defines the cell index used by the particle to be rendered from a sprite.
  12242. */
  12243. cellIndex: number;
  12244. /**
  12245. * The information required to support color remapping
  12246. */
  12247. remapData: Vector4;
  12248. /** @hidden */
  12249. _randomCellOffset?: number;
  12250. /** @hidden */
  12251. _initialDirection: Nullable<Vector3>;
  12252. /** @hidden */
  12253. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12254. /** @hidden */
  12255. _initialStartSpriteCellID: number;
  12256. /** @hidden */
  12257. _initialEndSpriteCellID: number;
  12258. /** @hidden */
  12259. _currentColorGradient: Nullable<ColorGradient>;
  12260. /** @hidden */
  12261. _currentColor1: Color4;
  12262. /** @hidden */
  12263. _currentColor2: Color4;
  12264. /** @hidden */
  12265. _currentSizeGradient: Nullable<FactorGradient>;
  12266. /** @hidden */
  12267. _currentSize1: number;
  12268. /** @hidden */
  12269. _currentSize2: number;
  12270. /** @hidden */
  12271. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12272. /** @hidden */
  12273. _currentAngularSpeed1: number;
  12274. /** @hidden */
  12275. _currentAngularSpeed2: number;
  12276. /** @hidden */
  12277. _currentVelocityGradient: Nullable<FactorGradient>;
  12278. /** @hidden */
  12279. _currentVelocity1: number;
  12280. /** @hidden */
  12281. _currentVelocity2: number;
  12282. /** @hidden */
  12283. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12284. /** @hidden */
  12285. _currentLimitVelocity1: number;
  12286. /** @hidden */
  12287. _currentLimitVelocity2: number;
  12288. /** @hidden */
  12289. _currentDragGradient: Nullable<FactorGradient>;
  12290. /** @hidden */
  12291. _currentDrag1: number;
  12292. /** @hidden */
  12293. _currentDrag2: number;
  12294. /** @hidden */
  12295. _randomNoiseCoordinates1: Vector3;
  12296. /** @hidden */
  12297. _randomNoiseCoordinates2: Vector3;
  12298. /** @hidden */
  12299. _localPosition?: Vector3;
  12300. /**
  12301. * Creates a new instance Particle
  12302. * @param particleSystem the particle system the particle belongs to
  12303. */
  12304. constructor(
  12305. /**
  12306. * The particle system the particle belongs to.
  12307. */
  12308. particleSystem: ParticleSystem);
  12309. private updateCellInfoFromSystem;
  12310. /**
  12311. * Defines how the sprite cell index is updated for the particle
  12312. */
  12313. updateCellIndex(): void;
  12314. /** @hidden */
  12315. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12316. /** @hidden */
  12317. _inheritParticleInfoToSubEmitters(): void;
  12318. /** @hidden */
  12319. _reset(): void;
  12320. /**
  12321. * Copy the properties of particle to another one.
  12322. * @param other the particle to copy the information to.
  12323. */
  12324. copyTo(other: Particle): void;
  12325. }
  12326. }
  12327. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12328. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12329. import { Effect } from "babylonjs/Materials/effect";
  12330. import { Particle } from "babylonjs/Particles/particle";
  12331. import { Scene } from "babylonjs/scene";
  12332. /**
  12333. * Particle emitter represents a volume emitting particles.
  12334. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12335. */
  12336. export interface IParticleEmitterType {
  12337. /**
  12338. * Called by the particle System when the direction is computed for the created particle.
  12339. * @param worldMatrix is the world matrix of the particle system
  12340. * @param directionToUpdate is the direction vector to update with the result
  12341. * @param particle is the particle we are computed the direction for
  12342. * @param isLocal defines if the direction should be set in local space
  12343. */
  12344. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12345. /**
  12346. * Called by the particle System when the position is computed for the created particle.
  12347. * @param worldMatrix is the world matrix of the particle system
  12348. * @param positionToUpdate is the position vector to update with the result
  12349. * @param particle is the particle we are computed the position for
  12350. * @param isLocal defines if the position should be set in local space
  12351. */
  12352. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12353. /**
  12354. * Clones the current emitter and returns a copy of it
  12355. * @returns the new emitter
  12356. */
  12357. clone(): IParticleEmitterType;
  12358. /**
  12359. * Called by the GPUParticleSystem to setup the update shader
  12360. * @param effect defines the update shader
  12361. */
  12362. applyToShader(effect: Effect): void;
  12363. /**
  12364. * Returns a string to use to update the GPU particles update shader
  12365. * @returns the effect defines string
  12366. */
  12367. getEffectDefines(): string;
  12368. /**
  12369. * Returns a string representing the class name
  12370. * @returns a string containing the class name
  12371. */
  12372. getClassName(): string;
  12373. /**
  12374. * Serializes the particle system to a JSON object.
  12375. * @returns the JSON object
  12376. */
  12377. serialize(): any;
  12378. /**
  12379. * Parse properties from a JSON object
  12380. * @param serializationObject defines the JSON object
  12381. * @param scene defines the hosting scene
  12382. */
  12383. parse(serializationObject: any, scene: Scene): void;
  12384. }
  12385. }
  12386. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12387. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12388. import { Effect } from "babylonjs/Materials/effect";
  12389. import { Particle } from "babylonjs/Particles/particle";
  12390. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12391. /**
  12392. * Particle emitter emitting particles from the inside of a box.
  12393. * It emits the particles randomly between 2 given directions.
  12394. */
  12395. export class BoxParticleEmitter implements IParticleEmitterType {
  12396. /**
  12397. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12398. */
  12399. direction1: Vector3;
  12400. /**
  12401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12402. */
  12403. direction2: Vector3;
  12404. /**
  12405. * 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.
  12406. */
  12407. minEmitBox: Vector3;
  12408. /**
  12409. * 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.
  12410. */
  12411. maxEmitBox: Vector3;
  12412. /**
  12413. * Creates a new instance BoxParticleEmitter
  12414. */
  12415. constructor();
  12416. /**
  12417. * Called by the particle System when the direction is computed for the created particle.
  12418. * @param worldMatrix is the world matrix of the particle system
  12419. * @param directionToUpdate is the direction vector to update with the result
  12420. * @param particle is the particle we are computed the direction for
  12421. * @param isLocal defines if the direction should be set in local space
  12422. */
  12423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12424. /**
  12425. * Called by the particle System when the position is computed for the created particle.
  12426. * @param worldMatrix is the world matrix of the particle system
  12427. * @param positionToUpdate is the position vector to update with the result
  12428. * @param particle is the particle we are computed the position for
  12429. * @param isLocal defines if the position should be set in local space
  12430. */
  12431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12432. /**
  12433. * Clones the current emitter and returns a copy of it
  12434. * @returns the new emitter
  12435. */
  12436. clone(): BoxParticleEmitter;
  12437. /**
  12438. * Called by the GPUParticleSystem to setup the update shader
  12439. * @param effect defines the update shader
  12440. */
  12441. applyToShader(effect: Effect): void;
  12442. /**
  12443. * Returns a string to use to update the GPU particles update shader
  12444. * @returns a string containng the defines string
  12445. */
  12446. getEffectDefines(): string;
  12447. /**
  12448. * Returns the string "BoxParticleEmitter"
  12449. * @returns a string containing the class name
  12450. */
  12451. getClassName(): string;
  12452. /**
  12453. * Serializes the particle system to a JSON object.
  12454. * @returns the JSON object
  12455. */
  12456. serialize(): any;
  12457. /**
  12458. * Parse properties from a JSON object
  12459. * @param serializationObject defines the JSON object
  12460. */
  12461. parse(serializationObject: any): void;
  12462. }
  12463. }
  12464. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12465. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12466. import { Effect } from "babylonjs/Materials/effect";
  12467. import { Particle } from "babylonjs/Particles/particle";
  12468. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12469. /**
  12470. * Particle emitter emitting particles from the inside of a cone.
  12471. * It emits the particles alongside the cone volume from the base to the particle.
  12472. * The emission direction might be randomized.
  12473. */
  12474. export class ConeParticleEmitter implements IParticleEmitterType {
  12475. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12476. directionRandomizer: number;
  12477. private _radius;
  12478. private _angle;
  12479. private _height;
  12480. /**
  12481. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12482. */
  12483. radiusRange: number;
  12484. /**
  12485. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12486. */
  12487. heightRange: number;
  12488. /**
  12489. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12490. */
  12491. emitFromSpawnPointOnly: boolean;
  12492. /**
  12493. * Gets or sets the radius of the emission cone
  12494. */
  12495. get radius(): number;
  12496. set radius(value: number);
  12497. /**
  12498. * Gets or sets the angle of the emission cone
  12499. */
  12500. get angle(): number;
  12501. set angle(value: number);
  12502. private _buildHeight;
  12503. /**
  12504. * Creates a new instance ConeParticleEmitter
  12505. * @param radius the radius of the emission cone (1 by default)
  12506. * @param angle the cone base angle (PI by default)
  12507. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12508. */
  12509. constructor(radius?: number, angle?: number,
  12510. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12511. directionRandomizer?: number);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. * @param isLocal defines if the direction should be set in local space
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Called by the particle System when the position is computed for the created particle.
  12522. * @param worldMatrix is the world matrix of the particle system
  12523. * @param positionToUpdate is the position vector to update with the result
  12524. * @param particle is the particle we are computed the position for
  12525. * @param isLocal defines if the position should be set in local space
  12526. */
  12527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): ConeParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "ConeParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12561. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12562. import { Effect } from "babylonjs/Materials/effect";
  12563. import { Particle } from "babylonjs/Particles/particle";
  12564. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12565. /**
  12566. * Particle emitter emitting particles from the inside of a cylinder.
  12567. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12568. */
  12569. export class CylinderParticleEmitter implements IParticleEmitterType {
  12570. /**
  12571. * The radius of the emission cylinder.
  12572. */
  12573. radius: number;
  12574. /**
  12575. * The height of the emission cylinder.
  12576. */
  12577. height: number;
  12578. /**
  12579. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12580. */
  12581. radiusRange: number;
  12582. /**
  12583. * How much to randomize the particle direction [0-1].
  12584. */
  12585. directionRandomizer: number;
  12586. /**
  12587. * Creates a new instance CylinderParticleEmitter
  12588. * @param radius the radius of the emission cylinder (1 by default)
  12589. * @param height the height of the emission cylinder (1 by default)
  12590. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12591. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12592. */
  12593. constructor(
  12594. /**
  12595. * The radius of the emission cylinder.
  12596. */
  12597. radius?: number,
  12598. /**
  12599. * The height of the emission cylinder.
  12600. */
  12601. height?: number,
  12602. /**
  12603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12604. */
  12605. radiusRange?: number,
  12606. /**
  12607. * How much to randomize the particle direction [0-1].
  12608. */
  12609. directionRandomizer?: number);
  12610. /**
  12611. * Called by the particle System when the direction is computed for the created particle.
  12612. * @param worldMatrix is the world matrix of the particle system
  12613. * @param directionToUpdate is the direction vector to update with the result
  12614. * @param particle is the particle we are computed the direction for
  12615. * @param isLocal defines if the direction should be set in local space
  12616. */
  12617. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12618. /**
  12619. * Called by the particle System when the position is computed for the created particle.
  12620. * @param worldMatrix is the world matrix of the particle system
  12621. * @param positionToUpdate is the position vector to update with the result
  12622. * @param particle is the particle we are computed the position for
  12623. * @param isLocal defines if the position should be set in local space
  12624. */
  12625. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12626. /**
  12627. * Clones the current emitter and returns a copy of it
  12628. * @returns the new emitter
  12629. */
  12630. clone(): CylinderParticleEmitter;
  12631. /**
  12632. * Called by the GPUParticleSystem to setup the update shader
  12633. * @param effect defines the update shader
  12634. */
  12635. applyToShader(effect: Effect): void;
  12636. /**
  12637. * Returns a string to use to update the GPU particles update shader
  12638. * @returns a string containng the defines string
  12639. */
  12640. getEffectDefines(): string;
  12641. /**
  12642. * Returns the string "CylinderParticleEmitter"
  12643. * @returns a string containing the class name
  12644. */
  12645. getClassName(): string;
  12646. /**
  12647. * Serializes the particle system to a JSON object.
  12648. * @returns the JSON object
  12649. */
  12650. serialize(): any;
  12651. /**
  12652. * Parse properties from a JSON object
  12653. * @param serializationObject defines the JSON object
  12654. */
  12655. parse(serializationObject: any): void;
  12656. }
  12657. /**
  12658. * Particle emitter emitting particles from the inside of a cylinder.
  12659. * It emits the particles randomly between two vectors.
  12660. */
  12661. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12662. /**
  12663. * The min limit of the emission direction.
  12664. */
  12665. direction1: Vector3;
  12666. /**
  12667. * The max limit of the emission direction.
  12668. */
  12669. direction2: Vector3;
  12670. /**
  12671. * Creates a new instance CylinderDirectedParticleEmitter
  12672. * @param radius the radius of the emission cylinder (1 by default)
  12673. * @param height the height of the emission cylinder (1 by default)
  12674. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12675. * @param direction1 the min limit of the emission direction (up vector by default)
  12676. * @param direction2 the max limit of the emission direction (up vector by default)
  12677. */
  12678. constructor(radius?: number, height?: number, radiusRange?: number,
  12679. /**
  12680. * The min limit of the emission direction.
  12681. */
  12682. direction1?: Vector3,
  12683. /**
  12684. * The max limit of the emission direction.
  12685. */
  12686. direction2?: Vector3);
  12687. /**
  12688. * Called by the particle System when the direction is computed for the created particle.
  12689. * @param worldMatrix is the world matrix of the particle system
  12690. * @param directionToUpdate is the direction vector to update with the result
  12691. * @param particle is the particle we are computed the direction for
  12692. */
  12693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12694. /**
  12695. * Clones the current emitter and returns a copy of it
  12696. * @returns the new emitter
  12697. */
  12698. clone(): CylinderDirectedParticleEmitter;
  12699. /**
  12700. * Called by the GPUParticleSystem to setup the update shader
  12701. * @param effect defines the update shader
  12702. */
  12703. applyToShader(effect: Effect): void;
  12704. /**
  12705. * Returns a string to use to update the GPU particles update shader
  12706. * @returns a string containng the defines string
  12707. */
  12708. getEffectDefines(): string;
  12709. /**
  12710. * Returns the string "CylinderDirectedParticleEmitter"
  12711. * @returns a string containing the class name
  12712. */
  12713. getClassName(): string;
  12714. /**
  12715. * Serializes the particle system to a JSON object.
  12716. * @returns the JSON object
  12717. */
  12718. serialize(): any;
  12719. /**
  12720. * Parse properties from a JSON object
  12721. * @param serializationObject defines the JSON object
  12722. */
  12723. parse(serializationObject: any): void;
  12724. }
  12725. }
  12726. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12728. import { Effect } from "babylonjs/Materials/effect";
  12729. import { Particle } from "babylonjs/Particles/particle";
  12730. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12731. /**
  12732. * Particle emitter emitting particles from the inside of a hemisphere.
  12733. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12734. */
  12735. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12736. /**
  12737. * The radius of the emission hemisphere.
  12738. */
  12739. radius: number;
  12740. /**
  12741. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12742. */
  12743. radiusRange: number;
  12744. /**
  12745. * How much to randomize the particle direction [0-1].
  12746. */
  12747. directionRandomizer: number;
  12748. /**
  12749. * Creates a new instance HemisphericParticleEmitter
  12750. * @param radius the radius of the emission hemisphere (1 by default)
  12751. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12752. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12753. */
  12754. constructor(
  12755. /**
  12756. * The radius of the emission hemisphere.
  12757. */
  12758. radius?: number,
  12759. /**
  12760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12761. */
  12762. radiusRange?: number,
  12763. /**
  12764. * How much to randomize the particle direction [0-1].
  12765. */
  12766. directionRandomizer?: number);
  12767. /**
  12768. * Called by the particle System when the direction is computed for the created particle.
  12769. * @param worldMatrix is the world matrix of the particle system
  12770. * @param directionToUpdate is the direction vector to update with the result
  12771. * @param particle is the particle we are computed the direction for
  12772. * @param isLocal defines if the direction should be set in local space
  12773. */
  12774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12775. /**
  12776. * Called by the particle System when the position is computed for the created particle.
  12777. * @param worldMatrix is the world matrix of the particle system
  12778. * @param positionToUpdate is the position vector to update with the result
  12779. * @param particle is the particle we are computed the position for
  12780. * @param isLocal defines if the position should be set in local space
  12781. */
  12782. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12783. /**
  12784. * Clones the current emitter and returns a copy of it
  12785. * @returns the new emitter
  12786. */
  12787. clone(): HemisphericParticleEmitter;
  12788. /**
  12789. * Called by the GPUParticleSystem to setup the update shader
  12790. * @param effect defines the update shader
  12791. */
  12792. applyToShader(effect: Effect): void;
  12793. /**
  12794. * Returns a string to use to update the GPU particles update shader
  12795. * @returns a string containng the defines string
  12796. */
  12797. getEffectDefines(): string;
  12798. /**
  12799. * Returns the string "HemisphericParticleEmitter"
  12800. * @returns a string containing the class name
  12801. */
  12802. getClassName(): string;
  12803. /**
  12804. * Serializes the particle system to a JSON object.
  12805. * @returns the JSON object
  12806. */
  12807. serialize(): any;
  12808. /**
  12809. * Parse properties from a JSON object
  12810. * @param serializationObject defines the JSON object
  12811. */
  12812. parse(serializationObject: any): void;
  12813. }
  12814. }
  12815. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12816. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12817. import { Effect } from "babylonjs/Materials/effect";
  12818. import { Particle } from "babylonjs/Particles/particle";
  12819. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12820. /**
  12821. * Particle emitter emitting particles from a point.
  12822. * It emits the particles randomly between 2 given directions.
  12823. */
  12824. export class PointParticleEmitter implements IParticleEmitterType {
  12825. /**
  12826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12827. */
  12828. direction1: Vector3;
  12829. /**
  12830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12831. */
  12832. direction2: Vector3;
  12833. /**
  12834. * Creates a new instance PointParticleEmitter
  12835. */
  12836. constructor();
  12837. /**
  12838. * Called by the particle System when the direction is computed for the created particle.
  12839. * @param worldMatrix is the world matrix of the particle system
  12840. * @param directionToUpdate is the direction vector to update with the result
  12841. * @param particle is the particle we are computed the direction for
  12842. * @param isLocal defines if the direction should be set in local space
  12843. */
  12844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12845. /**
  12846. * Called by the particle System when the position is computed for the created particle.
  12847. * @param worldMatrix is the world matrix of the particle system
  12848. * @param positionToUpdate is the position vector to update with the result
  12849. * @param particle is the particle we are computed the position for
  12850. * @param isLocal defines if the position should be set in local space
  12851. */
  12852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12853. /**
  12854. * Clones the current emitter and returns a copy of it
  12855. * @returns the new emitter
  12856. */
  12857. clone(): PointParticleEmitter;
  12858. /**
  12859. * Called by the GPUParticleSystem to setup the update shader
  12860. * @param effect defines the update shader
  12861. */
  12862. applyToShader(effect: Effect): void;
  12863. /**
  12864. * Returns a string to use to update the GPU particles update shader
  12865. * @returns a string containng the defines string
  12866. */
  12867. getEffectDefines(): string;
  12868. /**
  12869. * Returns the string "PointParticleEmitter"
  12870. * @returns a string containing the class name
  12871. */
  12872. getClassName(): string;
  12873. /**
  12874. * Serializes the particle system to a JSON object.
  12875. * @returns the JSON object
  12876. */
  12877. serialize(): any;
  12878. /**
  12879. * Parse properties from a JSON object
  12880. * @param serializationObject defines the JSON object
  12881. */
  12882. parse(serializationObject: any): void;
  12883. }
  12884. }
  12885. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12886. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12887. import { Effect } from "babylonjs/Materials/effect";
  12888. import { Particle } from "babylonjs/Particles/particle";
  12889. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12890. /**
  12891. * Particle emitter emitting particles from the inside of a sphere.
  12892. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12893. */
  12894. export class SphereParticleEmitter implements IParticleEmitterType {
  12895. /**
  12896. * The radius of the emission sphere.
  12897. */
  12898. radius: number;
  12899. /**
  12900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12901. */
  12902. radiusRange: number;
  12903. /**
  12904. * How much to randomize the particle direction [0-1].
  12905. */
  12906. directionRandomizer: number;
  12907. /**
  12908. * Creates a new instance SphereParticleEmitter
  12909. * @param radius the radius of the emission sphere (1 by default)
  12910. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12911. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12912. */
  12913. constructor(
  12914. /**
  12915. * The radius of the emission sphere.
  12916. */
  12917. radius?: number,
  12918. /**
  12919. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12920. */
  12921. radiusRange?: number,
  12922. /**
  12923. * How much to randomize the particle direction [0-1].
  12924. */
  12925. directionRandomizer?: number);
  12926. /**
  12927. * Called by the particle System when the direction is computed for the created particle.
  12928. * @param worldMatrix is the world matrix of the particle system
  12929. * @param directionToUpdate is the direction vector to update with the result
  12930. * @param particle is the particle we are computed the direction for
  12931. * @param isLocal defines if the direction should be set in local space
  12932. */
  12933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12934. /**
  12935. * Called by the particle System when the position is computed for the created particle.
  12936. * @param worldMatrix is the world matrix of the particle system
  12937. * @param positionToUpdate is the position vector to update with the result
  12938. * @param particle is the particle we are computed the position for
  12939. * @param isLocal defines if the position should be set in local space
  12940. */
  12941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12942. /**
  12943. * Clones the current emitter and returns a copy of it
  12944. * @returns the new emitter
  12945. */
  12946. clone(): SphereParticleEmitter;
  12947. /**
  12948. * Called by the GPUParticleSystem to setup the update shader
  12949. * @param effect defines the update shader
  12950. */
  12951. applyToShader(effect: Effect): void;
  12952. /**
  12953. * Returns a string to use to update the GPU particles update shader
  12954. * @returns a string containng the defines string
  12955. */
  12956. getEffectDefines(): string;
  12957. /**
  12958. * Returns the string "SphereParticleEmitter"
  12959. * @returns a string containing the class name
  12960. */
  12961. getClassName(): string;
  12962. /**
  12963. * Serializes the particle system to a JSON object.
  12964. * @returns the JSON object
  12965. */
  12966. serialize(): any;
  12967. /**
  12968. * Parse properties from a JSON object
  12969. * @param serializationObject defines the JSON object
  12970. */
  12971. parse(serializationObject: any): void;
  12972. }
  12973. /**
  12974. * Particle emitter emitting particles from the inside of a sphere.
  12975. * It emits the particles randomly between two vectors.
  12976. */
  12977. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12978. /**
  12979. * The min limit of the emission direction.
  12980. */
  12981. direction1: Vector3;
  12982. /**
  12983. * The max limit of the emission direction.
  12984. */
  12985. direction2: Vector3;
  12986. /**
  12987. * Creates a new instance SphereDirectedParticleEmitter
  12988. * @param radius the radius of the emission sphere (1 by default)
  12989. * @param direction1 the min limit of the emission direction (up vector by default)
  12990. * @param direction2 the max limit of the emission direction (up vector by default)
  12991. */
  12992. constructor(radius?: number,
  12993. /**
  12994. * The min limit of the emission direction.
  12995. */
  12996. direction1?: Vector3,
  12997. /**
  12998. * The max limit of the emission direction.
  12999. */
  13000. direction2?: Vector3);
  13001. /**
  13002. * Called by the particle System when the direction is computed for the created particle.
  13003. * @param worldMatrix is the world matrix of the particle system
  13004. * @param directionToUpdate is the direction vector to update with the result
  13005. * @param particle is the particle we are computed the direction for
  13006. */
  13007. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13008. /**
  13009. * Clones the current emitter and returns a copy of it
  13010. * @returns the new emitter
  13011. */
  13012. clone(): SphereDirectedParticleEmitter;
  13013. /**
  13014. * Called by the GPUParticleSystem to setup the update shader
  13015. * @param effect defines the update shader
  13016. */
  13017. applyToShader(effect: Effect): void;
  13018. /**
  13019. * Returns a string to use to update the GPU particles update shader
  13020. * @returns a string containng the defines string
  13021. */
  13022. getEffectDefines(): string;
  13023. /**
  13024. * Returns the string "SphereDirectedParticleEmitter"
  13025. * @returns a string containing the class name
  13026. */
  13027. getClassName(): string;
  13028. /**
  13029. * Serializes the particle system to a JSON object.
  13030. * @returns the JSON object
  13031. */
  13032. serialize(): any;
  13033. /**
  13034. * Parse properties from a JSON object
  13035. * @param serializationObject defines the JSON object
  13036. */
  13037. parse(serializationObject: any): void;
  13038. }
  13039. }
  13040. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13041. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13042. import { Effect } from "babylonjs/Materials/effect";
  13043. import { Particle } from "babylonjs/Particles/particle";
  13044. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13045. import { Nullable } from "babylonjs/types";
  13046. /**
  13047. * Particle emitter emitting particles from a custom list of positions.
  13048. */
  13049. export class CustomParticleEmitter implements IParticleEmitterType {
  13050. /**
  13051. * Gets or sets the position generator that will create the inital position of each particle.
  13052. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13053. */
  13054. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13055. /**
  13056. * Gets or sets the destination generator that will create the final destination of each particle.
  13057. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13058. */
  13059. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13060. /**
  13061. * Creates a new instance CustomParticleEmitter
  13062. */
  13063. constructor();
  13064. /**
  13065. * Called by the particle System when the direction is computed for the created particle.
  13066. * @param worldMatrix is the world matrix of the particle system
  13067. * @param directionToUpdate is the direction vector to update with the result
  13068. * @param particle is the particle we are computed the direction for
  13069. * @param isLocal defines if the direction should be set in local space
  13070. */
  13071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13072. /**
  13073. * Called by the particle System when the position is computed for the created particle.
  13074. * @param worldMatrix is the world matrix of the particle system
  13075. * @param positionToUpdate is the position vector to update with the result
  13076. * @param particle is the particle we are computed the position for
  13077. * @param isLocal defines if the position should be set in local space
  13078. */
  13079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13080. /**
  13081. * Clones the current emitter and returns a copy of it
  13082. * @returns the new emitter
  13083. */
  13084. clone(): CustomParticleEmitter;
  13085. /**
  13086. * Called by the GPUParticleSystem to setup the update shader
  13087. * @param effect defines the update shader
  13088. */
  13089. applyToShader(effect: Effect): void;
  13090. /**
  13091. * Returns a string to use to update the GPU particles update shader
  13092. * @returns a string containng the defines string
  13093. */
  13094. getEffectDefines(): string;
  13095. /**
  13096. * Returns the string "PointParticleEmitter"
  13097. * @returns a string containing the class name
  13098. */
  13099. getClassName(): string;
  13100. /**
  13101. * Serializes the particle system to a JSON object.
  13102. * @returns the JSON object
  13103. */
  13104. serialize(): any;
  13105. /**
  13106. * Parse properties from a JSON object
  13107. * @param serializationObject defines the JSON object
  13108. */
  13109. parse(serializationObject: any): void;
  13110. }
  13111. }
  13112. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13113. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13114. import { Effect } from "babylonjs/Materials/effect";
  13115. import { Particle } from "babylonjs/Particles/particle";
  13116. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13117. import { Scene } from "babylonjs/scene";
  13118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13119. /**
  13120. * Particle emitter emitting particles from the inside of a box.
  13121. * It emits the particles randomly between 2 given directions.
  13122. */
  13123. export class MeshParticleEmitter implements IParticleEmitterType {
  13124. /** Defines the mesh to use as source */
  13125. mesh?: AbstractMesh | undefined;
  13126. private _indices;
  13127. private _positions;
  13128. private _normals;
  13129. private _storedNormal;
  13130. /**
  13131. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13132. */
  13133. direction1: Vector3;
  13134. /**
  13135. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13136. */
  13137. direction2: Vector3;
  13138. /**
  13139. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13140. */
  13141. useMeshNormalsForDirection: boolean;
  13142. /**
  13143. * Creates a new instance MeshParticleEmitter
  13144. * @param mesh defines the mesh to use as source
  13145. */
  13146. constructor(
  13147. /** Defines the mesh to use as source */
  13148. mesh?: AbstractMesh | undefined);
  13149. /**
  13150. * Called by the particle System when the direction is computed for the created particle.
  13151. * @param worldMatrix is the world matrix of the particle system
  13152. * @param directionToUpdate is the direction vector to update with the result
  13153. * @param particle is the particle we are computed the direction for
  13154. * @param isLocal defines if the direction should be set in local space
  13155. */
  13156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13157. /**
  13158. * Called by the particle System when the position is computed for the created particle.
  13159. * @param worldMatrix is the world matrix of the particle system
  13160. * @param positionToUpdate is the position vector to update with the result
  13161. * @param particle is the particle we are computed the position for
  13162. * @param isLocal defines if the position should be set in local space
  13163. */
  13164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13165. /**
  13166. * Clones the current emitter and returns a copy of it
  13167. * @returns the new emitter
  13168. */
  13169. clone(): MeshParticleEmitter;
  13170. /**
  13171. * Called by the GPUParticleSystem to setup the update shader
  13172. * @param effect defines the update shader
  13173. */
  13174. applyToShader(effect: Effect): void;
  13175. /**
  13176. * Returns a string to use to update the GPU particles update shader
  13177. * @returns a string containng the defines string
  13178. */
  13179. getEffectDefines(): string;
  13180. /**
  13181. * Returns the string "BoxParticleEmitter"
  13182. * @returns a string containing the class name
  13183. */
  13184. getClassName(): string;
  13185. /**
  13186. * Serializes the particle system to a JSON object.
  13187. * @returns the JSON object
  13188. */
  13189. serialize(): any;
  13190. /**
  13191. * Parse properties from a JSON object
  13192. * @param serializationObject defines the JSON object
  13193. * @param scene defines the hosting scene
  13194. */
  13195. parse(serializationObject: any, scene: Scene): void;
  13196. }
  13197. }
  13198. declare module "babylonjs/Particles/EmitterTypes/index" {
  13199. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13200. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13201. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13202. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13203. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13204. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13205. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13206. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13207. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13208. }
  13209. declare module "babylonjs/Particles/IParticleSystem" {
  13210. import { Nullable } from "babylonjs/types";
  13211. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13212. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13215. import { Texture } from "babylonjs/Materials/Textures/texture";
  13216. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13217. import { Scene } from "babylonjs/scene";
  13218. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13219. import { Animation } from "babylonjs/Animations/animation";
  13220. /**
  13221. * Interface representing a particle system in Babylon.js.
  13222. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13223. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13224. */
  13225. export interface IParticleSystem {
  13226. /**
  13227. * List of animations used by the particle system.
  13228. */
  13229. animations: Animation[];
  13230. /**
  13231. * The id of the Particle system.
  13232. */
  13233. id: string;
  13234. /**
  13235. * The name of the Particle system.
  13236. */
  13237. name: string;
  13238. /**
  13239. * The emitter represents the Mesh or position we are attaching the particle system to.
  13240. */
  13241. emitter: Nullable<AbstractMesh | Vector3>;
  13242. /**
  13243. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13244. */
  13245. isBillboardBased: boolean;
  13246. /**
  13247. * The rendering group used by the Particle system to chose when to render.
  13248. */
  13249. renderingGroupId: number;
  13250. /**
  13251. * The layer mask we are rendering the particles through.
  13252. */
  13253. layerMask: number;
  13254. /**
  13255. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13256. */
  13257. updateSpeed: number;
  13258. /**
  13259. * The amount of time the particle system is running (depends of the overall update speed).
  13260. */
  13261. targetStopDuration: number;
  13262. /**
  13263. * The texture used to render each particle. (this can be a spritesheet)
  13264. */
  13265. particleTexture: Nullable<Texture>;
  13266. /**
  13267. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13268. */
  13269. blendMode: number;
  13270. /**
  13271. * Minimum life time of emitting particles.
  13272. */
  13273. minLifeTime: number;
  13274. /**
  13275. * Maximum life time of emitting particles.
  13276. */
  13277. maxLifeTime: number;
  13278. /**
  13279. * Minimum Size of emitting particles.
  13280. */
  13281. minSize: number;
  13282. /**
  13283. * Maximum Size of emitting particles.
  13284. */
  13285. maxSize: number;
  13286. /**
  13287. * Minimum scale of emitting particles on X axis.
  13288. */
  13289. minScaleX: number;
  13290. /**
  13291. * Maximum scale of emitting particles on X axis.
  13292. */
  13293. maxScaleX: number;
  13294. /**
  13295. * Minimum scale of emitting particles on Y axis.
  13296. */
  13297. minScaleY: number;
  13298. /**
  13299. * Maximum scale of emitting particles on Y axis.
  13300. */
  13301. maxScaleY: number;
  13302. /**
  13303. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13304. */
  13305. color1: Color4;
  13306. /**
  13307. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13308. */
  13309. color2: Color4;
  13310. /**
  13311. * Color the particle will have at the end of its lifetime.
  13312. */
  13313. colorDead: Color4;
  13314. /**
  13315. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13316. */
  13317. emitRate: number;
  13318. /**
  13319. * You can use gravity if you want to give an orientation to your particles.
  13320. */
  13321. gravity: Vector3;
  13322. /**
  13323. * Minimum power of emitting particles.
  13324. */
  13325. minEmitPower: number;
  13326. /**
  13327. * Maximum power of emitting particles.
  13328. */
  13329. maxEmitPower: number;
  13330. /**
  13331. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13332. */
  13333. minAngularSpeed: number;
  13334. /**
  13335. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13336. */
  13337. maxAngularSpeed: number;
  13338. /**
  13339. * Gets or sets the minimal initial rotation in radians.
  13340. */
  13341. minInitialRotation: number;
  13342. /**
  13343. * Gets or sets the maximal initial rotation in radians.
  13344. */
  13345. maxInitialRotation: number;
  13346. /**
  13347. * The particle emitter type defines the emitter used by the particle system.
  13348. * It can be for example box, sphere, or cone...
  13349. */
  13350. particleEmitterType: Nullable<IParticleEmitterType>;
  13351. /**
  13352. * Defines the delay in milliseconds before starting the system (0 by default)
  13353. */
  13354. startDelay: number;
  13355. /**
  13356. * 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
  13357. */
  13358. preWarmCycles: number;
  13359. /**
  13360. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13361. */
  13362. preWarmStepOffset: number;
  13363. /**
  13364. * 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)
  13365. */
  13366. spriteCellChangeSpeed: number;
  13367. /**
  13368. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13369. */
  13370. startSpriteCellID: number;
  13371. /**
  13372. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13373. */
  13374. endSpriteCellID: number;
  13375. /**
  13376. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13377. */
  13378. spriteCellWidth: number;
  13379. /**
  13380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13381. */
  13382. spriteCellHeight: number;
  13383. /**
  13384. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13385. */
  13386. spriteRandomStartCell: boolean;
  13387. /**
  13388. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13389. */
  13390. isAnimationSheetEnabled: boolean;
  13391. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13392. translationPivot: Vector2;
  13393. /**
  13394. * Gets or sets a texture used to add random noise to particle positions
  13395. */
  13396. noiseTexture: Nullable<BaseTexture>;
  13397. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13398. noiseStrength: Vector3;
  13399. /**
  13400. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13401. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13402. */
  13403. billboardMode: number;
  13404. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13405. limitVelocityDamping: number;
  13406. /**
  13407. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13408. */
  13409. beginAnimationOnStart: boolean;
  13410. /**
  13411. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13412. */
  13413. beginAnimationFrom: number;
  13414. /**
  13415. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13416. */
  13417. beginAnimationTo: number;
  13418. /**
  13419. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13420. */
  13421. beginAnimationLoop: boolean;
  13422. /**
  13423. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13424. */
  13425. disposeOnStop: boolean;
  13426. /**
  13427. * Specifies if the particles are updated in emitter local space or world space
  13428. */
  13429. isLocal: boolean;
  13430. /**
  13431. * Gets the maximum number of particles active at the same time.
  13432. * @returns The max number of active particles.
  13433. */
  13434. getCapacity(): number;
  13435. /**
  13436. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13437. * @returns True if it has been started, otherwise false.
  13438. */
  13439. isStarted(): boolean;
  13440. /**
  13441. * Animates the particle system for this frame.
  13442. */
  13443. animate(): void;
  13444. /**
  13445. * Renders the particle system in its current state.
  13446. * @returns the current number of particles
  13447. */
  13448. render(): number;
  13449. /**
  13450. * Dispose the particle system and frees its associated resources.
  13451. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13452. */
  13453. dispose(disposeTexture?: boolean): void;
  13454. /**
  13455. * Clones the particle system.
  13456. * @param name The name of the cloned object
  13457. * @param newEmitter The new emitter to use
  13458. * @returns the cloned particle system
  13459. */
  13460. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13461. /**
  13462. * Serializes the particle system to a JSON object.
  13463. * @returns the JSON object
  13464. */
  13465. serialize(): any;
  13466. /**
  13467. * Rebuild the particle system
  13468. */
  13469. rebuild(): void;
  13470. /**
  13471. * Starts the particle system and begins to emit
  13472. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13473. */
  13474. start(delay?: number): void;
  13475. /**
  13476. * Stops the particle system.
  13477. */
  13478. stop(): void;
  13479. /**
  13480. * Remove all active particles
  13481. */
  13482. reset(): void;
  13483. /**
  13484. * Is this system ready to be used/rendered
  13485. * @return true if the system is ready
  13486. */
  13487. isReady(): boolean;
  13488. /**
  13489. * Adds a new color gradient
  13490. * @param gradient defines the gradient to use (between 0 and 1)
  13491. * @param color1 defines the color to affect to the specified gradient
  13492. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13493. * @returns the current particle system
  13494. */
  13495. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13496. /**
  13497. * Remove a specific color gradient
  13498. * @param gradient defines the gradient to remove
  13499. * @returns the current particle system
  13500. */
  13501. removeColorGradient(gradient: number): IParticleSystem;
  13502. /**
  13503. * Adds a new size gradient
  13504. * @param gradient defines the gradient to use (between 0 and 1)
  13505. * @param factor defines the size factor to affect to the specified gradient
  13506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13507. * @returns the current particle system
  13508. */
  13509. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13510. /**
  13511. * Remove a specific size gradient
  13512. * @param gradient defines the gradient to remove
  13513. * @returns the current particle system
  13514. */
  13515. removeSizeGradient(gradient: number): IParticleSystem;
  13516. /**
  13517. * Gets the current list of color gradients.
  13518. * You must use addColorGradient and removeColorGradient to udpate this list
  13519. * @returns the list of color gradients
  13520. */
  13521. getColorGradients(): Nullable<Array<ColorGradient>>;
  13522. /**
  13523. * Gets the current list of size gradients.
  13524. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13525. * @returns the list of size gradients
  13526. */
  13527. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13528. /**
  13529. * Gets the current list of angular speed gradients.
  13530. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13531. * @returns the list of angular speed gradients
  13532. */
  13533. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13534. /**
  13535. * Adds a new angular speed gradient
  13536. * @param gradient defines the gradient to use (between 0 and 1)
  13537. * @param factor defines the angular speed to affect to the specified gradient
  13538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13539. * @returns the current particle system
  13540. */
  13541. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13542. /**
  13543. * Remove a specific angular speed gradient
  13544. * @param gradient defines the gradient to remove
  13545. * @returns the current particle system
  13546. */
  13547. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13548. /**
  13549. * Gets the current list of velocity gradients.
  13550. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13551. * @returns the list of velocity gradients
  13552. */
  13553. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13554. /**
  13555. * Adds a new velocity gradient
  13556. * @param gradient defines the gradient to use (between 0 and 1)
  13557. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13562. /**
  13563. * Remove a specific velocity gradient
  13564. * @param gradient defines the gradient to remove
  13565. * @returns the current particle system
  13566. */
  13567. removeVelocityGradient(gradient: number): IParticleSystem;
  13568. /**
  13569. * Gets the current list of limit velocity gradients.
  13570. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13571. * @returns the list of limit velocity gradients
  13572. */
  13573. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13574. /**
  13575. * Adds a new limit velocity gradient
  13576. * @param gradient defines the gradient to use (between 0 and 1)
  13577. * @param factor defines the limit velocity 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13582. /**
  13583. * Remove a specific limit velocity gradient
  13584. * @param gradient defines the gradient to remove
  13585. * @returns the current particle system
  13586. */
  13587. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13588. /**
  13589. * Adds a new drag gradient
  13590. * @param gradient defines the gradient to use (between 0 and 1)
  13591. * @param factor defines the drag to affect to the specified gradient
  13592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13593. * @returns the current particle system
  13594. */
  13595. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13596. /**
  13597. * Remove a specific drag gradient
  13598. * @param gradient defines the gradient to remove
  13599. * @returns the current particle system
  13600. */
  13601. removeDragGradient(gradient: number): IParticleSystem;
  13602. /**
  13603. * Gets the current list of drag gradients.
  13604. * You must use addDragGradient and removeDragGradient to udpate this list
  13605. * @returns the list of drag gradients
  13606. */
  13607. getDragGradients(): Nullable<Array<FactorGradient>>;
  13608. /**
  13609. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13610. * @param gradient defines the gradient to use (between 0 and 1)
  13611. * @param factor defines the emit rate to affect to the specified gradient
  13612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13613. * @returns the current particle system
  13614. */
  13615. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13616. /**
  13617. * Remove a specific emit rate gradient
  13618. * @param gradient defines the gradient to remove
  13619. * @returns the current particle system
  13620. */
  13621. removeEmitRateGradient(gradient: number): IParticleSystem;
  13622. /**
  13623. * Gets the current list of emit rate gradients.
  13624. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13625. * @returns the list of emit rate gradients
  13626. */
  13627. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13628. /**
  13629. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13630. * @param gradient defines the gradient to use (between 0 and 1)
  13631. * @param factor defines the start size to affect to the specified gradient
  13632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13633. * @returns the current particle system
  13634. */
  13635. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13636. /**
  13637. * Remove a specific start size gradient
  13638. * @param gradient defines the gradient to remove
  13639. * @returns the current particle system
  13640. */
  13641. removeStartSizeGradient(gradient: number): IParticleSystem;
  13642. /**
  13643. * Gets the current list of start size gradients.
  13644. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13645. * @returns the list of start size gradients
  13646. */
  13647. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13648. /**
  13649. * Adds a new life time gradient
  13650. * @param gradient defines the gradient to use (between 0 and 1)
  13651. * @param factor defines the life time factor to affect to the specified gradient
  13652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13653. * @returns the current particle system
  13654. */
  13655. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13656. /**
  13657. * Remove a specific life time gradient
  13658. * @param gradient defines the gradient to remove
  13659. * @returns the current particle system
  13660. */
  13661. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13662. /**
  13663. * Gets the current list of life time gradients.
  13664. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13665. * @returns the list of life time gradients
  13666. */
  13667. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13668. /**
  13669. * Gets the current list of color gradients.
  13670. * You must use addColorGradient and removeColorGradient to udpate this list
  13671. * @returns the list of color gradients
  13672. */
  13673. getColorGradients(): Nullable<Array<ColorGradient>>;
  13674. /**
  13675. * Adds a new ramp gradient used to remap particle colors
  13676. * @param gradient defines the gradient to use (between 0 and 1)
  13677. * @param color defines the color to affect to the specified gradient
  13678. * @returns the current particle system
  13679. */
  13680. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13681. /**
  13682. * Gets the current list of ramp gradients.
  13683. * You must use addRampGradient and removeRampGradient to udpate this list
  13684. * @returns the list of ramp gradients
  13685. */
  13686. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13687. /** Gets or sets a boolean indicating that ramp gradients must be used
  13688. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13689. */
  13690. useRampGradients: boolean;
  13691. /**
  13692. * Adds a new color remap gradient
  13693. * @param gradient defines the gradient to use (between 0 and 1)
  13694. * @param min defines the color remap minimal range
  13695. * @param max defines the color remap maximal range
  13696. * @returns the current particle system
  13697. */
  13698. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13699. /**
  13700. * Gets the current list of color remap gradients.
  13701. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13702. * @returns the list of color remap gradients
  13703. */
  13704. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13705. /**
  13706. * Adds a new alpha remap gradient
  13707. * @param gradient defines the gradient to use (between 0 and 1)
  13708. * @param min defines the alpha remap minimal range
  13709. * @param max defines the alpha remap maximal range
  13710. * @returns the current particle system
  13711. */
  13712. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13713. /**
  13714. * Gets the current list of alpha remap gradients.
  13715. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13716. * @returns the list of alpha remap gradients
  13717. */
  13718. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13719. /**
  13720. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13721. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13722. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13723. * @returns the emitter
  13724. */
  13725. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13726. /**
  13727. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13728. * @param radius The radius of the hemisphere to emit from
  13729. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13730. * @returns the emitter
  13731. */
  13732. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13733. /**
  13734. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13735. * @param radius The radius of the sphere to emit from
  13736. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13737. * @returns the emitter
  13738. */
  13739. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13740. /**
  13741. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13742. * @param radius The radius of the sphere to emit from
  13743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13745. * @returns the emitter
  13746. */
  13747. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13748. /**
  13749. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13750. * @param radius The radius of the emission cylinder
  13751. * @param height The height of the emission cylinder
  13752. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13753. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13754. * @returns the emitter
  13755. */
  13756. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13757. /**
  13758. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13759. * @param radius The radius of the cylinder to emit from
  13760. * @param height The height of the emission cylinder
  13761. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13762. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13763. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13764. * @returns the emitter
  13765. */
  13766. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13767. /**
  13768. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13769. * @param radius The radius of the cone to emit from
  13770. * @param angle The base angle of the cone
  13771. * @returns the emitter
  13772. */
  13773. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13774. /**
  13775. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13776. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13777. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13778. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13779. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13780. * @returns the emitter
  13781. */
  13782. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13783. /**
  13784. * Get hosting scene
  13785. * @returns the scene
  13786. */
  13787. getScene(): Scene;
  13788. }
  13789. }
  13790. declare module "babylonjs/Meshes/transformNode" {
  13791. import { DeepImmutable } from "babylonjs/types";
  13792. import { Observable } from "babylonjs/Misc/observable";
  13793. import { Nullable } from "babylonjs/types";
  13794. import { Camera } from "babylonjs/Cameras/camera";
  13795. import { Scene } from "babylonjs/scene";
  13796. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13797. import { Node } from "babylonjs/node";
  13798. import { Bone } from "babylonjs/Bones/bone";
  13799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13800. import { Space } from "babylonjs/Maths/math.axis";
  13801. /**
  13802. * 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.
  13803. * @see https://doc.babylonjs.com/how_to/transformnode
  13804. */
  13805. export class TransformNode extends Node {
  13806. /**
  13807. * Object will not rotate to face the camera
  13808. */
  13809. static BILLBOARDMODE_NONE: number;
  13810. /**
  13811. * Object will rotate to face the camera but only on the x axis
  13812. */
  13813. static BILLBOARDMODE_X: number;
  13814. /**
  13815. * Object will rotate to face the camera but only on the y axis
  13816. */
  13817. static BILLBOARDMODE_Y: number;
  13818. /**
  13819. * Object will rotate to face the camera but only on the z axis
  13820. */
  13821. static BILLBOARDMODE_Z: number;
  13822. /**
  13823. * Object will rotate to face the camera
  13824. */
  13825. static BILLBOARDMODE_ALL: number;
  13826. /**
  13827. * Object will rotate to face the camera's position instead of orientation
  13828. */
  13829. static BILLBOARDMODE_USE_POSITION: number;
  13830. private _forward;
  13831. private _forwardInverted;
  13832. private _up;
  13833. private _right;
  13834. private _rightInverted;
  13835. private _position;
  13836. private _rotation;
  13837. private _rotationQuaternion;
  13838. protected _scaling: Vector3;
  13839. protected _isDirty: boolean;
  13840. private _transformToBoneReferal;
  13841. private _isAbsoluteSynced;
  13842. private _billboardMode;
  13843. /**
  13844. * Gets or sets the billboard mode. Default is 0.
  13845. *
  13846. * | Value | Type | Description |
  13847. * | --- | --- | --- |
  13848. * | 0 | BILLBOARDMODE_NONE | |
  13849. * | 1 | BILLBOARDMODE_X | |
  13850. * | 2 | BILLBOARDMODE_Y | |
  13851. * | 4 | BILLBOARDMODE_Z | |
  13852. * | 7 | BILLBOARDMODE_ALL | |
  13853. *
  13854. */
  13855. get billboardMode(): number;
  13856. set billboardMode(value: number);
  13857. private _preserveParentRotationForBillboard;
  13858. /**
  13859. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13860. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13861. */
  13862. get preserveParentRotationForBillboard(): boolean;
  13863. set preserveParentRotationForBillboard(value: boolean);
  13864. /**
  13865. * 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
  13866. */
  13867. scalingDeterminant: number;
  13868. private _infiniteDistance;
  13869. /**
  13870. * Gets or sets the distance of the object to max, often used by skybox
  13871. */
  13872. get infiniteDistance(): boolean;
  13873. set infiniteDistance(value: boolean);
  13874. /**
  13875. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13876. * By default the system will update normals to compensate
  13877. */
  13878. ignoreNonUniformScaling: boolean;
  13879. /**
  13880. * 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
  13881. */
  13882. reIntegrateRotationIntoRotationQuaternion: boolean;
  13883. /** @hidden */
  13884. _poseMatrix: Nullable<Matrix>;
  13885. /** @hidden */
  13886. _localMatrix: Matrix;
  13887. private _usePivotMatrix;
  13888. private _absolutePosition;
  13889. private _absoluteScaling;
  13890. private _absoluteRotationQuaternion;
  13891. private _pivotMatrix;
  13892. private _pivotMatrixInverse;
  13893. protected _postMultiplyPivotMatrix: boolean;
  13894. protected _isWorldMatrixFrozen: boolean;
  13895. /** @hidden */
  13896. _indexInSceneTransformNodesArray: number;
  13897. /**
  13898. * An event triggered after the world matrix is updated
  13899. */
  13900. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13901. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13902. /**
  13903. * Gets a string identifying the name of the class
  13904. * @returns "TransformNode" string
  13905. */
  13906. getClassName(): string;
  13907. /**
  13908. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13909. */
  13910. get position(): Vector3;
  13911. set position(newPosition: Vector3);
  13912. /**
  13913. * 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)).
  13914. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13915. */
  13916. get rotation(): Vector3;
  13917. set rotation(newRotation: Vector3);
  13918. /**
  13919. * 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)).
  13920. */
  13921. get scaling(): Vector3;
  13922. set scaling(newScaling: Vector3);
  13923. /**
  13924. * 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).
  13925. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13926. */
  13927. get rotationQuaternion(): Nullable<Quaternion>;
  13928. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13929. /**
  13930. * The forward direction of that transform in world space.
  13931. */
  13932. get forward(): Vector3;
  13933. /**
  13934. * The up direction of that transform in world space.
  13935. */
  13936. get up(): Vector3;
  13937. /**
  13938. * The right direction of that transform in world space.
  13939. */
  13940. get right(): Vector3;
  13941. /**
  13942. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13943. * @param matrix the matrix to copy the pose from
  13944. * @returns this TransformNode.
  13945. */
  13946. updatePoseMatrix(matrix: Matrix): TransformNode;
  13947. /**
  13948. * Returns the mesh Pose matrix.
  13949. * @returns the pose matrix
  13950. */
  13951. getPoseMatrix(): Matrix;
  13952. /** @hidden */
  13953. _isSynchronized(): boolean;
  13954. /** @hidden */
  13955. _initCache(): void;
  13956. /**
  13957. * Flag the transform node as dirty (Forcing it to update everything)
  13958. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13959. * @returns this transform node
  13960. */
  13961. markAsDirty(property: string): TransformNode;
  13962. /**
  13963. * Returns the current mesh absolute position.
  13964. * Returns a Vector3.
  13965. */
  13966. get absolutePosition(): Vector3;
  13967. /**
  13968. * Returns the current mesh absolute scaling.
  13969. * Returns a Vector3.
  13970. */
  13971. get absoluteScaling(): Vector3;
  13972. /**
  13973. * Returns the current mesh absolute rotation.
  13974. * Returns a Quaternion.
  13975. */
  13976. get absoluteRotationQuaternion(): Quaternion;
  13977. /**
  13978. * Sets a new matrix to apply before all other transformation
  13979. * @param matrix defines the transform matrix
  13980. * @returns the current TransformNode
  13981. */
  13982. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13983. /**
  13984. * Sets a new pivot matrix to the current node
  13985. * @param matrix defines the new pivot matrix to use
  13986. * @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
  13987. * @returns the current TransformNode
  13988. */
  13989. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13990. /**
  13991. * Returns the mesh pivot matrix.
  13992. * Default : Identity.
  13993. * @returns the matrix
  13994. */
  13995. getPivotMatrix(): Matrix;
  13996. /**
  13997. * Instantiate (when possible) or clone that node with its hierarchy
  13998. * @param newParent defines the new parent to use for the instance (or clone)
  13999. * @param options defines options to configure how copy is done
  14000. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14001. * @returns an instance (or a clone) of the current node with its hiearchy
  14002. */
  14003. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14004. doNotInstantiate: boolean;
  14005. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14006. /**
  14007. * Prevents the World matrix to be computed any longer
  14008. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14009. * @returns the TransformNode.
  14010. */
  14011. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14012. /**
  14013. * Allows back the World matrix computation.
  14014. * @returns the TransformNode.
  14015. */
  14016. unfreezeWorldMatrix(): this;
  14017. /**
  14018. * True if the World matrix has been frozen.
  14019. */
  14020. get isWorldMatrixFrozen(): boolean;
  14021. /**
  14022. * Retuns the mesh absolute position in the World.
  14023. * @returns a Vector3.
  14024. */
  14025. getAbsolutePosition(): Vector3;
  14026. /**
  14027. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14028. * @param absolutePosition the absolute position to set
  14029. * @returns the TransformNode.
  14030. */
  14031. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14032. /**
  14033. * Sets the mesh position in its local space.
  14034. * @param vector3 the position to set in localspace
  14035. * @returns the TransformNode.
  14036. */
  14037. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14038. /**
  14039. * Returns the mesh position in the local space from the current World matrix values.
  14040. * @returns a new Vector3.
  14041. */
  14042. getPositionExpressedInLocalSpace(): Vector3;
  14043. /**
  14044. * Translates the mesh along the passed Vector3 in its local space.
  14045. * @param vector3 the distance to translate in localspace
  14046. * @returns the TransformNode.
  14047. */
  14048. locallyTranslate(vector3: Vector3): TransformNode;
  14049. private static _lookAtVectorCache;
  14050. /**
  14051. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14052. * @param targetPoint the position (must be in same space as current mesh) to look at
  14053. * @param yawCor optional yaw (y-axis) correction in radians
  14054. * @param pitchCor optional pitch (x-axis) correction in radians
  14055. * @param rollCor optional roll (z-axis) correction in radians
  14056. * @param space the choosen space of the target
  14057. * @returns the TransformNode.
  14058. */
  14059. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14060. /**
  14061. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14062. * This Vector3 is expressed in the World space.
  14063. * @param localAxis axis to rotate
  14064. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14065. */
  14066. getDirection(localAxis: Vector3): Vector3;
  14067. /**
  14068. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14069. * localAxis is expressed in the mesh local space.
  14070. * result is computed in the Wordl space from the mesh World matrix.
  14071. * @param localAxis axis to rotate
  14072. * @param result the resulting transformnode
  14073. * @returns this TransformNode.
  14074. */
  14075. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14076. /**
  14077. * Sets this transform node rotation to the given local axis.
  14078. * @param localAxis the axis in local space
  14079. * @param yawCor optional yaw (y-axis) correction in radians
  14080. * @param pitchCor optional pitch (x-axis) correction in radians
  14081. * @param rollCor optional roll (z-axis) correction in radians
  14082. * @returns this TransformNode
  14083. */
  14084. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14085. /**
  14086. * Sets a new pivot point to the current node
  14087. * @param point defines the new pivot point to use
  14088. * @param space defines if the point is in world or local space (local by default)
  14089. * @returns the current TransformNode
  14090. */
  14091. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14092. /**
  14093. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14094. * @returns the pivot point
  14095. */
  14096. getPivotPoint(): Vector3;
  14097. /**
  14098. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14099. * @param result the vector3 to store the result
  14100. * @returns this TransformNode.
  14101. */
  14102. getPivotPointToRef(result: Vector3): TransformNode;
  14103. /**
  14104. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14105. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14106. */
  14107. getAbsolutePivotPoint(): Vector3;
  14108. /**
  14109. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14110. * @param result vector3 to store the result
  14111. * @returns this TransformNode.
  14112. */
  14113. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14114. /**
  14115. * Defines the passed node as the parent of the current node.
  14116. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14117. * @see https://doc.babylonjs.com/how_to/parenting
  14118. * @param node the node ot set as the parent
  14119. * @returns this TransformNode.
  14120. */
  14121. setParent(node: Nullable<Node>): TransformNode;
  14122. private _nonUniformScaling;
  14123. /**
  14124. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14125. */
  14126. get nonUniformScaling(): boolean;
  14127. /** @hidden */
  14128. _updateNonUniformScalingState(value: boolean): boolean;
  14129. /**
  14130. * Attach the current TransformNode to another TransformNode associated with a bone
  14131. * @param bone Bone affecting the TransformNode
  14132. * @param affectedTransformNode TransformNode associated with the bone
  14133. * @returns this object
  14134. */
  14135. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14136. /**
  14137. * Detach the transform node if its associated with a bone
  14138. * @returns this object
  14139. */
  14140. detachFromBone(): TransformNode;
  14141. private static _rotationAxisCache;
  14142. /**
  14143. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14144. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14145. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14146. * The passed axis is also normalized.
  14147. * @param axis the axis to rotate around
  14148. * @param amount the amount to rotate in radians
  14149. * @param space Space to rotate in (Default: local)
  14150. * @returns the TransformNode.
  14151. */
  14152. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14153. /**
  14154. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14155. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14156. * The passed axis is also normalized. .
  14157. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14158. * @param point the point to rotate around
  14159. * @param axis the axis to rotate around
  14160. * @param amount the amount to rotate in radians
  14161. * @returns the TransformNode
  14162. */
  14163. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14164. /**
  14165. * Translates the mesh along the axis vector for the passed distance in the given space.
  14166. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14167. * @param axis the axis to translate in
  14168. * @param distance the distance to translate
  14169. * @param space Space to rotate in (Default: local)
  14170. * @returns the TransformNode.
  14171. */
  14172. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14173. /**
  14174. * Adds a rotation step to the mesh current rotation.
  14175. * x, y, z are Euler angles expressed in radians.
  14176. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14177. * This means this rotation is made in the mesh local space only.
  14178. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14179. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14180. * ```javascript
  14181. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14182. * ```
  14183. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14184. * 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.
  14185. * @param x Rotation to add
  14186. * @param y Rotation to add
  14187. * @param z Rotation to add
  14188. * @returns the TransformNode.
  14189. */
  14190. addRotation(x: number, y: number, z: number): TransformNode;
  14191. /**
  14192. * @hidden
  14193. */
  14194. protected _getEffectiveParent(): Nullable<Node>;
  14195. /**
  14196. * Computes the world matrix of the node
  14197. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14198. * @returns the world matrix
  14199. */
  14200. computeWorldMatrix(force?: boolean): Matrix;
  14201. /**
  14202. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14203. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14204. */
  14205. resetLocalMatrix(independentOfChildren?: boolean): void;
  14206. protected _afterComputeWorldMatrix(): void;
  14207. /**
  14208. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14209. * @param func callback function to add
  14210. *
  14211. * @returns the TransformNode.
  14212. */
  14213. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14214. /**
  14215. * Removes a registered callback function.
  14216. * @param func callback function to remove
  14217. * @returns the TransformNode.
  14218. */
  14219. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14220. /**
  14221. * Gets the position of the current mesh in camera space
  14222. * @param camera defines the camera to use
  14223. * @returns a position
  14224. */
  14225. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14226. /**
  14227. * Returns the distance from the mesh to the active camera
  14228. * @param camera defines the camera to use
  14229. * @returns the distance
  14230. */
  14231. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14232. /**
  14233. * Clone the current transform node
  14234. * @param name Name of the new clone
  14235. * @param newParent New parent for the clone
  14236. * @param doNotCloneChildren Do not clone children hierarchy
  14237. * @returns the new transform node
  14238. */
  14239. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14240. /**
  14241. * Serializes the objects information.
  14242. * @param currentSerializationObject defines the object to serialize in
  14243. * @returns the serialized object
  14244. */
  14245. serialize(currentSerializationObject?: any): any;
  14246. /**
  14247. * Returns a new TransformNode object parsed from the source provided.
  14248. * @param parsedTransformNode is the source.
  14249. * @param scene the scne the object belongs to
  14250. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14251. * @returns a new TransformNode object parsed from the source provided.
  14252. */
  14253. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14254. /**
  14255. * Get all child-transformNodes of this node
  14256. * @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
  14257. * @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
  14258. * @returns an array of TransformNode
  14259. */
  14260. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14261. /**
  14262. * Releases resources associated with this transform node.
  14263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14265. */
  14266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14267. /**
  14268. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14269. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14270. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14271. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14272. * @returns the current mesh
  14273. */
  14274. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14275. private _syncAbsoluteScalingAndRotation;
  14276. }
  14277. }
  14278. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14279. /**
  14280. * Class used to override all child animations of a given target
  14281. */
  14282. export class AnimationPropertiesOverride {
  14283. /**
  14284. * Gets or sets a value indicating if animation blending must be used
  14285. */
  14286. enableBlending: boolean;
  14287. /**
  14288. * Gets or sets the blending speed to use when enableBlending is true
  14289. */
  14290. blendingSpeed: number;
  14291. /**
  14292. * Gets or sets the default loop mode to use
  14293. */
  14294. loopMode: number;
  14295. }
  14296. }
  14297. declare module "babylonjs/Bones/bone" {
  14298. import { Skeleton } from "babylonjs/Bones/skeleton";
  14299. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14300. import { Nullable } from "babylonjs/types";
  14301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14302. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14303. import { Node } from "babylonjs/node";
  14304. import { Space } from "babylonjs/Maths/math.axis";
  14305. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14306. /**
  14307. * Class used to store bone information
  14308. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14309. */
  14310. export class Bone extends Node {
  14311. /**
  14312. * defines the bone name
  14313. */
  14314. name: string;
  14315. private static _tmpVecs;
  14316. private static _tmpQuat;
  14317. private static _tmpMats;
  14318. /**
  14319. * Gets the list of child bones
  14320. */
  14321. children: Bone[];
  14322. /** Gets the animations associated with this bone */
  14323. animations: import("babylonjs/Animations/animation").Animation[];
  14324. /**
  14325. * Gets or sets bone length
  14326. */
  14327. length: number;
  14328. /**
  14329. * @hidden Internal only
  14330. * Set this value to map this bone to a different index in the transform matrices
  14331. * Set this value to -1 to exclude the bone from the transform matrices
  14332. */
  14333. _index: Nullable<number>;
  14334. private _skeleton;
  14335. private _localMatrix;
  14336. private _restPose;
  14337. private _baseMatrix;
  14338. private _absoluteTransform;
  14339. private _invertedAbsoluteTransform;
  14340. private _parent;
  14341. private _scalingDeterminant;
  14342. private _worldTransform;
  14343. private _localScaling;
  14344. private _localRotation;
  14345. private _localPosition;
  14346. private _needToDecompose;
  14347. private _needToCompose;
  14348. /** @hidden */
  14349. _linkedTransformNode: Nullable<TransformNode>;
  14350. /** @hidden */
  14351. _waitingTransformNodeId: Nullable<string>;
  14352. /** @hidden */
  14353. get _matrix(): Matrix;
  14354. /** @hidden */
  14355. set _matrix(value: Matrix);
  14356. /**
  14357. * Create a new bone
  14358. * @param name defines the bone name
  14359. * @param skeleton defines the parent skeleton
  14360. * @param parentBone defines the parent (can be null if the bone is the root)
  14361. * @param localMatrix defines the local matrix
  14362. * @param restPose defines the rest pose matrix
  14363. * @param baseMatrix defines the base matrix
  14364. * @param index defines index of the bone in the hiearchy
  14365. */
  14366. constructor(
  14367. /**
  14368. * defines the bone name
  14369. */
  14370. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14371. /**
  14372. * Gets the current object class name.
  14373. * @return the class name
  14374. */
  14375. getClassName(): string;
  14376. /**
  14377. * Gets the parent skeleton
  14378. * @returns a skeleton
  14379. */
  14380. getSkeleton(): Skeleton;
  14381. /**
  14382. * Gets parent bone
  14383. * @returns a bone or null if the bone is the root of the bone hierarchy
  14384. */
  14385. getParent(): Nullable<Bone>;
  14386. /**
  14387. * Returns an array containing the root bones
  14388. * @returns an array containing the root bones
  14389. */
  14390. getChildren(): Array<Bone>;
  14391. /**
  14392. * Gets the node index in matrix array generated for rendering
  14393. * @returns the node index
  14394. */
  14395. getIndex(): number;
  14396. /**
  14397. * Sets the parent bone
  14398. * @param parent defines the parent (can be null if the bone is the root)
  14399. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14400. */
  14401. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14402. /**
  14403. * Gets the local matrix
  14404. * @returns a matrix
  14405. */
  14406. getLocalMatrix(): Matrix;
  14407. /**
  14408. * Gets the base matrix (initial matrix which remains unchanged)
  14409. * @returns a matrix
  14410. */
  14411. getBaseMatrix(): Matrix;
  14412. /**
  14413. * Gets the rest pose matrix
  14414. * @returns a matrix
  14415. */
  14416. getRestPose(): Matrix;
  14417. /**
  14418. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14419. */
  14420. getWorldMatrix(): Matrix;
  14421. /**
  14422. * Sets the local matrix to rest pose matrix
  14423. */
  14424. returnToRest(): void;
  14425. /**
  14426. * Gets the inverse of the absolute transform matrix.
  14427. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14428. * @returns a matrix
  14429. */
  14430. getInvertedAbsoluteTransform(): Matrix;
  14431. /**
  14432. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14433. * @returns a matrix
  14434. */
  14435. getAbsoluteTransform(): Matrix;
  14436. /**
  14437. * Links with the given transform node.
  14438. * The local matrix of this bone is copied from the transform node every frame.
  14439. * @param transformNode defines the transform node to link to
  14440. */
  14441. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14442. /**
  14443. * Gets the node used to drive the bone's transformation
  14444. * @returns a transform node or null
  14445. */
  14446. getTransformNode(): Nullable<TransformNode>;
  14447. /** Gets or sets current position (in local space) */
  14448. get position(): Vector3;
  14449. set position(newPosition: Vector3);
  14450. /** Gets or sets current rotation (in local space) */
  14451. get rotation(): Vector3;
  14452. set rotation(newRotation: Vector3);
  14453. /** Gets or sets current rotation quaternion (in local space) */
  14454. get rotationQuaternion(): Quaternion;
  14455. set rotationQuaternion(newRotation: Quaternion);
  14456. /** Gets or sets current scaling (in local space) */
  14457. get scaling(): Vector3;
  14458. set scaling(newScaling: Vector3);
  14459. /**
  14460. * Gets the animation properties override
  14461. */
  14462. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14463. private _decompose;
  14464. private _compose;
  14465. /**
  14466. * Update the base and local matrices
  14467. * @param matrix defines the new base or local matrix
  14468. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14469. * @param updateLocalMatrix defines if the local matrix should be updated
  14470. */
  14471. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14472. /** @hidden */
  14473. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14474. /**
  14475. * Flag the bone as dirty (Forcing it to update everything)
  14476. */
  14477. markAsDirty(): void;
  14478. /** @hidden */
  14479. _markAsDirtyAndCompose(): void;
  14480. private _markAsDirtyAndDecompose;
  14481. /**
  14482. * Translate the bone in local or world space
  14483. * @param vec The amount to translate the bone
  14484. * @param space The space that the translation is in
  14485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14486. */
  14487. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14488. /**
  14489. * Set the postion of the bone in local or world space
  14490. * @param position The position to set the bone
  14491. * @param space The space that the position is in
  14492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14493. */
  14494. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14495. /**
  14496. * Set the absolute position of the bone (world space)
  14497. * @param position The position to set the bone
  14498. * @param mesh The mesh that this bone is attached to
  14499. */
  14500. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14501. /**
  14502. * Scale the bone on the x, y and z axes (in local space)
  14503. * @param x The amount to scale the bone on the x axis
  14504. * @param y The amount to scale the bone on the y axis
  14505. * @param z The amount to scale the bone on the z axis
  14506. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14507. */
  14508. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14509. /**
  14510. * Set the bone scaling in local space
  14511. * @param scale defines the scaling vector
  14512. */
  14513. setScale(scale: Vector3): void;
  14514. /**
  14515. * Gets the current scaling in local space
  14516. * @returns the current scaling vector
  14517. */
  14518. getScale(): Vector3;
  14519. /**
  14520. * Gets the current scaling in local space and stores it in a target vector
  14521. * @param result defines the target vector
  14522. */
  14523. getScaleToRef(result: Vector3): void;
  14524. /**
  14525. * Set the yaw, pitch, and roll of the bone in local or world space
  14526. * @param yaw The rotation of the bone on the y axis
  14527. * @param pitch The rotation of the bone on the x axis
  14528. * @param roll The rotation of the bone on the z axis
  14529. * @param space The space that the axes of rotation are in
  14530. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14531. */
  14532. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14533. /**
  14534. * Add a rotation to the bone on an axis in local or world space
  14535. * @param axis The axis to rotate the bone on
  14536. * @param amount The amount to rotate the bone
  14537. * @param space The space that the axis is in
  14538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14539. */
  14540. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14541. /**
  14542. * Set the rotation of the bone to a particular axis angle in local or world space
  14543. * @param axis The axis to rotate the bone on
  14544. * @param angle The angle that the bone should be rotated to
  14545. * @param space The space that the axis is in
  14546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14547. */
  14548. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14549. /**
  14550. * Set the euler rotation of the bone in local of world space
  14551. * @param rotation The euler rotation that the bone should be set to
  14552. * @param space The space that the rotation is in
  14553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14554. */
  14555. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14556. /**
  14557. * Set the quaternion rotation of the bone in local of world space
  14558. * @param quat The quaternion rotation that the bone should be set to
  14559. * @param space The space that the rotation is in
  14560. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14561. */
  14562. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14563. /**
  14564. * Set the rotation matrix of the bone in local of world space
  14565. * @param rotMat The rotation matrix that the bone should be set to
  14566. * @param space The space that the rotation is in
  14567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14568. */
  14569. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14570. private _rotateWithMatrix;
  14571. private _getNegativeRotationToRef;
  14572. /**
  14573. * Get the position of the bone in local or world space
  14574. * @param space The space that the returned position is in
  14575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14576. * @returns The position of the bone
  14577. */
  14578. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14579. /**
  14580. * Copy the position of the bone to a vector3 in local or world space
  14581. * @param space The space that the returned position is in
  14582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14583. * @param result The vector3 to copy the position to
  14584. */
  14585. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14586. /**
  14587. * Get the absolute position of the bone (world space)
  14588. * @param mesh The mesh that this bone is attached to
  14589. * @returns The absolute position of the bone
  14590. */
  14591. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14592. /**
  14593. * Copy the absolute position of the bone (world space) to the result param
  14594. * @param mesh The mesh that this bone is attached to
  14595. * @param result The vector3 to copy the absolute position to
  14596. */
  14597. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14598. /**
  14599. * Compute the absolute transforms of this bone and its children
  14600. */
  14601. computeAbsoluteTransforms(): void;
  14602. /**
  14603. * Get the world direction from an axis that is in the local space of the bone
  14604. * @param localAxis The local direction that is used to compute the world direction
  14605. * @param mesh The mesh that this bone is attached to
  14606. * @returns The world direction
  14607. */
  14608. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14609. /**
  14610. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14611. * @param localAxis The local direction that is used to compute the world direction
  14612. * @param mesh The mesh that this bone is attached to
  14613. * @param result The vector3 that the world direction will be copied to
  14614. */
  14615. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14616. /**
  14617. * Get the euler rotation of the bone in local or world space
  14618. * @param space The space that the rotation should be in
  14619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14620. * @returns The euler rotation
  14621. */
  14622. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14623. /**
  14624. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14625. * @param space The space that the rotation should be in
  14626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14627. * @param result The vector3 that the rotation should be copied to
  14628. */
  14629. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14630. /**
  14631. * Get the quaternion rotation of the bone in either local or world space
  14632. * @param space The space that the rotation should be in
  14633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14634. * @returns The quaternion rotation
  14635. */
  14636. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14637. /**
  14638. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14639. * @param space The space that the rotation should be in
  14640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14641. * @param result The quaternion that the rotation should be copied to
  14642. */
  14643. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14644. /**
  14645. * Get the rotation matrix of the bone in local or world space
  14646. * @param space The space that the rotation should be in
  14647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14648. * @returns The rotation matrix
  14649. */
  14650. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14651. /**
  14652. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14653. * @param space The space that the rotation should be in
  14654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14655. * @param result The quaternion that the rotation should be copied to
  14656. */
  14657. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14658. /**
  14659. * Get the world position of a point that is in the local space of the bone
  14660. * @param position The local position
  14661. * @param mesh The mesh that this bone is attached to
  14662. * @returns The world position
  14663. */
  14664. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14665. /**
  14666. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14667. * @param position The local position
  14668. * @param mesh The mesh that this bone is attached to
  14669. * @param result The vector3 that the world position should be copied to
  14670. */
  14671. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14672. /**
  14673. * Get the local position of a point that is in world space
  14674. * @param position The world position
  14675. * @param mesh The mesh that this bone is attached to
  14676. * @returns The local position
  14677. */
  14678. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14679. /**
  14680. * Get the local position of a point that is in world space and copy it to the result param
  14681. * @param position The world position
  14682. * @param mesh The mesh that this bone is attached to
  14683. * @param result The vector3 that the local position should be copied to
  14684. */
  14685. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14686. }
  14687. }
  14688. declare module "babylonjs/Animations/runtimeAnimation" {
  14689. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14690. import { Animatable } from "babylonjs/Animations/animatable";
  14691. import { Scene } from "babylonjs/scene";
  14692. /**
  14693. * Defines a runtime animation
  14694. */
  14695. export class RuntimeAnimation {
  14696. private _events;
  14697. /**
  14698. * The current frame of the runtime animation
  14699. */
  14700. private _currentFrame;
  14701. /**
  14702. * The animation used by the runtime animation
  14703. */
  14704. private _animation;
  14705. /**
  14706. * The target of the runtime animation
  14707. */
  14708. private _target;
  14709. /**
  14710. * The initiating animatable
  14711. */
  14712. private _host;
  14713. /**
  14714. * The original value of the runtime animation
  14715. */
  14716. private _originalValue;
  14717. /**
  14718. * The original blend value of the runtime animation
  14719. */
  14720. private _originalBlendValue;
  14721. /**
  14722. * The offsets cache of the runtime animation
  14723. */
  14724. private _offsetsCache;
  14725. /**
  14726. * The high limits cache of the runtime animation
  14727. */
  14728. private _highLimitsCache;
  14729. /**
  14730. * Specifies if the runtime animation has been stopped
  14731. */
  14732. private _stopped;
  14733. /**
  14734. * The blending factor of the runtime animation
  14735. */
  14736. private _blendingFactor;
  14737. /**
  14738. * The BabylonJS scene
  14739. */
  14740. private _scene;
  14741. /**
  14742. * The current value of the runtime animation
  14743. */
  14744. private _currentValue;
  14745. /** @hidden */
  14746. _animationState: _IAnimationState;
  14747. /**
  14748. * The active target of the runtime animation
  14749. */
  14750. private _activeTargets;
  14751. private _currentActiveTarget;
  14752. private _directTarget;
  14753. /**
  14754. * The target path of the runtime animation
  14755. */
  14756. private _targetPath;
  14757. /**
  14758. * The weight of the runtime animation
  14759. */
  14760. private _weight;
  14761. /**
  14762. * The ratio offset of the runtime animation
  14763. */
  14764. private _ratioOffset;
  14765. /**
  14766. * The previous delay of the runtime animation
  14767. */
  14768. private _previousDelay;
  14769. /**
  14770. * The previous ratio of the runtime animation
  14771. */
  14772. private _previousRatio;
  14773. private _enableBlending;
  14774. private _keys;
  14775. private _minFrame;
  14776. private _maxFrame;
  14777. private _minValue;
  14778. private _maxValue;
  14779. private _targetIsArray;
  14780. /**
  14781. * Gets the current frame of the runtime animation
  14782. */
  14783. get currentFrame(): number;
  14784. /**
  14785. * Gets the weight of the runtime animation
  14786. */
  14787. get weight(): number;
  14788. /**
  14789. * Gets the current value of the runtime animation
  14790. */
  14791. get currentValue(): any;
  14792. /**
  14793. * Gets the target path of the runtime animation
  14794. */
  14795. get targetPath(): string;
  14796. /**
  14797. * Gets the actual target of the runtime animation
  14798. */
  14799. get target(): any;
  14800. /** @hidden */
  14801. _onLoop: () => void;
  14802. /**
  14803. * Create a new RuntimeAnimation object
  14804. * @param target defines the target of the animation
  14805. * @param animation defines the source animation object
  14806. * @param scene defines the hosting scene
  14807. * @param host defines the initiating Animatable
  14808. */
  14809. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14810. private _preparePath;
  14811. /**
  14812. * Gets the animation from the runtime animation
  14813. */
  14814. get animation(): Animation;
  14815. /**
  14816. * Resets the runtime animation to the beginning
  14817. * @param restoreOriginal defines whether to restore the target property to the original value
  14818. */
  14819. reset(restoreOriginal?: boolean): void;
  14820. /**
  14821. * Specifies if the runtime animation is stopped
  14822. * @returns Boolean specifying if the runtime animation is stopped
  14823. */
  14824. isStopped(): boolean;
  14825. /**
  14826. * Disposes of the runtime animation
  14827. */
  14828. dispose(): void;
  14829. /**
  14830. * Apply the interpolated value to the target
  14831. * @param currentValue defines the value computed by the animation
  14832. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14833. */
  14834. setValue(currentValue: any, weight: number): void;
  14835. private _getOriginalValues;
  14836. private _setValue;
  14837. /**
  14838. * Gets the loop pmode of the runtime animation
  14839. * @returns Loop Mode
  14840. */
  14841. private _getCorrectLoopMode;
  14842. /**
  14843. * Move the current animation to a given frame
  14844. * @param frame defines the frame to move to
  14845. */
  14846. goToFrame(frame: number): void;
  14847. /**
  14848. * @hidden Internal use only
  14849. */
  14850. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14851. /**
  14852. * Execute the current animation
  14853. * @param delay defines the delay to add to the current frame
  14854. * @param from defines the lower bound of the animation range
  14855. * @param to defines the upper bound of the animation range
  14856. * @param loop defines if the current animation must loop
  14857. * @param speedRatio defines the current speed ratio
  14858. * @param weight defines the weight of the animation (default is -1 so no weight)
  14859. * @param onLoop optional callback called when animation loops
  14860. * @returns a boolean indicating if the animation is running
  14861. */
  14862. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14863. }
  14864. }
  14865. declare module "babylonjs/Animations/animatable" {
  14866. import { Animation } from "babylonjs/Animations/animation";
  14867. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14868. import { Nullable } from "babylonjs/types";
  14869. import { Observable } from "babylonjs/Misc/observable";
  14870. import { Scene } from "babylonjs/scene";
  14871. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14872. import { Node } from "babylonjs/node";
  14873. /**
  14874. * Class used to store an actual running animation
  14875. */
  14876. export class Animatable {
  14877. /** defines the target object */
  14878. target: any;
  14879. /** defines the starting frame number (default is 0) */
  14880. fromFrame: number;
  14881. /** defines the ending frame number (default is 100) */
  14882. toFrame: number;
  14883. /** defines if the animation must loop (default is false) */
  14884. loopAnimation: boolean;
  14885. /** defines a callback to call when animation ends if it is not looping */
  14886. onAnimationEnd?: (() => void) | null | undefined;
  14887. /** defines a callback to call when animation loops */
  14888. onAnimationLoop?: (() => void) | null | undefined;
  14889. private _localDelayOffset;
  14890. private _pausedDelay;
  14891. private _runtimeAnimations;
  14892. private _paused;
  14893. private _scene;
  14894. private _speedRatio;
  14895. private _weight;
  14896. private _syncRoot;
  14897. /**
  14898. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14899. * This will only apply for non looping animation (default is true)
  14900. */
  14901. disposeOnEnd: boolean;
  14902. /**
  14903. * Gets a boolean indicating if the animation has started
  14904. */
  14905. animationStarted: boolean;
  14906. /**
  14907. * Observer raised when the animation ends
  14908. */
  14909. onAnimationEndObservable: Observable<Animatable>;
  14910. /**
  14911. * Observer raised when the animation loops
  14912. */
  14913. onAnimationLoopObservable: Observable<Animatable>;
  14914. /**
  14915. * Gets the root Animatable used to synchronize and normalize animations
  14916. */
  14917. get syncRoot(): Nullable<Animatable>;
  14918. /**
  14919. * Gets the current frame of the first RuntimeAnimation
  14920. * Used to synchronize Animatables
  14921. */
  14922. get masterFrame(): number;
  14923. /**
  14924. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14925. */
  14926. get weight(): number;
  14927. set weight(value: number);
  14928. /**
  14929. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14930. */
  14931. get speedRatio(): number;
  14932. set speedRatio(value: number);
  14933. /**
  14934. * Creates a new Animatable
  14935. * @param scene defines the hosting scene
  14936. * @param target defines the target object
  14937. * @param fromFrame defines the starting frame number (default is 0)
  14938. * @param toFrame defines the ending frame number (default is 100)
  14939. * @param loopAnimation defines if the animation must loop (default is false)
  14940. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14941. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14942. * @param animations defines a group of animation to add to the new Animatable
  14943. * @param onAnimationLoop defines a callback to call when animation loops
  14944. */
  14945. constructor(scene: Scene,
  14946. /** defines the target object */
  14947. target: any,
  14948. /** defines the starting frame number (default is 0) */
  14949. fromFrame?: number,
  14950. /** defines the ending frame number (default is 100) */
  14951. toFrame?: number,
  14952. /** defines if the animation must loop (default is false) */
  14953. loopAnimation?: boolean, speedRatio?: number,
  14954. /** defines a callback to call when animation ends if it is not looping */
  14955. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14956. /** defines a callback to call when animation loops */
  14957. onAnimationLoop?: (() => void) | null | undefined);
  14958. /**
  14959. * Synchronize and normalize current Animatable with a source Animatable
  14960. * This is useful when using animation weights and when animations are not of the same length
  14961. * @param root defines the root Animatable to synchronize with
  14962. * @returns the current Animatable
  14963. */
  14964. syncWith(root: Animatable): Animatable;
  14965. /**
  14966. * Gets the list of runtime animations
  14967. * @returns an array of RuntimeAnimation
  14968. */
  14969. getAnimations(): RuntimeAnimation[];
  14970. /**
  14971. * Adds more animations to the current animatable
  14972. * @param target defines the target of the animations
  14973. * @param animations defines the new animations to add
  14974. */
  14975. appendAnimations(target: any, animations: Animation[]): void;
  14976. /**
  14977. * Gets the source animation for a specific property
  14978. * @param property defines the propertyu to look for
  14979. * @returns null or the source animation for the given property
  14980. */
  14981. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14982. /**
  14983. * Gets the runtime animation for a specific property
  14984. * @param property defines the propertyu to look for
  14985. * @returns null or the runtime animation for the given property
  14986. */
  14987. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14988. /**
  14989. * Resets the animatable to its original state
  14990. */
  14991. reset(): void;
  14992. /**
  14993. * Allows the animatable to blend with current running animations
  14994. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14995. * @param blendingSpeed defines the blending speed to use
  14996. */
  14997. enableBlending(blendingSpeed: number): void;
  14998. /**
  14999. * Disable animation blending
  15000. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15001. */
  15002. disableBlending(): void;
  15003. /**
  15004. * Jump directly to a given frame
  15005. * @param frame defines the frame to jump to
  15006. */
  15007. goToFrame(frame: number): void;
  15008. /**
  15009. * Pause the animation
  15010. */
  15011. pause(): void;
  15012. /**
  15013. * Restart the animation
  15014. */
  15015. restart(): void;
  15016. private _raiseOnAnimationEnd;
  15017. /**
  15018. * Stop and delete the current animation
  15019. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15020. * @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)
  15021. */
  15022. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15023. /**
  15024. * Wait asynchronously for the animation to end
  15025. * @returns a promise which will be fullfilled when the animation ends
  15026. */
  15027. waitAsync(): Promise<Animatable>;
  15028. /** @hidden */
  15029. _animate(delay: number): boolean;
  15030. }
  15031. module "babylonjs/scene" {
  15032. interface Scene {
  15033. /** @hidden */
  15034. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15035. /** @hidden */
  15036. _processLateAnimationBindingsForMatrices(holder: {
  15037. totalWeight: number;
  15038. animations: RuntimeAnimation[];
  15039. originalValue: Matrix;
  15040. }): any;
  15041. /** @hidden */
  15042. _processLateAnimationBindingsForQuaternions(holder: {
  15043. totalWeight: number;
  15044. animations: RuntimeAnimation[];
  15045. originalValue: Quaternion;
  15046. }, refQuaternion: Quaternion): Quaternion;
  15047. /** @hidden */
  15048. _processLateAnimationBindings(): void;
  15049. /**
  15050. * Will start the animation sequence of a given target
  15051. * @param target defines the target
  15052. * @param from defines from which frame should animation start
  15053. * @param to defines until which frame should animation run.
  15054. * @param weight defines the weight to apply to the animation (1.0 by default)
  15055. * @param loop defines if the animation loops
  15056. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15057. * @param onAnimationEnd defines the function to be executed when the animation ends
  15058. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15059. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15060. * @param onAnimationLoop defines the callback to call when an animation loops
  15061. * @returns the animatable object created for this animation
  15062. */
  15063. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15064. /**
  15065. * Will start the animation sequence of a given target
  15066. * @param target defines the target
  15067. * @param from defines from which frame should animation start
  15068. * @param to defines until which frame should animation run.
  15069. * @param loop defines if the animation loops
  15070. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15071. * @param onAnimationEnd defines the function to be executed when the animation ends
  15072. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15073. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15074. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15075. * @param onAnimationLoop defines the callback to call when an animation loops
  15076. * @returns the animatable object created for this animation
  15077. */
  15078. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15079. /**
  15080. * Will start the animation sequence of a given target and its hierarchy
  15081. * @param target defines the target
  15082. * @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.
  15083. * @param from defines from which frame should animation start
  15084. * @param to defines until which frame should animation run.
  15085. * @param loop defines if the animation loops
  15086. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15087. * @param onAnimationEnd defines the function to be executed when the animation ends
  15088. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15089. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15090. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15091. * @param onAnimationLoop defines the callback to call when an animation loops
  15092. * @returns the list of created animatables
  15093. */
  15094. 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[];
  15095. /**
  15096. * Begin a new animation on a given node
  15097. * @param target defines the target where the animation will take place
  15098. * @param animations defines the list of animations to start
  15099. * @param from defines the initial value
  15100. * @param to defines the final value
  15101. * @param loop defines if you want animation to loop (off by default)
  15102. * @param speedRatio defines the speed ratio to apply to all animations
  15103. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15104. * @param onAnimationLoop defines the callback to call when an animation loops
  15105. * @returns the list of created animatables
  15106. */
  15107. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15108. /**
  15109. * Begin a new animation on a given node and its hierarchy
  15110. * @param target defines the root node where the animation will take place
  15111. * @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.
  15112. * @param animations defines the list of animations to start
  15113. * @param from defines the initial value
  15114. * @param to defines the final value
  15115. * @param loop defines if you want animation to loop (off by default)
  15116. * @param speedRatio defines the speed ratio to apply to all animations
  15117. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15118. * @param onAnimationLoop defines the callback to call when an animation loops
  15119. * @returns the list of animatables created for all nodes
  15120. */
  15121. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15122. /**
  15123. * Gets the animatable associated with a specific target
  15124. * @param target defines the target of the animatable
  15125. * @returns the required animatable if found
  15126. */
  15127. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15128. /**
  15129. * Gets all animatables associated with a given target
  15130. * @param target defines the target to look animatables for
  15131. * @returns an array of Animatables
  15132. */
  15133. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15134. /**
  15135. * Stops and removes all animations that have been applied to the scene
  15136. */
  15137. stopAllAnimations(): void;
  15138. /**
  15139. * Gets the current delta time used by animation engine
  15140. */
  15141. deltaTime: number;
  15142. }
  15143. }
  15144. module "babylonjs/Bones/bone" {
  15145. interface Bone {
  15146. /**
  15147. * Copy an animation range from another bone
  15148. * @param source defines the source bone
  15149. * @param rangeName defines the range name to copy
  15150. * @param frameOffset defines the frame offset
  15151. * @param rescaleAsRequired defines if rescaling must be applied if required
  15152. * @param skelDimensionsRatio defines the scaling ratio
  15153. * @returns true if operation was successful
  15154. */
  15155. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15156. }
  15157. }
  15158. }
  15159. declare module "babylonjs/Bones/skeleton" {
  15160. import { Bone } from "babylonjs/Bones/bone";
  15161. import { Observable } from "babylonjs/Misc/observable";
  15162. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15163. import { Scene } from "babylonjs/scene";
  15164. import { Nullable } from "babylonjs/types";
  15165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15166. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15167. import { Animatable } from "babylonjs/Animations/animatable";
  15168. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15169. import { Animation } from "babylonjs/Animations/animation";
  15170. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15171. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15172. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15173. /**
  15174. * Class used to handle skinning animations
  15175. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15176. */
  15177. export class Skeleton implements IAnimatable {
  15178. /** defines the skeleton name */
  15179. name: string;
  15180. /** defines the skeleton Id */
  15181. id: string;
  15182. /**
  15183. * Defines the list of child bones
  15184. */
  15185. bones: Bone[];
  15186. /**
  15187. * Defines an estimate of the dimension of the skeleton at rest
  15188. */
  15189. dimensionsAtRest: Vector3;
  15190. /**
  15191. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15192. */
  15193. needInitialSkinMatrix: boolean;
  15194. /**
  15195. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15196. */
  15197. overrideMesh: Nullable<AbstractMesh>;
  15198. /**
  15199. * Gets the list of animations attached to this skeleton
  15200. */
  15201. animations: Array<Animation>;
  15202. private _scene;
  15203. private _isDirty;
  15204. private _transformMatrices;
  15205. private _transformMatrixTexture;
  15206. private _meshesWithPoseMatrix;
  15207. private _animatables;
  15208. private _identity;
  15209. private _synchronizedWithMesh;
  15210. private _ranges;
  15211. private _lastAbsoluteTransformsUpdateId;
  15212. private _canUseTextureForBones;
  15213. private _uniqueId;
  15214. /** @hidden */
  15215. _numBonesWithLinkedTransformNode: number;
  15216. /** @hidden */
  15217. _hasWaitingData: Nullable<boolean>;
  15218. /**
  15219. * Specifies if the skeleton should be serialized
  15220. */
  15221. doNotSerialize: boolean;
  15222. private _useTextureToStoreBoneMatrices;
  15223. /**
  15224. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15225. * Please note that this option is not available if the hardware does not support it
  15226. */
  15227. get useTextureToStoreBoneMatrices(): boolean;
  15228. set useTextureToStoreBoneMatrices(value: boolean);
  15229. private _animationPropertiesOverride;
  15230. /**
  15231. * Gets or sets the animation properties override
  15232. */
  15233. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15234. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15235. /**
  15236. * List of inspectable custom properties (used by the Inspector)
  15237. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15238. */
  15239. inspectableCustomProperties: IInspectable[];
  15240. /**
  15241. * An observable triggered before computing the skeleton's matrices
  15242. */
  15243. onBeforeComputeObservable: Observable<Skeleton>;
  15244. /**
  15245. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15246. */
  15247. get isUsingTextureForMatrices(): boolean;
  15248. /**
  15249. * Gets the unique ID of this skeleton
  15250. */
  15251. get uniqueId(): number;
  15252. /**
  15253. * Creates a new skeleton
  15254. * @param name defines the skeleton name
  15255. * @param id defines the skeleton Id
  15256. * @param scene defines the hosting scene
  15257. */
  15258. constructor(
  15259. /** defines the skeleton name */
  15260. name: string,
  15261. /** defines the skeleton Id */
  15262. id: string, scene: Scene);
  15263. /**
  15264. * Gets the current object class name.
  15265. * @return the class name
  15266. */
  15267. getClassName(): string;
  15268. /**
  15269. * Returns an array containing the root bones
  15270. * @returns an array containing the root bones
  15271. */
  15272. getChildren(): Array<Bone>;
  15273. /**
  15274. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15275. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15276. * @returns a Float32Array containing matrices data
  15277. */
  15278. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15279. /**
  15280. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15281. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15282. * @returns a raw texture containing the data
  15283. */
  15284. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15285. /**
  15286. * Gets the current hosting scene
  15287. * @returns a scene object
  15288. */
  15289. getScene(): Scene;
  15290. /**
  15291. * Gets a string representing the current skeleton data
  15292. * @param fullDetails defines a boolean indicating if we want a verbose version
  15293. * @returns a string representing the current skeleton data
  15294. */
  15295. toString(fullDetails?: boolean): string;
  15296. /**
  15297. * Get bone's index searching by name
  15298. * @param name defines bone's name to search for
  15299. * @return the indice of the bone. Returns -1 if not found
  15300. */
  15301. getBoneIndexByName(name: string): number;
  15302. /**
  15303. * Creater a new animation range
  15304. * @param name defines the name of the range
  15305. * @param from defines the start key
  15306. * @param to defines the end key
  15307. */
  15308. createAnimationRange(name: string, from: number, to: number): void;
  15309. /**
  15310. * Delete a specific animation range
  15311. * @param name defines the name of the range
  15312. * @param deleteFrames defines if frames must be removed as well
  15313. */
  15314. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15315. /**
  15316. * Gets a specific animation range
  15317. * @param name defines the name of the range to look for
  15318. * @returns the requested animation range or null if not found
  15319. */
  15320. getAnimationRange(name: string): Nullable<AnimationRange>;
  15321. /**
  15322. * Gets the list of all animation ranges defined on this skeleton
  15323. * @returns an array
  15324. */
  15325. getAnimationRanges(): Nullable<AnimationRange>[];
  15326. /**
  15327. * Copy animation range from a source skeleton.
  15328. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15329. * @param source defines the source skeleton
  15330. * @param name defines the name of the range to copy
  15331. * @param rescaleAsRequired defines if rescaling must be applied if required
  15332. * @returns true if operation was successful
  15333. */
  15334. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15335. /**
  15336. * Forces the skeleton to go to rest pose
  15337. */
  15338. returnToRest(): void;
  15339. private _getHighestAnimationFrame;
  15340. /**
  15341. * Begin a specific animation range
  15342. * @param name defines the name of the range to start
  15343. * @param loop defines if looping must be turned on (false by default)
  15344. * @param speedRatio defines the speed ratio to apply (1 by default)
  15345. * @param onAnimationEnd defines a callback which will be called when animation will end
  15346. * @returns a new animatable
  15347. */
  15348. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15349. /** @hidden */
  15350. _markAsDirty(): void;
  15351. /** @hidden */
  15352. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15353. /** @hidden */
  15354. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15355. private _computeTransformMatrices;
  15356. /**
  15357. * Build all resources required to render a skeleton
  15358. */
  15359. prepare(): void;
  15360. /**
  15361. * Gets the list of animatables currently running for this skeleton
  15362. * @returns an array of animatables
  15363. */
  15364. getAnimatables(): IAnimatable[];
  15365. /**
  15366. * Clone the current skeleton
  15367. * @param name defines the name of the new skeleton
  15368. * @param id defines the id of the new skeleton
  15369. * @returns the new skeleton
  15370. */
  15371. clone(name: string, id?: string): Skeleton;
  15372. /**
  15373. * Enable animation blending for this skeleton
  15374. * @param blendingSpeed defines the blending speed to apply
  15375. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15376. */
  15377. enableBlending(blendingSpeed?: number): void;
  15378. /**
  15379. * Releases all resources associated with the current skeleton
  15380. */
  15381. dispose(): void;
  15382. /**
  15383. * Serialize the skeleton in a JSON object
  15384. * @returns a JSON object
  15385. */
  15386. serialize(): any;
  15387. /**
  15388. * Creates a new skeleton from serialized data
  15389. * @param parsedSkeleton defines the serialized data
  15390. * @param scene defines the hosting scene
  15391. * @returns a new skeleton
  15392. */
  15393. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15394. /**
  15395. * Compute all node absolute transforms
  15396. * @param forceUpdate defines if computation must be done even if cache is up to date
  15397. */
  15398. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15399. /**
  15400. * Gets the root pose matrix
  15401. * @returns a matrix
  15402. */
  15403. getPoseMatrix(): Nullable<Matrix>;
  15404. /**
  15405. * Sorts bones per internal index
  15406. */
  15407. sortBones(): void;
  15408. private _sortBones;
  15409. }
  15410. }
  15411. declare module "babylonjs/Meshes/instancedMesh" {
  15412. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15413. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15414. import { Camera } from "babylonjs/Cameras/camera";
  15415. import { Node } from "babylonjs/node";
  15416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15417. import { Mesh } from "babylonjs/Meshes/mesh";
  15418. import { Material } from "babylonjs/Materials/material";
  15419. import { Skeleton } from "babylonjs/Bones/skeleton";
  15420. import { Light } from "babylonjs/Lights/light";
  15421. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15422. /**
  15423. * Creates an instance based on a source mesh.
  15424. */
  15425. export class InstancedMesh extends AbstractMesh {
  15426. private _sourceMesh;
  15427. private _currentLOD;
  15428. /** @hidden */
  15429. _indexInSourceMeshInstanceArray: number;
  15430. constructor(name: string, source: Mesh);
  15431. /**
  15432. * Returns the string "InstancedMesh".
  15433. */
  15434. getClassName(): string;
  15435. /** Gets the list of lights affecting that mesh */
  15436. get lightSources(): Light[];
  15437. _resyncLightSources(): void;
  15438. _resyncLightSource(light: Light): void;
  15439. _removeLightSource(light: Light, dispose: boolean): void;
  15440. /**
  15441. * If the source mesh receives shadows
  15442. */
  15443. get receiveShadows(): boolean;
  15444. /**
  15445. * The material of the source mesh
  15446. */
  15447. get material(): Nullable<Material>;
  15448. /**
  15449. * Visibility of the source mesh
  15450. */
  15451. get visibility(): number;
  15452. /**
  15453. * Skeleton of the source mesh
  15454. */
  15455. get skeleton(): Nullable<Skeleton>;
  15456. /**
  15457. * Rendering ground id of the source mesh
  15458. */
  15459. get renderingGroupId(): number;
  15460. set renderingGroupId(value: number);
  15461. /**
  15462. * Returns the total number of vertices (integer).
  15463. */
  15464. getTotalVertices(): number;
  15465. /**
  15466. * Returns a positive integer : the total number of indices in this mesh geometry.
  15467. * @returns the numner of indices or zero if the mesh has no geometry.
  15468. */
  15469. getTotalIndices(): number;
  15470. /**
  15471. * The source mesh of the instance
  15472. */
  15473. get sourceMesh(): Mesh;
  15474. /**
  15475. * Is this node ready to be used/rendered
  15476. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15477. * @return {boolean} is it ready
  15478. */
  15479. isReady(completeCheck?: boolean): boolean;
  15480. /**
  15481. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15482. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15483. * @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.
  15484. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15485. */
  15486. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15487. /**
  15488. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15489. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15490. * The `data` are either a numeric array either a Float32Array.
  15491. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15492. * 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).
  15493. * Note that a new underlying VertexBuffer object is created each call.
  15494. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15495. *
  15496. * Possible `kind` values :
  15497. * - VertexBuffer.PositionKind
  15498. * - VertexBuffer.UVKind
  15499. * - VertexBuffer.UV2Kind
  15500. * - VertexBuffer.UV3Kind
  15501. * - VertexBuffer.UV4Kind
  15502. * - VertexBuffer.UV5Kind
  15503. * - VertexBuffer.UV6Kind
  15504. * - VertexBuffer.ColorKind
  15505. * - VertexBuffer.MatricesIndicesKind
  15506. * - VertexBuffer.MatricesIndicesExtraKind
  15507. * - VertexBuffer.MatricesWeightsKind
  15508. * - VertexBuffer.MatricesWeightsExtraKind
  15509. *
  15510. * Returns the Mesh.
  15511. */
  15512. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15513. /**
  15514. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15515. * If the mesh has no geometry, it is simply returned as it is.
  15516. * The `data` are either a numeric array either a Float32Array.
  15517. * No new underlying VertexBuffer object is created.
  15518. * 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.
  15519. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15520. *
  15521. * Possible `kind` values :
  15522. * - VertexBuffer.PositionKind
  15523. * - VertexBuffer.UVKind
  15524. * - VertexBuffer.UV2Kind
  15525. * - VertexBuffer.UV3Kind
  15526. * - VertexBuffer.UV4Kind
  15527. * - VertexBuffer.UV5Kind
  15528. * - VertexBuffer.UV6Kind
  15529. * - VertexBuffer.ColorKind
  15530. * - VertexBuffer.MatricesIndicesKind
  15531. * - VertexBuffer.MatricesIndicesExtraKind
  15532. * - VertexBuffer.MatricesWeightsKind
  15533. * - VertexBuffer.MatricesWeightsExtraKind
  15534. *
  15535. * Returns the Mesh.
  15536. */
  15537. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15538. /**
  15539. * Sets the mesh indices.
  15540. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15541. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15542. * This method creates a new index buffer each call.
  15543. * Returns the Mesh.
  15544. */
  15545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15546. /**
  15547. * Boolean : True if the mesh owns the requested kind of data.
  15548. */
  15549. isVerticesDataPresent(kind: string): boolean;
  15550. /**
  15551. * Returns an array of indices (IndicesArray).
  15552. */
  15553. getIndices(): Nullable<IndicesArray>;
  15554. get _positions(): Nullable<Vector3[]>;
  15555. /**
  15556. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15557. * This means the mesh underlying bounding box and sphere are recomputed.
  15558. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15559. * @returns the current mesh
  15560. */
  15561. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15562. /** @hidden */
  15563. _preActivate(): InstancedMesh;
  15564. /** @hidden */
  15565. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15566. /** @hidden */
  15567. _postActivate(): void;
  15568. getWorldMatrix(): Matrix;
  15569. get isAnInstance(): boolean;
  15570. /**
  15571. * Returns the current associated LOD AbstractMesh.
  15572. */
  15573. getLOD(camera: Camera): AbstractMesh;
  15574. /** @hidden */
  15575. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15576. /** @hidden */
  15577. _syncSubMeshes(): InstancedMesh;
  15578. /** @hidden */
  15579. _generatePointsArray(): boolean;
  15580. /**
  15581. * Creates a new InstancedMesh from the current mesh.
  15582. * - name (string) : the cloned mesh name
  15583. * - newParent (optional Node) : the optional Node to parent the clone to.
  15584. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15585. *
  15586. * Returns the clone.
  15587. */
  15588. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15589. /**
  15590. * Disposes the InstancedMesh.
  15591. * Returns nothing.
  15592. */
  15593. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15594. }
  15595. module "babylonjs/Meshes/mesh" {
  15596. interface Mesh {
  15597. /**
  15598. * Register a custom buffer that will be instanced
  15599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15600. * @param kind defines the buffer kind
  15601. * @param stride defines the stride in floats
  15602. */
  15603. registerInstancedBuffer(kind: string, stride: number): void;
  15604. /** @hidden */
  15605. _userInstancedBuffersStorage: {
  15606. data: {
  15607. [key: string]: Float32Array;
  15608. };
  15609. sizes: {
  15610. [key: string]: number;
  15611. };
  15612. vertexBuffers: {
  15613. [key: string]: Nullable<VertexBuffer>;
  15614. };
  15615. strides: {
  15616. [key: string]: number;
  15617. };
  15618. };
  15619. }
  15620. }
  15621. module "babylonjs/Meshes/abstractMesh" {
  15622. interface AbstractMesh {
  15623. /**
  15624. * Object used to store instanced buffers defined by user
  15625. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15626. */
  15627. instancedBuffers: {
  15628. [key: string]: any;
  15629. };
  15630. }
  15631. }
  15632. }
  15633. declare module "babylonjs/Materials/shaderMaterial" {
  15634. import { Scene } from "babylonjs/scene";
  15635. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15637. import { Mesh } from "babylonjs/Meshes/mesh";
  15638. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15640. import { Texture } from "babylonjs/Materials/Textures/texture";
  15641. import { Material } from "babylonjs/Materials/material";
  15642. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15643. /**
  15644. * Defines the options associated with the creation of a shader material.
  15645. */
  15646. export interface IShaderMaterialOptions {
  15647. /**
  15648. * Does the material work in alpha blend mode
  15649. */
  15650. needAlphaBlending: boolean;
  15651. /**
  15652. * Does the material work in alpha test mode
  15653. */
  15654. needAlphaTesting: boolean;
  15655. /**
  15656. * The list of attribute names used in the shader
  15657. */
  15658. attributes: string[];
  15659. /**
  15660. * The list of unifrom names used in the shader
  15661. */
  15662. uniforms: string[];
  15663. /**
  15664. * The list of UBO names used in the shader
  15665. */
  15666. uniformBuffers: string[];
  15667. /**
  15668. * The list of sampler names used in the shader
  15669. */
  15670. samplers: string[];
  15671. /**
  15672. * The list of defines used in the shader
  15673. */
  15674. defines: string[];
  15675. }
  15676. /**
  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. *
  15679. * This returned material effects how the mesh will look based on the code in the shaders.
  15680. *
  15681. * @see http://doc.babylonjs.com/how_to/shader_material
  15682. */
  15683. export class ShaderMaterial extends Material {
  15684. private _shaderPath;
  15685. private _options;
  15686. private _textures;
  15687. private _textureArrays;
  15688. private _floats;
  15689. private _ints;
  15690. private _floatsArrays;
  15691. private _colors3;
  15692. private _colors3Arrays;
  15693. private _colors4;
  15694. private _colors4Arrays;
  15695. private _vectors2;
  15696. private _vectors3;
  15697. private _vectors4;
  15698. private _matrices;
  15699. private _matrixArrays;
  15700. private _matrices3x3;
  15701. private _matrices2x2;
  15702. private _vectors2Arrays;
  15703. private _vectors3Arrays;
  15704. private _vectors4Arrays;
  15705. private _cachedWorldViewMatrix;
  15706. private _cachedWorldViewProjectionMatrix;
  15707. private _renderId;
  15708. private _multiview;
  15709. /**
  15710. * Instantiate a new shader material.
  15711. * 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.
  15712. * This returned material effects how the mesh will look based on the code in the shaders.
  15713. * @see http://doc.babylonjs.com/how_to/shader_material
  15714. * @param name Define the name of the material in the scene
  15715. * @param scene Define the scene the material belongs to
  15716. * @param shaderPath Defines the route to the shader code in one of three ways:
  15717. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15718. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15719. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15720. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15721. * @param options Define the options used to create the shader
  15722. */
  15723. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15724. /**
  15725. * Gets the shader path used to define the shader code
  15726. * It can be modified to trigger a new compilation
  15727. */
  15728. get shaderPath(): any;
  15729. /**
  15730. * Sets the shader path used to define the shader code
  15731. * It can be modified to trigger a new compilation
  15732. */
  15733. set shaderPath(shaderPath: any);
  15734. /**
  15735. * Gets the options used to compile the shader.
  15736. * They can be modified to trigger a new compilation
  15737. */
  15738. get options(): IShaderMaterialOptions;
  15739. /**
  15740. * Gets the current class name of the material e.g. "ShaderMaterial"
  15741. * Mainly use in serialization.
  15742. * @returns the class name
  15743. */
  15744. getClassName(): string;
  15745. /**
  15746. * Specifies if the material will require alpha blending
  15747. * @returns a boolean specifying if alpha blending is needed
  15748. */
  15749. needAlphaBlending(): boolean;
  15750. /**
  15751. * Specifies if this material should be rendered in alpha test mode
  15752. * @returns a boolean specifying if an alpha test is needed.
  15753. */
  15754. needAlphaTesting(): boolean;
  15755. private _checkUniform;
  15756. /**
  15757. * Set a texture in the shader.
  15758. * @param name Define the name of the uniform samplers as defined in the shader
  15759. * @param texture Define the texture to bind to this sampler
  15760. * @return the material itself allowing "fluent" like uniform updates
  15761. */
  15762. setTexture(name: string, texture: Texture): ShaderMaterial;
  15763. /**
  15764. * Set a texture array in the shader.
  15765. * @param name Define the name of the uniform sampler array as defined in the shader
  15766. * @param textures Define the list of textures to bind to this sampler
  15767. * @return the material itself allowing "fluent" like uniform updates
  15768. */
  15769. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15770. /**
  15771. * Set a float in the shader.
  15772. * @param name Define the name of the uniform as defined in the shader
  15773. * @param value Define the value to give to the uniform
  15774. * @return the material itself allowing "fluent" like uniform updates
  15775. */
  15776. setFloat(name: string, value: number): ShaderMaterial;
  15777. /**
  15778. * Set a int in the shader.
  15779. * @param name Define the name of the uniform as defined in the shader
  15780. * @param value Define the value to give to the uniform
  15781. * @return the material itself allowing "fluent" like uniform updates
  15782. */
  15783. setInt(name: string, value: number): ShaderMaterial;
  15784. /**
  15785. * Set an array of floats in the shader.
  15786. * @param name Define the name of the uniform as defined in the shader
  15787. * @param value Define the value to give to the uniform
  15788. * @return the material itself allowing "fluent" like uniform updates
  15789. */
  15790. setFloats(name: string, value: number[]): ShaderMaterial;
  15791. /**
  15792. * Set a vec3 in the shader from a Color3.
  15793. * @param name Define the name of the uniform as defined in the shader
  15794. * @param value Define the value to give to the uniform
  15795. * @return the material itself allowing "fluent" like uniform updates
  15796. */
  15797. setColor3(name: string, value: Color3): ShaderMaterial;
  15798. /**
  15799. * Set a vec3 array in the shader from a Color3 array.
  15800. * @param name Define the name of the uniform as defined in the shader
  15801. * @param value Define the value to give to the uniform
  15802. * @return the material itself allowing "fluent" like uniform updates
  15803. */
  15804. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15805. /**
  15806. * Set a vec4 in the shader from a Color4.
  15807. * @param name Define the name of the uniform as defined in the shader
  15808. * @param value Define the value to give to the uniform
  15809. * @return the material itself allowing "fluent" like uniform updates
  15810. */
  15811. setColor4(name: string, value: Color4): ShaderMaterial;
  15812. /**
  15813. * Set a vec4 array in the shader from a Color4 array.
  15814. * @param name Define the name of the uniform as defined in the shader
  15815. * @param value Define the value to give to the uniform
  15816. * @return the material itself allowing "fluent" like uniform updates
  15817. */
  15818. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15819. /**
  15820. * Set a vec2 in the shader from a Vector2.
  15821. * @param name Define the name of the uniform as defined in the shader
  15822. * @param value Define the value to give to the uniform
  15823. * @return the material itself allowing "fluent" like uniform updates
  15824. */
  15825. setVector2(name: string, value: Vector2): ShaderMaterial;
  15826. /**
  15827. * Set a vec3 in the shader from a Vector3.
  15828. * @param name Define the name of the uniform as defined in the shader
  15829. * @param value Define the value to give to the uniform
  15830. * @return the material itself allowing "fluent" like uniform updates
  15831. */
  15832. setVector3(name: string, value: Vector3): ShaderMaterial;
  15833. /**
  15834. * Set a vec4 in the shader from a Vector4.
  15835. * @param name Define the name of the uniform as defined in the shader
  15836. * @param value Define the value to give to the uniform
  15837. * @return the material itself allowing "fluent" like uniform updates
  15838. */
  15839. setVector4(name: string, value: Vector4): ShaderMaterial;
  15840. /**
  15841. * Set a mat4 in the shader from a Matrix.
  15842. * @param name Define the name of the uniform as defined in the shader
  15843. * @param value Define the value to give to the uniform
  15844. * @return the material itself allowing "fluent" like uniform updates
  15845. */
  15846. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15847. /**
  15848. * Set a float32Array in the shader from a matrix array.
  15849. * @param name Define the name of the uniform as defined in the shader
  15850. * @param value Define the value to give to the uniform
  15851. * @return the material itself allowing "fluent" like uniform updates
  15852. */
  15853. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15854. /**
  15855. * Set a mat3 in the shader from a Float32Array.
  15856. * @param name Define the name of the uniform as defined in the shader
  15857. * @param value Define the value to give to the uniform
  15858. * @return the material itself allowing "fluent" like uniform updates
  15859. */
  15860. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15861. /**
  15862. * Set a mat2 in the shader from a Float32Array.
  15863. * @param name Define the name of the uniform as defined in the shader
  15864. * @param value Define the value to give to the uniform
  15865. * @return the material itself allowing "fluent" like uniform updates
  15866. */
  15867. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15868. /**
  15869. * Set a vec2 array in the shader from a number array.
  15870. * @param name Define the name of the uniform as defined in the shader
  15871. * @param value Define the value to give to the uniform
  15872. * @return the material itself allowing "fluent" like uniform updates
  15873. */
  15874. setArray2(name: string, value: number[]): ShaderMaterial;
  15875. /**
  15876. * Set a vec3 array in the shader from a number array.
  15877. * @param name Define the name of the uniform as defined in the shader
  15878. * @param value Define the value to give to the uniform
  15879. * @return the material itself allowing "fluent" like uniform updates
  15880. */
  15881. setArray3(name: string, value: number[]): ShaderMaterial;
  15882. /**
  15883. * Set a vec4 array in the shader from a number array.
  15884. * @param name Define the name of the uniform as defined in the shader
  15885. * @param value Define the value to give to the uniform
  15886. * @return the material itself allowing "fluent" like uniform updates
  15887. */
  15888. setArray4(name: string, value: number[]): ShaderMaterial;
  15889. private _checkCache;
  15890. /**
  15891. * Specifies that the submesh is ready to be used
  15892. * @param mesh defines the mesh to check
  15893. * @param subMesh defines which submesh to check
  15894. * @param useInstances specifies that instances should be used
  15895. * @returns a boolean indicating that the submesh is ready or not
  15896. */
  15897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15898. /**
  15899. * Checks if the material is ready to render the requested mesh
  15900. * @param mesh Define the mesh to render
  15901. * @param useInstances Define whether or not the material is used with instances
  15902. * @returns true if ready, otherwise false
  15903. */
  15904. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15905. /**
  15906. * Binds the world matrix to the material
  15907. * @param world defines the world transformation matrix
  15908. */
  15909. bindOnlyWorldMatrix(world: Matrix): void;
  15910. /**
  15911. * Binds the material to the mesh
  15912. * @param world defines the world transformation matrix
  15913. * @param mesh defines the mesh to bind the material to
  15914. */
  15915. bind(world: Matrix, mesh?: Mesh): void;
  15916. /**
  15917. * Gets the active textures from the material
  15918. * @returns an array of textures
  15919. */
  15920. getActiveTextures(): BaseTexture[];
  15921. /**
  15922. * Specifies if the material uses a texture
  15923. * @param texture defines the texture to check against the material
  15924. * @returns a boolean specifying if the material uses the texture
  15925. */
  15926. hasTexture(texture: BaseTexture): boolean;
  15927. /**
  15928. * Makes a duplicate of the material, and gives it a new name
  15929. * @param name defines the new name for the duplicated material
  15930. * @returns the cloned material
  15931. */
  15932. clone(name: string): ShaderMaterial;
  15933. /**
  15934. * Disposes the material
  15935. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15936. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15937. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15938. */
  15939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15940. /**
  15941. * Serializes this material in a JSON representation
  15942. * @returns the serialized material object
  15943. */
  15944. serialize(): any;
  15945. /**
  15946. * Creates a shader material from parsed shader material data
  15947. * @param source defines the JSON represnetation of the material
  15948. * @param scene defines the hosting scene
  15949. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15950. * @returns a new material
  15951. */
  15952. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15953. }
  15954. }
  15955. declare module "babylonjs/Shaders/color.fragment" {
  15956. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15957. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15958. /** @hidden */
  15959. export var colorPixelShader: {
  15960. name: string;
  15961. shader: string;
  15962. };
  15963. }
  15964. declare module "babylonjs/Shaders/color.vertex" {
  15965. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15966. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15967. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15968. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15969. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15970. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15971. /** @hidden */
  15972. export var colorVertexShader: {
  15973. name: string;
  15974. shader: string;
  15975. };
  15976. }
  15977. declare module "babylonjs/Meshes/linesMesh" {
  15978. import { Nullable } from "babylonjs/types";
  15979. import { Scene } from "babylonjs/scene";
  15980. import { Color3 } from "babylonjs/Maths/math.color";
  15981. import { Node } from "babylonjs/node";
  15982. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15983. import { Mesh } from "babylonjs/Meshes/mesh";
  15984. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15985. import { Effect } from "babylonjs/Materials/effect";
  15986. import { Material } from "babylonjs/Materials/material";
  15987. import "babylonjs/Shaders/color.fragment";
  15988. import "babylonjs/Shaders/color.vertex";
  15989. /**
  15990. * Line mesh
  15991. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15992. */
  15993. export class LinesMesh extends Mesh {
  15994. /**
  15995. * If vertex color should be applied to the mesh
  15996. */
  15997. readonly useVertexColor?: boolean | undefined;
  15998. /**
  15999. * If vertex alpha should be applied to the mesh
  16000. */
  16001. readonly useVertexAlpha?: boolean | undefined;
  16002. /**
  16003. * Color of the line (Default: White)
  16004. */
  16005. color: Color3;
  16006. /**
  16007. * Alpha of the line (Default: 1)
  16008. */
  16009. alpha: number;
  16010. /**
  16011. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16012. * This margin is expressed in world space coordinates, so its value may vary.
  16013. * Default value is 0.1
  16014. */
  16015. intersectionThreshold: number;
  16016. private _colorShader;
  16017. private color4;
  16018. /**
  16019. * Creates a new LinesMesh
  16020. * @param name defines the name
  16021. * @param scene defines the hosting scene
  16022. * @param parent defines the parent mesh if any
  16023. * @param source defines the optional source LinesMesh used to clone data from
  16024. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16025. * When false, achieved by calling a clone(), also passing False.
  16026. * This will make creation of children, recursive.
  16027. * @param useVertexColor defines if this LinesMesh supports vertex color
  16028. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16029. */
  16030. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16031. /**
  16032. * If vertex color should be applied to the mesh
  16033. */
  16034. useVertexColor?: boolean | undefined,
  16035. /**
  16036. * If vertex alpha should be applied to the mesh
  16037. */
  16038. useVertexAlpha?: boolean | undefined);
  16039. private _addClipPlaneDefine;
  16040. private _removeClipPlaneDefine;
  16041. isReady(): boolean;
  16042. /**
  16043. * Returns the string "LineMesh"
  16044. */
  16045. getClassName(): string;
  16046. /**
  16047. * @hidden
  16048. */
  16049. get material(): Material;
  16050. /**
  16051. * @hidden
  16052. */
  16053. set material(value: Material);
  16054. /**
  16055. * @hidden
  16056. */
  16057. get checkCollisions(): boolean;
  16058. /** @hidden */
  16059. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16060. /** @hidden */
  16061. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16062. /**
  16063. * Disposes of the line mesh
  16064. * @param doNotRecurse If children should be disposed
  16065. */
  16066. dispose(doNotRecurse?: boolean): void;
  16067. /**
  16068. * Returns a new LineMesh object cloned from the current one.
  16069. */
  16070. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16071. /**
  16072. * Creates a new InstancedLinesMesh object from the mesh model.
  16073. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16074. * @param name defines the name of the new instance
  16075. * @returns a new InstancedLinesMesh
  16076. */
  16077. createInstance(name: string): InstancedLinesMesh;
  16078. }
  16079. /**
  16080. * Creates an instance based on a source LinesMesh
  16081. */
  16082. export class InstancedLinesMesh extends InstancedMesh {
  16083. /**
  16084. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16085. * This margin is expressed in world space coordinates, so its value may vary.
  16086. * Initilized with the intersectionThreshold value of the source LinesMesh
  16087. */
  16088. intersectionThreshold: number;
  16089. constructor(name: string, source: LinesMesh);
  16090. /**
  16091. * Returns the string "InstancedLinesMesh".
  16092. */
  16093. getClassName(): string;
  16094. }
  16095. }
  16096. declare module "babylonjs/Shaders/line.fragment" {
  16097. /** @hidden */
  16098. export var linePixelShader: {
  16099. name: string;
  16100. shader: string;
  16101. };
  16102. }
  16103. declare module "babylonjs/Shaders/line.vertex" {
  16104. /** @hidden */
  16105. export var lineVertexShader: {
  16106. name: string;
  16107. shader: string;
  16108. };
  16109. }
  16110. declare module "babylonjs/Rendering/edgesRenderer" {
  16111. import { Nullable } from "babylonjs/types";
  16112. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16114. import { Vector3 } from "babylonjs/Maths/math.vector";
  16115. import { IDisposable } from "babylonjs/scene";
  16116. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16117. import "babylonjs/Shaders/line.fragment";
  16118. import "babylonjs/Shaders/line.vertex";
  16119. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16120. module "babylonjs/Meshes/abstractMesh" {
  16121. interface AbstractMesh {
  16122. /**
  16123. * Gets the edgesRenderer associated with the mesh
  16124. */
  16125. edgesRenderer: Nullable<EdgesRenderer>;
  16126. }
  16127. }
  16128. module "babylonjs/Meshes/linesMesh" {
  16129. interface LinesMesh {
  16130. /**
  16131. * Enables the edge rendering mode on the mesh.
  16132. * This mode makes the mesh edges visible
  16133. * @param epsilon defines the maximal distance between two angles to detect a face
  16134. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16135. * @returns the currentAbstractMesh
  16136. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16137. */
  16138. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16139. }
  16140. }
  16141. module "babylonjs/Meshes/linesMesh" {
  16142. interface InstancedLinesMesh {
  16143. /**
  16144. * Enables the edge rendering mode on the mesh.
  16145. * This mode makes the mesh edges visible
  16146. * @param epsilon defines the maximal distance between two angles to detect a face
  16147. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16148. * @returns the current InstancedLinesMesh
  16149. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16150. */
  16151. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16152. }
  16153. }
  16154. /**
  16155. * Defines the minimum contract an Edges renderer should follow.
  16156. */
  16157. export interface IEdgesRenderer extends IDisposable {
  16158. /**
  16159. * Gets or sets a boolean indicating if the edgesRenderer is active
  16160. */
  16161. isEnabled: boolean;
  16162. /**
  16163. * Renders the edges of the attached mesh,
  16164. */
  16165. render(): void;
  16166. /**
  16167. * Checks wether or not the edges renderer is ready to render.
  16168. * @return true if ready, otherwise false.
  16169. */
  16170. isReady(): boolean;
  16171. }
  16172. /**
  16173. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16174. */
  16175. export class EdgesRenderer implements IEdgesRenderer {
  16176. /**
  16177. * Define the size of the edges with an orthographic camera
  16178. */
  16179. edgesWidthScalerForOrthographic: number;
  16180. /**
  16181. * Define the size of the edges with a perspective camera
  16182. */
  16183. edgesWidthScalerForPerspective: number;
  16184. protected _source: AbstractMesh;
  16185. protected _linesPositions: number[];
  16186. protected _linesNormals: number[];
  16187. protected _linesIndices: number[];
  16188. protected _epsilon: number;
  16189. protected _indicesCount: number;
  16190. protected _lineShader: ShaderMaterial;
  16191. protected _ib: DataBuffer;
  16192. protected _buffers: {
  16193. [key: string]: Nullable<VertexBuffer>;
  16194. };
  16195. protected _checkVerticesInsteadOfIndices: boolean;
  16196. private _meshRebuildObserver;
  16197. private _meshDisposeObserver;
  16198. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16199. isEnabled: boolean;
  16200. /**
  16201. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16202. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16203. * @param source Mesh used to create edges
  16204. * @param epsilon sum of angles in adjacency to check for edge
  16205. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16206. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16207. */
  16208. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16209. protected _prepareRessources(): void;
  16210. /** @hidden */
  16211. _rebuild(): void;
  16212. /**
  16213. * Releases the required resources for the edges renderer
  16214. */
  16215. dispose(): void;
  16216. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16217. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16218. /**
  16219. * Checks if the pair of p0 and p1 is en edge
  16220. * @param faceIndex
  16221. * @param edge
  16222. * @param faceNormals
  16223. * @param p0
  16224. * @param p1
  16225. * @private
  16226. */
  16227. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16228. /**
  16229. * push line into the position, normal and index buffer
  16230. * @protected
  16231. */
  16232. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16233. /**
  16234. * Generates lines edges from adjacencjes
  16235. * @private
  16236. */
  16237. _generateEdgesLines(): void;
  16238. /**
  16239. * Checks wether or not the edges renderer is ready to render.
  16240. * @return true if ready, otherwise false.
  16241. */
  16242. isReady(): boolean;
  16243. /**
  16244. * Renders the edges of the attached mesh,
  16245. */
  16246. render(): void;
  16247. }
  16248. /**
  16249. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16250. */
  16251. export class LineEdgesRenderer extends EdgesRenderer {
  16252. /**
  16253. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16254. * @param source LineMesh used to generate edges
  16255. * @param epsilon not important (specified angle for edge detection)
  16256. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16257. */
  16258. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16259. /**
  16260. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16261. */
  16262. _generateEdgesLines(): void;
  16263. }
  16264. }
  16265. declare module "babylonjs/Rendering/renderingGroup" {
  16266. import { SmartArray } from "babylonjs/Misc/smartArray";
  16267. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16269. import { Nullable } from "babylonjs/types";
  16270. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16271. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16272. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16273. import { Material } from "babylonjs/Materials/material";
  16274. import { Scene } from "babylonjs/scene";
  16275. /**
  16276. * This represents the object necessary to create a rendering group.
  16277. * This is exclusively used and created by the rendering manager.
  16278. * To modify the behavior, you use the available helpers in your scene or meshes.
  16279. * @hidden
  16280. */
  16281. export class RenderingGroup {
  16282. index: number;
  16283. private static _zeroVector;
  16284. private _scene;
  16285. private _opaqueSubMeshes;
  16286. private _transparentSubMeshes;
  16287. private _alphaTestSubMeshes;
  16288. private _depthOnlySubMeshes;
  16289. private _particleSystems;
  16290. private _spriteManagers;
  16291. private _opaqueSortCompareFn;
  16292. private _alphaTestSortCompareFn;
  16293. private _transparentSortCompareFn;
  16294. private _renderOpaque;
  16295. private _renderAlphaTest;
  16296. private _renderTransparent;
  16297. /** @hidden */
  16298. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16299. onBeforeTransparentRendering: () => void;
  16300. /**
  16301. * Set the opaque sort comparison function.
  16302. * If null the sub meshes will be render in the order they were created
  16303. */
  16304. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16305. /**
  16306. * Set the alpha test sort comparison function.
  16307. * If null the sub meshes will be render in the order they were created
  16308. */
  16309. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16310. /**
  16311. * Set the transparent sort comparison function.
  16312. * If null the sub meshes will be render in the order they were created
  16313. */
  16314. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16315. /**
  16316. * Creates a new rendering group.
  16317. * @param index The rendering group index
  16318. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16319. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16320. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16321. */
  16322. 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>);
  16323. /**
  16324. * Render all the sub meshes contained in the group.
  16325. * @param customRenderFunction Used to override the default render behaviour of the group.
  16326. * @returns true if rendered some submeshes.
  16327. */
  16328. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16329. /**
  16330. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16331. * @param subMeshes The submeshes to render
  16332. */
  16333. private renderOpaqueSorted;
  16334. /**
  16335. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16336. * @param subMeshes The submeshes to render
  16337. */
  16338. private renderAlphaTestSorted;
  16339. /**
  16340. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16341. * @param subMeshes The submeshes to render
  16342. */
  16343. private renderTransparentSorted;
  16344. /**
  16345. * Renders the submeshes in a specified order.
  16346. * @param subMeshes The submeshes to sort before render
  16347. * @param sortCompareFn The comparison function use to sort
  16348. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16349. * @param transparent Specifies to activate blending if true
  16350. */
  16351. private static renderSorted;
  16352. /**
  16353. * Renders the submeshes in the order they were dispatched (no sort applied).
  16354. * @param subMeshes The submeshes to render
  16355. */
  16356. private static renderUnsorted;
  16357. /**
  16358. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16359. * are rendered back to front if in the same alpha index.
  16360. *
  16361. * @param a The first submesh
  16362. * @param b The second submesh
  16363. * @returns The result of the comparison
  16364. */
  16365. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16366. /**
  16367. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16368. * are rendered back to front.
  16369. *
  16370. * @param a The first submesh
  16371. * @param b The second submesh
  16372. * @returns The result of the comparison
  16373. */
  16374. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16375. /**
  16376. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16377. * are rendered front to back (prevent overdraw).
  16378. *
  16379. * @param a The first submesh
  16380. * @param b The second submesh
  16381. * @returns The result of the comparison
  16382. */
  16383. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16384. /**
  16385. * Resets the different lists of submeshes to prepare a new frame.
  16386. */
  16387. prepare(): void;
  16388. dispose(): void;
  16389. /**
  16390. * Inserts the submesh in its correct queue depending on its material.
  16391. * @param subMesh The submesh to dispatch
  16392. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16393. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16394. */
  16395. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16396. dispatchSprites(spriteManager: ISpriteManager): void;
  16397. dispatchParticles(particleSystem: IParticleSystem): void;
  16398. private _renderParticles;
  16399. private _renderSprites;
  16400. }
  16401. }
  16402. declare module "babylonjs/Rendering/renderingManager" {
  16403. import { Nullable } from "babylonjs/types";
  16404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16405. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16406. import { SmartArray } from "babylonjs/Misc/smartArray";
  16407. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16408. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16409. import { Material } from "babylonjs/Materials/material";
  16410. import { Scene } from "babylonjs/scene";
  16411. import { Camera } from "babylonjs/Cameras/camera";
  16412. /**
  16413. * Interface describing the different options available in the rendering manager
  16414. * regarding Auto Clear between groups.
  16415. */
  16416. export interface IRenderingManagerAutoClearSetup {
  16417. /**
  16418. * Defines whether or not autoclear is enable.
  16419. */
  16420. autoClear: boolean;
  16421. /**
  16422. * Defines whether or not to autoclear the depth buffer.
  16423. */
  16424. depth: boolean;
  16425. /**
  16426. * Defines whether or not to autoclear the stencil buffer.
  16427. */
  16428. stencil: boolean;
  16429. }
  16430. /**
  16431. * This class is used by the onRenderingGroupObservable
  16432. */
  16433. export class RenderingGroupInfo {
  16434. /**
  16435. * The Scene that being rendered
  16436. */
  16437. scene: Scene;
  16438. /**
  16439. * The camera currently used for the rendering pass
  16440. */
  16441. camera: Nullable<Camera>;
  16442. /**
  16443. * The ID of the renderingGroup being processed
  16444. */
  16445. renderingGroupId: number;
  16446. }
  16447. /**
  16448. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16449. * It is enable to manage the different groups as well as the different necessary sort functions.
  16450. * This should not be used directly aside of the few static configurations
  16451. */
  16452. export class RenderingManager {
  16453. /**
  16454. * The max id used for rendering groups (not included)
  16455. */
  16456. static MAX_RENDERINGGROUPS: number;
  16457. /**
  16458. * The min id used for rendering groups (included)
  16459. */
  16460. static MIN_RENDERINGGROUPS: number;
  16461. /**
  16462. * Used to globally prevent autoclearing scenes.
  16463. */
  16464. static AUTOCLEAR: boolean;
  16465. /**
  16466. * @hidden
  16467. */
  16468. _useSceneAutoClearSetup: boolean;
  16469. private _scene;
  16470. private _renderingGroups;
  16471. private _depthStencilBufferAlreadyCleaned;
  16472. private _autoClearDepthStencil;
  16473. private _customOpaqueSortCompareFn;
  16474. private _customAlphaTestSortCompareFn;
  16475. private _customTransparentSortCompareFn;
  16476. private _renderingGroupInfo;
  16477. /**
  16478. * Instantiates a new rendering group for a particular scene
  16479. * @param scene Defines the scene the groups belongs to
  16480. */
  16481. constructor(scene: Scene);
  16482. private _clearDepthStencilBuffer;
  16483. /**
  16484. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16485. * @hidden
  16486. */
  16487. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16488. /**
  16489. * Resets the different information of the group to prepare a new frame
  16490. * @hidden
  16491. */
  16492. reset(): void;
  16493. /**
  16494. * Dispose and release the group and its associated resources.
  16495. * @hidden
  16496. */
  16497. dispose(): void;
  16498. /**
  16499. * Clear the info related to rendering groups preventing retention points during dispose.
  16500. */
  16501. freeRenderingGroups(): void;
  16502. private _prepareRenderingGroup;
  16503. /**
  16504. * Add a sprite manager to the rendering manager in order to render it this frame.
  16505. * @param spriteManager Define the sprite manager to render
  16506. */
  16507. dispatchSprites(spriteManager: ISpriteManager): void;
  16508. /**
  16509. * Add a particle system to the rendering manager in order to render it this frame.
  16510. * @param particleSystem Define the particle system to render
  16511. */
  16512. dispatchParticles(particleSystem: IParticleSystem): void;
  16513. /**
  16514. * Add a submesh to the manager in order to render it this frame
  16515. * @param subMesh The submesh to dispatch
  16516. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16517. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16518. */
  16519. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16520. /**
  16521. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16522. * This allowed control for front to back rendering or reversly depending of the special needs.
  16523. *
  16524. * @param renderingGroupId The rendering group id corresponding to its index
  16525. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16526. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16527. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16528. */
  16529. 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;
  16530. /**
  16531. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16532. *
  16533. * @param renderingGroupId The rendering group id corresponding to its index
  16534. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16535. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16536. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16537. */
  16538. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16539. /**
  16540. * Gets the current auto clear configuration for one rendering group of the rendering
  16541. * manager.
  16542. * @param index the rendering group index to get the information for
  16543. * @returns The auto clear setup for the requested rendering group
  16544. */
  16545. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16546. }
  16547. }
  16548. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16549. import { SmartArray } from "babylonjs/Misc/smartArray";
  16550. import { Nullable } from "babylonjs/types";
  16551. import { Scene } from "babylonjs/scene";
  16552. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16555. import { Mesh } from "babylonjs/Meshes/mesh";
  16556. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16557. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16558. import { Effect } from "babylonjs/Materials/effect";
  16559. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16561. import "babylonjs/Shaders/shadowMap.fragment";
  16562. import "babylonjs/Shaders/shadowMap.vertex";
  16563. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16564. import { Observable } from "babylonjs/Misc/observable";
  16565. /**
  16566. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16567. */
  16568. export interface ICustomShaderOptions {
  16569. /**
  16570. * Gets or sets the custom shader name to use
  16571. */
  16572. shaderName: string;
  16573. /**
  16574. * The list of attribute names used in the shader
  16575. */
  16576. attributes?: string[];
  16577. /**
  16578. * The list of unifrom names used in the shader
  16579. */
  16580. uniforms?: string[];
  16581. /**
  16582. * The list of sampler names used in the shader
  16583. */
  16584. samplers?: string[];
  16585. /**
  16586. * The list of defines used in the shader
  16587. */
  16588. defines?: string[];
  16589. }
  16590. /**
  16591. * Interface to implement to create a shadow generator compatible with BJS.
  16592. */
  16593. export interface IShadowGenerator {
  16594. /**
  16595. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16596. * @returns The render target texture if present otherwise, null
  16597. */
  16598. getShadowMap(): Nullable<RenderTargetTexture>;
  16599. /**
  16600. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16601. * @param subMesh The submesh we want to render in the shadow map
  16602. * @param useInstances Defines wether will draw in the map using instances
  16603. * @returns true if ready otherwise, false
  16604. */
  16605. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16606. /**
  16607. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16608. * @param defines Defines of the material we want to update
  16609. * @param lightIndex Index of the light in the enabled light list of the material
  16610. */
  16611. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16612. /**
  16613. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16614. * defined in the generator but impacting the effect).
  16615. * It implies the unifroms available on the materials are the standard BJS ones.
  16616. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16617. * @param effect The effect we are binfing the information for
  16618. */
  16619. bindShadowLight(lightIndex: string, effect: Effect): void;
  16620. /**
  16621. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16622. * (eq to shadow prjection matrix * light transform matrix)
  16623. * @returns The transform matrix used to create the shadow map
  16624. */
  16625. getTransformMatrix(): Matrix;
  16626. /**
  16627. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16628. * Cube and 2D textures for instance.
  16629. */
  16630. recreateShadowMap(): void;
  16631. /**
  16632. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16633. * @param onCompiled Callback triggered at the and of the effects compilation
  16634. * @param options Sets of optional options forcing the compilation with different modes
  16635. */
  16636. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16637. useInstances: boolean;
  16638. }>): void;
  16639. /**
  16640. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16641. * @param options Sets of optional options forcing the compilation with different modes
  16642. * @returns A promise that resolves when the compilation completes
  16643. */
  16644. forceCompilationAsync(options?: Partial<{
  16645. useInstances: boolean;
  16646. }>): Promise<void>;
  16647. /**
  16648. * Serializes the shadow generator setup to a json object.
  16649. * @returns The serialized JSON object
  16650. */
  16651. serialize(): any;
  16652. /**
  16653. * Disposes the Shadow map and related Textures and effects.
  16654. */
  16655. dispose(): void;
  16656. }
  16657. /**
  16658. * Default implementation IShadowGenerator.
  16659. * This is the main object responsible of generating shadows in the framework.
  16660. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16661. */
  16662. export class ShadowGenerator implements IShadowGenerator {
  16663. /**
  16664. * Name of the shadow generator class
  16665. */
  16666. static CLASSNAME: string;
  16667. /**
  16668. * Shadow generator mode None: no filtering applied.
  16669. */
  16670. static readonly FILTER_NONE: number;
  16671. /**
  16672. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16673. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16674. */
  16675. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16676. /**
  16677. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16678. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16679. */
  16680. static readonly FILTER_POISSONSAMPLING: number;
  16681. /**
  16682. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16683. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16684. */
  16685. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16686. /**
  16687. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16688. * edge artifacts on steep falloff.
  16689. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16690. */
  16691. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16692. /**
  16693. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16694. * edge artifacts on steep falloff.
  16695. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16696. */
  16697. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16698. /**
  16699. * Shadow generator mode PCF: Percentage Closer Filtering
  16700. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16701. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16702. */
  16703. static readonly FILTER_PCF: number;
  16704. /**
  16705. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16706. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16707. * Contact Hardening
  16708. */
  16709. static readonly FILTER_PCSS: number;
  16710. /**
  16711. * Reserved for PCF and PCSS
  16712. * Highest Quality.
  16713. *
  16714. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16715. *
  16716. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16717. */
  16718. static readonly QUALITY_HIGH: number;
  16719. /**
  16720. * Reserved for PCF and PCSS
  16721. * Good tradeoff for quality/perf cross devices
  16722. *
  16723. * Execute PCF on a 3*3 kernel.
  16724. *
  16725. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16726. */
  16727. static readonly QUALITY_MEDIUM: number;
  16728. /**
  16729. * Reserved for PCF and PCSS
  16730. * The lowest quality but the fastest.
  16731. *
  16732. * Execute PCF on a 1*1 kernel.
  16733. *
  16734. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16735. */
  16736. static readonly QUALITY_LOW: number;
  16737. /** Gets or sets the custom shader name to use */
  16738. customShaderOptions: ICustomShaderOptions;
  16739. /**
  16740. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16741. */
  16742. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16743. /**
  16744. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16745. */
  16746. onAfterShadowMapRenderObservable: Observable<Effect>;
  16747. /**
  16748. * Observable triggered before a mesh is rendered in the shadow map.
  16749. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16750. */
  16751. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16752. /**
  16753. * Observable triggered after a mesh is rendered in the shadow map.
  16754. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16755. */
  16756. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16757. protected _bias: number;
  16758. /**
  16759. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16760. */
  16761. get bias(): number;
  16762. /**
  16763. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16764. */
  16765. set bias(bias: number);
  16766. protected _normalBias: number;
  16767. /**
  16768. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16769. */
  16770. get normalBias(): number;
  16771. /**
  16772. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16773. */
  16774. set normalBias(normalBias: number);
  16775. protected _blurBoxOffset: number;
  16776. /**
  16777. * Gets the blur box offset: offset applied during the blur pass.
  16778. * Only useful if useKernelBlur = false
  16779. */
  16780. get blurBoxOffset(): number;
  16781. /**
  16782. * Sets the blur box offset: offset applied during the blur pass.
  16783. * Only useful if useKernelBlur = false
  16784. */
  16785. set blurBoxOffset(value: number);
  16786. protected _blurScale: number;
  16787. /**
  16788. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16789. * 2 means half of the size.
  16790. */
  16791. get blurScale(): number;
  16792. /**
  16793. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16794. * 2 means half of the size.
  16795. */
  16796. set blurScale(value: number);
  16797. protected _blurKernel: number;
  16798. /**
  16799. * Gets the blur kernel: kernel size of the blur pass.
  16800. * Only useful if useKernelBlur = true
  16801. */
  16802. get blurKernel(): number;
  16803. /**
  16804. * Sets the blur kernel: kernel size of the blur pass.
  16805. * Only useful if useKernelBlur = true
  16806. */
  16807. set blurKernel(value: number);
  16808. protected _useKernelBlur: boolean;
  16809. /**
  16810. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16811. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16812. */
  16813. get useKernelBlur(): boolean;
  16814. /**
  16815. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16816. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16817. */
  16818. set useKernelBlur(value: boolean);
  16819. protected _depthScale: number;
  16820. /**
  16821. * Gets the depth scale used in ESM mode.
  16822. */
  16823. get depthScale(): number;
  16824. /**
  16825. * Sets the depth scale used in ESM mode.
  16826. * This can override the scale stored on the light.
  16827. */
  16828. set depthScale(value: number);
  16829. protected _validateFilter(filter: number): number;
  16830. protected _filter: number;
  16831. /**
  16832. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16833. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16834. */
  16835. get filter(): number;
  16836. /**
  16837. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16838. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16839. */
  16840. set filter(value: number);
  16841. /**
  16842. * Gets if the current filter is set to Poisson Sampling.
  16843. */
  16844. get usePoissonSampling(): boolean;
  16845. /**
  16846. * Sets the current filter to Poisson Sampling.
  16847. */
  16848. set usePoissonSampling(value: boolean);
  16849. /**
  16850. * Gets if the current filter is set to ESM.
  16851. */
  16852. get useExponentialShadowMap(): boolean;
  16853. /**
  16854. * Sets the current filter is to ESM.
  16855. */
  16856. set useExponentialShadowMap(value: boolean);
  16857. /**
  16858. * Gets if the current filter is set to filtered ESM.
  16859. */
  16860. get useBlurExponentialShadowMap(): boolean;
  16861. /**
  16862. * Gets if the current filter is set to filtered ESM.
  16863. */
  16864. set useBlurExponentialShadowMap(value: boolean);
  16865. /**
  16866. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16867. * exponential to prevent steep falloff artifacts).
  16868. */
  16869. get useCloseExponentialShadowMap(): boolean;
  16870. /**
  16871. * Sets the current filter to "close ESM" (using the inverse of the
  16872. * exponential to prevent steep falloff artifacts).
  16873. */
  16874. set useCloseExponentialShadowMap(value: boolean);
  16875. /**
  16876. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16877. * exponential to prevent steep falloff artifacts).
  16878. */
  16879. get useBlurCloseExponentialShadowMap(): boolean;
  16880. /**
  16881. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16882. * exponential to prevent steep falloff artifacts).
  16883. */
  16884. set useBlurCloseExponentialShadowMap(value: boolean);
  16885. /**
  16886. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16887. */
  16888. get usePercentageCloserFiltering(): boolean;
  16889. /**
  16890. * Sets the current filter to "PCF" (percentage closer filtering).
  16891. */
  16892. set usePercentageCloserFiltering(value: boolean);
  16893. protected _filteringQuality: number;
  16894. /**
  16895. * Gets the PCF or PCSS Quality.
  16896. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16897. */
  16898. get filteringQuality(): number;
  16899. /**
  16900. * Sets the PCF or PCSS Quality.
  16901. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16902. */
  16903. set filteringQuality(filteringQuality: number);
  16904. /**
  16905. * Gets if the current filter is set to "PCSS" (contact hardening).
  16906. */
  16907. get useContactHardeningShadow(): boolean;
  16908. /**
  16909. * Sets the current filter to "PCSS" (contact hardening).
  16910. */
  16911. set useContactHardeningShadow(value: boolean);
  16912. protected _contactHardeningLightSizeUVRatio: number;
  16913. /**
  16914. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16915. * Using a ratio helps keeping shape stability independently of the map size.
  16916. *
  16917. * It does not account for the light projection as it was having too much
  16918. * instability during the light setup or during light position changes.
  16919. *
  16920. * Only valid if useContactHardeningShadow is true.
  16921. */
  16922. get contactHardeningLightSizeUVRatio(): number;
  16923. /**
  16924. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16925. * Using a ratio helps keeping shape stability independently of the map size.
  16926. *
  16927. * It does not account for the light projection as it was having too much
  16928. * instability during the light setup or during light position changes.
  16929. *
  16930. * Only valid if useContactHardeningShadow is true.
  16931. */
  16932. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16933. protected _darkness: number;
  16934. /** Gets or sets the actual darkness of a shadow */
  16935. get darkness(): number;
  16936. set darkness(value: number);
  16937. /**
  16938. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16939. * 0 means strongest and 1 would means no shadow.
  16940. * @returns the darkness.
  16941. */
  16942. getDarkness(): number;
  16943. /**
  16944. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16945. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16946. * @returns the shadow generator allowing fluent coding.
  16947. */
  16948. setDarkness(darkness: number): ShadowGenerator;
  16949. protected _transparencyShadow: boolean;
  16950. /** Gets or sets the ability to have transparent shadow */
  16951. get transparencyShadow(): boolean;
  16952. set transparencyShadow(value: boolean);
  16953. /**
  16954. * Sets the ability to have transparent shadow (boolean).
  16955. * @param transparent True if transparent else False
  16956. * @returns the shadow generator allowing fluent coding
  16957. */
  16958. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16959. protected _shadowMap: Nullable<RenderTargetTexture>;
  16960. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16961. /**
  16962. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16963. * @returns The render target texture if present otherwise, null
  16964. */
  16965. getShadowMap(): Nullable<RenderTargetTexture>;
  16966. /**
  16967. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16968. * @returns The render target texture if the shadow map is present otherwise, null
  16969. */
  16970. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16971. /**
  16972. * Gets the class name of that object
  16973. * @returns "ShadowGenerator"
  16974. */
  16975. getClassName(): string;
  16976. /**
  16977. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16978. * @param mesh Mesh to add
  16979. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16980. * @returns the Shadow Generator itself
  16981. */
  16982. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16983. /**
  16984. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16985. * @param mesh Mesh to remove
  16986. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16987. * @returns the Shadow Generator itself
  16988. */
  16989. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16990. /**
  16991. * Controls the extent to which the shadows fade out at the edge of the frustum
  16992. */
  16993. frustumEdgeFalloff: number;
  16994. protected _light: IShadowLight;
  16995. /**
  16996. * Returns the associated light object.
  16997. * @returns the light generating the shadow
  16998. */
  16999. getLight(): IShadowLight;
  17000. /**
  17001. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17002. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17003. * It might on the other hand introduce peter panning.
  17004. */
  17005. forceBackFacesOnly: boolean;
  17006. protected _scene: Scene;
  17007. protected _lightDirection: Vector3;
  17008. protected _effect: Effect;
  17009. protected _viewMatrix: Matrix;
  17010. protected _projectionMatrix: Matrix;
  17011. protected _transformMatrix: Matrix;
  17012. protected _cachedPosition: Vector3;
  17013. protected _cachedDirection: Vector3;
  17014. protected _cachedDefines: string;
  17015. protected _currentRenderID: number;
  17016. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17017. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17018. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17019. protected _blurPostProcesses: PostProcess[];
  17020. protected _mapSize: number;
  17021. protected _currentFaceIndex: number;
  17022. protected _currentFaceIndexCache: number;
  17023. protected _textureType: number;
  17024. protected _defaultTextureMatrix: Matrix;
  17025. protected _storedUniqueId: Nullable<number>;
  17026. /** @hidden */
  17027. static _SceneComponentInitialization: (scene: Scene) => void;
  17028. /**
  17029. * Creates a ShadowGenerator object.
  17030. * A ShadowGenerator is the required tool to use the shadows.
  17031. * Each light casting shadows needs to use its own ShadowGenerator.
  17032. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17033. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17034. * @param light The light object generating the shadows.
  17035. * @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.
  17036. */
  17037. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17038. protected _initializeGenerator(): void;
  17039. protected _createTargetRenderTexture(): void;
  17040. protected _initializeShadowMap(): void;
  17041. protected _initializeBlurRTTAndPostProcesses(): void;
  17042. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17043. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17044. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17045. protected _applyFilterValues(): void;
  17046. /**
  17047. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17048. * @param onCompiled Callback triggered at the and of the effects compilation
  17049. * @param options Sets of optional options forcing the compilation with different modes
  17050. */
  17051. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17052. useInstances: boolean;
  17053. }>): void;
  17054. /**
  17055. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17056. * @param options Sets of optional options forcing the compilation with different modes
  17057. * @returns A promise that resolves when the compilation completes
  17058. */
  17059. forceCompilationAsync(options?: Partial<{
  17060. useInstances: boolean;
  17061. }>): Promise<void>;
  17062. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17063. /**
  17064. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17065. * @param subMesh The submesh we want to render in the shadow map
  17066. * @param useInstances Defines wether will draw in the map using instances
  17067. * @returns true if ready otherwise, false
  17068. */
  17069. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17070. /**
  17071. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17072. * @param defines Defines of the material we want to update
  17073. * @param lightIndex Index of the light in the enabled light list of the material
  17074. */
  17075. prepareDefines(defines: any, lightIndex: number): void;
  17076. /**
  17077. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17078. * defined in the generator but impacting the effect).
  17079. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17080. * @param effect The effect we are binfing the information for
  17081. */
  17082. bindShadowLight(lightIndex: string, effect: Effect): void;
  17083. /**
  17084. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17085. * (eq to shadow prjection matrix * light transform matrix)
  17086. * @returns The transform matrix used to create the shadow map
  17087. */
  17088. getTransformMatrix(): Matrix;
  17089. /**
  17090. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17091. * Cube and 2D textures for instance.
  17092. */
  17093. recreateShadowMap(): void;
  17094. protected _disposeBlurPostProcesses(): void;
  17095. protected _disposeRTTandPostProcesses(): void;
  17096. /**
  17097. * Disposes the ShadowGenerator.
  17098. * Returns nothing.
  17099. */
  17100. dispose(): void;
  17101. /**
  17102. * Serializes the shadow generator setup to a json object.
  17103. * @returns The serialized JSON object
  17104. */
  17105. serialize(): any;
  17106. /**
  17107. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17108. * @param parsedShadowGenerator The JSON object to parse
  17109. * @param scene The scene to create the shadow map for
  17110. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17111. * @returns The parsed shadow generator
  17112. */
  17113. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17114. }
  17115. }
  17116. declare module "babylonjs/Lights/light" {
  17117. import { Nullable } from "babylonjs/types";
  17118. import { Scene } from "babylonjs/scene";
  17119. import { Vector3 } from "babylonjs/Maths/math.vector";
  17120. import { Color3 } from "babylonjs/Maths/math.color";
  17121. import { Node } from "babylonjs/node";
  17122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17123. import { Effect } from "babylonjs/Materials/effect";
  17124. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17125. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17126. /**
  17127. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17128. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17129. * 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.
  17130. */
  17131. export abstract class Light extends Node {
  17132. /**
  17133. * Falloff Default: light is falling off following the material specification:
  17134. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17135. */
  17136. static readonly FALLOFF_DEFAULT: number;
  17137. /**
  17138. * Falloff Physical: light is falling off following the inverse squared distance law.
  17139. */
  17140. static readonly FALLOFF_PHYSICAL: number;
  17141. /**
  17142. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17143. * to enhance interoperability with other engines.
  17144. */
  17145. static readonly FALLOFF_GLTF: number;
  17146. /**
  17147. * Falloff Standard: light is falling off like in the standard material
  17148. * to enhance interoperability with other materials.
  17149. */
  17150. static readonly FALLOFF_STANDARD: number;
  17151. /**
  17152. * If every light affecting the material is in this lightmapMode,
  17153. * material.lightmapTexture adds or multiplies
  17154. * (depends on material.useLightmapAsShadowmap)
  17155. * after every other light calculations.
  17156. */
  17157. static readonly LIGHTMAP_DEFAULT: number;
  17158. /**
  17159. * material.lightmapTexture as only diffuse lighting from this light
  17160. * adds only specular lighting from this light
  17161. * adds dynamic shadows
  17162. */
  17163. static readonly LIGHTMAP_SPECULAR: number;
  17164. /**
  17165. * material.lightmapTexture as only lighting
  17166. * no light calculation from this light
  17167. * only adds dynamic shadows from this light
  17168. */
  17169. static readonly LIGHTMAP_SHADOWSONLY: number;
  17170. /**
  17171. * Each light type uses the default quantity according to its type:
  17172. * point/spot lights use luminous intensity
  17173. * directional lights use illuminance
  17174. */
  17175. static readonly INTENSITYMODE_AUTOMATIC: number;
  17176. /**
  17177. * lumen (lm)
  17178. */
  17179. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17180. /**
  17181. * candela (lm/sr)
  17182. */
  17183. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17184. /**
  17185. * lux (lm/m^2)
  17186. */
  17187. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17188. /**
  17189. * nit (cd/m^2)
  17190. */
  17191. static readonly INTENSITYMODE_LUMINANCE: number;
  17192. /**
  17193. * Light type const id of the point light.
  17194. */
  17195. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17196. /**
  17197. * Light type const id of the directional light.
  17198. */
  17199. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17200. /**
  17201. * Light type const id of the spot light.
  17202. */
  17203. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17204. /**
  17205. * Light type const id of the hemispheric light.
  17206. */
  17207. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17208. /**
  17209. * Diffuse gives the basic color to an object.
  17210. */
  17211. diffuse: Color3;
  17212. /**
  17213. * Specular produces a highlight color on an object.
  17214. * Note: This is note affecting PBR materials.
  17215. */
  17216. specular: Color3;
  17217. /**
  17218. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17219. * falling off base on range or angle.
  17220. * This can be set to any values in Light.FALLOFF_x.
  17221. *
  17222. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17223. * other types of materials.
  17224. */
  17225. falloffType: number;
  17226. /**
  17227. * Strength of the light.
  17228. * Note: By default it is define in the framework own unit.
  17229. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17230. */
  17231. intensity: number;
  17232. private _range;
  17233. protected _inverseSquaredRange: number;
  17234. /**
  17235. * Defines how far from the source the light is impacting in scene units.
  17236. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17237. */
  17238. get range(): number;
  17239. /**
  17240. * Defines how far from the source the light is impacting in scene units.
  17241. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17242. */
  17243. set range(value: number);
  17244. /**
  17245. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17246. * of light.
  17247. */
  17248. private _photometricScale;
  17249. private _intensityMode;
  17250. /**
  17251. * Gets the photometric scale used to interpret the intensity.
  17252. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17253. */
  17254. get intensityMode(): number;
  17255. /**
  17256. * Sets the photometric scale used to interpret the intensity.
  17257. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17258. */
  17259. set intensityMode(value: number);
  17260. private _radius;
  17261. /**
  17262. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17263. */
  17264. get radius(): number;
  17265. /**
  17266. * sets the light radius used by PBR Materials to simulate soft area lights.
  17267. */
  17268. set radius(value: number);
  17269. private _renderPriority;
  17270. /**
  17271. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17272. * exceeding the number allowed of the materials.
  17273. */
  17274. renderPriority: number;
  17275. private _shadowEnabled;
  17276. /**
  17277. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17278. * the current shadow generator.
  17279. */
  17280. get shadowEnabled(): boolean;
  17281. /**
  17282. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17283. * the current shadow generator.
  17284. */
  17285. set shadowEnabled(value: boolean);
  17286. private _includedOnlyMeshes;
  17287. /**
  17288. * Gets the only meshes impacted by this light.
  17289. */
  17290. get includedOnlyMeshes(): AbstractMesh[];
  17291. /**
  17292. * Sets the only meshes impacted by this light.
  17293. */
  17294. set includedOnlyMeshes(value: AbstractMesh[]);
  17295. private _excludedMeshes;
  17296. /**
  17297. * Gets the meshes not impacted by this light.
  17298. */
  17299. get excludedMeshes(): AbstractMesh[];
  17300. /**
  17301. * Sets the meshes not impacted by this light.
  17302. */
  17303. set excludedMeshes(value: AbstractMesh[]);
  17304. private _excludeWithLayerMask;
  17305. /**
  17306. * Gets the layer id use to find what meshes are not impacted by the light.
  17307. * Inactive if 0
  17308. */
  17309. get excludeWithLayerMask(): number;
  17310. /**
  17311. * Sets the layer id use to find what meshes are not impacted by the light.
  17312. * Inactive if 0
  17313. */
  17314. set excludeWithLayerMask(value: number);
  17315. private _includeOnlyWithLayerMask;
  17316. /**
  17317. * Gets the layer id use to find what meshes are impacted by the light.
  17318. * Inactive if 0
  17319. */
  17320. get includeOnlyWithLayerMask(): number;
  17321. /**
  17322. * Sets the layer id use to find what meshes are impacted by the light.
  17323. * Inactive if 0
  17324. */
  17325. set includeOnlyWithLayerMask(value: number);
  17326. private _lightmapMode;
  17327. /**
  17328. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17329. */
  17330. get lightmapMode(): number;
  17331. /**
  17332. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17333. */
  17334. set lightmapMode(value: number);
  17335. /**
  17336. * Shadow generator associted to the light.
  17337. * @hidden Internal use only.
  17338. */
  17339. _shadowGenerator: Nullable<IShadowGenerator>;
  17340. /**
  17341. * @hidden Internal use only.
  17342. */
  17343. _excludedMeshesIds: string[];
  17344. /**
  17345. * @hidden Internal use only.
  17346. */
  17347. _includedOnlyMeshesIds: string[];
  17348. /**
  17349. * The current light unifom buffer.
  17350. * @hidden Internal use only.
  17351. */
  17352. _uniformBuffer: UniformBuffer;
  17353. /** @hidden */
  17354. _renderId: number;
  17355. /**
  17356. * Creates a Light object in the scene.
  17357. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17358. * @param name The firendly name of the light
  17359. * @param scene The scene the light belongs too
  17360. */
  17361. constructor(name: string, scene: Scene);
  17362. protected abstract _buildUniformLayout(): void;
  17363. /**
  17364. * Sets the passed Effect "effect" with the Light information.
  17365. * @param effect The effect to update
  17366. * @param lightIndex The index of the light in the effect to update
  17367. * @returns The light
  17368. */
  17369. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17370. /**
  17371. * Sets the passed Effect "effect" with the Light textures.
  17372. * @param effect The effect to update
  17373. * @param lightIndex The index of the light in the effect to update
  17374. * @returns The light
  17375. */
  17376. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17377. /**
  17378. * Binds the lights information from the scene to the effect for the given mesh.
  17379. * @param lightIndex Light index
  17380. * @param scene The scene where the light belongs to
  17381. * @param effect The effect we are binding the data to
  17382. * @param useSpecular Defines if specular is supported
  17383. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17384. */
  17385. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17386. /**
  17387. * Sets the passed Effect "effect" with the Light information.
  17388. * @param effect The effect to update
  17389. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17390. * @returns The light
  17391. */
  17392. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17393. /**
  17394. * Returns the string "Light".
  17395. * @returns the class name
  17396. */
  17397. getClassName(): string;
  17398. /** @hidden */
  17399. readonly _isLight: boolean;
  17400. /**
  17401. * Converts the light information to a readable string for debug purpose.
  17402. * @param fullDetails Supports for multiple levels of logging within scene loading
  17403. * @returns the human readable light info
  17404. */
  17405. toString(fullDetails?: boolean): string;
  17406. /** @hidden */
  17407. protected _syncParentEnabledState(): void;
  17408. /**
  17409. * Set the enabled state of this node.
  17410. * @param value - the new enabled state
  17411. */
  17412. setEnabled(value: boolean): void;
  17413. /**
  17414. * Returns the Light associated shadow generator if any.
  17415. * @return the associated shadow generator.
  17416. */
  17417. getShadowGenerator(): Nullable<IShadowGenerator>;
  17418. /**
  17419. * Returns a Vector3, the absolute light position in the World.
  17420. * @returns the world space position of the light
  17421. */
  17422. getAbsolutePosition(): Vector3;
  17423. /**
  17424. * Specifies if the light will affect the passed mesh.
  17425. * @param mesh The mesh to test against the light
  17426. * @return true the mesh is affected otherwise, false.
  17427. */
  17428. canAffectMesh(mesh: AbstractMesh): boolean;
  17429. /**
  17430. * Sort function to order lights for rendering.
  17431. * @param a First Light object to compare to second.
  17432. * @param b Second Light object to compare first.
  17433. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17434. */
  17435. static CompareLightsPriority(a: Light, b: Light): number;
  17436. /**
  17437. * Releases resources associated with this node.
  17438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17440. */
  17441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17442. /**
  17443. * Returns the light type ID (integer).
  17444. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17445. */
  17446. getTypeID(): number;
  17447. /**
  17448. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17449. * @returns the scaled intensity in intensity mode unit
  17450. */
  17451. getScaledIntensity(): number;
  17452. /**
  17453. * Returns a new Light object, named "name", from the current one.
  17454. * @param name The name of the cloned light
  17455. * @returns the new created light
  17456. */
  17457. clone(name: string): Nullable<Light>;
  17458. /**
  17459. * Serializes the current light into a Serialization object.
  17460. * @returns the serialized object.
  17461. */
  17462. serialize(): any;
  17463. /**
  17464. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17465. * This new light is named "name" and added to the passed scene.
  17466. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17467. * @param name The friendly name of the light
  17468. * @param scene The scene the new light will belong to
  17469. * @returns the constructor function
  17470. */
  17471. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17472. /**
  17473. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17474. * @param parsedLight The JSON representation of the light
  17475. * @param scene The scene to create the parsed light in
  17476. * @returns the created light after parsing
  17477. */
  17478. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17479. private _hookArrayForExcluded;
  17480. private _hookArrayForIncludedOnly;
  17481. private _resyncMeshes;
  17482. /**
  17483. * Forces the meshes to update their light related information in their rendering used effects
  17484. * @hidden Internal Use Only
  17485. */
  17486. _markMeshesAsLightDirty(): void;
  17487. /**
  17488. * Recomputes the cached photometric scale if needed.
  17489. */
  17490. private _computePhotometricScale;
  17491. /**
  17492. * Returns the Photometric Scale according to the light type and intensity mode.
  17493. */
  17494. private _getPhotometricScale;
  17495. /**
  17496. * Reorder the light in the scene according to their defined priority.
  17497. * @hidden Internal Use Only
  17498. */
  17499. _reorderLightsInScene(): void;
  17500. /**
  17501. * Prepares the list of defines specific to the light type.
  17502. * @param defines the list of defines
  17503. * @param lightIndex defines the index of the light for the effect
  17504. */
  17505. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17506. }
  17507. }
  17508. declare module "babylonjs/Actions/action" {
  17509. import { Observable } from "babylonjs/Misc/observable";
  17510. import { Condition } from "babylonjs/Actions/condition";
  17511. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17512. import { ActionManager } from "babylonjs/Actions/actionManager";
  17513. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17514. /**
  17515. * Interface used to define Action
  17516. */
  17517. export interface IAction {
  17518. /**
  17519. * Trigger for the action
  17520. */
  17521. trigger: number;
  17522. /** Options of the trigger */
  17523. triggerOptions: any;
  17524. /**
  17525. * Gets the trigger parameters
  17526. * @returns the trigger parameters
  17527. */
  17528. getTriggerParameter(): any;
  17529. /**
  17530. * Internal only - executes current action event
  17531. * @hidden
  17532. */
  17533. _executeCurrent(evt?: ActionEvent): void;
  17534. /**
  17535. * Serialize placeholder for child classes
  17536. * @param parent of child
  17537. * @returns the serialized object
  17538. */
  17539. serialize(parent: any): any;
  17540. /**
  17541. * Internal only
  17542. * @hidden
  17543. */
  17544. _prepare(): void;
  17545. /**
  17546. * Internal only - manager for action
  17547. * @hidden
  17548. */
  17549. _actionManager: AbstractActionManager;
  17550. /**
  17551. * Adds action to chain of actions, may be a DoNothingAction
  17552. * @param action defines the next action to execute
  17553. * @returns The action passed in
  17554. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17555. */
  17556. then(action: IAction): IAction;
  17557. }
  17558. /**
  17559. * The action to be carried out following a trigger
  17560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17561. */
  17562. export class Action implements IAction {
  17563. /** the trigger, with or without parameters, for the action */
  17564. triggerOptions: any;
  17565. /**
  17566. * Trigger for the action
  17567. */
  17568. trigger: number;
  17569. /**
  17570. * Internal only - manager for action
  17571. * @hidden
  17572. */
  17573. _actionManager: ActionManager;
  17574. private _nextActiveAction;
  17575. private _child;
  17576. private _condition?;
  17577. private _triggerParameter;
  17578. /**
  17579. * An event triggered prior to action being executed.
  17580. */
  17581. onBeforeExecuteObservable: Observable<Action>;
  17582. /**
  17583. * Creates a new Action
  17584. * @param triggerOptions the trigger, with or without parameters, for the action
  17585. * @param condition an optional determinant of action
  17586. */
  17587. constructor(
  17588. /** the trigger, with or without parameters, for the action */
  17589. triggerOptions: any, condition?: Condition);
  17590. /**
  17591. * Internal only
  17592. * @hidden
  17593. */
  17594. _prepare(): void;
  17595. /**
  17596. * Gets the trigger parameters
  17597. * @returns the trigger parameters
  17598. */
  17599. getTriggerParameter(): any;
  17600. /**
  17601. * Internal only - executes current action event
  17602. * @hidden
  17603. */
  17604. _executeCurrent(evt?: ActionEvent): void;
  17605. /**
  17606. * Execute placeholder for child classes
  17607. * @param evt optional action event
  17608. */
  17609. execute(evt?: ActionEvent): void;
  17610. /**
  17611. * Skips to next active action
  17612. */
  17613. skipToNextActiveAction(): void;
  17614. /**
  17615. * Adds action to chain of actions, may be a DoNothingAction
  17616. * @param action defines the next action to execute
  17617. * @returns The action passed in
  17618. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17619. */
  17620. then(action: Action): Action;
  17621. /**
  17622. * Internal only
  17623. * @hidden
  17624. */
  17625. _getProperty(propertyPath: string): string;
  17626. /**
  17627. * Internal only
  17628. * @hidden
  17629. */
  17630. _getEffectiveTarget(target: any, propertyPath: string): any;
  17631. /**
  17632. * Serialize placeholder for child classes
  17633. * @param parent of child
  17634. * @returns the serialized object
  17635. */
  17636. serialize(parent: any): any;
  17637. /**
  17638. * Internal only called by serialize
  17639. * @hidden
  17640. */
  17641. protected _serialize(serializedAction: any, parent?: any): any;
  17642. /**
  17643. * Internal only
  17644. * @hidden
  17645. */
  17646. static _SerializeValueAsString: (value: any) => string;
  17647. /**
  17648. * Internal only
  17649. * @hidden
  17650. */
  17651. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17652. name: string;
  17653. targetType: string;
  17654. value: string;
  17655. };
  17656. }
  17657. }
  17658. declare module "babylonjs/Actions/condition" {
  17659. import { ActionManager } from "babylonjs/Actions/actionManager";
  17660. /**
  17661. * A Condition applied to an Action
  17662. */
  17663. export class Condition {
  17664. /**
  17665. * Internal only - manager for action
  17666. * @hidden
  17667. */
  17668. _actionManager: ActionManager;
  17669. /**
  17670. * Internal only
  17671. * @hidden
  17672. */
  17673. _evaluationId: number;
  17674. /**
  17675. * Internal only
  17676. * @hidden
  17677. */
  17678. _currentResult: boolean;
  17679. /**
  17680. * Creates a new Condition
  17681. * @param actionManager the manager of the action the condition is applied to
  17682. */
  17683. constructor(actionManager: ActionManager);
  17684. /**
  17685. * Check if the current condition is valid
  17686. * @returns a boolean
  17687. */
  17688. isValid(): boolean;
  17689. /**
  17690. * Internal only
  17691. * @hidden
  17692. */
  17693. _getProperty(propertyPath: string): string;
  17694. /**
  17695. * Internal only
  17696. * @hidden
  17697. */
  17698. _getEffectiveTarget(target: any, propertyPath: string): any;
  17699. /**
  17700. * Serialize placeholder for child classes
  17701. * @returns the serialized object
  17702. */
  17703. serialize(): any;
  17704. /**
  17705. * Internal only
  17706. * @hidden
  17707. */
  17708. protected _serialize(serializedCondition: any): any;
  17709. }
  17710. /**
  17711. * Defines specific conditional operators as extensions of Condition
  17712. */
  17713. export class ValueCondition extends Condition {
  17714. /** path to specify the property of the target the conditional operator uses */
  17715. propertyPath: string;
  17716. /** the value compared by the conditional operator against the current value of the property */
  17717. value: any;
  17718. /** the conditional operator, default ValueCondition.IsEqual */
  17719. operator: number;
  17720. /**
  17721. * Internal only
  17722. * @hidden
  17723. */
  17724. private static _IsEqual;
  17725. /**
  17726. * Internal only
  17727. * @hidden
  17728. */
  17729. private static _IsDifferent;
  17730. /**
  17731. * Internal only
  17732. * @hidden
  17733. */
  17734. private static _IsGreater;
  17735. /**
  17736. * Internal only
  17737. * @hidden
  17738. */
  17739. private static _IsLesser;
  17740. /**
  17741. * returns the number for IsEqual
  17742. */
  17743. static get IsEqual(): number;
  17744. /**
  17745. * Returns the number for IsDifferent
  17746. */
  17747. static get IsDifferent(): number;
  17748. /**
  17749. * Returns the number for IsGreater
  17750. */
  17751. static get IsGreater(): number;
  17752. /**
  17753. * Returns the number for IsLesser
  17754. */
  17755. static get IsLesser(): number;
  17756. /**
  17757. * Internal only The action manager for the condition
  17758. * @hidden
  17759. */
  17760. _actionManager: ActionManager;
  17761. /**
  17762. * Internal only
  17763. * @hidden
  17764. */
  17765. private _target;
  17766. /**
  17767. * Internal only
  17768. * @hidden
  17769. */
  17770. private _effectiveTarget;
  17771. /**
  17772. * Internal only
  17773. * @hidden
  17774. */
  17775. private _property;
  17776. /**
  17777. * Creates a new ValueCondition
  17778. * @param actionManager manager for the action the condition applies to
  17779. * @param target for the action
  17780. * @param propertyPath path to specify the property of the target the conditional operator uses
  17781. * @param value the value compared by the conditional operator against the current value of the property
  17782. * @param operator the conditional operator, default ValueCondition.IsEqual
  17783. */
  17784. constructor(actionManager: ActionManager, target: any,
  17785. /** path to specify the property of the target the conditional operator uses */
  17786. propertyPath: string,
  17787. /** the value compared by the conditional operator against the current value of the property */
  17788. value: any,
  17789. /** the conditional operator, default ValueCondition.IsEqual */
  17790. operator?: number);
  17791. /**
  17792. * Compares the given value with the property value for the specified conditional operator
  17793. * @returns the result of the comparison
  17794. */
  17795. isValid(): boolean;
  17796. /**
  17797. * Serialize the ValueCondition into a JSON compatible object
  17798. * @returns serialization object
  17799. */
  17800. serialize(): any;
  17801. /**
  17802. * Gets the name of the conditional operator for the ValueCondition
  17803. * @param operator the conditional operator
  17804. * @returns the name
  17805. */
  17806. static GetOperatorName(operator: number): string;
  17807. }
  17808. /**
  17809. * Defines a predicate condition as an extension of Condition
  17810. */
  17811. export class PredicateCondition extends Condition {
  17812. /** defines the predicate function used to validate the condition */
  17813. predicate: () => boolean;
  17814. /**
  17815. * Internal only - manager for action
  17816. * @hidden
  17817. */
  17818. _actionManager: ActionManager;
  17819. /**
  17820. * Creates a new PredicateCondition
  17821. * @param actionManager manager for the action the condition applies to
  17822. * @param predicate defines the predicate function used to validate the condition
  17823. */
  17824. constructor(actionManager: ActionManager,
  17825. /** defines the predicate function used to validate the condition */
  17826. predicate: () => boolean);
  17827. /**
  17828. * @returns the validity of the predicate condition
  17829. */
  17830. isValid(): boolean;
  17831. }
  17832. /**
  17833. * Defines a state condition as an extension of Condition
  17834. */
  17835. export class StateCondition extends Condition {
  17836. /** Value to compare with target state */
  17837. value: string;
  17838. /**
  17839. * Internal only - manager for action
  17840. * @hidden
  17841. */
  17842. _actionManager: ActionManager;
  17843. /**
  17844. * Internal only
  17845. * @hidden
  17846. */
  17847. private _target;
  17848. /**
  17849. * Creates a new StateCondition
  17850. * @param actionManager manager for the action the condition applies to
  17851. * @param target of the condition
  17852. * @param value to compare with target state
  17853. */
  17854. constructor(actionManager: ActionManager, target: any,
  17855. /** Value to compare with target state */
  17856. value: string);
  17857. /**
  17858. * Gets a boolean indicating if the current condition is met
  17859. * @returns the validity of the state
  17860. */
  17861. isValid(): boolean;
  17862. /**
  17863. * Serialize the StateCondition into a JSON compatible object
  17864. * @returns serialization object
  17865. */
  17866. serialize(): any;
  17867. }
  17868. }
  17869. declare module "babylonjs/Actions/directActions" {
  17870. import { Action } from "babylonjs/Actions/action";
  17871. import { Condition } from "babylonjs/Actions/condition";
  17872. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17873. /**
  17874. * This defines an action responsible to toggle a boolean once triggered.
  17875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17876. */
  17877. export class SwitchBooleanAction extends Action {
  17878. /**
  17879. * The path to the boolean property in the target object
  17880. */
  17881. propertyPath: string;
  17882. private _target;
  17883. private _effectiveTarget;
  17884. private _property;
  17885. /**
  17886. * Instantiate the action
  17887. * @param triggerOptions defines the trigger options
  17888. * @param target defines the object containing the boolean
  17889. * @param propertyPath defines the path to the boolean property in the target object
  17890. * @param condition defines the trigger related conditions
  17891. */
  17892. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17893. /** @hidden */
  17894. _prepare(): void;
  17895. /**
  17896. * Execute the action toggle the boolean value.
  17897. */
  17898. execute(): void;
  17899. /**
  17900. * Serializes the actions and its related information.
  17901. * @param parent defines the object to serialize in
  17902. * @returns the serialized object
  17903. */
  17904. serialize(parent: any): any;
  17905. }
  17906. /**
  17907. * This defines an action responsible to set a the state field of the target
  17908. * to a desired value once triggered.
  17909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17910. */
  17911. export class SetStateAction extends Action {
  17912. /**
  17913. * The value to store in the state field.
  17914. */
  17915. value: string;
  17916. private _target;
  17917. /**
  17918. * Instantiate the action
  17919. * @param triggerOptions defines the trigger options
  17920. * @param target defines the object containing the state property
  17921. * @param value defines the value to store in the state field
  17922. * @param condition defines the trigger related conditions
  17923. */
  17924. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17925. /**
  17926. * Execute the action and store the value on the target state property.
  17927. */
  17928. execute(): void;
  17929. /**
  17930. * Serializes the actions and its related information.
  17931. * @param parent defines the object to serialize in
  17932. * @returns the serialized object
  17933. */
  17934. serialize(parent: any): any;
  17935. }
  17936. /**
  17937. * This defines an action responsible to set a property of the target
  17938. * to a desired value once triggered.
  17939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17940. */
  17941. export class SetValueAction extends Action {
  17942. /**
  17943. * The path of the property to set in the target.
  17944. */
  17945. propertyPath: string;
  17946. /**
  17947. * The value to set in the property
  17948. */
  17949. value: any;
  17950. private _target;
  17951. private _effectiveTarget;
  17952. private _property;
  17953. /**
  17954. * Instantiate the action
  17955. * @param triggerOptions defines the trigger options
  17956. * @param target defines the object containing the property
  17957. * @param propertyPath defines the path of the property to set in the target
  17958. * @param value defines the value to set in the property
  17959. * @param condition defines the trigger related conditions
  17960. */
  17961. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17962. /** @hidden */
  17963. _prepare(): void;
  17964. /**
  17965. * Execute the action and set the targetted property to the desired value.
  17966. */
  17967. execute(): void;
  17968. /**
  17969. * Serializes the actions and its related information.
  17970. * @param parent defines the object to serialize in
  17971. * @returns the serialized object
  17972. */
  17973. serialize(parent: any): any;
  17974. }
  17975. /**
  17976. * This defines an action responsible to increment the target value
  17977. * to a desired value once triggered.
  17978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17979. */
  17980. export class IncrementValueAction extends Action {
  17981. /**
  17982. * The path of the property to increment in the target.
  17983. */
  17984. propertyPath: string;
  17985. /**
  17986. * The value we should increment the property by.
  17987. */
  17988. value: any;
  17989. private _target;
  17990. private _effectiveTarget;
  17991. private _property;
  17992. /**
  17993. * Instantiate the action
  17994. * @param triggerOptions defines the trigger options
  17995. * @param target defines the object containing the property
  17996. * @param propertyPath defines the path of the property to increment in the target
  17997. * @param value defines the value value we should increment the property by
  17998. * @param condition defines the trigger related conditions
  17999. */
  18000. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18001. /** @hidden */
  18002. _prepare(): void;
  18003. /**
  18004. * Execute the action and increment the target of the value amount.
  18005. */
  18006. execute(): void;
  18007. /**
  18008. * Serializes the actions and its related information.
  18009. * @param parent defines the object to serialize in
  18010. * @returns the serialized object
  18011. */
  18012. serialize(parent: any): any;
  18013. }
  18014. /**
  18015. * This defines an action responsible to start an animation once triggered.
  18016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18017. */
  18018. export class PlayAnimationAction extends Action {
  18019. /**
  18020. * Where the animation should start (animation frame)
  18021. */
  18022. from: number;
  18023. /**
  18024. * Where the animation should stop (animation frame)
  18025. */
  18026. to: number;
  18027. /**
  18028. * Define if the animation should loop or stop after the first play.
  18029. */
  18030. loop?: boolean;
  18031. private _target;
  18032. /**
  18033. * Instantiate the action
  18034. * @param triggerOptions defines the trigger options
  18035. * @param target defines the target animation or animation name
  18036. * @param from defines from where the animation should start (animation frame)
  18037. * @param end defines where the animation should stop (animation frame)
  18038. * @param loop defines if the animation should loop or stop after the first play
  18039. * @param condition defines the trigger related conditions
  18040. */
  18041. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18042. /** @hidden */
  18043. _prepare(): void;
  18044. /**
  18045. * Execute the action and play the animation.
  18046. */
  18047. execute(): void;
  18048. /**
  18049. * Serializes the actions and its related information.
  18050. * @param parent defines the object to serialize in
  18051. * @returns the serialized object
  18052. */
  18053. serialize(parent: any): any;
  18054. }
  18055. /**
  18056. * This defines an action responsible to stop an animation once triggered.
  18057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18058. */
  18059. export class StopAnimationAction extends Action {
  18060. private _target;
  18061. /**
  18062. * Instantiate the action
  18063. * @param triggerOptions defines the trigger options
  18064. * @param target defines the target animation or animation name
  18065. * @param condition defines the trigger related conditions
  18066. */
  18067. constructor(triggerOptions: any, target: any, condition?: Condition);
  18068. /** @hidden */
  18069. _prepare(): void;
  18070. /**
  18071. * Execute the action and stop the animation.
  18072. */
  18073. execute(): void;
  18074. /**
  18075. * Serializes the actions and its related information.
  18076. * @param parent defines the object to serialize in
  18077. * @returns the serialized object
  18078. */
  18079. serialize(parent: any): any;
  18080. }
  18081. /**
  18082. * This defines an action responsible that does nothing once triggered.
  18083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18084. */
  18085. export class DoNothingAction extends Action {
  18086. /**
  18087. * Instantiate the action
  18088. * @param triggerOptions defines the trigger options
  18089. * @param condition defines the trigger related conditions
  18090. */
  18091. constructor(triggerOptions?: any, condition?: Condition);
  18092. /**
  18093. * Execute the action and do nothing.
  18094. */
  18095. execute(): void;
  18096. /**
  18097. * Serializes the actions and its related information.
  18098. * @param parent defines the object to serialize in
  18099. * @returns the serialized object
  18100. */
  18101. serialize(parent: any): any;
  18102. }
  18103. /**
  18104. * This defines an action responsible to trigger several actions once triggered.
  18105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18106. */
  18107. export class CombineAction extends Action {
  18108. /**
  18109. * The list of aggregated animations to run.
  18110. */
  18111. children: Action[];
  18112. /**
  18113. * Instantiate the action
  18114. * @param triggerOptions defines the trigger options
  18115. * @param children defines the list of aggregated animations to run
  18116. * @param condition defines the trigger related conditions
  18117. */
  18118. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18119. /** @hidden */
  18120. _prepare(): void;
  18121. /**
  18122. * Execute the action and executes all the aggregated actions.
  18123. */
  18124. execute(evt: ActionEvent): void;
  18125. /**
  18126. * Serializes the actions and its related information.
  18127. * @param parent defines the object to serialize in
  18128. * @returns the serialized object
  18129. */
  18130. serialize(parent: any): any;
  18131. }
  18132. /**
  18133. * This defines an action responsible to run code (external event) once triggered.
  18134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18135. */
  18136. export class ExecuteCodeAction extends Action {
  18137. /**
  18138. * The callback function to run.
  18139. */
  18140. func: (evt: ActionEvent) => void;
  18141. /**
  18142. * Instantiate the action
  18143. * @param triggerOptions defines the trigger options
  18144. * @param func defines the callback function to run
  18145. * @param condition defines the trigger related conditions
  18146. */
  18147. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18148. /**
  18149. * Execute the action and run the attached code.
  18150. */
  18151. execute(evt: ActionEvent): void;
  18152. }
  18153. /**
  18154. * This defines an action responsible to set the parent property of the target once triggered.
  18155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18156. */
  18157. export class SetParentAction extends Action {
  18158. private _parent;
  18159. private _target;
  18160. /**
  18161. * Instantiate the action
  18162. * @param triggerOptions defines the trigger options
  18163. * @param target defines the target containing the parent property
  18164. * @param parent defines from where the animation should start (animation frame)
  18165. * @param condition defines the trigger related conditions
  18166. */
  18167. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18168. /** @hidden */
  18169. _prepare(): void;
  18170. /**
  18171. * Execute the action and set the parent property.
  18172. */
  18173. execute(): void;
  18174. /**
  18175. * Serializes the actions and its related information.
  18176. * @param parent defines the object to serialize in
  18177. * @returns the serialized object
  18178. */
  18179. serialize(parent: any): any;
  18180. }
  18181. }
  18182. declare module "babylonjs/Actions/actionManager" {
  18183. import { Nullable } from "babylonjs/types";
  18184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18185. import { Scene } from "babylonjs/scene";
  18186. import { IAction } from "babylonjs/Actions/action";
  18187. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18188. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18189. /**
  18190. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18191. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18193. */
  18194. export class ActionManager extends AbstractActionManager {
  18195. /**
  18196. * Nothing
  18197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18198. */
  18199. static readonly NothingTrigger: number;
  18200. /**
  18201. * On pick
  18202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18203. */
  18204. static readonly OnPickTrigger: number;
  18205. /**
  18206. * On left pick
  18207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18208. */
  18209. static readonly OnLeftPickTrigger: number;
  18210. /**
  18211. * On right pick
  18212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18213. */
  18214. static readonly OnRightPickTrigger: number;
  18215. /**
  18216. * On center pick
  18217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18218. */
  18219. static readonly OnCenterPickTrigger: number;
  18220. /**
  18221. * On pick down
  18222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18223. */
  18224. static readonly OnPickDownTrigger: number;
  18225. /**
  18226. * On double pick
  18227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18228. */
  18229. static readonly OnDoublePickTrigger: number;
  18230. /**
  18231. * On pick up
  18232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18233. */
  18234. static readonly OnPickUpTrigger: number;
  18235. /**
  18236. * On pick out.
  18237. * This trigger will only be raised if you also declared a OnPickDown
  18238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18239. */
  18240. static readonly OnPickOutTrigger: number;
  18241. /**
  18242. * On long press
  18243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18244. */
  18245. static readonly OnLongPressTrigger: number;
  18246. /**
  18247. * On pointer over
  18248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18249. */
  18250. static readonly OnPointerOverTrigger: number;
  18251. /**
  18252. * On pointer out
  18253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18254. */
  18255. static readonly OnPointerOutTrigger: number;
  18256. /**
  18257. * On every frame
  18258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18259. */
  18260. static readonly OnEveryFrameTrigger: number;
  18261. /**
  18262. * On intersection enter
  18263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18264. */
  18265. static readonly OnIntersectionEnterTrigger: number;
  18266. /**
  18267. * On intersection exit
  18268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18269. */
  18270. static readonly OnIntersectionExitTrigger: number;
  18271. /**
  18272. * On key down
  18273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18274. */
  18275. static readonly OnKeyDownTrigger: number;
  18276. /**
  18277. * On key up
  18278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18279. */
  18280. static readonly OnKeyUpTrigger: number;
  18281. private _scene;
  18282. /**
  18283. * Creates a new action manager
  18284. * @param scene defines the hosting scene
  18285. */
  18286. constructor(scene: Scene);
  18287. /**
  18288. * Releases all associated resources
  18289. */
  18290. dispose(): void;
  18291. /**
  18292. * Gets hosting scene
  18293. * @returns the hosting scene
  18294. */
  18295. getScene(): Scene;
  18296. /**
  18297. * Does this action manager handles actions of any of the given triggers
  18298. * @param triggers defines the triggers to be tested
  18299. * @return a boolean indicating whether one (or more) of the triggers is handled
  18300. */
  18301. hasSpecificTriggers(triggers: number[]): boolean;
  18302. /**
  18303. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18304. * speed.
  18305. * @param triggerA defines the trigger to be tested
  18306. * @param triggerB defines the trigger to be tested
  18307. * @return a boolean indicating whether one (or more) of the triggers is handled
  18308. */
  18309. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18310. /**
  18311. * Does this action manager handles actions of a given trigger
  18312. * @param trigger defines the trigger to be tested
  18313. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18314. * @return whether the trigger is handled
  18315. */
  18316. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18317. /**
  18318. * Does this action manager has pointer triggers
  18319. */
  18320. get hasPointerTriggers(): boolean;
  18321. /**
  18322. * Does this action manager has pick triggers
  18323. */
  18324. get hasPickTriggers(): boolean;
  18325. /**
  18326. * Registers an action to this action manager
  18327. * @param action defines the action to be registered
  18328. * @return the action amended (prepared) after registration
  18329. */
  18330. registerAction(action: IAction): Nullable<IAction>;
  18331. /**
  18332. * Unregisters an action to this action manager
  18333. * @param action defines the action to be unregistered
  18334. * @return a boolean indicating whether the action has been unregistered
  18335. */
  18336. unregisterAction(action: IAction): Boolean;
  18337. /**
  18338. * Process a specific trigger
  18339. * @param trigger defines the trigger to process
  18340. * @param evt defines the event details to be processed
  18341. */
  18342. processTrigger(trigger: number, evt?: IActionEvent): void;
  18343. /** @hidden */
  18344. _getEffectiveTarget(target: any, propertyPath: string): any;
  18345. /** @hidden */
  18346. _getProperty(propertyPath: string): string;
  18347. /**
  18348. * Serialize this manager to a JSON object
  18349. * @param name defines the property name to store this manager
  18350. * @returns a JSON representation of this manager
  18351. */
  18352. serialize(name: string): any;
  18353. /**
  18354. * Creates a new ActionManager from a JSON data
  18355. * @param parsedActions defines the JSON data to read from
  18356. * @param object defines the hosting mesh
  18357. * @param scene defines the hosting scene
  18358. */
  18359. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18360. /**
  18361. * Get a trigger name by index
  18362. * @param trigger defines the trigger index
  18363. * @returns a trigger name
  18364. */
  18365. static GetTriggerName(trigger: number): string;
  18366. }
  18367. }
  18368. declare module "babylonjs/Sprites/sprite" {
  18369. import { Vector3 } from "babylonjs/Maths/math.vector";
  18370. import { Nullable } from "babylonjs/types";
  18371. import { ActionManager } from "babylonjs/Actions/actionManager";
  18372. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18373. import { Color4 } from "babylonjs/Maths/math.color";
  18374. /**
  18375. * Class used to represent a sprite
  18376. * @see http://doc.babylonjs.com/babylon101/sprites
  18377. */
  18378. export class Sprite {
  18379. /** defines the name */
  18380. name: string;
  18381. /** Gets or sets the current world position */
  18382. position: Vector3;
  18383. /** Gets or sets the main color */
  18384. color: Color4;
  18385. /** Gets or sets the width */
  18386. width: number;
  18387. /** Gets or sets the height */
  18388. height: number;
  18389. /** Gets or sets rotation angle */
  18390. angle: number;
  18391. /** Gets or sets the cell index in the sprite sheet */
  18392. cellIndex: number;
  18393. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18394. cellRef: string;
  18395. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18396. invertU: number;
  18397. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18398. invertV: number;
  18399. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18400. disposeWhenFinishedAnimating: boolean;
  18401. /** Gets the list of attached animations */
  18402. animations: Animation[];
  18403. /** Gets or sets a boolean indicating if the sprite can be picked */
  18404. isPickable: boolean;
  18405. /**
  18406. * Gets or sets the associated action manager
  18407. */
  18408. actionManager: Nullable<ActionManager>;
  18409. private _animationStarted;
  18410. private _loopAnimation;
  18411. private _fromIndex;
  18412. private _toIndex;
  18413. private _delay;
  18414. private _direction;
  18415. private _manager;
  18416. private _time;
  18417. private _onAnimationEnd;
  18418. /**
  18419. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18420. */
  18421. isVisible: boolean;
  18422. /**
  18423. * Gets or sets the sprite size
  18424. */
  18425. get size(): number;
  18426. set size(value: number);
  18427. /**
  18428. * Creates a new Sprite
  18429. * @param name defines the name
  18430. * @param manager defines the manager
  18431. */
  18432. constructor(
  18433. /** defines the name */
  18434. name: string, manager: ISpriteManager);
  18435. /**
  18436. * Starts an animation
  18437. * @param from defines the initial key
  18438. * @param to defines the end key
  18439. * @param loop defines if the animation must loop
  18440. * @param delay defines the start delay (in ms)
  18441. * @param onAnimationEnd defines a callback to call when animation ends
  18442. */
  18443. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18444. /** Stops current animation (if any) */
  18445. stopAnimation(): void;
  18446. /** @hidden */
  18447. _animate(deltaTime: number): void;
  18448. /** Release associated resources */
  18449. dispose(): void;
  18450. }
  18451. }
  18452. declare module "babylonjs/Collisions/pickingInfo" {
  18453. import { Nullable } from "babylonjs/types";
  18454. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18456. import { Sprite } from "babylonjs/Sprites/sprite";
  18457. import { Ray } from "babylonjs/Culling/ray";
  18458. /**
  18459. * Information about the result of picking within a scene
  18460. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18461. */
  18462. export class PickingInfo {
  18463. /** @hidden */
  18464. _pickingUnavailable: boolean;
  18465. /**
  18466. * If the pick collided with an object
  18467. */
  18468. hit: boolean;
  18469. /**
  18470. * Distance away where the pick collided
  18471. */
  18472. distance: number;
  18473. /**
  18474. * The location of pick collision
  18475. */
  18476. pickedPoint: Nullable<Vector3>;
  18477. /**
  18478. * The mesh corresponding the the pick collision
  18479. */
  18480. pickedMesh: Nullable<AbstractMesh>;
  18481. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18482. bu: number;
  18483. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18484. bv: number;
  18485. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18486. faceId: number;
  18487. /** Id of the the submesh that was picked */
  18488. subMeshId: number;
  18489. /** If a sprite was picked, this will be the sprite the pick collided with */
  18490. pickedSprite: Nullable<Sprite>;
  18491. /**
  18492. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18493. */
  18494. originMesh: Nullable<AbstractMesh>;
  18495. /**
  18496. * The ray that was used to perform the picking.
  18497. */
  18498. ray: Nullable<Ray>;
  18499. /**
  18500. * Gets the normal correspodning to the face the pick collided with
  18501. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18502. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18503. * @returns The normal correspodning to the face the pick collided with
  18504. */
  18505. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18506. /**
  18507. * Gets the texture coordinates of where the pick occured
  18508. * @returns the vector containing the coordnates of the texture
  18509. */
  18510. getTextureCoordinates(): Nullable<Vector2>;
  18511. }
  18512. }
  18513. declare module "babylonjs/Events/pointerEvents" {
  18514. import { Nullable } from "babylonjs/types";
  18515. import { Vector2 } from "babylonjs/Maths/math.vector";
  18516. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18517. import { Ray } from "babylonjs/Culling/ray";
  18518. /**
  18519. * Gather the list of pointer event types as constants.
  18520. */
  18521. export class PointerEventTypes {
  18522. /**
  18523. * 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.
  18524. */
  18525. static readonly POINTERDOWN: number;
  18526. /**
  18527. * The pointerup event is fired when a pointer is no longer active.
  18528. */
  18529. static readonly POINTERUP: number;
  18530. /**
  18531. * The pointermove event is fired when a pointer changes coordinates.
  18532. */
  18533. static readonly POINTERMOVE: number;
  18534. /**
  18535. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18536. */
  18537. static readonly POINTERWHEEL: number;
  18538. /**
  18539. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18540. */
  18541. static readonly POINTERPICK: number;
  18542. /**
  18543. * The pointertap event is fired when a the object has been touched and released without drag.
  18544. */
  18545. static readonly POINTERTAP: number;
  18546. /**
  18547. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18548. */
  18549. static readonly POINTERDOUBLETAP: number;
  18550. }
  18551. /**
  18552. * Base class of pointer info types.
  18553. */
  18554. export class PointerInfoBase {
  18555. /**
  18556. * Defines the type of event (PointerEventTypes)
  18557. */
  18558. type: number;
  18559. /**
  18560. * Defines the related dom event
  18561. */
  18562. event: PointerEvent | MouseWheelEvent;
  18563. /**
  18564. * Instantiates the base class of pointers info.
  18565. * @param type Defines the type of event (PointerEventTypes)
  18566. * @param event Defines the related dom event
  18567. */
  18568. constructor(
  18569. /**
  18570. * Defines the type of event (PointerEventTypes)
  18571. */
  18572. type: number,
  18573. /**
  18574. * Defines the related dom event
  18575. */
  18576. event: PointerEvent | MouseWheelEvent);
  18577. }
  18578. /**
  18579. * This class is used to store pointer related info for the onPrePointerObservable event.
  18580. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18581. */
  18582. export class PointerInfoPre extends PointerInfoBase {
  18583. /**
  18584. * Ray from a pointer if availible (eg. 6dof controller)
  18585. */
  18586. ray: Nullable<Ray>;
  18587. /**
  18588. * Defines the local position of the pointer on the canvas.
  18589. */
  18590. localPosition: Vector2;
  18591. /**
  18592. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18593. */
  18594. skipOnPointerObservable: boolean;
  18595. /**
  18596. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18597. * @param type Defines the type of event (PointerEventTypes)
  18598. * @param event Defines the related dom event
  18599. * @param localX Defines the local x coordinates of the pointer when the event occured
  18600. * @param localY Defines the local y coordinates of the pointer when the event occured
  18601. */
  18602. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18603. }
  18604. /**
  18605. * This type contains all the data related to a pointer event in Babylon.js.
  18606. * 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.
  18607. */
  18608. export class PointerInfo extends PointerInfoBase {
  18609. /**
  18610. * Defines the picking info associated to the info (if any)\
  18611. */
  18612. pickInfo: Nullable<PickingInfo>;
  18613. /**
  18614. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18615. * @param type Defines the type of event (PointerEventTypes)
  18616. * @param event Defines the related dom event
  18617. * @param pickInfo Defines the picking info associated to the info (if any)\
  18618. */
  18619. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18620. /**
  18621. * Defines the picking info associated to the info (if any)\
  18622. */
  18623. pickInfo: Nullable<PickingInfo>);
  18624. }
  18625. /**
  18626. * Data relating to a touch event on the screen.
  18627. */
  18628. export interface PointerTouch {
  18629. /**
  18630. * X coordinate of touch.
  18631. */
  18632. x: number;
  18633. /**
  18634. * Y coordinate of touch.
  18635. */
  18636. y: number;
  18637. /**
  18638. * Id of touch. Unique for each finger.
  18639. */
  18640. pointerId: number;
  18641. /**
  18642. * Event type passed from DOM.
  18643. */
  18644. type: any;
  18645. }
  18646. }
  18647. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18648. import { Observable } from "babylonjs/Misc/observable";
  18649. import { Nullable } from "babylonjs/types";
  18650. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18651. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18652. /**
  18653. * Manage the mouse inputs to control the movement of a free camera.
  18654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18655. */
  18656. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18657. /**
  18658. * Define if touch is enabled in the mouse input
  18659. */
  18660. touchEnabled: boolean;
  18661. /**
  18662. * Defines the camera the input is attached to.
  18663. */
  18664. camera: FreeCamera;
  18665. /**
  18666. * Defines the buttons associated with the input to handle camera move.
  18667. */
  18668. buttons: number[];
  18669. /**
  18670. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18671. */
  18672. angularSensibility: number;
  18673. private _pointerInput;
  18674. private _onMouseMove;
  18675. private _observer;
  18676. private previousPosition;
  18677. /**
  18678. * Observable for when a pointer move event occurs containing the move offset
  18679. */
  18680. onPointerMovedObservable: Observable<{
  18681. offsetX: number;
  18682. offsetY: number;
  18683. }>;
  18684. /**
  18685. * @hidden
  18686. * If the camera should be rotated automatically based on pointer movement
  18687. */
  18688. _allowCameraRotation: boolean;
  18689. /**
  18690. * Manage the mouse inputs to control the movement of a free camera.
  18691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18692. * @param touchEnabled Defines if touch is enabled or not
  18693. */
  18694. constructor(
  18695. /**
  18696. * Define if touch is enabled in the mouse input
  18697. */
  18698. touchEnabled?: boolean);
  18699. /**
  18700. * Attach the input controls to a specific dom element to get the input from.
  18701. * @param element Defines the element the controls should be listened from
  18702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18703. */
  18704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18705. /**
  18706. * Called on JS contextmenu event.
  18707. * Override this method to provide functionality.
  18708. */
  18709. protected onContextMenu(evt: PointerEvent): void;
  18710. /**
  18711. * Detach the current controls from the specified dom element.
  18712. * @param element Defines the element to stop listening the inputs from
  18713. */
  18714. detachControl(element: Nullable<HTMLElement>): void;
  18715. /**
  18716. * Gets the class name of the current intput.
  18717. * @returns the class name
  18718. */
  18719. getClassName(): string;
  18720. /**
  18721. * Get the friendly name associated with the input class.
  18722. * @returns the input friendly name
  18723. */
  18724. getSimpleName(): string;
  18725. }
  18726. }
  18727. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18728. import { Nullable } from "babylonjs/types";
  18729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18731. /**
  18732. * Manage the touch inputs to control the movement of a free camera.
  18733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18734. */
  18735. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18736. /**
  18737. * Defines the camera the input is attached to.
  18738. */
  18739. camera: FreeCamera;
  18740. /**
  18741. * Defines the touch sensibility for rotation.
  18742. * The higher the faster.
  18743. */
  18744. touchAngularSensibility: number;
  18745. /**
  18746. * Defines the touch sensibility for move.
  18747. * The higher the faster.
  18748. */
  18749. touchMoveSensibility: number;
  18750. private _offsetX;
  18751. private _offsetY;
  18752. private _pointerPressed;
  18753. private _pointerInput;
  18754. private _observer;
  18755. private _onLostFocus;
  18756. /**
  18757. * Attach the input controls to a specific dom element to get the input from.
  18758. * @param element Defines the element the controls should be listened from
  18759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18760. */
  18761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18762. /**
  18763. * Detach the current controls from the specified dom element.
  18764. * @param element Defines the element to stop listening the inputs from
  18765. */
  18766. detachControl(element: Nullable<HTMLElement>): void;
  18767. /**
  18768. * Update the current camera state depending on the inputs that have been used this frame.
  18769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18770. */
  18771. checkInputs(): void;
  18772. /**
  18773. * Gets the class name of the current intput.
  18774. * @returns the class name
  18775. */
  18776. getClassName(): string;
  18777. /**
  18778. * Get the friendly name associated with the input class.
  18779. * @returns the input friendly name
  18780. */
  18781. getSimpleName(): string;
  18782. }
  18783. }
  18784. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18785. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18786. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18787. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18788. import { Nullable } from "babylonjs/types";
  18789. /**
  18790. * Default Inputs manager for the FreeCamera.
  18791. * It groups all the default supported inputs for ease of use.
  18792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18793. */
  18794. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18795. /**
  18796. * @hidden
  18797. */
  18798. _mouseInput: Nullable<FreeCameraMouseInput>;
  18799. /**
  18800. * Instantiates a new FreeCameraInputsManager.
  18801. * @param camera Defines the camera the inputs belong to
  18802. */
  18803. constructor(camera: FreeCamera);
  18804. /**
  18805. * Add keyboard input support to the input manager.
  18806. * @returns the current input manager
  18807. */
  18808. addKeyboard(): FreeCameraInputsManager;
  18809. /**
  18810. * Add mouse input support to the input manager.
  18811. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18812. * @returns the current input manager
  18813. */
  18814. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18815. /**
  18816. * Removes the mouse input support from the manager
  18817. * @returns the current input manager
  18818. */
  18819. removeMouse(): FreeCameraInputsManager;
  18820. /**
  18821. * Add touch input support to the input manager.
  18822. * @returns the current input manager
  18823. */
  18824. addTouch(): FreeCameraInputsManager;
  18825. /**
  18826. * Remove all attached input methods from a camera
  18827. */
  18828. clear(): void;
  18829. }
  18830. }
  18831. declare module "babylonjs/Cameras/freeCamera" {
  18832. import { Vector3 } from "babylonjs/Maths/math.vector";
  18833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18834. import { Scene } from "babylonjs/scene";
  18835. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18836. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18837. /**
  18838. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18839. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18840. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18841. */
  18842. export class FreeCamera extends TargetCamera {
  18843. /**
  18844. * Define the collision ellipsoid of the camera.
  18845. * This is helpful to simulate a camera body like the player body around the camera
  18846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18847. */
  18848. ellipsoid: Vector3;
  18849. /**
  18850. * Define an offset for the position of the ellipsoid around the camera.
  18851. * This can be helpful to determine the center of the body near the gravity center of the body
  18852. * instead of its head.
  18853. */
  18854. ellipsoidOffset: Vector3;
  18855. /**
  18856. * Enable or disable collisions of the camera with the rest of the scene objects.
  18857. */
  18858. checkCollisions: boolean;
  18859. /**
  18860. * Enable or disable gravity on the camera.
  18861. */
  18862. applyGravity: boolean;
  18863. /**
  18864. * Define the input manager associated to the camera.
  18865. */
  18866. inputs: FreeCameraInputsManager;
  18867. /**
  18868. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18869. * Higher values reduce sensitivity.
  18870. */
  18871. get angularSensibility(): number;
  18872. /**
  18873. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18874. * Higher values reduce sensitivity.
  18875. */
  18876. set angularSensibility(value: number);
  18877. /**
  18878. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18879. */
  18880. get keysUp(): number[];
  18881. set keysUp(value: number[]);
  18882. /**
  18883. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18884. */
  18885. get keysDown(): number[];
  18886. set keysDown(value: number[]);
  18887. /**
  18888. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18889. */
  18890. get keysLeft(): number[];
  18891. set keysLeft(value: number[]);
  18892. /**
  18893. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18894. */
  18895. get keysRight(): number[];
  18896. set keysRight(value: number[]);
  18897. /**
  18898. * Event raised when the camera collide with a mesh in the scene.
  18899. */
  18900. onCollide: (collidedMesh: AbstractMesh) => void;
  18901. private _collider;
  18902. private _needMoveForGravity;
  18903. private _oldPosition;
  18904. private _diffPosition;
  18905. private _newPosition;
  18906. /** @hidden */
  18907. _localDirection: Vector3;
  18908. /** @hidden */
  18909. _transformedDirection: Vector3;
  18910. /**
  18911. * Instantiates a Free Camera.
  18912. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18913. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18914. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18915. * @param name Define the name of the camera in the scene
  18916. * @param position Define the start position of the camera in the scene
  18917. * @param scene Define the scene the camera belongs to
  18918. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18919. */
  18920. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18921. /**
  18922. * Attached controls to the current camera.
  18923. * @param element Defines the element the controls should be listened from
  18924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18925. */
  18926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18927. /**
  18928. * Detach the current controls from the camera.
  18929. * The camera will stop reacting to inputs.
  18930. * @param element Defines the element to stop listening the inputs from
  18931. */
  18932. detachControl(element: HTMLElement): void;
  18933. private _collisionMask;
  18934. /**
  18935. * Define a collision mask to limit the list of object the camera can collide with
  18936. */
  18937. get collisionMask(): number;
  18938. set collisionMask(mask: number);
  18939. /** @hidden */
  18940. _collideWithWorld(displacement: Vector3): void;
  18941. private _onCollisionPositionChange;
  18942. /** @hidden */
  18943. _checkInputs(): void;
  18944. /** @hidden */
  18945. _decideIfNeedsToMove(): boolean;
  18946. /** @hidden */
  18947. _updatePosition(): void;
  18948. /**
  18949. * Destroy the camera and release the current resources hold by it.
  18950. */
  18951. dispose(): void;
  18952. /**
  18953. * Gets the current object class name.
  18954. * @return the class name
  18955. */
  18956. getClassName(): string;
  18957. }
  18958. }
  18959. declare module "babylonjs/Gamepads/gamepad" {
  18960. import { Observable } from "babylonjs/Misc/observable";
  18961. /**
  18962. * Represents a gamepad control stick position
  18963. */
  18964. export class StickValues {
  18965. /**
  18966. * The x component of the control stick
  18967. */
  18968. x: number;
  18969. /**
  18970. * The y component of the control stick
  18971. */
  18972. y: number;
  18973. /**
  18974. * Initializes the gamepad x and y control stick values
  18975. * @param x The x component of the gamepad control stick value
  18976. * @param y The y component of the gamepad control stick value
  18977. */
  18978. constructor(
  18979. /**
  18980. * The x component of the control stick
  18981. */
  18982. x: number,
  18983. /**
  18984. * The y component of the control stick
  18985. */
  18986. y: number);
  18987. }
  18988. /**
  18989. * An interface which manages callbacks for gamepad button changes
  18990. */
  18991. export interface GamepadButtonChanges {
  18992. /**
  18993. * Called when a gamepad has been changed
  18994. */
  18995. changed: boolean;
  18996. /**
  18997. * Called when a gamepad press event has been triggered
  18998. */
  18999. pressChanged: boolean;
  19000. /**
  19001. * Called when a touch event has been triggered
  19002. */
  19003. touchChanged: boolean;
  19004. /**
  19005. * Called when a value has changed
  19006. */
  19007. valueChanged: boolean;
  19008. }
  19009. /**
  19010. * Represents a gamepad
  19011. */
  19012. export class Gamepad {
  19013. /**
  19014. * The id of the gamepad
  19015. */
  19016. id: string;
  19017. /**
  19018. * The index of the gamepad
  19019. */
  19020. index: number;
  19021. /**
  19022. * The browser gamepad
  19023. */
  19024. browserGamepad: any;
  19025. /**
  19026. * Specifies what type of gamepad this represents
  19027. */
  19028. type: number;
  19029. private _leftStick;
  19030. private _rightStick;
  19031. /** @hidden */
  19032. _isConnected: boolean;
  19033. private _leftStickAxisX;
  19034. private _leftStickAxisY;
  19035. private _rightStickAxisX;
  19036. private _rightStickAxisY;
  19037. /**
  19038. * Triggered when the left control stick has been changed
  19039. */
  19040. private _onleftstickchanged;
  19041. /**
  19042. * Triggered when the right control stick has been changed
  19043. */
  19044. private _onrightstickchanged;
  19045. /**
  19046. * Represents a gamepad controller
  19047. */
  19048. static GAMEPAD: number;
  19049. /**
  19050. * Represents a generic controller
  19051. */
  19052. static GENERIC: number;
  19053. /**
  19054. * Represents an XBox controller
  19055. */
  19056. static XBOX: number;
  19057. /**
  19058. * Represents a pose-enabled controller
  19059. */
  19060. static POSE_ENABLED: number;
  19061. /**
  19062. * Represents an Dual Shock controller
  19063. */
  19064. static DUALSHOCK: number;
  19065. /**
  19066. * Specifies whether the left control stick should be Y-inverted
  19067. */
  19068. protected _invertLeftStickY: boolean;
  19069. /**
  19070. * Specifies if the gamepad has been connected
  19071. */
  19072. get isConnected(): boolean;
  19073. /**
  19074. * Initializes the gamepad
  19075. * @param id The id of the gamepad
  19076. * @param index The index of the gamepad
  19077. * @param browserGamepad The browser gamepad
  19078. * @param leftStickX The x component of the left joystick
  19079. * @param leftStickY The y component of the left joystick
  19080. * @param rightStickX The x component of the right joystick
  19081. * @param rightStickY The y component of the right joystick
  19082. */
  19083. constructor(
  19084. /**
  19085. * The id of the gamepad
  19086. */
  19087. id: string,
  19088. /**
  19089. * The index of the gamepad
  19090. */
  19091. index: number,
  19092. /**
  19093. * The browser gamepad
  19094. */
  19095. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19096. /**
  19097. * Callback triggered when the left joystick has changed
  19098. * @param callback
  19099. */
  19100. onleftstickchanged(callback: (values: StickValues) => void): void;
  19101. /**
  19102. * Callback triggered when the right joystick has changed
  19103. * @param callback
  19104. */
  19105. onrightstickchanged(callback: (values: StickValues) => void): void;
  19106. /**
  19107. * Gets the left joystick
  19108. */
  19109. get leftStick(): StickValues;
  19110. /**
  19111. * Sets the left joystick values
  19112. */
  19113. set leftStick(newValues: StickValues);
  19114. /**
  19115. * Gets the right joystick
  19116. */
  19117. get rightStick(): StickValues;
  19118. /**
  19119. * Sets the right joystick value
  19120. */
  19121. set rightStick(newValues: StickValues);
  19122. /**
  19123. * Updates the gamepad joystick positions
  19124. */
  19125. update(): void;
  19126. /**
  19127. * Disposes the gamepad
  19128. */
  19129. dispose(): void;
  19130. }
  19131. /**
  19132. * Represents a generic gamepad
  19133. */
  19134. export class GenericPad extends Gamepad {
  19135. private _buttons;
  19136. private _onbuttondown;
  19137. private _onbuttonup;
  19138. /**
  19139. * Observable triggered when a button has been pressed
  19140. */
  19141. onButtonDownObservable: Observable<number>;
  19142. /**
  19143. * Observable triggered when a button has been released
  19144. */
  19145. onButtonUpObservable: Observable<number>;
  19146. /**
  19147. * Callback triggered when a button has been pressed
  19148. * @param callback Called when a button has been pressed
  19149. */
  19150. onbuttondown(callback: (buttonPressed: number) => void): void;
  19151. /**
  19152. * Callback triggered when a button has been released
  19153. * @param callback Called when a button has been released
  19154. */
  19155. onbuttonup(callback: (buttonReleased: number) => void): void;
  19156. /**
  19157. * Initializes the generic gamepad
  19158. * @param id The id of the generic gamepad
  19159. * @param index The index of the generic gamepad
  19160. * @param browserGamepad The browser gamepad
  19161. */
  19162. constructor(id: string, index: number, browserGamepad: any);
  19163. private _setButtonValue;
  19164. /**
  19165. * Updates the generic gamepad
  19166. */
  19167. update(): void;
  19168. /**
  19169. * Disposes the generic gamepad
  19170. */
  19171. dispose(): void;
  19172. }
  19173. }
  19174. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19175. import { Observable } from "babylonjs/Misc/observable";
  19176. import { Nullable } from "babylonjs/types";
  19177. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19178. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19180. import { Ray } from "babylonjs/Culling/ray";
  19181. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19182. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19183. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19184. /**
  19185. * Defines the types of pose enabled controllers that are supported
  19186. */
  19187. export enum PoseEnabledControllerType {
  19188. /**
  19189. * HTC Vive
  19190. */
  19191. VIVE = 0,
  19192. /**
  19193. * Oculus Rift
  19194. */
  19195. OCULUS = 1,
  19196. /**
  19197. * Windows mixed reality
  19198. */
  19199. WINDOWS = 2,
  19200. /**
  19201. * Samsung gear VR
  19202. */
  19203. GEAR_VR = 3,
  19204. /**
  19205. * Google Daydream
  19206. */
  19207. DAYDREAM = 4,
  19208. /**
  19209. * Generic
  19210. */
  19211. GENERIC = 5
  19212. }
  19213. /**
  19214. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19215. */
  19216. export interface MutableGamepadButton {
  19217. /**
  19218. * Value of the button/trigger
  19219. */
  19220. value: number;
  19221. /**
  19222. * If the button/trigger is currently touched
  19223. */
  19224. touched: boolean;
  19225. /**
  19226. * If the button/trigger is currently pressed
  19227. */
  19228. pressed: boolean;
  19229. }
  19230. /**
  19231. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19232. * @hidden
  19233. */
  19234. export interface ExtendedGamepadButton extends GamepadButton {
  19235. /**
  19236. * If the button/trigger is currently pressed
  19237. */
  19238. readonly pressed: boolean;
  19239. /**
  19240. * If the button/trigger is currently touched
  19241. */
  19242. readonly touched: boolean;
  19243. /**
  19244. * Value of the button/trigger
  19245. */
  19246. readonly value: number;
  19247. }
  19248. /** @hidden */
  19249. export interface _GamePadFactory {
  19250. /**
  19251. * Returns whether or not the current gamepad can be created for this type of controller.
  19252. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19253. * @returns true if it can be created, otherwise false
  19254. */
  19255. canCreate(gamepadInfo: any): boolean;
  19256. /**
  19257. * Creates a new instance of the Gamepad.
  19258. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19259. * @returns the new gamepad instance
  19260. */
  19261. create(gamepadInfo: any): Gamepad;
  19262. }
  19263. /**
  19264. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19265. */
  19266. export class PoseEnabledControllerHelper {
  19267. /** @hidden */
  19268. static _ControllerFactories: _GamePadFactory[];
  19269. /** @hidden */
  19270. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19271. /**
  19272. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19273. * @param vrGamepad the gamepad to initialized
  19274. * @returns a vr controller of the type the gamepad identified as
  19275. */
  19276. static InitiateController(vrGamepad: any): Gamepad;
  19277. }
  19278. /**
  19279. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19280. */
  19281. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19282. /**
  19283. * If the controller is used in a webXR session
  19284. */
  19285. isXR: boolean;
  19286. private _deviceRoomPosition;
  19287. private _deviceRoomRotationQuaternion;
  19288. /**
  19289. * The device position in babylon space
  19290. */
  19291. devicePosition: Vector3;
  19292. /**
  19293. * The device rotation in babylon space
  19294. */
  19295. deviceRotationQuaternion: Quaternion;
  19296. /**
  19297. * The scale factor of the device in babylon space
  19298. */
  19299. deviceScaleFactor: number;
  19300. /**
  19301. * (Likely devicePosition should be used instead) The device position in its room space
  19302. */
  19303. position: Vector3;
  19304. /**
  19305. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19306. */
  19307. rotationQuaternion: Quaternion;
  19308. /**
  19309. * The type of controller (Eg. Windows mixed reality)
  19310. */
  19311. controllerType: PoseEnabledControllerType;
  19312. protected _calculatedPosition: Vector3;
  19313. private _calculatedRotation;
  19314. /**
  19315. * The raw pose from the device
  19316. */
  19317. rawPose: DevicePose;
  19318. private _trackPosition;
  19319. private _maxRotationDistFromHeadset;
  19320. private _draggedRoomRotation;
  19321. /**
  19322. * @hidden
  19323. */
  19324. _disableTrackPosition(fixedPosition: Vector3): void;
  19325. /**
  19326. * Internal, the mesh attached to the controller
  19327. * @hidden
  19328. */
  19329. _mesh: Nullable<AbstractMesh>;
  19330. private _poseControlledCamera;
  19331. private _leftHandSystemQuaternion;
  19332. /**
  19333. * Internal, matrix used to convert room space to babylon space
  19334. * @hidden
  19335. */
  19336. _deviceToWorld: Matrix;
  19337. /**
  19338. * Node to be used when casting a ray from the controller
  19339. * @hidden
  19340. */
  19341. _pointingPoseNode: Nullable<TransformNode>;
  19342. /**
  19343. * Name of the child mesh that can be used to cast a ray from the controller
  19344. */
  19345. static readonly POINTING_POSE: string;
  19346. /**
  19347. * Creates a new PoseEnabledController from a gamepad
  19348. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19349. */
  19350. constructor(browserGamepad: any);
  19351. private _workingMatrix;
  19352. /**
  19353. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19354. */
  19355. update(): void;
  19356. /**
  19357. * Updates only the pose device and mesh without doing any button event checking
  19358. */
  19359. protected _updatePoseAndMesh(): void;
  19360. /**
  19361. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19362. * @param poseData raw pose fromthe device
  19363. */
  19364. updateFromDevice(poseData: DevicePose): void;
  19365. /**
  19366. * @hidden
  19367. */
  19368. _meshAttachedObservable: Observable<AbstractMesh>;
  19369. /**
  19370. * Attaches a mesh to the controller
  19371. * @param mesh the mesh to be attached
  19372. */
  19373. attachToMesh(mesh: AbstractMesh): void;
  19374. /**
  19375. * Attaches the controllers mesh to a camera
  19376. * @param camera the camera the mesh should be attached to
  19377. */
  19378. attachToPoseControlledCamera(camera: TargetCamera): void;
  19379. /**
  19380. * Disposes of the controller
  19381. */
  19382. dispose(): void;
  19383. /**
  19384. * The mesh that is attached to the controller
  19385. */
  19386. get mesh(): Nullable<AbstractMesh>;
  19387. /**
  19388. * Gets the ray of the controller in the direction the controller is pointing
  19389. * @param length the length the resulting ray should be
  19390. * @returns a ray in the direction the controller is pointing
  19391. */
  19392. getForwardRay(length?: number): Ray;
  19393. }
  19394. }
  19395. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19396. import { Observable } from "babylonjs/Misc/observable";
  19397. import { Scene } from "babylonjs/scene";
  19398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19399. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19400. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19401. import { Nullable } from "babylonjs/types";
  19402. /**
  19403. * Defines the WebVRController object that represents controllers tracked in 3D space
  19404. */
  19405. export abstract class WebVRController extends PoseEnabledController {
  19406. /**
  19407. * Internal, the default controller model for the controller
  19408. */
  19409. protected _defaultModel: Nullable<AbstractMesh>;
  19410. /**
  19411. * Fired when the trigger state has changed
  19412. */
  19413. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19414. /**
  19415. * Fired when the main button state has changed
  19416. */
  19417. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19418. /**
  19419. * Fired when the secondary button state has changed
  19420. */
  19421. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19422. /**
  19423. * Fired when the pad state has changed
  19424. */
  19425. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19426. /**
  19427. * Fired when controllers stick values have changed
  19428. */
  19429. onPadValuesChangedObservable: Observable<StickValues>;
  19430. /**
  19431. * Array of button availible on the controller
  19432. */
  19433. protected _buttons: Array<MutableGamepadButton>;
  19434. private _onButtonStateChange;
  19435. /**
  19436. * Fired when a controller button's state has changed
  19437. * @param callback the callback containing the button that was modified
  19438. */
  19439. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19440. /**
  19441. * X and Y axis corresponding to the controllers joystick
  19442. */
  19443. pad: StickValues;
  19444. /**
  19445. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19446. */
  19447. hand: string;
  19448. /**
  19449. * The default controller model for the controller
  19450. */
  19451. get defaultModel(): Nullable<AbstractMesh>;
  19452. /**
  19453. * Creates a new WebVRController from a gamepad
  19454. * @param vrGamepad the gamepad that the WebVRController should be created from
  19455. */
  19456. constructor(vrGamepad: any);
  19457. /**
  19458. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19459. */
  19460. update(): void;
  19461. /**
  19462. * Function to be called when a button is modified
  19463. */
  19464. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19465. /**
  19466. * Loads a mesh and attaches it to the controller
  19467. * @param scene the scene the mesh should be added to
  19468. * @param meshLoaded callback for when the mesh has been loaded
  19469. */
  19470. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19471. private _setButtonValue;
  19472. private _changes;
  19473. private _checkChanges;
  19474. /**
  19475. * Disposes of th webVRCOntroller
  19476. */
  19477. dispose(): void;
  19478. }
  19479. }
  19480. declare module "babylonjs/Lights/hemisphericLight" {
  19481. import { Nullable } from "babylonjs/types";
  19482. import { Scene } from "babylonjs/scene";
  19483. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19484. import { Color3 } from "babylonjs/Maths/math.color";
  19485. import { Effect } from "babylonjs/Materials/effect";
  19486. import { Light } from "babylonjs/Lights/light";
  19487. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19488. /**
  19489. * The HemisphericLight simulates the ambient environment light,
  19490. * so the passed direction is the light reflection direction, not the incoming direction.
  19491. */
  19492. export class HemisphericLight extends Light {
  19493. /**
  19494. * The groundColor is the light in the opposite direction to the one specified during creation.
  19495. * 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.
  19496. */
  19497. groundColor: Color3;
  19498. /**
  19499. * The light reflection direction, not the incoming direction.
  19500. */
  19501. direction: Vector3;
  19502. /**
  19503. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19504. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19505. * The HemisphericLight can't cast shadows.
  19506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19507. * @param name The friendly name of the light
  19508. * @param direction The direction of the light reflection
  19509. * @param scene The scene the light belongs to
  19510. */
  19511. constructor(name: string, direction: Vector3, scene: Scene);
  19512. protected _buildUniformLayout(): void;
  19513. /**
  19514. * Returns the string "HemisphericLight".
  19515. * @return The class name
  19516. */
  19517. getClassName(): string;
  19518. /**
  19519. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19520. * Returns the updated direction.
  19521. * @param target The target the direction should point to
  19522. * @return The computed direction
  19523. */
  19524. setDirectionToTarget(target: Vector3): Vector3;
  19525. /**
  19526. * Returns the shadow generator associated to the light.
  19527. * @returns Always null for hemispheric lights because it does not support shadows.
  19528. */
  19529. getShadowGenerator(): Nullable<IShadowGenerator>;
  19530. /**
  19531. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19532. * @param effect The effect to update
  19533. * @param lightIndex The index of the light in the effect to update
  19534. * @returns The hemispheric light
  19535. */
  19536. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19537. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19538. /**
  19539. * Computes the world matrix of the node
  19540. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19541. * @param useWasUpdatedFlag defines a reserved property
  19542. * @returns the world matrix
  19543. */
  19544. computeWorldMatrix(): Matrix;
  19545. /**
  19546. * Returns the integer 3.
  19547. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19548. */
  19549. getTypeID(): number;
  19550. /**
  19551. * Prepares the list of defines specific to the light type.
  19552. * @param defines the list of defines
  19553. * @param lightIndex defines the index of the light for the effect
  19554. */
  19555. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19556. }
  19557. }
  19558. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19559. /** @hidden */
  19560. export var vrMultiviewToSingleviewPixelShader: {
  19561. name: string;
  19562. shader: string;
  19563. };
  19564. }
  19565. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19567. import { Scene } from "babylonjs/scene";
  19568. /**
  19569. * Renders to multiple views with a single draw call
  19570. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19571. */
  19572. export class MultiviewRenderTarget extends RenderTargetTexture {
  19573. /**
  19574. * Creates a multiview render target
  19575. * @param scene scene used with the render target
  19576. * @param size the size of the render target (used for each view)
  19577. */
  19578. constructor(scene: Scene, size?: number | {
  19579. width: number;
  19580. height: number;
  19581. } | {
  19582. ratio: number;
  19583. });
  19584. /**
  19585. * @hidden
  19586. * @param faceIndex the face index, if its a cube texture
  19587. */
  19588. _bindFrameBuffer(faceIndex?: number): void;
  19589. /**
  19590. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19591. * @returns the view count
  19592. */
  19593. getViewCount(): number;
  19594. }
  19595. }
  19596. declare module "babylonjs/Maths/math.frustum" {
  19597. import { Matrix } from "babylonjs/Maths/math.vector";
  19598. import { DeepImmutable } from "babylonjs/types";
  19599. import { Plane } from "babylonjs/Maths/math.plane";
  19600. /**
  19601. * Represents a camera frustum
  19602. */
  19603. export class Frustum {
  19604. /**
  19605. * Gets the planes representing the frustum
  19606. * @param transform matrix to be applied to the returned planes
  19607. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19608. */
  19609. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19610. /**
  19611. * Gets the near frustum plane transformed by the transform matrix
  19612. * @param transform transformation matrix to be applied to the resulting frustum plane
  19613. * @param frustumPlane the resuling frustum plane
  19614. */
  19615. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19616. /**
  19617. * Gets the far frustum plane transformed by the transform matrix
  19618. * @param transform transformation matrix to be applied to the resulting frustum plane
  19619. * @param frustumPlane the resuling frustum plane
  19620. */
  19621. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19622. /**
  19623. * Gets the left frustum plane transformed by the transform matrix
  19624. * @param transform transformation matrix to be applied to the resulting frustum plane
  19625. * @param frustumPlane the resuling frustum plane
  19626. */
  19627. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19628. /**
  19629. * Gets the right frustum plane transformed by the transform matrix
  19630. * @param transform transformation matrix to be applied to the resulting frustum plane
  19631. * @param frustumPlane the resuling frustum plane
  19632. */
  19633. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19634. /**
  19635. * Gets the top frustum plane transformed by the transform matrix
  19636. * @param transform transformation matrix to be applied to the resulting frustum plane
  19637. * @param frustumPlane the resuling frustum plane
  19638. */
  19639. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19640. /**
  19641. * Gets the bottom frustum plane transformed by the transform matrix
  19642. * @param transform transformation matrix to be applied to the resulting frustum plane
  19643. * @param frustumPlane the resuling frustum plane
  19644. */
  19645. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19646. /**
  19647. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19648. * @param transform transformation matrix to be applied to the resulting frustum planes
  19649. * @param frustumPlanes the resuling frustum planes
  19650. */
  19651. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19652. }
  19653. }
  19654. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19655. import { Camera } from "babylonjs/Cameras/camera";
  19656. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19657. import { Nullable } from "babylonjs/types";
  19658. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19659. import { Matrix } from "babylonjs/Maths/math.vector";
  19660. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19661. module "babylonjs/Engines/engine" {
  19662. interface Engine {
  19663. /**
  19664. * Creates a new multiview render target
  19665. * @param width defines the width of the texture
  19666. * @param height defines the height of the texture
  19667. * @returns the created multiview texture
  19668. */
  19669. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19670. /**
  19671. * Binds a multiview framebuffer to be drawn to
  19672. * @param multiviewTexture texture to bind
  19673. */
  19674. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19675. }
  19676. }
  19677. module "babylonjs/Cameras/camera" {
  19678. interface Camera {
  19679. /**
  19680. * @hidden
  19681. * 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)
  19682. */
  19683. _useMultiviewToSingleView: boolean;
  19684. /**
  19685. * @hidden
  19686. * 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)
  19687. */
  19688. _multiviewTexture: Nullable<RenderTargetTexture>;
  19689. /**
  19690. * @hidden
  19691. * ensures the multiview texture of the camera exists and has the specified width/height
  19692. * @param width height to set on the multiview texture
  19693. * @param height width to set on the multiview texture
  19694. */
  19695. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19696. }
  19697. }
  19698. module "babylonjs/scene" {
  19699. interface Scene {
  19700. /** @hidden */
  19701. _transformMatrixR: Matrix;
  19702. /** @hidden */
  19703. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19704. /** @hidden */
  19705. _createMultiviewUbo(): void;
  19706. /** @hidden */
  19707. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19708. /** @hidden */
  19709. _renderMultiviewToSingleView(camera: Camera): void;
  19710. }
  19711. }
  19712. }
  19713. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19714. import { Camera } from "babylonjs/Cameras/camera";
  19715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19716. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19717. import "babylonjs/Engines/Extensions/engine.multiview";
  19718. /**
  19719. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19720. * This will not be used for webXR as it supports displaying texture arrays directly
  19721. */
  19722. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19723. /**
  19724. * Initializes a VRMultiviewToSingleview
  19725. * @param name name of the post process
  19726. * @param camera camera to be applied to
  19727. * @param scaleFactor scaling factor to the size of the output texture
  19728. */
  19729. constructor(name: string, camera: Camera, scaleFactor: number);
  19730. }
  19731. }
  19732. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19733. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19734. import { Nullable } from "babylonjs/types";
  19735. import { Size } from "babylonjs/Maths/math.size";
  19736. import { Observable } from "babylonjs/Misc/observable";
  19737. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19738. /**
  19739. * Interface used to define additional presentation attributes
  19740. */
  19741. export interface IVRPresentationAttributes {
  19742. /**
  19743. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19744. */
  19745. highRefreshRate: boolean;
  19746. /**
  19747. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19748. */
  19749. foveationLevel: number;
  19750. }
  19751. module "babylonjs/Engines/engine" {
  19752. interface Engine {
  19753. /** @hidden */
  19754. _vrDisplay: any;
  19755. /** @hidden */
  19756. _vrSupported: boolean;
  19757. /** @hidden */
  19758. _oldSize: Size;
  19759. /** @hidden */
  19760. _oldHardwareScaleFactor: number;
  19761. /** @hidden */
  19762. _vrExclusivePointerMode: boolean;
  19763. /** @hidden */
  19764. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19765. /** @hidden */
  19766. _onVRDisplayPointerRestricted: () => void;
  19767. /** @hidden */
  19768. _onVRDisplayPointerUnrestricted: () => void;
  19769. /** @hidden */
  19770. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19771. /** @hidden */
  19772. _onVrDisplayDisconnect: Nullable<() => void>;
  19773. /** @hidden */
  19774. _onVrDisplayPresentChange: Nullable<() => void>;
  19775. /**
  19776. * Observable signaled when VR display mode changes
  19777. */
  19778. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19779. /**
  19780. * Observable signaled when VR request present is complete
  19781. */
  19782. onVRRequestPresentComplete: Observable<boolean>;
  19783. /**
  19784. * Observable signaled when VR request present starts
  19785. */
  19786. onVRRequestPresentStart: Observable<Engine>;
  19787. /**
  19788. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19789. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19790. */
  19791. isInVRExclusivePointerMode: boolean;
  19792. /**
  19793. * Gets a boolean indicating if a webVR device was detected
  19794. * @returns true if a webVR device was detected
  19795. */
  19796. isVRDevicePresent(): boolean;
  19797. /**
  19798. * Gets the current webVR device
  19799. * @returns the current webVR device (or null)
  19800. */
  19801. getVRDevice(): any;
  19802. /**
  19803. * Initializes a webVR display and starts listening to display change events
  19804. * The onVRDisplayChangedObservable will be notified upon these changes
  19805. * @returns A promise containing a VRDisplay and if vr is supported
  19806. */
  19807. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19808. /** @hidden */
  19809. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19810. /**
  19811. * Gets or sets the presentation attributes used to configure VR rendering
  19812. */
  19813. vrPresentationAttributes?: IVRPresentationAttributes;
  19814. /**
  19815. * Call this function to switch to webVR mode
  19816. * Will do nothing if webVR is not supported or if there is no webVR device
  19817. * @param options the webvr options provided to the camera. mainly used for multiview
  19818. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19819. */
  19820. enableVR(options: WebVROptions): void;
  19821. /** @hidden */
  19822. _onVRFullScreenTriggered(): void;
  19823. }
  19824. }
  19825. }
  19826. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19827. import { Nullable } from "babylonjs/types";
  19828. import { Observable } from "babylonjs/Misc/observable";
  19829. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19830. import { Scene } from "babylonjs/scene";
  19831. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19832. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19833. import { Node } from "babylonjs/node";
  19834. import { Ray } from "babylonjs/Culling/ray";
  19835. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19836. import "babylonjs/Engines/Extensions/engine.webVR";
  19837. /**
  19838. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19839. * IMPORTANT!! The data is right-hand data.
  19840. * @export
  19841. * @interface DevicePose
  19842. */
  19843. export interface DevicePose {
  19844. /**
  19845. * The position of the device, values in array are [x,y,z].
  19846. */
  19847. readonly position: Nullable<Float32Array>;
  19848. /**
  19849. * The linearVelocity of the device, values in array are [x,y,z].
  19850. */
  19851. readonly linearVelocity: Nullable<Float32Array>;
  19852. /**
  19853. * The linearAcceleration of the device, values in array are [x,y,z].
  19854. */
  19855. readonly linearAcceleration: Nullable<Float32Array>;
  19856. /**
  19857. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19858. */
  19859. readonly orientation: Nullable<Float32Array>;
  19860. /**
  19861. * The angularVelocity of the device, values in array are [x,y,z].
  19862. */
  19863. readonly angularVelocity: Nullable<Float32Array>;
  19864. /**
  19865. * The angularAcceleration of the device, values in array are [x,y,z].
  19866. */
  19867. readonly angularAcceleration: Nullable<Float32Array>;
  19868. }
  19869. /**
  19870. * Interface representing a pose controlled object in Babylon.
  19871. * A pose controlled object has both regular pose values as well as pose values
  19872. * from an external device such as a VR head mounted display
  19873. */
  19874. export interface PoseControlled {
  19875. /**
  19876. * The position of the object in babylon space.
  19877. */
  19878. position: Vector3;
  19879. /**
  19880. * The rotation quaternion of the object in babylon space.
  19881. */
  19882. rotationQuaternion: Quaternion;
  19883. /**
  19884. * The position of the device in babylon space.
  19885. */
  19886. devicePosition?: Vector3;
  19887. /**
  19888. * The rotation quaternion of the device in babylon space.
  19889. */
  19890. deviceRotationQuaternion: Quaternion;
  19891. /**
  19892. * The raw pose coming from the device.
  19893. */
  19894. rawPose: Nullable<DevicePose>;
  19895. /**
  19896. * The scale of the device to be used when translating from device space to babylon space.
  19897. */
  19898. deviceScaleFactor: number;
  19899. /**
  19900. * Updates the poseControlled values based on the input device pose.
  19901. * @param poseData the pose data to update the object with
  19902. */
  19903. updateFromDevice(poseData: DevicePose): void;
  19904. }
  19905. /**
  19906. * Set of options to customize the webVRCamera
  19907. */
  19908. export interface WebVROptions {
  19909. /**
  19910. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19911. */
  19912. trackPosition?: boolean;
  19913. /**
  19914. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19915. */
  19916. positionScale?: number;
  19917. /**
  19918. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19919. */
  19920. displayName?: string;
  19921. /**
  19922. * Should the native controller meshes be initialized. (default: true)
  19923. */
  19924. controllerMeshes?: boolean;
  19925. /**
  19926. * Creating a default HemiLight only on controllers. (default: true)
  19927. */
  19928. defaultLightingOnControllers?: boolean;
  19929. /**
  19930. * If you don't want to use the default VR button of the helper. (default: false)
  19931. */
  19932. useCustomVRButton?: boolean;
  19933. /**
  19934. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19935. */
  19936. customVRButton?: HTMLButtonElement;
  19937. /**
  19938. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19939. */
  19940. rayLength?: number;
  19941. /**
  19942. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19943. */
  19944. defaultHeight?: number;
  19945. /**
  19946. * If multiview should be used if availible (default: false)
  19947. */
  19948. useMultiview?: boolean;
  19949. }
  19950. /**
  19951. * This represents a WebVR camera.
  19952. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19953. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19954. */
  19955. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19956. private webVROptions;
  19957. /**
  19958. * @hidden
  19959. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19960. */
  19961. _vrDevice: any;
  19962. /**
  19963. * The rawPose of the vrDevice.
  19964. */
  19965. rawPose: Nullable<DevicePose>;
  19966. private _onVREnabled;
  19967. private _specsVersion;
  19968. private _attached;
  19969. private _frameData;
  19970. protected _descendants: Array<Node>;
  19971. private _deviceRoomPosition;
  19972. /** @hidden */
  19973. _deviceRoomRotationQuaternion: Quaternion;
  19974. private _standingMatrix;
  19975. /**
  19976. * Represents device position in babylon space.
  19977. */
  19978. devicePosition: Vector3;
  19979. /**
  19980. * Represents device rotation in babylon space.
  19981. */
  19982. deviceRotationQuaternion: Quaternion;
  19983. /**
  19984. * The scale of the device to be used when translating from device space to babylon space.
  19985. */
  19986. deviceScaleFactor: number;
  19987. private _deviceToWorld;
  19988. private _worldToDevice;
  19989. /**
  19990. * References to the webVR controllers for the vrDevice.
  19991. */
  19992. controllers: Array<WebVRController>;
  19993. /**
  19994. * Emits an event when a controller is attached.
  19995. */
  19996. onControllersAttachedObservable: Observable<WebVRController[]>;
  19997. /**
  19998. * Emits an event when a controller's mesh has been loaded;
  19999. */
  20000. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20001. /**
  20002. * Emits an event when the HMD's pose has been updated.
  20003. */
  20004. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20005. private _poseSet;
  20006. /**
  20007. * If the rig cameras be used as parent instead of this camera.
  20008. */
  20009. rigParenting: boolean;
  20010. private _lightOnControllers;
  20011. private _defaultHeight?;
  20012. /**
  20013. * Instantiates a WebVRFreeCamera.
  20014. * @param name The name of the WebVRFreeCamera
  20015. * @param position The starting anchor position for the camera
  20016. * @param scene The scene the camera belongs to
  20017. * @param webVROptions a set of customizable options for the webVRCamera
  20018. */
  20019. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20020. /**
  20021. * Gets the device distance from the ground in meters.
  20022. * @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.
  20023. */
  20024. deviceDistanceToRoomGround(): number;
  20025. /**
  20026. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20027. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20028. */
  20029. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20030. /**
  20031. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20032. * @returns A promise with a boolean set to if the standing matrix is supported.
  20033. */
  20034. useStandingMatrixAsync(): Promise<boolean>;
  20035. /**
  20036. * Disposes the camera
  20037. */
  20038. dispose(): void;
  20039. /**
  20040. * Gets a vrController by name.
  20041. * @param name The name of the controller to retreive
  20042. * @returns the controller matching the name specified or null if not found
  20043. */
  20044. getControllerByName(name: string): Nullable<WebVRController>;
  20045. private _leftController;
  20046. /**
  20047. * The controller corresponding to the users left hand.
  20048. */
  20049. get leftController(): Nullable<WebVRController>;
  20050. private _rightController;
  20051. /**
  20052. * The controller corresponding to the users right hand.
  20053. */
  20054. get rightController(): Nullable<WebVRController>;
  20055. /**
  20056. * Casts a ray forward from the vrCamera's gaze.
  20057. * @param length Length of the ray (default: 100)
  20058. * @returns the ray corresponding to the gaze
  20059. */
  20060. getForwardRay(length?: number): Ray;
  20061. /**
  20062. * @hidden
  20063. * Updates the camera based on device's frame data
  20064. */
  20065. _checkInputs(): void;
  20066. /**
  20067. * Updates the poseControlled values based on the input device pose.
  20068. * @param poseData Pose coming from the device
  20069. */
  20070. updateFromDevice(poseData: DevicePose): void;
  20071. private _htmlElementAttached;
  20072. private _detachIfAttached;
  20073. /**
  20074. * WebVR's attach control will start broadcasting frames to the device.
  20075. * Note that in certain browsers (chrome for example) this function must be called
  20076. * within a user-interaction callback. Example:
  20077. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20078. *
  20079. * @param element html element to attach the vrDevice to
  20080. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20081. */
  20082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20083. /**
  20084. * Detaches the camera from the html element and disables VR
  20085. *
  20086. * @param element html element to detach from
  20087. */
  20088. detachControl(element: HTMLElement): void;
  20089. /**
  20090. * @returns the name of this class
  20091. */
  20092. getClassName(): string;
  20093. /**
  20094. * Calls resetPose on the vrDisplay
  20095. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20096. */
  20097. resetToCurrentRotation(): void;
  20098. /**
  20099. * @hidden
  20100. * Updates the rig cameras (left and right eye)
  20101. */
  20102. _updateRigCameras(): void;
  20103. private _workingVector;
  20104. private _oneVector;
  20105. private _workingMatrix;
  20106. private updateCacheCalled;
  20107. private _correctPositionIfNotTrackPosition;
  20108. /**
  20109. * @hidden
  20110. * Updates the cached values of the camera
  20111. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20112. */
  20113. _updateCache(ignoreParentClass?: boolean): void;
  20114. /**
  20115. * @hidden
  20116. * Get current device position in babylon world
  20117. */
  20118. _computeDevicePosition(): void;
  20119. /**
  20120. * Updates the current device position and rotation in the babylon world
  20121. */
  20122. update(): void;
  20123. /**
  20124. * @hidden
  20125. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20126. * @returns an identity matrix
  20127. */
  20128. _getViewMatrix(): Matrix;
  20129. private _tmpMatrix;
  20130. /**
  20131. * This function is called by the two RIG cameras.
  20132. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20133. * @hidden
  20134. */
  20135. _getWebVRViewMatrix(): Matrix;
  20136. /** @hidden */
  20137. _getWebVRProjectionMatrix(): Matrix;
  20138. private _onGamepadConnectedObserver;
  20139. private _onGamepadDisconnectedObserver;
  20140. private _updateCacheWhenTrackingDisabledObserver;
  20141. /**
  20142. * Initializes the controllers and their meshes
  20143. */
  20144. initControllers(): void;
  20145. }
  20146. }
  20147. declare module "babylonjs/PostProcesses/postProcess" {
  20148. import { Nullable } from "babylonjs/types";
  20149. import { SmartArray } from "babylonjs/Misc/smartArray";
  20150. import { Observable } from "babylonjs/Misc/observable";
  20151. import { Vector2 } from "babylonjs/Maths/math.vector";
  20152. import { Camera } from "babylonjs/Cameras/camera";
  20153. import { Effect } from "babylonjs/Materials/effect";
  20154. import "babylonjs/Shaders/postprocess.vertex";
  20155. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20156. import { Engine } from "babylonjs/Engines/engine";
  20157. import { Color4 } from "babylonjs/Maths/math.color";
  20158. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20159. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20160. /**
  20161. * Size options for a post process
  20162. */
  20163. export type PostProcessOptions = {
  20164. width: number;
  20165. height: number;
  20166. };
  20167. /**
  20168. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20169. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20170. */
  20171. export class PostProcess {
  20172. /** Name of the PostProcess. */
  20173. name: string;
  20174. /**
  20175. * Gets or sets the unique id of the post process
  20176. */
  20177. uniqueId: number;
  20178. /**
  20179. * Width of the texture to apply the post process on
  20180. */
  20181. width: number;
  20182. /**
  20183. * Height of the texture to apply the post process on
  20184. */
  20185. height: number;
  20186. /**
  20187. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20188. * @hidden
  20189. */
  20190. _outputTexture: Nullable<InternalTexture>;
  20191. /**
  20192. * Sampling mode used by the shader
  20193. * See https://doc.babylonjs.com/classes/3.1/texture
  20194. */
  20195. renderTargetSamplingMode: number;
  20196. /**
  20197. * Clear color to use when screen clearing
  20198. */
  20199. clearColor: Color4;
  20200. /**
  20201. * If the buffer needs to be cleared before applying the post process. (default: true)
  20202. * Should be set to false if shader will overwrite all previous pixels.
  20203. */
  20204. autoClear: boolean;
  20205. /**
  20206. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20207. */
  20208. alphaMode: number;
  20209. /**
  20210. * Sets the setAlphaBlendConstants of the babylon engine
  20211. */
  20212. alphaConstants: Color4;
  20213. /**
  20214. * Animations to be used for the post processing
  20215. */
  20216. animations: import("babylonjs/Animations/animation").Animation[];
  20217. /**
  20218. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20219. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20220. */
  20221. enablePixelPerfectMode: boolean;
  20222. /**
  20223. * Force the postprocess to be applied without taking in account viewport
  20224. */
  20225. forceFullscreenViewport: boolean;
  20226. /**
  20227. * List of inspectable custom properties (used by the Inspector)
  20228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20229. */
  20230. inspectableCustomProperties: IInspectable[];
  20231. /**
  20232. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20233. *
  20234. * | Value | Type | Description |
  20235. * | ----- | ----------------------------------- | ----------- |
  20236. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20237. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20238. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20239. *
  20240. */
  20241. scaleMode: number;
  20242. /**
  20243. * Force textures to be a power of two (default: false)
  20244. */
  20245. alwaysForcePOT: boolean;
  20246. private _samples;
  20247. /**
  20248. * Number of sample textures (default: 1)
  20249. */
  20250. get samples(): number;
  20251. set samples(n: number);
  20252. /**
  20253. * Modify the scale of the post process to be the same as the viewport (default: false)
  20254. */
  20255. adaptScaleToCurrentViewport: boolean;
  20256. private _camera;
  20257. private _scene;
  20258. private _engine;
  20259. private _options;
  20260. private _reusable;
  20261. private _textureType;
  20262. private _textureFormat;
  20263. /**
  20264. * Smart array of input and output textures for the post process.
  20265. * @hidden
  20266. */
  20267. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20268. /**
  20269. * The index in _textures that corresponds to the output texture.
  20270. * @hidden
  20271. */
  20272. _currentRenderTextureInd: number;
  20273. private _effect;
  20274. private _samplers;
  20275. private _fragmentUrl;
  20276. private _vertexUrl;
  20277. private _parameters;
  20278. private _scaleRatio;
  20279. protected _indexParameters: any;
  20280. private _shareOutputWithPostProcess;
  20281. private _texelSize;
  20282. private _forcedOutputTexture;
  20283. /**
  20284. * Returns the fragment url or shader name used in the post process.
  20285. * @returns the fragment url or name in the shader store.
  20286. */
  20287. getEffectName(): string;
  20288. /**
  20289. * An event triggered when the postprocess is activated.
  20290. */
  20291. onActivateObservable: Observable<Camera>;
  20292. private _onActivateObserver;
  20293. /**
  20294. * A function that is added to the onActivateObservable
  20295. */
  20296. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20297. /**
  20298. * An event triggered when the postprocess changes its size.
  20299. */
  20300. onSizeChangedObservable: Observable<PostProcess>;
  20301. private _onSizeChangedObserver;
  20302. /**
  20303. * A function that is added to the onSizeChangedObservable
  20304. */
  20305. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20306. /**
  20307. * An event triggered when the postprocess applies its effect.
  20308. */
  20309. onApplyObservable: Observable<Effect>;
  20310. private _onApplyObserver;
  20311. /**
  20312. * A function that is added to the onApplyObservable
  20313. */
  20314. set onApply(callback: (effect: Effect) => void);
  20315. /**
  20316. * An event triggered before rendering the postprocess
  20317. */
  20318. onBeforeRenderObservable: Observable<Effect>;
  20319. private _onBeforeRenderObserver;
  20320. /**
  20321. * A function that is added to the onBeforeRenderObservable
  20322. */
  20323. set onBeforeRender(callback: (effect: Effect) => void);
  20324. /**
  20325. * An event triggered after rendering the postprocess
  20326. */
  20327. onAfterRenderObservable: Observable<Effect>;
  20328. private _onAfterRenderObserver;
  20329. /**
  20330. * A function that is added to the onAfterRenderObservable
  20331. */
  20332. set onAfterRender(callback: (efect: Effect) => void);
  20333. /**
  20334. * 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
  20335. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20336. */
  20337. get inputTexture(): InternalTexture;
  20338. set inputTexture(value: InternalTexture);
  20339. /**
  20340. * Gets the camera which post process is applied to.
  20341. * @returns The camera the post process is applied to.
  20342. */
  20343. getCamera(): Camera;
  20344. /**
  20345. * Gets the texel size of the postprocess.
  20346. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20347. */
  20348. get texelSize(): Vector2;
  20349. /**
  20350. * Creates a new instance PostProcess
  20351. * @param name The name of the PostProcess.
  20352. * @param fragmentUrl The url of the fragment shader to be used.
  20353. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20354. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20355. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20356. * @param camera The camera to apply the render pass to.
  20357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20358. * @param engine The engine which the post process will be applied. (default: current engine)
  20359. * @param reusable If the post process can be reused on the same frame. (default: false)
  20360. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20361. * @param textureType Type of textures used when performing the post process. (default: 0)
  20362. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20363. * @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
  20364. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20365. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20366. */
  20367. constructor(
  20368. /** Name of the PostProcess. */
  20369. 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);
  20370. /**
  20371. * Gets a string idenfifying the name of the class
  20372. * @returns "PostProcess" string
  20373. */
  20374. getClassName(): string;
  20375. /**
  20376. * Gets the engine which this post process belongs to.
  20377. * @returns The engine the post process was enabled with.
  20378. */
  20379. getEngine(): Engine;
  20380. /**
  20381. * The effect that is created when initializing the post process.
  20382. * @returns The created effect corresponding the the postprocess.
  20383. */
  20384. getEffect(): Effect;
  20385. /**
  20386. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20387. * @param postProcess The post process to share the output with.
  20388. * @returns This post process.
  20389. */
  20390. shareOutputWith(postProcess: PostProcess): PostProcess;
  20391. /**
  20392. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20393. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20394. */
  20395. useOwnOutput(): void;
  20396. /**
  20397. * Updates the effect with the current post process compile time values and recompiles the shader.
  20398. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20399. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20400. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20401. * @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
  20402. * @param onCompiled Called when the shader has been compiled.
  20403. * @param onError Called if there is an error when compiling a shader.
  20404. */
  20405. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20406. /**
  20407. * The post process is reusable if it can be used multiple times within one frame.
  20408. * @returns If the post process is reusable
  20409. */
  20410. isReusable(): boolean;
  20411. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20412. markTextureDirty(): void;
  20413. /**
  20414. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20415. * 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.
  20416. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20417. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20418. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20419. * @returns The target texture that was bound to be written to.
  20420. */
  20421. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20422. /**
  20423. * If the post process is supported.
  20424. */
  20425. get isSupported(): boolean;
  20426. /**
  20427. * The aspect ratio of the output texture.
  20428. */
  20429. get aspectRatio(): number;
  20430. /**
  20431. * Get a value indicating if the post-process is ready to be used
  20432. * @returns true if the post-process is ready (shader is compiled)
  20433. */
  20434. isReady(): boolean;
  20435. /**
  20436. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20437. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20438. */
  20439. apply(): Nullable<Effect>;
  20440. private _disposeTextures;
  20441. /**
  20442. * Disposes the post process.
  20443. * @param camera The camera to dispose the post process on.
  20444. */
  20445. dispose(camera?: Camera): void;
  20446. }
  20447. }
  20448. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20449. /** @hidden */
  20450. export var kernelBlurVaryingDeclaration: {
  20451. name: string;
  20452. shader: string;
  20453. };
  20454. }
  20455. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20456. /** @hidden */
  20457. export var kernelBlurFragment: {
  20458. name: string;
  20459. shader: string;
  20460. };
  20461. }
  20462. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20463. /** @hidden */
  20464. export var kernelBlurFragment2: {
  20465. name: string;
  20466. shader: string;
  20467. };
  20468. }
  20469. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20470. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20471. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20472. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20473. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20474. /** @hidden */
  20475. export var kernelBlurPixelShader: {
  20476. name: string;
  20477. shader: string;
  20478. };
  20479. }
  20480. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20481. /** @hidden */
  20482. export var kernelBlurVertex: {
  20483. name: string;
  20484. shader: string;
  20485. };
  20486. }
  20487. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20488. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20489. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20490. /** @hidden */
  20491. export var kernelBlurVertexShader: {
  20492. name: string;
  20493. shader: string;
  20494. };
  20495. }
  20496. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20497. import { Vector2 } from "babylonjs/Maths/math.vector";
  20498. import { Nullable } from "babylonjs/types";
  20499. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20500. import { Camera } from "babylonjs/Cameras/camera";
  20501. import { Effect } from "babylonjs/Materials/effect";
  20502. import { Engine } from "babylonjs/Engines/engine";
  20503. import "babylonjs/Shaders/kernelBlur.fragment";
  20504. import "babylonjs/Shaders/kernelBlur.vertex";
  20505. /**
  20506. * The Blur Post Process which blurs an image based on a kernel and direction.
  20507. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20508. */
  20509. export class BlurPostProcess extends PostProcess {
  20510. /** The direction in which to blur the image. */
  20511. direction: Vector2;
  20512. private blockCompilation;
  20513. protected _kernel: number;
  20514. protected _idealKernel: number;
  20515. protected _packedFloat: boolean;
  20516. private _staticDefines;
  20517. /**
  20518. * Sets the length in pixels of the blur sample region
  20519. */
  20520. set kernel(v: number);
  20521. /**
  20522. * Gets the length in pixels of the blur sample region
  20523. */
  20524. get kernel(): number;
  20525. /**
  20526. * Sets wether or not the blur needs to unpack/repack floats
  20527. */
  20528. set packedFloat(v: boolean);
  20529. /**
  20530. * Gets wether or not the blur is unpacking/repacking floats
  20531. */
  20532. get packedFloat(): boolean;
  20533. /**
  20534. * Creates a new instance BlurPostProcess
  20535. * @param name The name of the effect.
  20536. * @param direction The direction in which to blur the image.
  20537. * @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.
  20538. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20539. * @param camera The camera to apply the render pass to.
  20540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20541. * @param engine The engine which the post process will be applied. (default: current engine)
  20542. * @param reusable If the post process can be reused on the same frame. (default: false)
  20543. * @param textureType Type of textures used when performing the post process. (default: 0)
  20544. * @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)
  20545. */
  20546. constructor(name: string,
  20547. /** The direction in which to blur the image. */
  20548. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20549. /**
  20550. * Updates the effect with the current post process compile time values and recompiles the shader.
  20551. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20552. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20553. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20554. * @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
  20555. * @param onCompiled Called when the shader has been compiled.
  20556. * @param onError Called if there is an error when compiling a shader.
  20557. */
  20558. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20559. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20560. /**
  20561. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20562. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20563. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20564. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20565. * The gaps between physical kernels are compensated for in the weighting of the samples
  20566. * @param idealKernel Ideal blur kernel.
  20567. * @return Nearest best kernel.
  20568. */
  20569. protected _nearestBestKernel(idealKernel: number): number;
  20570. /**
  20571. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20572. * @param x The point on the Gaussian distribution to sample.
  20573. * @return the value of the Gaussian function at x.
  20574. */
  20575. protected _gaussianWeight(x: number): number;
  20576. /**
  20577. * Generates a string that can be used as a floating point number in GLSL.
  20578. * @param x Value to print.
  20579. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20580. * @return GLSL float string.
  20581. */
  20582. protected _glslFloat(x: number, decimalFigures?: number): string;
  20583. }
  20584. }
  20585. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20586. import { Scene } from "babylonjs/scene";
  20587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20588. import { Plane } from "babylonjs/Maths/math.plane";
  20589. /**
  20590. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20591. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20592. * You can then easily use it as a reflectionTexture on a flat surface.
  20593. * In case the surface is not a plane, please consider relying on reflection probes.
  20594. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20595. */
  20596. export class MirrorTexture extends RenderTargetTexture {
  20597. private scene;
  20598. /**
  20599. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20600. * 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.
  20601. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20602. */
  20603. mirrorPlane: Plane;
  20604. /**
  20605. * Define the blur ratio used to blur the reflection if needed.
  20606. */
  20607. set blurRatio(value: number);
  20608. get blurRatio(): number;
  20609. /**
  20610. * Define the adaptive blur kernel used to blur the reflection if needed.
  20611. * This will autocompute the closest best match for the `blurKernel`
  20612. */
  20613. set adaptiveBlurKernel(value: number);
  20614. /**
  20615. * Define the blur kernel used to blur the reflection if needed.
  20616. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20617. */
  20618. set blurKernel(value: number);
  20619. /**
  20620. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20621. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20622. */
  20623. set blurKernelX(value: number);
  20624. get blurKernelX(): number;
  20625. /**
  20626. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20627. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20628. */
  20629. set blurKernelY(value: number);
  20630. get blurKernelY(): number;
  20631. private _autoComputeBlurKernel;
  20632. protected _onRatioRescale(): void;
  20633. private _updateGammaSpace;
  20634. private _imageProcessingConfigChangeObserver;
  20635. private _transformMatrix;
  20636. private _mirrorMatrix;
  20637. private _savedViewMatrix;
  20638. private _blurX;
  20639. private _blurY;
  20640. private _adaptiveBlurKernel;
  20641. private _blurKernelX;
  20642. private _blurKernelY;
  20643. private _blurRatio;
  20644. /**
  20645. * Instantiates a Mirror Texture.
  20646. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20647. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20648. * You can then easily use it as a reflectionTexture on a flat surface.
  20649. * In case the surface is not a plane, please consider relying on reflection probes.
  20650. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20651. * @param name
  20652. * @param size
  20653. * @param scene
  20654. * @param generateMipMaps
  20655. * @param type
  20656. * @param samplingMode
  20657. * @param generateDepthBuffer
  20658. */
  20659. constructor(name: string, size: number | {
  20660. width: number;
  20661. height: number;
  20662. } | {
  20663. ratio: number;
  20664. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20665. private _preparePostProcesses;
  20666. /**
  20667. * Clone the mirror texture.
  20668. * @returns the cloned texture
  20669. */
  20670. clone(): MirrorTexture;
  20671. /**
  20672. * Serialize the texture to a JSON representation you could use in Parse later on
  20673. * @returns the serialized JSON representation
  20674. */
  20675. serialize(): any;
  20676. /**
  20677. * Dispose the texture and release its associated resources.
  20678. */
  20679. dispose(): void;
  20680. }
  20681. }
  20682. declare module "babylonjs/Materials/Textures/texture" {
  20683. import { Observable } from "babylonjs/Misc/observable";
  20684. import { Nullable } from "babylonjs/types";
  20685. import { Matrix } from "babylonjs/Maths/math.vector";
  20686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20687. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20688. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20689. import { Scene } from "babylonjs/scene";
  20690. /**
  20691. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20692. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20693. */
  20694. export class Texture extends BaseTexture {
  20695. /**
  20696. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20697. */
  20698. static SerializeBuffers: boolean;
  20699. /** @hidden */
  20700. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20701. /** @hidden */
  20702. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20703. /** @hidden */
  20704. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20705. /** nearest is mag = nearest and min = nearest and mip = linear */
  20706. static readonly NEAREST_SAMPLINGMODE: number;
  20707. /** nearest is mag = nearest and min = nearest and mip = linear */
  20708. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20709. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20710. static readonly BILINEAR_SAMPLINGMODE: number;
  20711. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20712. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20713. /** Trilinear is mag = linear and min = linear and mip = linear */
  20714. static readonly TRILINEAR_SAMPLINGMODE: number;
  20715. /** Trilinear is mag = linear and min = linear and mip = linear */
  20716. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20717. /** mag = nearest and min = nearest and mip = nearest */
  20718. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20719. /** mag = nearest and min = linear and mip = nearest */
  20720. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20721. /** mag = nearest and min = linear and mip = linear */
  20722. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20723. /** mag = nearest and min = linear and mip = none */
  20724. static readonly NEAREST_LINEAR: number;
  20725. /** mag = nearest and min = nearest and mip = none */
  20726. static readonly NEAREST_NEAREST: number;
  20727. /** mag = linear and min = nearest and mip = nearest */
  20728. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20729. /** mag = linear and min = nearest and mip = linear */
  20730. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20731. /** mag = linear and min = linear and mip = none */
  20732. static readonly LINEAR_LINEAR: number;
  20733. /** mag = linear and min = nearest and mip = none */
  20734. static readonly LINEAR_NEAREST: number;
  20735. /** Explicit coordinates mode */
  20736. static readonly EXPLICIT_MODE: number;
  20737. /** Spherical coordinates mode */
  20738. static readonly SPHERICAL_MODE: number;
  20739. /** Planar coordinates mode */
  20740. static readonly PLANAR_MODE: number;
  20741. /** Cubic coordinates mode */
  20742. static readonly CUBIC_MODE: number;
  20743. /** Projection coordinates mode */
  20744. static readonly PROJECTION_MODE: number;
  20745. /** Inverse Cubic coordinates mode */
  20746. static readonly SKYBOX_MODE: number;
  20747. /** Inverse Cubic coordinates mode */
  20748. static readonly INVCUBIC_MODE: number;
  20749. /** Equirectangular coordinates mode */
  20750. static readonly EQUIRECTANGULAR_MODE: number;
  20751. /** Equirectangular Fixed coordinates mode */
  20752. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20753. /** Equirectangular Fixed Mirrored coordinates mode */
  20754. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20755. /** Texture is not repeating outside of 0..1 UVs */
  20756. static readonly CLAMP_ADDRESSMODE: number;
  20757. /** Texture is repeating outside of 0..1 UVs */
  20758. static readonly WRAP_ADDRESSMODE: number;
  20759. /** Texture is repeating and mirrored */
  20760. static readonly MIRROR_ADDRESSMODE: number;
  20761. /**
  20762. * 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
  20763. */
  20764. static UseSerializedUrlIfAny: boolean;
  20765. /**
  20766. * Define the url of the texture.
  20767. */
  20768. url: Nullable<string>;
  20769. /**
  20770. * Define an offset on the texture to offset the u coordinates of the UVs
  20771. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20772. */
  20773. uOffset: number;
  20774. /**
  20775. * Define an offset on the texture to offset the v coordinates of the UVs
  20776. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20777. */
  20778. vOffset: number;
  20779. /**
  20780. * Define an offset on the texture to scale the u coordinates of the UVs
  20781. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20782. */
  20783. uScale: number;
  20784. /**
  20785. * Define an offset on the texture to scale the v coordinates of the UVs
  20786. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20787. */
  20788. vScale: number;
  20789. /**
  20790. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20791. * @see http://doc.babylonjs.com/how_to/more_materials
  20792. */
  20793. uAng: number;
  20794. /**
  20795. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20796. * @see http://doc.babylonjs.com/how_to/more_materials
  20797. */
  20798. vAng: number;
  20799. /**
  20800. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20801. * @see http://doc.babylonjs.com/how_to/more_materials
  20802. */
  20803. wAng: number;
  20804. /**
  20805. * Defines the center of rotation (U)
  20806. */
  20807. uRotationCenter: number;
  20808. /**
  20809. * Defines the center of rotation (V)
  20810. */
  20811. vRotationCenter: number;
  20812. /**
  20813. * Defines the center of rotation (W)
  20814. */
  20815. wRotationCenter: number;
  20816. /**
  20817. * Are mip maps generated for this texture or not.
  20818. */
  20819. get noMipmap(): boolean;
  20820. /**
  20821. * List of inspectable custom properties (used by the Inspector)
  20822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20823. */
  20824. inspectableCustomProperties: Nullable<IInspectable[]>;
  20825. private _noMipmap;
  20826. /** @hidden */
  20827. _invertY: boolean;
  20828. private _rowGenerationMatrix;
  20829. private _cachedTextureMatrix;
  20830. private _projectionModeMatrix;
  20831. private _t0;
  20832. private _t1;
  20833. private _t2;
  20834. private _cachedUOffset;
  20835. private _cachedVOffset;
  20836. private _cachedUScale;
  20837. private _cachedVScale;
  20838. private _cachedUAng;
  20839. private _cachedVAng;
  20840. private _cachedWAng;
  20841. private _cachedProjectionMatrixId;
  20842. private _cachedCoordinatesMode;
  20843. /** @hidden */
  20844. protected _initialSamplingMode: number;
  20845. /** @hidden */
  20846. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20847. private _deleteBuffer;
  20848. protected _format: Nullable<number>;
  20849. private _delayedOnLoad;
  20850. private _delayedOnError;
  20851. private _mimeType?;
  20852. /**
  20853. * Observable triggered once the texture has been loaded.
  20854. */
  20855. onLoadObservable: Observable<Texture>;
  20856. protected _isBlocking: boolean;
  20857. /**
  20858. * Is the texture preventing material to render while loading.
  20859. * If false, a default texture will be used instead of the loading one during the preparation step.
  20860. */
  20861. set isBlocking(value: boolean);
  20862. get isBlocking(): boolean;
  20863. /**
  20864. * Get the current sampling mode associated with the texture.
  20865. */
  20866. get samplingMode(): number;
  20867. /**
  20868. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20869. */
  20870. get invertY(): boolean;
  20871. /**
  20872. * Instantiates a new texture.
  20873. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20874. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20875. * @param url defines the url of the picture to load as a texture
  20876. * @param scene defines the scene or engine the texture will belong to
  20877. * @param noMipmap defines if the texture will require mip maps or not
  20878. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20879. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20880. * @param onLoad defines a callback triggered when the texture has been loaded
  20881. * @param onError defines a callback triggered when an error occurred during the loading session
  20882. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20883. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20884. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20885. * @param mimeType defines an optional mime type information
  20886. */
  20887. 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);
  20888. /**
  20889. * Update the url (and optional buffer) of this texture if url was null during construction.
  20890. * @param url the url of the texture
  20891. * @param buffer the buffer of the texture (defaults to null)
  20892. * @param onLoad callback called when the texture is loaded (defaults to null)
  20893. */
  20894. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20895. /**
  20896. * Finish the loading sequence of a texture flagged as delayed load.
  20897. * @hidden
  20898. */
  20899. delayLoad(): void;
  20900. private _prepareRowForTextureGeneration;
  20901. /**
  20902. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20903. * @returns the transform matrix of the texture.
  20904. */
  20905. getTextureMatrix(uBase?: number): Matrix;
  20906. /**
  20907. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20908. * @returns The reflection texture transform
  20909. */
  20910. getReflectionTextureMatrix(): Matrix;
  20911. /**
  20912. * Clones the texture.
  20913. * @returns the cloned texture
  20914. */
  20915. clone(): Texture;
  20916. /**
  20917. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20918. * @returns The JSON representation of the texture
  20919. */
  20920. serialize(): any;
  20921. /**
  20922. * Get the current class name of the texture useful for serialization or dynamic coding.
  20923. * @returns "Texture"
  20924. */
  20925. getClassName(): string;
  20926. /**
  20927. * Dispose the texture and release its associated resources.
  20928. */
  20929. dispose(): void;
  20930. /**
  20931. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20932. * @param parsedTexture Define the JSON representation of the texture
  20933. * @param scene Define the scene the parsed texture should be instantiated in
  20934. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20935. * @returns The parsed texture if successful
  20936. */
  20937. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20938. /**
  20939. * Creates a texture from its base 64 representation.
  20940. * @param data Define the base64 payload without the data: prefix
  20941. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20942. * @param scene Define the scene the texture should belong to
  20943. * @param noMipmap Forces the texture to not create mip map information if true
  20944. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20945. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20946. * @param onLoad define a callback triggered when the texture has been loaded
  20947. * @param onError define a callback triggered when an error occurred during the loading session
  20948. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20949. * @returns the created texture
  20950. */
  20951. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20952. /**
  20953. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20954. * @param data Define the base64 payload without the data: prefix
  20955. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20956. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20957. * @param scene Define the scene the texture should belong to
  20958. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20959. * @param noMipmap Forces the texture to not create mip map information if true
  20960. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20961. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20962. * @param onLoad define a callback triggered when the texture has been loaded
  20963. * @param onError define a callback triggered when an error occurred during the loading session
  20964. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20965. * @returns the created texture
  20966. */
  20967. 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;
  20968. }
  20969. }
  20970. declare module "babylonjs/PostProcesses/postProcessManager" {
  20971. import { Nullable } from "babylonjs/types";
  20972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20974. import { Scene } from "babylonjs/scene";
  20975. /**
  20976. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20977. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20978. */
  20979. export class PostProcessManager {
  20980. private _scene;
  20981. private _indexBuffer;
  20982. private _vertexBuffers;
  20983. /**
  20984. * Creates a new instance PostProcess
  20985. * @param scene The scene that the post process is associated with.
  20986. */
  20987. constructor(scene: Scene);
  20988. private _prepareBuffers;
  20989. private _buildIndexBuffer;
  20990. /**
  20991. * Rebuilds the vertex buffers of the manager.
  20992. * @hidden
  20993. */
  20994. _rebuild(): void;
  20995. /**
  20996. * Prepares a frame to be run through a post process.
  20997. * @param sourceTexture The input texture to the post procesess. (default: null)
  20998. * @param postProcesses An array of post processes to be run. (default: null)
  20999. * @returns True if the post processes were able to be run.
  21000. * @hidden
  21001. */
  21002. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21003. /**
  21004. * Manually render a set of post processes to a texture.
  21005. * @param postProcesses An array of post processes to be run.
  21006. * @param targetTexture The target texture to render to.
  21007. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21008. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21009. * @param lodLevel defines which lod of the texture to render to
  21010. */
  21011. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21012. /**
  21013. * Finalize the result of the output of the postprocesses.
  21014. * @param doNotPresent If true the result will not be displayed to the screen.
  21015. * @param targetTexture The target texture to render to.
  21016. * @param faceIndex The index of the face to bind the target texture to.
  21017. * @param postProcesses The array of post processes to render.
  21018. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21019. * @hidden
  21020. */
  21021. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21022. /**
  21023. * Disposes of the post process manager.
  21024. */
  21025. dispose(): void;
  21026. }
  21027. }
  21028. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21029. import { Observable } from "babylonjs/Misc/observable";
  21030. import { SmartArray } from "babylonjs/Misc/smartArray";
  21031. import { Nullable, Immutable } from "babylonjs/types";
  21032. import { Camera } from "babylonjs/Cameras/camera";
  21033. import { Scene } from "babylonjs/scene";
  21034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21035. import { Color4 } from "babylonjs/Maths/math.color";
  21036. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21038. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21040. import { Texture } from "babylonjs/Materials/Textures/texture";
  21041. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21042. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21043. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21044. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21045. import { Engine } from "babylonjs/Engines/engine";
  21046. /**
  21047. * This Helps creating a texture that will be created from a camera in your scene.
  21048. * It is basically a dynamic texture that could be used to create special effects for instance.
  21049. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21050. */
  21051. export class RenderTargetTexture extends Texture {
  21052. isCube: boolean;
  21053. /**
  21054. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21055. */
  21056. static readonly REFRESHRATE_RENDER_ONCE: number;
  21057. /**
  21058. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21059. */
  21060. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21061. /**
  21062. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21063. * the central point of your effect and can save a lot of performances.
  21064. */
  21065. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21066. /**
  21067. * Use this predicate to dynamically define the list of mesh you want to render.
  21068. * If set, the renderList property will be overwritten.
  21069. */
  21070. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21071. private _renderList;
  21072. /**
  21073. * Use this list to define the list of mesh you want to render.
  21074. */
  21075. get renderList(): Nullable<Array<AbstractMesh>>;
  21076. set renderList(value: Nullable<Array<AbstractMesh>>);
  21077. /**
  21078. * Use this function to overload the renderList array at rendering time.
  21079. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21080. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21081. * the cube (if the RTT is a cube, else layerOrFace=0).
  21082. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21083. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21084. * hold dummy elements!
  21085. */
  21086. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21087. private _hookArray;
  21088. /**
  21089. * Define if particles should be rendered in your texture.
  21090. */
  21091. renderParticles: boolean;
  21092. /**
  21093. * Define if sprites should be rendered in your texture.
  21094. */
  21095. renderSprites: boolean;
  21096. /**
  21097. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21098. */
  21099. coordinatesMode: number;
  21100. /**
  21101. * Define the camera used to render the texture.
  21102. */
  21103. activeCamera: Nullable<Camera>;
  21104. /**
  21105. * Override the render function of the texture with your own one.
  21106. */
  21107. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21108. /**
  21109. * Define if camera post processes should be use while rendering the texture.
  21110. */
  21111. useCameraPostProcesses: boolean;
  21112. /**
  21113. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21114. */
  21115. ignoreCameraViewport: boolean;
  21116. private _postProcessManager;
  21117. private _postProcesses;
  21118. private _resizeObserver;
  21119. /**
  21120. * An event triggered when the texture is unbind.
  21121. */
  21122. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21123. /**
  21124. * An event triggered when the texture is unbind.
  21125. */
  21126. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21127. private _onAfterUnbindObserver;
  21128. /**
  21129. * Set a after unbind callback in the texture.
  21130. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21131. */
  21132. set onAfterUnbind(callback: () => void);
  21133. /**
  21134. * An event triggered before rendering the texture
  21135. */
  21136. onBeforeRenderObservable: Observable<number>;
  21137. private _onBeforeRenderObserver;
  21138. /**
  21139. * Set a before render callback in the texture.
  21140. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21141. */
  21142. set onBeforeRender(callback: (faceIndex: number) => void);
  21143. /**
  21144. * An event triggered after rendering the texture
  21145. */
  21146. onAfterRenderObservable: Observable<number>;
  21147. private _onAfterRenderObserver;
  21148. /**
  21149. * Set a after render callback in the texture.
  21150. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21151. */
  21152. set onAfterRender(callback: (faceIndex: number) => void);
  21153. /**
  21154. * An event triggered after the texture clear
  21155. */
  21156. onClearObservable: Observable<Engine>;
  21157. private _onClearObserver;
  21158. /**
  21159. * Set a clear callback in the texture.
  21160. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21161. */
  21162. set onClear(callback: (Engine: Engine) => void);
  21163. /**
  21164. * An event triggered when the texture is resized.
  21165. */
  21166. onResizeObservable: Observable<RenderTargetTexture>;
  21167. /**
  21168. * Define the clear color of the Render Target if it should be different from the scene.
  21169. */
  21170. clearColor: Color4;
  21171. protected _size: number | {
  21172. width: number;
  21173. height: number;
  21174. layers?: number;
  21175. };
  21176. protected _initialSizeParameter: number | {
  21177. width: number;
  21178. height: number;
  21179. } | {
  21180. ratio: number;
  21181. };
  21182. protected _sizeRatio: Nullable<number>;
  21183. /** @hidden */
  21184. _generateMipMaps: boolean;
  21185. protected _renderingManager: RenderingManager;
  21186. /** @hidden */
  21187. _waitingRenderList: string[];
  21188. protected _doNotChangeAspectRatio: boolean;
  21189. protected _currentRefreshId: number;
  21190. protected _refreshRate: number;
  21191. protected _textureMatrix: Matrix;
  21192. protected _samples: number;
  21193. protected _renderTargetOptions: RenderTargetCreationOptions;
  21194. /**
  21195. * Gets render target creation options that were used.
  21196. */
  21197. get renderTargetOptions(): RenderTargetCreationOptions;
  21198. protected _engine: Engine;
  21199. protected _onRatioRescale(): void;
  21200. /**
  21201. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21202. * It must define where the camera used to render the texture is set
  21203. */
  21204. boundingBoxPosition: Vector3;
  21205. private _boundingBoxSize;
  21206. /**
  21207. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21208. * When defined, the cubemap will switch to local mode
  21209. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21210. * @example https://www.babylonjs-playground.com/#RNASML
  21211. */
  21212. set boundingBoxSize(value: Vector3);
  21213. get boundingBoxSize(): Vector3;
  21214. /**
  21215. * In case the RTT has been created with a depth texture, get the associated
  21216. * depth texture.
  21217. * Otherwise, return null.
  21218. */
  21219. get depthStencilTexture(): Nullable<InternalTexture>;
  21220. /**
  21221. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21222. * or used a shadow, depth texture...
  21223. * @param name The friendly name of the texture
  21224. * @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)
  21225. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21226. * @param generateMipMaps True if mip maps need to be generated after render.
  21227. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21228. * @param type The type of the buffer in the RTT (int, half float, float...)
  21229. * @param isCube True if a cube texture needs to be created
  21230. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21231. * @param generateDepthBuffer True to generate a depth buffer
  21232. * @param generateStencilBuffer True to generate a stencil buffer
  21233. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21234. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21235. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21236. */
  21237. constructor(name: string, size: number | {
  21238. width: number;
  21239. height: number;
  21240. layers?: number;
  21241. } | {
  21242. ratio: number;
  21243. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21244. /**
  21245. * Creates a depth stencil texture.
  21246. * This is only available in WebGL 2 or with the depth texture extension available.
  21247. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21248. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21249. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21250. */
  21251. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21252. private _processSizeParameter;
  21253. /**
  21254. * Define the number of samples to use in case of MSAA.
  21255. * It defaults to one meaning no MSAA has been enabled.
  21256. */
  21257. get samples(): number;
  21258. set samples(value: number);
  21259. /**
  21260. * Resets the refresh counter of the texture and start bak from scratch.
  21261. * Could be useful to regenerate the texture if it is setup to render only once.
  21262. */
  21263. resetRefreshCounter(): void;
  21264. /**
  21265. * Define the refresh rate of the texture or the rendering frequency.
  21266. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21267. */
  21268. get refreshRate(): number;
  21269. set refreshRate(value: number);
  21270. /**
  21271. * Adds a post process to the render target rendering passes.
  21272. * @param postProcess define the post process to add
  21273. */
  21274. addPostProcess(postProcess: PostProcess): void;
  21275. /**
  21276. * Clear all the post processes attached to the render target
  21277. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21278. */
  21279. clearPostProcesses(dispose?: boolean): void;
  21280. /**
  21281. * Remove one of the post process from the list of attached post processes to the texture
  21282. * @param postProcess define the post process to remove from the list
  21283. */
  21284. removePostProcess(postProcess: PostProcess): void;
  21285. /** @hidden */
  21286. _shouldRender(): boolean;
  21287. /**
  21288. * Gets the actual render size of the texture.
  21289. * @returns the width of the render size
  21290. */
  21291. getRenderSize(): number;
  21292. /**
  21293. * Gets the actual render width of the texture.
  21294. * @returns the width of the render size
  21295. */
  21296. getRenderWidth(): number;
  21297. /**
  21298. * Gets the actual render height of the texture.
  21299. * @returns the height of the render size
  21300. */
  21301. getRenderHeight(): number;
  21302. /**
  21303. * Gets the actual number of layers of the texture.
  21304. * @returns the number of layers
  21305. */
  21306. getRenderLayers(): number;
  21307. /**
  21308. * Get if the texture can be rescaled or not.
  21309. */
  21310. get canRescale(): boolean;
  21311. /**
  21312. * Resize the texture using a ratio.
  21313. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21314. */
  21315. scale(ratio: number): void;
  21316. /**
  21317. * Get the texture reflection matrix used to rotate/transform the reflection.
  21318. * @returns the reflection matrix
  21319. */
  21320. getReflectionTextureMatrix(): Matrix;
  21321. /**
  21322. * Resize the texture to a new desired size.
  21323. * Be carrefull as it will recreate all the data in the new texture.
  21324. * @param size Define the new size. It can be:
  21325. * - a number for squared texture,
  21326. * - an object containing { width: number, height: number }
  21327. * - or an object containing a ratio { ratio: number }
  21328. */
  21329. resize(size: number | {
  21330. width: number;
  21331. height: number;
  21332. } | {
  21333. ratio: number;
  21334. }): void;
  21335. private _defaultRenderListPrepared;
  21336. /**
  21337. * Renders all the objects from the render list into the texture.
  21338. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21339. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21340. */
  21341. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21342. private _bestReflectionRenderTargetDimension;
  21343. private _prepareRenderingManager;
  21344. /**
  21345. * @hidden
  21346. * @param faceIndex face index to bind to if this is a cubetexture
  21347. * @param layer defines the index of the texture to bind in the array
  21348. */
  21349. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21350. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21351. private renderToTarget;
  21352. /**
  21353. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21354. * This allowed control for front to back rendering or reversly depending of the special needs.
  21355. *
  21356. * @param renderingGroupId The rendering group id corresponding to its index
  21357. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21358. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21359. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21360. */
  21361. 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;
  21362. /**
  21363. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21364. *
  21365. * @param renderingGroupId The rendering group id corresponding to its index
  21366. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21367. */
  21368. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21369. /**
  21370. * Clones the texture.
  21371. * @returns the cloned texture
  21372. */
  21373. clone(): RenderTargetTexture;
  21374. /**
  21375. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21376. * @returns The JSON representation of the texture
  21377. */
  21378. serialize(): any;
  21379. /**
  21380. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21381. */
  21382. disposeFramebufferObjects(): void;
  21383. /**
  21384. * Dispose the texture and release its associated resources.
  21385. */
  21386. dispose(): void;
  21387. /** @hidden */
  21388. _rebuild(): void;
  21389. /**
  21390. * Clear the info related to rendering groups preventing retention point in material dispose.
  21391. */
  21392. freeRenderingGroups(): void;
  21393. /**
  21394. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21395. * @returns the view count
  21396. */
  21397. getViewCount(): number;
  21398. }
  21399. }
  21400. declare module "babylonjs/Materials/material" {
  21401. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21402. import { SmartArray } from "babylonjs/Misc/smartArray";
  21403. import { Observable } from "babylonjs/Misc/observable";
  21404. import { Nullable } from "babylonjs/types";
  21405. import { Scene } from "babylonjs/scene";
  21406. import { Matrix } from "babylonjs/Maths/math.vector";
  21407. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21409. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21410. import { Effect } from "babylonjs/Materials/effect";
  21411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21412. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21413. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21414. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21415. import { Mesh } from "babylonjs/Meshes/mesh";
  21416. import { Animation } from "babylonjs/Animations/animation";
  21417. /**
  21418. * Options for compiling materials.
  21419. */
  21420. export interface IMaterialCompilationOptions {
  21421. /**
  21422. * Defines whether clip planes are enabled.
  21423. */
  21424. clipPlane: boolean;
  21425. /**
  21426. * Defines whether instances are enabled.
  21427. */
  21428. useInstances: boolean;
  21429. }
  21430. /**
  21431. * Base class for the main features of a material in Babylon.js
  21432. */
  21433. export class Material implements IAnimatable {
  21434. /**
  21435. * Returns the triangle fill mode
  21436. */
  21437. static readonly TriangleFillMode: number;
  21438. /**
  21439. * Returns the wireframe mode
  21440. */
  21441. static readonly WireFrameFillMode: number;
  21442. /**
  21443. * Returns the point fill mode
  21444. */
  21445. static readonly PointFillMode: number;
  21446. /**
  21447. * Returns the point list draw mode
  21448. */
  21449. static readonly PointListDrawMode: number;
  21450. /**
  21451. * Returns the line list draw mode
  21452. */
  21453. static readonly LineListDrawMode: number;
  21454. /**
  21455. * Returns the line loop draw mode
  21456. */
  21457. static readonly LineLoopDrawMode: number;
  21458. /**
  21459. * Returns the line strip draw mode
  21460. */
  21461. static readonly LineStripDrawMode: number;
  21462. /**
  21463. * Returns the triangle strip draw mode
  21464. */
  21465. static readonly TriangleStripDrawMode: number;
  21466. /**
  21467. * Returns the triangle fan draw mode
  21468. */
  21469. static readonly TriangleFanDrawMode: number;
  21470. /**
  21471. * Stores the clock-wise side orientation
  21472. */
  21473. static readonly ClockWiseSideOrientation: number;
  21474. /**
  21475. * Stores the counter clock-wise side orientation
  21476. */
  21477. static readonly CounterClockWiseSideOrientation: number;
  21478. /**
  21479. * The dirty texture flag value
  21480. */
  21481. static readonly TextureDirtyFlag: number;
  21482. /**
  21483. * The dirty light flag value
  21484. */
  21485. static readonly LightDirtyFlag: number;
  21486. /**
  21487. * The dirty fresnel flag value
  21488. */
  21489. static readonly FresnelDirtyFlag: number;
  21490. /**
  21491. * The dirty attribute flag value
  21492. */
  21493. static readonly AttributesDirtyFlag: number;
  21494. /**
  21495. * The dirty misc flag value
  21496. */
  21497. static readonly MiscDirtyFlag: number;
  21498. /**
  21499. * The all dirty flag value
  21500. */
  21501. static readonly AllDirtyFlag: number;
  21502. /**
  21503. * The ID of the material
  21504. */
  21505. id: string;
  21506. /**
  21507. * Gets or sets the unique id of the material
  21508. */
  21509. uniqueId: number;
  21510. /**
  21511. * The name of the material
  21512. */
  21513. name: string;
  21514. /**
  21515. * Gets or sets user defined metadata
  21516. */
  21517. metadata: any;
  21518. /**
  21519. * For internal use only. Please do not use.
  21520. */
  21521. reservedDataStore: any;
  21522. /**
  21523. * Specifies if the ready state should be checked on each call
  21524. */
  21525. checkReadyOnEveryCall: boolean;
  21526. /**
  21527. * Specifies if the ready state should be checked once
  21528. */
  21529. checkReadyOnlyOnce: boolean;
  21530. /**
  21531. * The state of the material
  21532. */
  21533. state: string;
  21534. /**
  21535. * The alpha value of the material
  21536. */
  21537. protected _alpha: number;
  21538. /**
  21539. * List of inspectable custom properties (used by the Inspector)
  21540. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21541. */
  21542. inspectableCustomProperties: IInspectable[];
  21543. /**
  21544. * Sets the alpha value of the material
  21545. */
  21546. set alpha(value: number);
  21547. /**
  21548. * Gets the alpha value of the material
  21549. */
  21550. get alpha(): number;
  21551. /**
  21552. * Specifies if back face culling is enabled
  21553. */
  21554. protected _backFaceCulling: boolean;
  21555. /**
  21556. * Sets the back-face culling state
  21557. */
  21558. set backFaceCulling(value: boolean);
  21559. /**
  21560. * Gets the back-face culling state
  21561. */
  21562. get backFaceCulling(): boolean;
  21563. /**
  21564. * Stores the value for side orientation
  21565. */
  21566. sideOrientation: number;
  21567. /**
  21568. * Callback triggered when the material is compiled
  21569. */
  21570. onCompiled: Nullable<(effect: Effect) => void>;
  21571. /**
  21572. * Callback triggered when an error occurs
  21573. */
  21574. onError: Nullable<(effect: Effect, errors: string) => void>;
  21575. /**
  21576. * Callback triggered to get the render target textures
  21577. */
  21578. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21579. /**
  21580. * Gets a boolean indicating that current material needs to register RTT
  21581. */
  21582. get hasRenderTargetTextures(): boolean;
  21583. /**
  21584. * Specifies if the material should be serialized
  21585. */
  21586. doNotSerialize: boolean;
  21587. /**
  21588. * @hidden
  21589. */
  21590. _storeEffectOnSubMeshes: boolean;
  21591. /**
  21592. * Stores the animations for the material
  21593. */
  21594. animations: Nullable<Array<Animation>>;
  21595. /**
  21596. * An event triggered when the material is disposed
  21597. */
  21598. onDisposeObservable: Observable<Material>;
  21599. /**
  21600. * An observer which watches for dispose events
  21601. */
  21602. private _onDisposeObserver;
  21603. private _onUnBindObservable;
  21604. /**
  21605. * Called during a dispose event
  21606. */
  21607. set onDispose(callback: () => void);
  21608. private _onBindObservable;
  21609. /**
  21610. * An event triggered when the material is bound
  21611. */
  21612. get onBindObservable(): Observable<AbstractMesh>;
  21613. /**
  21614. * An observer which watches for bind events
  21615. */
  21616. private _onBindObserver;
  21617. /**
  21618. * Called during a bind event
  21619. */
  21620. set onBind(callback: (Mesh: AbstractMesh) => void);
  21621. /**
  21622. * An event triggered when the material is unbound
  21623. */
  21624. get onUnBindObservable(): Observable<Material>;
  21625. /**
  21626. * Stores the value of the alpha mode
  21627. */
  21628. private _alphaMode;
  21629. /**
  21630. * Sets the value of the alpha mode.
  21631. *
  21632. * | Value | Type | Description |
  21633. * | --- | --- | --- |
  21634. * | 0 | ALPHA_DISABLE | |
  21635. * | 1 | ALPHA_ADD | |
  21636. * | 2 | ALPHA_COMBINE | |
  21637. * | 3 | ALPHA_SUBTRACT | |
  21638. * | 4 | ALPHA_MULTIPLY | |
  21639. * | 5 | ALPHA_MAXIMIZED | |
  21640. * | 6 | ALPHA_ONEONE | |
  21641. * | 7 | ALPHA_PREMULTIPLIED | |
  21642. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21643. * | 9 | ALPHA_INTERPOLATE | |
  21644. * | 10 | ALPHA_SCREENMODE | |
  21645. *
  21646. */
  21647. set alphaMode(value: number);
  21648. /**
  21649. * Gets the value of the alpha mode
  21650. */
  21651. get alphaMode(): number;
  21652. /**
  21653. * Stores the state of the need depth pre-pass value
  21654. */
  21655. private _needDepthPrePass;
  21656. /**
  21657. * Sets the need depth pre-pass value
  21658. */
  21659. set needDepthPrePass(value: boolean);
  21660. /**
  21661. * Gets the depth pre-pass value
  21662. */
  21663. get needDepthPrePass(): boolean;
  21664. /**
  21665. * Specifies if depth writing should be disabled
  21666. */
  21667. disableDepthWrite: boolean;
  21668. /**
  21669. * Specifies if depth writing should be forced
  21670. */
  21671. forceDepthWrite: boolean;
  21672. /**
  21673. * Specifies the depth function that should be used. 0 means the default engine function
  21674. */
  21675. depthFunction: number;
  21676. /**
  21677. * Specifies if there should be a separate pass for culling
  21678. */
  21679. separateCullingPass: boolean;
  21680. /**
  21681. * Stores the state specifing if fog should be enabled
  21682. */
  21683. private _fogEnabled;
  21684. /**
  21685. * Sets the state for enabling fog
  21686. */
  21687. set fogEnabled(value: boolean);
  21688. /**
  21689. * Gets the value of the fog enabled state
  21690. */
  21691. get fogEnabled(): boolean;
  21692. /**
  21693. * Stores the size of points
  21694. */
  21695. pointSize: number;
  21696. /**
  21697. * Stores the z offset value
  21698. */
  21699. zOffset: number;
  21700. /**
  21701. * Gets a value specifying if wireframe mode is enabled
  21702. */
  21703. get wireframe(): boolean;
  21704. /**
  21705. * Sets the state of wireframe mode
  21706. */
  21707. set wireframe(value: boolean);
  21708. /**
  21709. * Gets the value specifying if point clouds are enabled
  21710. */
  21711. get pointsCloud(): boolean;
  21712. /**
  21713. * Sets the state of point cloud mode
  21714. */
  21715. set pointsCloud(value: boolean);
  21716. /**
  21717. * Gets the material fill mode
  21718. */
  21719. get fillMode(): number;
  21720. /**
  21721. * Sets the material fill mode
  21722. */
  21723. set fillMode(value: number);
  21724. /**
  21725. * @hidden
  21726. * Stores the effects for the material
  21727. */
  21728. _effect: Nullable<Effect>;
  21729. /**
  21730. * Specifies if uniform buffers should be used
  21731. */
  21732. private _useUBO;
  21733. /**
  21734. * Stores a reference to the scene
  21735. */
  21736. private _scene;
  21737. /**
  21738. * Stores the fill mode state
  21739. */
  21740. private _fillMode;
  21741. /**
  21742. * Specifies if the depth write state should be cached
  21743. */
  21744. private _cachedDepthWriteState;
  21745. /**
  21746. * Specifies if the depth function state should be cached
  21747. */
  21748. private _cachedDepthFunctionState;
  21749. /**
  21750. * Stores the uniform buffer
  21751. */
  21752. protected _uniformBuffer: UniformBuffer;
  21753. /** @hidden */
  21754. _indexInSceneMaterialArray: number;
  21755. /** @hidden */
  21756. meshMap: Nullable<{
  21757. [id: string]: AbstractMesh | undefined;
  21758. }>;
  21759. /**
  21760. * Creates a material instance
  21761. * @param name defines the name of the material
  21762. * @param scene defines the scene to reference
  21763. * @param doNotAdd specifies if the material should be added to the scene
  21764. */
  21765. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21766. /**
  21767. * Returns a string representation of the current material
  21768. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21769. * @returns a string with material information
  21770. */
  21771. toString(fullDetails?: boolean): string;
  21772. /**
  21773. * Gets the class name of the material
  21774. * @returns a string with the class name of the material
  21775. */
  21776. getClassName(): string;
  21777. /**
  21778. * Specifies if updates for the material been locked
  21779. */
  21780. get isFrozen(): boolean;
  21781. /**
  21782. * Locks updates for the material
  21783. */
  21784. freeze(): void;
  21785. /**
  21786. * Unlocks updates for the material
  21787. */
  21788. unfreeze(): void;
  21789. /**
  21790. * Specifies if the material is ready to be used
  21791. * @param mesh defines the mesh to check
  21792. * @param useInstances specifies if instances should be used
  21793. * @returns a boolean indicating if the material is ready to be used
  21794. */
  21795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21796. /**
  21797. * Specifies that the submesh is ready to be used
  21798. * @param mesh defines the mesh to check
  21799. * @param subMesh defines which submesh to check
  21800. * @param useInstances specifies that instances should be used
  21801. * @returns a boolean indicating that the submesh is ready or not
  21802. */
  21803. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21804. /**
  21805. * Returns the material effect
  21806. * @returns the effect associated with the material
  21807. */
  21808. getEffect(): Nullable<Effect>;
  21809. /**
  21810. * Returns the current scene
  21811. * @returns a Scene
  21812. */
  21813. getScene(): Scene;
  21814. /**
  21815. * Specifies if the material will require alpha blending
  21816. * @returns a boolean specifying if alpha blending is needed
  21817. */
  21818. needAlphaBlending(): boolean;
  21819. /**
  21820. * Specifies if the mesh will require alpha blending
  21821. * @param mesh defines the mesh to check
  21822. * @returns a boolean specifying if alpha blending is needed for the mesh
  21823. */
  21824. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21825. /**
  21826. * Specifies if this material should be rendered in alpha test mode
  21827. * @returns a boolean specifying if an alpha test is needed.
  21828. */
  21829. needAlphaTesting(): boolean;
  21830. /**
  21831. * Gets the texture used for the alpha test
  21832. * @returns the texture to use for alpha testing
  21833. */
  21834. getAlphaTestTexture(): Nullable<BaseTexture>;
  21835. /**
  21836. * Marks the material to indicate that it needs to be re-calculated
  21837. */
  21838. markDirty(): void;
  21839. /** @hidden */
  21840. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21841. /**
  21842. * Binds the material to the mesh
  21843. * @param world defines the world transformation matrix
  21844. * @param mesh defines the mesh to bind the material to
  21845. */
  21846. bind(world: Matrix, mesh?: Mesh): void;
  21847. /**
  21848. * Binds the submesh to the material
  21849. * @param world defines the world transformation matrix
  21850. * @param mesh defines the mesh containing the submesh
  21851. * @param subMesh defines the submesh to bind the material to
  21852. */
  21853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21854. /**
  21855. * Binds the world matrix to the material
  21856. * @param world defines the world transformation matrix
  21857. */
  21858. bindOnlyWorldMatrix(world: Matrix): void;
  21859. /**
  21860. * Binds the scene's uniform buffer to the effect.
  21861. * @param effect defines the effect to bind to the scene uniform buffer
  21862. * @param sceneUbo defines the uniform buffer storing scene data
  21863. */
  21864. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21865. /**
  21866. * Binds the view matrix to the effect
  21867. * @param effect defines the effect to bind the view matrix to
  21868. */
  21869. bindView(effect: Effect): void;
  21870. /**
  21871. * Binds the view projection matrix to the effect
  21872. * @param effect defines the effect to bind the view projection matrix to
  21873. */
  21874. bindViewProjection(effect: Effect): void;
  21875. /**
  21876. * Specifies if material alpha testing should be turned on for the mesh
  21877. * @param mesh defines the mesh to check
  21878. */
  21879. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21880. /**
  21881. * Processes to execute after binding the material to a mesh
  21882. * @param mesh defines the rendered mesh
  21883. */
  21884. protected _afterBind(mesh?: Mesh): void;
  21885. /**
  21886. * Unbinds the material from the mesh
  21887. */
  21888. unbind(): void;
  21889. /**
  21890. * Gets the active textures from the material
  21891. * @returns an array of textures
  21892. */
  21893. getActiveTextures(): BaseTexture[];
  21894. /**
  21895. * Specifies if the material uses a texture
  21896. * @param texture defines the texture to check against the material
  21897. * @returns a boolean specifying if the material uses the texture
  21898. */
  21899. hasTexture(texture: BaseTexture): boolean;
  21900. /**
  21901. * Makes a duplicate of the material, and gives it a new name
  21902. * @param name defines the new name for the duplicated material
  21903. * @returns the cloned material
  21904. */
  21905. clone(name: string): Nullable<Material>;
  21906. /**
  21907. * Gets the meshes bound to the material
  21908. * @returns an array of meshes bound to the material
  21909. */
  21910. getBindedMeshes(): AbstractMesh[];
  21911. /**
  21912. * Force shader compilation
  21913. * @param mesh defines the mesh associated with this material
  21914. * @param onCompiled defines a function to execute once the material is compiled
  21915. * @param options defines the options to configure the compilation
  21916. * @param onError defines a function to execute if the material fails compiling
  21917. */
  21918. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21919. /**
  21920. * Force shader compilation
  21921. * @param mesh defines the mesh that will use this material
  21922. * @param options defines additional options for compiling the shaders
  21923. * @returns a promise that resolves when the compilation completes
  21924. */
  21925. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21926. private static readonly _AllDirtyCallBack;
  21927. private static readonly _ImageProcessingDirtyCallBack;
  21928. private static readonly _TextureDirtyCallBack;
  21929. private static readonly _FresnelDirtyCallBack;
  21930. private static readonly _MiscDirtyCallBack;
  21931. private static readonly _LightsDirtyCallBack;
  21932. private static readonly _AttributeDirtyCallBack;
  21933. private static _FresnelAndMiscDirtyCallBack;
  21934. private static _TextureAndMiscDirtyCallBack;
  21935. private static readonly _DirtyCallbackArray;
  21936. private static readonly _RunDirtyCallBacks;
  21937. /**
  21938. * Marks a define in the material to indicate that it needs to be re-computed
  21939. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21940. */
  21941. markAsDirty(flag: number): void;
  21942. /**
  21943. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21944. * @param func defines a function which checks material defines against the submeshes
  21945. */
  21946. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21947. /**
  21948. * Indicates that we need to re-calculated for all submeshes
  21949. */
  21950. protected _markAllSubMeshesAsAllDirty(): void;
  21951. /**
  21952. * Indicates that image processing needs to be re-calculated for all submeshes
  21953. */
  21954. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21955. /**
  21956. * Indicates that textures need to be re-calculated for all submeshes
  21957. */
  21958. protected _markAllSubMeshesAsTexturesDirty(): void;
  21959. /**
  21960. * Indicates that fresnel needs to be re-calculated for all submeshes
  21961. */
  21962. protected _markAllSubMeshesAsFresnelDirty(): void;
  21963. /**
  21964. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21965. */
  21966. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21967. /**
  21968. * Indicates that lights need to be re-calculated for all submeshes
  21969. */
  21970. protected _markAllSubMeshesAsLightsDirty(): void;
  21971. /**
  21972. * Indicates that attributes need to be re-calculated for all submeshes
  21973. */
  21974. protected _markAllSubMeshesAsAttributesDirty(): void;
  21975. /**
  21976. * Indicates that misc needs to be re-calculated for all submeshes
  21977. */
  21978. protected _markAllSubMeshesAsMiscDirty(): void;
  21979. /**
  21980. * Indicates that textures and misc need to be re-calculated for all submeshes
  21981. */
  21982. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21983. /**
  21984. * Disposes the material
  21985. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21986. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21987. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21988. */
  21989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21990. /** @hidden */
  21991. private releaseVertexArrayObject;
  21992. /**
  21993. * Serializes this material
  21994. * @returns the serialized material object
  21995. */
  21996. serialize(): any;
  21997. /**
  21998. * Creates a material from parsed material data
  21999. * @param parsedMaterial defines parsed material data
  22000. * @param scene defines the hosting scene
  22001. * @param rootUrl defines the root URL to use to load textures
  22002. * @returns a new material
  22003. */
  22004. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22005. }
  22006. }
  22007. declare module "babylonjs/Materials/multiMaterial" {
  22008. import { Nullable } from "babylonjs/types";
  22009. import { Scene } from "babylonjs/scene";
  22010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22011. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22013. import { Material } from "babylonjs/Materials/material";
  22014. /**
  22015. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22016. * separate meshes. This can be use to improve performances.
  22017. * @see http://doc.babylonjs.com/how_to/multi_materials
  22018. */
  22019. export class MultiMaterial extends Material {
  22020. private _subMaterials;
  22021. /**
  22022. * Gets or Sets the list of Materials used within the multi material.
  22023. * They need to be ordered according to the submeshes order in the associated mesh
  22024. */
  22025. get subMaterials(): Nullable<Material>[];
  22026. set subMaterials(value: Nullable<Material>[]);
  22027. /**
  22028. * Function used to align with Node.getChildren()
  22029. * @returns the list of Materials used within the multi material
  22030. */
  22031. getChildren(): Nullable<Material>[];
  22032. /**
  22033. * Instantiates a new Multi Material
  22034. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22035. * separate meshes. This can be use to improve performances.
  22036. * @see http://doc.babylonjs.com/how_to/multi_materials
  22037. * @param name Define the name in the scene
  22038. * @param scene Define the scene the material belongs to
  22039. */
  22040. constructor(name: string, scene: Scene);
  22041. private _hookArray;
  22042. /**
  22043. * Get one of the submaterial by its index in the submaterials array
  22044. * @param index The index to look the sub material at
  22045. * @returns The Material if the index has been defined
  22046. */
  22047. getSubMaterial(index: number): Nullable<Material>;
  22048. /**
  22049. * Get the list of active textures for the whole sub materials list.
  22050. * @returns All the textures that will be used during the rendering
  22051. */
  22052. getActiveTextures(): BaseTexture[];
  22053. /**
  22054. * Gets the current class name of the material e.g. "MultiMaterial"
  22055. * Mainly use in serialization.
  22056. * @returns the class name
  22057. */
  22058. getClassName(): string;
  22059. /**
  22060. * Checks if the material is ready to render the requested sub mesh
  22061. * @param mesh Define the mesh the submesh belongs to
  22062. * @param subMesh Define the sub mesh to look readyness for
  22063. * @param useInstances Define whether or not the material is used with instances
  22064. * @returns true if ready, otherwise false
  22065. */
  22066. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22067. /**
  22068. * Clones the current material and its related sub materials
  22069. * @param name Define the name of the newly cloned material
  22070. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22071. * @returns the cloned material
  22072. */
  22073. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22074. /**
  22075. * Serializes the materials into a JSON representation.
  22076. * @returns the JSON representation
  22077. */
  22078. serialize(): any;
  22079. /**
  22080. * Dispose the material and release its associated resources
  22081. * @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)
  22082. * @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)
  22083. * @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)
  22084. */
  22085. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22086. /**
  22087. * Creates a MultiMaterial from parsed MultiMaterial data.
  22088. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22089. * @param scene defines the hosting scene
  22090. * @returns a new MultiMaterial
  22091. */
  22092. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22093. }
  22094. }
  22095. declare module "babylonjs/Meshes/subMesh" {
  22096. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22097. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22098. import { Engine } from "babylonjs/Engines/engine";
  22099. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22100. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22101. import { Effect } from "babylonjs/Materials/effect";
  22102. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22103. import { Plane } from "babylonjs/Maths/math.plane";
  22104. import { Collider } from "babylonjs/Collisions/collider";
  22105. import { Material } from "babylonjs/Materials/material";
  22106. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22108. import { Mesh } from "babylonjs/Meshes/mesh";
  22109. import { Ray } from "babylonjs/Culling/ray";
  22110. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22111. /**
  22112. * Base class for submeshes
  22113. */
  22114. export class BaseSubMesh {
  22115. /** @hidden */
  22116. _materialDefines: Nullable<MaterialDefines>;
  22117. /** @hidden */
  22118. _materialEffect: Nullable<Effect>;
  22119. /**
  22120. * Gets material defines used by the effect associated to the sub mesh
  22121. */
  22122. get materialDefines(): Nullable<MaterialDefines>;
  22123. /**
  22124. * Sets material defines used by the effect associated to the sub mesh
  22125. */
  22126. set materialDefines(defines: Nullable<MaterialDefines>);
  22127. /**
  22128. * Gets associated effect
  22129. */
  22130. get effect(): Nullable<Effect>;
  22131. /**
  22132. * Sets associated effect (effect used to render this submesh)
  22133. * @param effect defines the effect to associate with
  22134. * @param defines defines the set of defines used to compile this effect
  22135. */
  22136. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22137. }
  22138. /**
  22139. * Defines a subdivision inside a mesh
  22140. */
  22141. export class SubMesh extends BaseSubMesh implements ICullable {
  22142. /** the material index to use */
  22143. materialIndex: number;
  22144. /** vertex index start */
  22145. verticesStart: number;
  22146. /** vertices count */
  22147. verticesCount: number;
  22148. /** index start */
  22149. indexStart: number;
  22150. /** indices count */
  22151. indexCount: number;
  22152. /** @hidden */
  22153. _linesIndexCount: number;
  22154. private _mesh;
  22155. private _renderingMesh;
  22156. private _boundingInfo;
  22157. private _linesIndexBuffer;
  22158. /** @hidden */
  22159. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22160. /** @hidden */
  22161. _trianglePlanes: Plane[];
  22162. /** @hidden */
  22163. _lastColliderTransformMatrix: Nullable<Matrix>;
  22164. /** @hidden */
  22165. _renderId: number;
  22166. /** @hidden */
  22167. _alphaIndex: number;
  22168. /** @hidden */
  22169. _distanceToCamera: number;
  22170. /** @hidden */
  22171. _id: number;
  22172. private _currentMaterial;
  22173. /**
  22174. * Add a new submesh to a mesh
  22175. * @param materialIndex defines the material index to use
  22176. * @param verticesStart defines vertex index start
  22177. * @param verticesCount defines vertices count
  22178. * @param indexStart defines index start
  22179. * @param indexCount defines indices count
  22180. * @param mesh defines the parent mesh
  22181. * @param renderingMesh defines an optional rendering mesh
  22182. * @param createBoundingBox defines if bounding box should be created for this submesh
  22183. * @returns the new submesh
  22184. */
  22185. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22186. /**
  22187. * Creates a new submesh
  22188. * @param materialIndex defines the material index to use
  22189. * @param verticesStart defines vertex index start
  22190. * @param verticesCount defines vertices count
  22191. * @param indexStart defines index start
  22192. * @param indexCount defines indices count
  22193. * @param mesh defines the parent mesh
  22194. * @param renderingMesh defines an optional rendering mesh
  22195. * @param createBoundingBox defines if bounding box should be created for this submesh
  22196. */
  22197. constructor(
  22198. /** the material index to use */
  22199. materialIndex: number,
  22200. /** vertex index start */
  22201. verticesStart: number,
  22202. /** vertices count */
  22203. verticesCount: number,
  22204. /** index start */
  22205. indexStart: number,
  22206. /** indices count */
  22207. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22208. /**
  22209. * Returns true if this submesh covers the entire parent mesh
  22210. * @ignorenaming
  22211. */
  22212. get IsGlobal(): boolean;
  22213. /**
  22214. * Returns the submesh BoudingInfo object
  22215. * @returns current bounding info (or mesh's one if the submesh is global)
  22216. */
  22217. getBoundingInfo(): BoundingInfo;
  22218. /**
  22219. * Sets the submesh BoundingInfo
  22220. * @param boundingInfo defines the new bounding info to use
  22221. * @returns the SubMesh
  22222. */
  22223. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22224. /**
  22225. * Returns the mesh of the current submesh
  22226. * @return the parent mesh
  22227. */
  22228. getMesh(): AbstractMesh;
  22229. /**
  22230. * Returns the rendering mesh of the submesh
  22231. * @returns the rendering mesh (could be different from parent mesh)
  22232. */
  22233. getRenderingMesh(): Mesh;
  22234. /**
  22235. * Returns the submesh material
  22236. * @returns null or the current material
  22237. */
  22238. getMaterial(): Nullable<Material>;
  22239. /**
  22240. * Sets a new updated BoundingInfo object to the submesh
  22241. * @param data defines an optional position array to use to determine the bounding info
  22242. * @returns the SubMesh
  22243. */
  22244. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22245. /** @hidden */
  22246. _checkCollision(collider: Collider): boolean;
  22247. /**
  22248. * Updates the submesh BoundingInfo
  22249. * @param world defines the world matrix to use to update the bounding info
  22250. * @returns the submesh
  22251. */
  22252. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22253. /**
  22254. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22255. * @param frustumPlanes defines the frustum planes
  22256. * @returns true if the submesh is intersecting with the frustum
  22257. */
  22258. isInFrustum(frustumPlanes: Plane[]): boolean;
  22259. /**
  22260. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22261. * @param frustumPlanes defines the frustum planes
  22262. * @returns true if the submesh is inside the frustum
  22263. */
  22264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22265. /**
  22266. * Renders the submesh
  22267. * @param enableAlphaMode defines if alpha needs to be used
  22268. * @returns the submesh
  22269. */
  22270. render(enableAlphaMode: boolean): SubMesh;
  22271. /**
  22272. * @hidden
  22273. */
  22274. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22275. /**
  22276. * Checks if the submesh intersects with a ray
  22277. * @param ray defines the ray to test
  22278. * @returns true is the passed ray intersects the submesh bounding box
  22279. */
  22280. canIntersects(ray: Ray): boolean;
  22281. /**
  22282. * Intersects current submesh with a ray
  22283. * @param ray defines the ray to test
  22284. * @param positions defines mesh's positions array
  22285. * @param indices defines mesh's indices array
  22286. * @param fastCheck defines if only bounding info should be used
  22287. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22288. * @returns intersection info or null if no intersection
  22289. */
  22290. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22291. /** @hidden */
  22292. private _intersectLines;
  22293. /** @hidden */
  22294. private _intersectUnIndexedLines;
  22295. /** @hidden */
  22296. private _intersectTriangles;
  22297. /** @hidden */
  22298. private _intersectUnIndexedTriangles;
  22299. /** @hidden */
  22300. _rebuild(): void;
  22301. /**
  22302. * Creates a new submesh from the passed mesh
  22303. * @param newMesh defines the new hosting mesh
  22304. * @param newRenderingMesh defines an optional rendering mesh
  22305. * @returns the new submesh
  22306. */
  22307. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22308. /**
  22309. * Release associated resources
  22310. */
  22311. dispose(): void;
  22312. /**
  22313. * Gets the class name
  22314. * @returns the string "SubMesh".
  22315. */
  22316. getClassName(): string;
  22317. /**
  22318. * Creates a new submesh from indices data
  22319. * @param materialIndex the index of the main mesh material
  22320. * @param startIndex the index where to start the copy in the mesh indices array
  22321. * @param indexCount the number of indices to copy then from the startIndex
  22322. * @param mesh the main mesh to create the submesh from
  22323. * @param renderingMesh the optional rendering mesh
  22324. * @returns a new submesh
  22325. */
  22326. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22327. }
  22328. }
  22329. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22330. /**
  22331. * Class used to represent data loading progression
  22332. */
  22333. export class SceneLoaderFlags {
  22334. private static _ForceFullSceneLoadingForIncremental;
  22335. private static _ShowLoadingScreen;
  22336. private static _CleanBoneMatrixWeights;
  22337. private static _loggingLevel;
  22338. /**
  22339. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22340. */
  22341. static get ForceFullSceneLoadingForIncremental(): boolean;
  22342. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22343. /**
  22344. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22345. */
  22346. static get ShowLoadingScreen(): boolean;
  22347. static set ShowLoadingScreen(value: boolean);
  22348. /**
  22349. * Defines the current logging level (while loading the scene)
  22350. * @ignorenaming
  22351. */
  22352. static get loggingLevel(): number;
  22353. static set loggingLevel(value: number);
  22354. /**
  22355. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22356. */
  22357. static get CleanBoneMatrixWeights(): boolean;
  22358. static set CleanBoneMatrixWeights(value: boolean);
  22359. }
  22360. }
  22361. declare module "babylonjs/Meshes/geometry" {
  22362. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22363. import { Scene } from "babylonjs/scene";
  22364. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22365. import { Engine } from "babylonjs/Engines/engine";
  22366. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22367. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22368. import { Effect } from "babylonjs/Materials/effect";
  22369. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22370. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22371. import { Mesh } from "babylonjs/Meshes/mesh";
  22372. /**
  22373. * Class used to store geometry data (vertex buffers + index buffer)
  22374. */
  22375. export class Geometry implements IGetSetVerticesData {
  22376. /**
  22377. * Gets or sets the ID of the geometry
  22378. */
  22379. id: string;
  22380. /**
  22381. * Gets or sets the unique ID of the geometry
  22382. */
  22383. uniqueId: number;
  22384. /**
  22385. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22386. */
  22387. delayLoadState: number;
  22388. /**
  22389. * Gets the file containing the data to load when running in delay load state
  22390. */
  22391. delayLoadingFile: Nullable<string>;
  22392. /**
  22393. * Callback called when the geometry is updated
  22394. */
  22395. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22396. private _scene;
  22397. private _engine;
  22398. private _meshes;
  22399. private _totalVertices;
  22400. /** @hidden */
  22401. _indices: IndicesArray;
  22402. /** @hidden */
  22403. _vertexBuffers: {
  22404. [key: string]: VertexBuffer;
  22405. };
  22406. private _isDisposed;
  22407. private _extend;
  22408. private _boundingBias;
  22409. /** @hidden */
  22410. _delayInfo: Array<string>;
  22411. private _indexBuffer;
  22412. private _indexBufferIsUpdatable;
  22413. /** @hidden */
  22414. _boundingInfo: Nullable<BoundingInfo>;
  22415. /** @hidden */
  22416. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22417. /** @hidden */
  22418. _softwareSkinningFrameId: number;
  22419. private _vertexArrayObjects;
  22420. private _updatable;
  22421. /** @hidden */
  22422. _positions: Nullable<Vector3[]>;
  22423. /**
  22424. * 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
  22425. */
  22426. get boundingBias(): Vector2;
  22427. /**
  22428. * 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
  22429. */
  22430. set boundingBias(value: Vector2);
  22431. /**
  22432. * Static function used to attach a new empty geometry to a mesh
  22433. * @param mesh defines the mesh to attach the geometry to
  22434. * @returns the new Geometry
  22435. */
  22436. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22437. /**
  22438. * Creates a new geometry
  22439. * @param id defines the unique ID
  22440. * @param scene defines the hosting scene
  22441. * @param vertexData defines the VertexData used to get geometry data
  22442. * @param updatable defines if geometry must be updatable (false by default)
  22443. * @param mesh defines the mesh that will be associated with the geometry
  22444. */
  22445. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22446. /**
  22447. * Gets the current extend of the geometry
  22448. */
  22449. get extend(): {
  22450. minimum: Vector3;
  22451. maximum: Vector3;
  22452. };
  22453. /**
  22454. * Gets the hosting scene
  22455. * @returns the hosting Scene
  22456. */
  22457. getScene(): Scene;
  22458. /**
  22459. * Gets the hosting engine
  22460. * @returns the hosting Engine
  22461. */
  22462. getEngine(): Engine;
  22463. /**
  22464. * Defines if the geometry is ready to use
  22465. * @returns true if the geometry is ready to be used
  22466. */
  22467. isReady(): boolean;
  22468. /**
  22469. * Gets a value indicating that the geometry should not be serialized
  22470. */
  22471. get doNotSerialize(): boolean;
  22472. /** @hidden */
  22473. _rebuild(): void;
  22474. /**
  22475. * Affects all geometry data in one call
  22476. * @param vertexData defines the geometry data
  22477. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22478. */
  22479. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22480. /**
  22481. * Set specific vertex data
  22482. * @param kind defines the data kind (Position, normal, etc...)
  22483. * @param data defines the vertex data to use
  22484. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22485. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22486. */
  22487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22488. /**
  22489. * Removes a specific vertex data
  22490. * @param kind defines the data kind (Position, normal, etc...)
  22491. */
  22492. removeVerticesData(kind: string): void;
  22493. /**
  22494. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22495. * @param buffer defines the vertex buffer to use
  22496. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22497. */
  22498. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22499. /**
  22500. * Update a specific vertex buffer
  22501. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22502. * It will do nothing if the buffer is not updatable
  22503. * @param kind defines the data kind (Position, normal, etc...)
  22504. * @param data defines the data to use
  22505. * @param offset defines the offset in the target buffer where to store the data
  22506. * @param useBytes set to true if the offset is in bytes
  22507. */
  22508. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22509. /**
  22510. * Update a specific vertex buffer
  22511. * This function will create a new buffer if the current one is not updatable
  22512. * @param kind defines the data kind (Position, normal, etc...)
  22513. * @param data defines the data to use
  22514. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22515. */
  22516. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22517. private _updateBoundingInfo;
  22518. /** @hidden */
  22519. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22520. /**
  22521. * Gets total number of vertices
  22522. * @returns the total number of vertices
  22523. */
  22524. getTotalVertices(): number;
  22525. /**
  22526. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22527. * @param kind defines the data kind (Position, normal, etc...)
  22528. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22529. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22530. * @returns a float array containing vertex data
  22531. */
  22532. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22533. /**
  22534. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22535. * @param kind defines the data kind (Position, normal, etc...)
  22536. * @returns true if the vertex buffer with the specified kind is updatable
  22537. */
  22538. isVertexBufferUpdatable(kind: string): boolean;
  22539. /**
  22540. * Gets a specific vertex buffer
  22541. * @param kind defines the data kind (Position, normal, etc...)
  22542. * @returns a VertexBuffer
  22543. */
  22544. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22545. /**
  22546. * Returns all vertex buffers
  22547. * @return an object holding all vertex buffers indexed by kind
  22548. */
  22549. getVertexBuffers(): Nullable<{
  22550. [key: string]: VertexBuffer;
  22551. }>;
  22552. /**
  22553. * Gets a boolean indicating if specific vertex buffer is present
  22554. * @param kind defines the data kind (Position, normal, etc...)
  22555. * @returns true if data is present
  22556. */
  22557. isVerticesDataPresent(kind: string): boolean;
  22558. /**
  22559. * Gets a list of all attached data kinds (Position, normal, etc...)
  22560. * @returns a list of string containing all kinds
  22561. */
  22562. getVerticesDataKinds(): string[];
  22563. /**
  22564. * Update index buffer
  22565. * @param indices defines the indices to store in the index buffer
  22566. * @param offset defines the offset in the target buffer where to store the data
  22567. * @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)
  22568. */
  22569. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22570. /**
  22571. * Creates a new index buffer
  22572. * @param indices defines the indices to store in the index buffer
  22573. * @param totalVertices defines the total number of vertices (could be null)
  22574. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22575. */
  22576. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22577. /**
  22578. * Return the total number of indices
  22579. * @returns the total number of indices
  22580. */
  22581. getTotalIndices(): number;
  22582. /**
  22583. * Gets the index buffer array
  22584. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22586. * @returns the index buffer array
  22587. */
  22588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22589. /**
  22590. * Gets the index buffer
  22591. * @return the index buffer
  22592. */
  22593. getIndexBuffer(): Nullable<DataBuffer>;
  22594. /** @hidden */
  22595. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22596. /**
  22597. * Release the associated resources for a specific mesh
  22598. * @param mesh defines the source mesh
  22599. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22600. */
  22601. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22602. /**
  22603. * Apply current geometry to a given mesh
  22604. * @param mesh defines the mesh to apply geometry to
  22605. */
  22606. applyToMesh(mesh: Mesh): void;
  22607. private _updateExtend;
  22608. private _applyToMesh;
  22609. private notifyUpdate;
  22610. /**
  22611. * Load the geometry if it was flagged as delay loaded
  22612. * @param scene defines the hosting scene
  22613. * @param onLoaded defines a callback called when the geometry is loaded
  22614. */
  22615. load(scene: Scene, onLoaded?: () => void): void;
  22616. private _queueLoad;
  22617. /**
  22618. * Invert the geometry to move from a right handed system to a left handed one.
  22619. */
  22620. toLeftHanded(): void;
  22621. /** @hidden */
  22622. _resetPointsArrayCache(): void;
  22623. /** @hidden */
  22624. _generatePointsArray(): boolean;
  22625. /**
  22626. * Gets a value indicating if the geometry is disposed
  22627. * @returns true if the geometry was disposed
  22628. */
  22629. isDisposed(): boolean;
  22630. private _disposeVertexArrayObjects;
  22631. /**
  22632. * Free all associated resources
  22633. */
  22634. dispose(): void;
  22635. /**
  22636. * Clone the current geometry into a new geometry
  22637. * @param id defines the unique ID of the new geometry
  22638. * @returns a new geometry object
  22639. */
  22640. copy(id: string): Geometry;
  22641. /**
  22642. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22643. * @return a JSON representation of the current geometry data (without the vertices data)
  22644. */
  22645. serialize(): any;
  22646. private toNumberArray;
  22647. /**
  22648. * Serialize all vertices data into a JSON oject
  22649. * @returns a JSON representation of the current geometry data
  22650. */
  22651. serializeVerticeData(): any;
  22652. /**
  22653. * Extracts a clone of a mesh geometry
  22654. * @param mesh defines the source mesh
  22655. * @param id defines the unique ID of the new geometry object
  22656. * @returns the new geometry object
  22657. */
  22658. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22659. /**
  22660. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22661. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22662. * Be aware Math.random() could cause collisions, but:
  22663. * "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"
  22664. * @returns a string containing a new GUID
  22665. */
  22666. static RandomId(): string;
  22667. /** @hidden */
  22668. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22669. private static _CleanMatricesWeights;
  22670. /**
  22671. * Create a new geometry from persisted data (Using .babylon file format)
  22672. * @param parsedVertexData defines the persisted data
  22673. * @param scene defines the hosting scene
  22674. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22675. * @returns the new geometry object
  22676. */
  22677. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22678. }
  22679. }
  22680. declare module "babylonjs/Meshes/mesh.vertexData" {
  22681. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22682. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22683. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22684. import { Geometry } from "babylonjs/Meshes/geometry";
  22685. import { Mesh } from "babylonjs/Meshes/mesh";
  22686. /**
  22687. * Define an interface for all classes that will get and set the data on vertices
  22688. */
  22689. export interface IGetSetVerticesData {
  22690. /**
  22691. * Gets a boolean indicating if specific vertex data is present
  22692. * @param kind defines the vertex data kind to use
  22693. * @returns true is data kind is present
  22694. */
  22695. isVerticesDataPresent(kind: string): boolean;
  22696. /**
  22697. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22698. * @param kind defines the data kind (Position, normal, etc...)
  22699. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22700. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22701. * @returns a float array containing vertex data
  22702. */
  22703. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22704. /**
  22705. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22706. * @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.
  22707. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22708. * @returns the indices array or an empty array if the mesh has no geometry
  22709. */
  22710. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22711. /**
  22712. * Set specific vertex data
  22713. * @param kind defines the data kind (Position, normal, etc...)
  22714. * @param data defines the vertex data to use
  22715. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22716. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22717. */
  22718. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22719. /**
  22720. * Update a specific associated vertex buffer
  22721. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22722. * - VertexBuffer.PositionKind
  22723. * - VertexBuffer.UVKind
  22724. * - VertexBuffer.UV2Kind
  22725. * - VertexBuffer.UV3Kind
  22726. * - VertexBuffer.UV4Kind
  22727. * - VertexBuffer.UV5Kind
  22728. * - VertexBuffer.UV6Kind
  22729. * - VertexBuffer.ColorKind
  22730. * - VertexBuffer.MatricesIndicesKind
  22731. * - VertexBuffer.MatricesIndicesExtraKind
  22732. * - VertexBuffer.MatricesWeightsKind
  22733. * - VertexBuffer.MatricesWeightsExtraKind
  22734. * @param data defines the data source
  22735. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22736. * @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)
  22737. */
  22738. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22739. /**
  22740. * Creates a new index buffer
  22741. * @param indices defines the indices to store in the index buffer
  22742. * @param totalVertices defines the total number of vertices (could be null)
  22743. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22744. */
  22745. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22746. }
  22747. /**
  22748. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22749. */
  22750. export class VertexData {
  22751. /**
  22752. * Mesh side orientation : usually the external or front surface
  22753. */
  22754. static readonly FRONTSIDE: number;
  22755. /**
  22756. * Mesh side orientation : usually the internal or back surface
  22757. */
  22758. static readonly BACKSIDE: number;
  22759. /**
  22760. * Mesh side orientation : both internal and external or front and back surfaces
  22761. */
  22762. static readonly DOUBLESIDE: number;
  22763. /**
  22764. * Mesh side orientation : by default, `FRONTSIDE`
  22765. */
  22766. static readonly DEFAULTSIDE: number;
  22767. /**
  22768. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22769. */
  22770. positions: Nullable<FloatArray>;
  22771. /**
  22772. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22773. */
  22774. normals: Nullable<FloatArray>;
  22775. /**
  22776. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22777. */
  22778. tangents: Nullable<FloatArray>;
  22779. /**
  22780. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22781. */
  22782. uvs: Nullable<FloatArray>;
  22783. /**
  22784. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22785. */
  22786. uvs2: Nullable<FloatArray>;
  22787. /**
  22788. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22789. */
  22790. uvs3: Nullable<FloatArray>;
  22791. /**
  22792. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22793. */
  22794. uvs4: Nullable<FloatArray>;
  22795. /**
  22796. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22797. */
  22798. uvs5: Nullable<FloatArray>;
  22799. /**
  22800. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22801. */
  22802. uvs6: Nullable<FloatArray>;
  22803. /**
  22804. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22805. */
  22806. colors: Nullable<FloatArray>;
  22807. /**
  22808. * 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).
  22809. */
  22810. matricesIndices: Nullable<FloatArray>;
  22811. /**
  22812. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22813. */
  22814. matricesWeights: Nullable<FloatArray>;
  22815. /**
  22816. * An array extending the number of possible indices
  22817. */
  22818. matricesIndicesExtra: Nullable<FloatArray>;
  22819. /**
  22820. * An array extending the number of possible weights when the number of indices is extended
  22821. */
  22822. matricesWeightsExtra: Nullable<FloatArray>;
  22823. /**
  22824. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22825. */
  22826. indices: Nullable<IndicesArray>;
  22827. /**
  22828. * Uses the passed data array to set the set the values for the specified kind of data
  22829. * @param data a linear array of floating numbers
  22830. * @param kind the type of data that is being set, eg positions, colors etc
  22831. */
  22832. set(data: FloatArray, kind: string): void;
  22833. /**
  22834. * Associates the vertexData to the passed Mesh.
  22835. * Sets it as updatable or not (default `false`)
  22836. * @param mesh the mesh the vertexData is applied to
  22837. * @param updatable when used and having the value true allows new data to update the vertexData
  22838. * @returns the VertexData
  22839. */
  22840. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22841. /**
  22842. * Associates the vertexData to the passed Geometry.
  22843. * Sets it as updatable or not (default `false`)
  22844. * @param geometry the geometry the vertexData is applied to
  22845. * @param updatable when used and having the value true allows new data to update the vertexData
  22846. * @returns VertexData
  22847. */
  22848. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22849. /**
  22850. * Updates the associated mesh
  22851. * @param mesh the mesh to be updated
  22852. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22853. * @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
  22854. * @returns VertexData
  22855. */
  22856. updateMesh(mesh: Mesh): VertexData;
  22857. /**
  22858. * Updates the associated geometry
  22859. * @param geometry the geometry to be updated
  22860. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22861. * @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
  22862. * @returns VertexData.
  22863. */
  22864. updateGeometry(geometry: Geometry): VertexData;
  22865. private _applyTo;
  22866. private _update;
  22867. /**
  22868. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22869. * @param matrix the transforming matrix
  22870. * @returns the VertexData
  22871. */
  22872. transform(matrix: Matrix): VertexData;
  22873. /**
  22874. * Merges the passed VertexData into the current one
  22875. * @param other the VertexData to be merged into the current one
  22876. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22877. * @returns the modified VertexData
  22878. */
  22879. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22880. private _mergeElement;
  22881. private _validate;
  22882. /**
  22883. * Serializes the VertexData
  22884. * @returns a serialized object
  22885. */
  22886. serialize(): any;
  22887. /**
  22888. * Extracts the vertexData from a mesh
  22889. * @param mesh the mesh from which to extract the VertexData
  22890. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22891. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22892. * @returns the object VertexData associated to the passed mesh
  22893. */
  22894. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22895. /**
  22896. * Extracts the vertexData from the geometry
  22897. * @param geometry the geometry from which to extract the VertexData
  22898. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22899. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22900. * @returns the object VertexData associated to the passed mesh
  22901. */
  22902. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22903. private static _ExtractFrom;
  22904. /**
  22905. * Creates the VertexData for a Ribbon
  22906. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22907. * * pathArray array of paths, each of which an array of successive Vector3
  22908. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22909. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22910. * * 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
  22911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22912. * * 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)
  22913. * * 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)
  22914. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22915. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22916. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22917. * @returns the VertexData of the ribbon
  22918. */
  22919. static CreateRibbon(options: {
  22920. pathArray: Vector3[][];
  22921. closeArray?: boolean;
  22922. closePath?: boolean;
  22923. offset?: number;
  22924. sideOrientation?: number;
  22925. frontUVs?: Vector4;
  22926. backUVs?: Vector4;
  22927. invertUV?: boolean;
  22928. uvs?: Vector2[];
  22929. colors?: Color4[];
  22930. }): VertexData;
  22931. /**
  22932. * Creates the VertexData for a box
  22933. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22934. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22935. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22936. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22937. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22938. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22939. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22941. * * 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)
  22942. * * 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)
  22943. * @returns the VertexData of the box
  22944. */
  22945. static CreateBox(options: {
  22946. size?: number;
  22947. width?: number;
  22948. height?: number;
  22949. depth?: number;
  22950. faceUV?: Vector4[];
  22951. faceColors?: Color4[];
  22952. sideOrientation?: number;
  22953. frontUVs?: Vector4;
  22954. backUVs?: Vector4;
  22955. }): VertexData;
  22956. /**
  22957. * Creates the VertexData for a tiled box
  22958. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22959. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22960. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22961. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22963. * @returns the VertexData of the box
  22964. */
  22965. static CreateTiledBox(options: {
  22966. pattern?: number;
  22967. width?: number;
  22968. height?: number;
  22969. depth?: number;
  22970. tileSize?: number;
  22971. tileWidth?: number;
  22972. tileHeight?: number;
  22973. alignHorizontal?: number;
  22974. alignVertical?: number;
  22975. faceUV?: Vector4[];
  22976. faceColors?: Color4[];
  22977. sideOrientation?: number;
  22978. }): VertexData;
  22979. /**
  22980. * Creates the VertexData for a tiled plane
  22981. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22982. * * pattern a limited pattern arrangement depending on the number
  22983. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22984. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22985. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22986. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22987. * * 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)
  22988. * * 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)
  22989. * @returns the VertexData of the tiled plane
  22990. */
  22991. static CreateTiledPlane(options: {
  22992. pattern?: number;
  22993. tileSize?: number;
  22994. tileWidth?: number;
  22995. tileHeight?: number;
  22996. size?: number;
  22997. width?: number;
  22998. height?: number;
  22999. alignHorizontal?: number;
  23000. alignVertical?: number;
  23001. sideOrientation?: number;
  23002. frontUVs?: Vector4;
  23003. backUVs?: Vector4;
  23004. }): VertexData;
  23005. /**
  23006. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23007. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23008. * * segments sets the number of horizontal strips optional, default 32
  23009. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23010. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23011. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23012. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23013. * * 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
  23014. * * 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
  23015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23016. * * 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)
  23017. * * 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)
  23018. * @returns the VertexData of the ellipsoid
  23019. */
  23020. static CreateSphere(options: {
  23021. segments?: number;
  23022. diameter?: number;
  23023. diameterX?: number;
  23024. diameterY?: number;
  23025. diameterZ?: number;
  23026. arc?: number;
  23027. slice?: number;
  23028. sideOrientation?: number;
  23029. frontUVs?: Vector4;
  23030. backUVs?: Vector4;
  23031. }): VertexData;
  23032. /**
  23033. * Creates the VertexData for a cylinder, cone or prism
  23034. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23035. * * height sets the height (y direction) of the cylinder, optional, default 2
  23036. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23037. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23038. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23039. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23040. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23041. * * 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
  23042. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23043. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23044. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23045. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23047. * * 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)
  23048. * * 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)
  23049. * @returns the VertexData of the cylinder, cone or prism
  23050. */
  23051. static CreateCylinder(options: {
  23052. height?: number;
  23053. diameterTop?: number;
  23054. diameterBottom?: number;
  23055. diameter?: number;
  23056. tessellation?: number;
  23057. subdivisions?: number;
  23058. arc?: number;
  23059. faceColors?: Color4[];
  23060. faceUV?: Vector4[];
  23061. hasRings?: boolean;
  23062. enclose?: boolean;
  23063. sideOrientation?: number;
  23064. frontUVs?: Vector4;
  23065. backUVs?: Vector4;
  23066. }): VertexData;
  23067. /**
  23068. * Creates the VertexData for a torus
  23069. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23070. * * diameter the diameter of the torus, optional default 1
  23071. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23072. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * * 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)
  23075. * * 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)
  23076. * @returns the VertexData of the torus
  23077. */
  23078. static CreateTorus(options: {
  23079. diameter?: number;
  23080. thickness?: number;
  23081. tessellation?: number;
  23082. sideOrientation?: number;
  23083. frontUVs?: Vector4;
  23084. backUVs?: Vector4;
  23085. }): VertexData;
  23086. /**
  23087. * Creates the VertexData of the LineSystem
  23088. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23089. * - lines an array of lines, each line being an array of successive Vector3
  23090. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23091. * @returns the VertexData of the LineSystem
  23092. */
  23093. static CreateLineSystem(options: {
  23094. lines: Vector3[][];
  23095. colors?: Nullable<Color4[][]>;
  23096. }): VertexData;
  23097. /**
  23098. * Create the VertexData for a DashedLines
  23099. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23100. * - points an array successive Vector3
  23101. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23102. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23103. * - dashNb the intended total number of dashes, optional, default 200
  23104. * @returns the VertexData for the DashedLines
  23105. */
  23106. static CreateDashedLines(options: {
  23107. points: Vector3[];
  23108. dashSize?: number;
  23109. gapSize?: number;
  23110. dashNb?: number;
  23111. }): VertexData;
  23112. /**
  23113. * Creates the VertexData for a Ground
  23114. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23115. * - width the width (x direction) of the ground, optional, default 1
  23116. * - height the height (z direction) of the ground, optional, default 1
  23117. * - subdivisions the number of subdivisions per side, optional, default 1
  23118. * @returns the VertexData of the Ground
  23119. */
  23120. static CreateGround(options: {
  23121. width?: number;
  23122. height?: number;
  23123. subdivisions?: number;
  23124. subdivisionsX?: number;
  23125. subdivisionsY?: number;
  23126. }): VertexData;
  23127. /**
  23128. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23129. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23130. * * xmin the ground minimum X coordinate, optional, default -1
  23131. * * zmin the ground minimum Z coordinate, optional, default -1
  23132. * * xmax the ground maximum X coordinate, optional, default 1
  23133. * * zmax the ground maximum Z coordinate, optional, default 1
  23134. * * 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}
  23135. * * 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}
  23136. * @returns the VertexData of the TiledGround
  23137. */
  23138. static CreateTiledGround(options: {
  23139. xmin: number;
  23140. zmin: number;
  23141. xmax: number;
  23142. zmax: number;
  23143. subdivisions?: {
  23144. w: number;
  23145. h: number;
  23146. };
  23147. precision?: {
  23148. w: number;
  23149. h: number;
  23150. };
  23151. }): VertexData;
  23152. /**
  23153. * Creates the VertexData of the Ground designed from a heightmap
  23154. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23155. * * width the width (x direction) of the ground
  23156. * * height the height (z direction) of the ground
  23157. * * subdivisions the number of subdivisions per side
  23158. * * minHeight the minimum altitude on the ground, optional, default 0
  23159. * * maxHeight the maximum altitude on the ground, optional default 1
  23160. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23161. * * buffer the array holding the image color data
  23162. * * bufferWidth the width of image
  23163. * * bufferHeight the height of image
  23164. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23165. * @returns the VertexData of the Ground designed from a heightmap
  23166. */
  23167. static CreateGroundFromHeightMap(options: {
  23168. width: number;
  23169. height: number;
  23170. subdivisions: number;
  23171. minHeight: number;
  23172. maxHeight: number;
  23173. colorFilter: Color3;
  23174. buffer: Uint8Array;
  23175. bufferWidth: number;
  23176. bufferHeight: number;
  23177. alphaFilter: number;
  23178. }): VertexData;
  23179. /**
  23180. * Creates the VertexData for a Plane
  23181. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23182. * * size sets the width and height of the plane to the value of size, optional default 1
  23183. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23184. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * * 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)
  23187. * * 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)
  23188. * @returns the VertexData of the box
  23189. */
  23190. static CreatePlane(options: {
  23191. size?: number;
  23192. width?: number;
  23193. height?: number;
  23194. sideOrientation?: number;
  23195. frontUVs?: Vector4;
  23196. backUVs?: Vector4;
  23197. }): VertexData;
  23198. /**
  23199. * Creates the VertexData of the Disc or regular Polygon
  23200. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23201. * * radius the radius of the disc, optional default 0.5
  23202. * * tessellation the number of polygon sides, optional, default 64
  23203. * * 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
  23204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23205. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23206. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23207. * @returns the VertexData of the box
  23208. */
  23209. static CreateDisc(options: {
  23210. radius?: number;
  23211. tessellation?: number;
  23212. arc?: number;
  23213. sideOrientation?: number;
  23214. frontUVs?: Vector4;
  23215. backUVs?: Vector4;
  23216. }): VertexData;
  23217. /**
  23218. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23219. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23220. * @param polygon a mesh built from polygonTriangulation.build()
  23221. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23222. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23223. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23224. * @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)
  23225. * @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)
  23226. * @returns the VertexData of the Polygon
  23227. */
  23228. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23229. /**
  23230. * Creates the VertexData of the IcoSphere
  23231. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23232. * * radius the radius of the IcoSphere, optional default 1
  23233. * * radiusX allows stretching in the x direction, optional, default radius
  23234. * * radiusY allows stretching in the y direction, optional, default radius
  23235. * * radiusZ allows stretching in the z direction, optional, default radius
  23236. * * flat when true creates a flat shaded mesh, optional, default true
  23237. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * 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)
  23240. * * 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)
  23241. * @returns the VertexData of the IcoSphere
  23242. */
  23243. static CreateIcoSphere(options: {
  23244. radius?: number;
  23245. radiusX?: number;
  23246. radiusY?: number;
  23247. radiusZ?: number;
  23248. flat?: boolean;
  23249. subdivisions?: number;
  23250. sideOrientation?: number;
  23251. frontUVs?: Vector4;
  23252. backUVs?: Vector4;
  23253. }): VertexData;
  23254. /**
  23255. * Creates the VertexData for a Polyhedron
  23256. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23257. * * type provided types are:
  23258. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23259. * * 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)
  23260. * * size the size of the IcoSphere, optional default 1
  23261. * * sizeX allows stretching in the x direction, optional, default size
  23262. * * sizeY allows stretching in the y direction, optional, default size
  23263. * * sizeZ allows stretching in the z direction, optional, default size
  23264. * * 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
  23265. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23266. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23267. * * flat when true creates a flat shaded mesh, optional, default true
  23268. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23270. * * 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)
  23271. * * 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)
  23272. * @returns the VertexData of the Polyhedron
  23273. */
  23274. static CreatePolyhedron(options: {
  23275. type?: number;
  23276. size?: number;
  23277. sizeX?: number;
  23278. sizeY?: number;
  23279. sizeZ?: number;
  23280. custom?: any;
  23281. faceUV?: Vector4[];
  23282. faceColors?: Color4[];
  23283. flat?: boolean;
  23284. sideOrientation?: number;
  23285. frontUVs?: Vector4;
  23286. backUVs?: Vector4;
  23287. }): VertexData;
  23288. /**
  23289. * Creates the VertexData for a TorusKnot
  23290. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23291. * * radius the radius of the torus knot, optional, default 2
  23292. * * tube the thickness of the tube, optional, default 0.5
  23293. * * radialSegments the number of sides on each tube segments, optional, default 32
  23294. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23295. * * p the number of windings around the z axis, optional, default 2
  23296. * * q the number of windings around the x axis, optional, default 3
  23297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23298. * * 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)
  23299. * * 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)
  23300. * @returns the VertexData of the Torus Knot
  23301. */
  23302. static CreateTorusKnot(options: {
  23303. radius?: number;
  23304. tube?: number;
  23305. radialSegments?: number;
  23306. tubularSegments?: number;
  23307. p?: number;
  23308. q?: number;
  23309. sideOrientation?: number;
  23310. frontUVs?: Vector4;
  23311. backUVs?: Vector4;
  23312. }): VertexData;
  23313. /**
  23314. * Compute normals for given positions and indices
  23315. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23316. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23317. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23318. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23319. * * facetNormals : optional array of facet normals (vector3)
  23320. * * facetPositions : optional array of facet positions (vector3)
  23321. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23322. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23323. * * bInfo : optional bounding info, required for facetPartitioning computation
  23324. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23325. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23326. * * useRightHandedSystem: optional boolean to for right handed system computation
  23327. * * depthSort : optional boolean to enable the facet depth sort computation
  23328. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23329. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23330. */
  23331. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23332. facetNormals?: any;
  23333. facetPositions?: any;
  23334. facetPartitioning?: any;
  23335. ratio?: number;
  23336. bInfo?: any;
  23337. bbSize?: Vector3;
  23338. subDiv?: any;
  23339. useRightHandedSystem?: boolean;
  23340. depthSort?: boolean;
  23341. distanceTo?: Vector3;
  23342. depthSortedFacets?: any;
  23343. }): void;
  23344. /** @hidden */
  23345. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23346. /**
  23347. * Applies VertexData created from the imported parameters to the geometry
  23348. * @param parsedVertexData the parsed data from an imported file
  23349. * @param geometry the geometry to apply the VertexData to
  23350. */
  23351. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23352. }
  23353. }
  23354. declare module "babylonjs/Morph/morphTarget" {
  23355. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23356. import { Observable } from "babylonjs/Misc/observable";
  23357. import { Nullable, FloatArray } from "babylonjs/types";
  23358. import { Scene } from "babylonjs/scene";
  23359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23360. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23361. /**
  23362. * Defines a target to use with MorphTargetManager
  23363. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23364. */
  23365. export class MorphTarget implements IAnimatable {
  23366. /** defines the name of the target */
  23367. name: string;
  23368. /**
  23369. * Gets or sets the list of animations
  23370. */
  23371. animations: import("babylonjs/Animations/animation").Animation[];
  23372. private _scene;
  23373. private _positions;
  23374. private _normals;
  23375. private _tangents;
  23376. private _uvs;
  23377. private _influence;
  23378. private _uniqueId;
  23379. /**
  23380. * Observable raised when the influence changes
  23381. */
  23382. onInfluenceChanged: Observable<boolean>;
  23383. /** @hidden */
  23384. _onDataLayoutChanged: Observable<void>;
  23385. /**
  23386. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23387. */
  23388. get influence(): number;
  23389. set influence(influence: number);
  23390. /**
  23391. * Gets or sets the id of the morph Target
  23392. */
  23393. id: string;
  23394. private _animationPropertiesOverride;
  23395. /**
  23396. * Gets or sets the animation properties override
  23397. */
  23398. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23399. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23400. /**
  23401. * Creates a new MorphTarget
  23402. * @param name defines the name of the target
  23403. * @param influence defines the influence to use
  23404. * @param scene defines the scene the morphtarget belongs to
  23405. */
  23406. constructor(
  23407. /** defines the name of the target */
  23408. name: string, influence?: number, scene?: Nullable<Scene>);
  23409. /**
  23410. * Gets the unique ID of this manager
  23411. */
  23412. get uniqueId(): number;
  23413. /**
  23414. * Gets a boolean defining if the target contains position data
  23415. */
  23416. get hasPositions(): boolean;
  23417. /**
  23418. * Gets a boolean defining if the target contains normal data
  23419. */
  23420. get hasNormals(): boolean;
  23421. /**
  23422. * Gets a boolean defining if the target contains tangent data
  23423. */
  23424. get hasTangents(): boolean;
  23425. /**
  23426. * Gets a boolean defining if the target contains texture coordinates data
  23427. */
  23428. get hasUVs(): boolean;
  23429. /**
  23430. * Affects position data to this target
  23431. * @param data defines the position data to use
  23432. */
  23433. setPositions(data: Nullable<FloatArray>): void;
  23434. /**
  23435. * Gets the position data stored in this target
  23436. * @returns a FloatArray containing the position data (or null if not present)
  23437. */
  23438. getPositions(): Nullable<FloatArray>;
  23439. /**
  23440. * Affects normal data to this target
  23441. * @param data defines the normal data to use
  23442. */
  23443. setNormals(data: Nullable<FloatArray>): void;
  23444. /**
  23445. * Gets the normal data stored in this target
  23446. * @returns a FloatArray containing the normal data (or null if not present)
  23447. */
  23448. getNormals(): Nullable<FloatArray>;
  23449. /**
  23450. * Affects tangent data to this target
  23451. * @param data defines the tangent data to use
  23452. */
  23453. setTangents(data: Nullable<FloatArray>): void;
  23454. /**
  23455. * Gets the tangent data stored in this target
  23456. * @returns a FloatArray containing the tangent data (or null if not present)
  23457. */
  23458. getTangents(): Nullable<FloatArray>;
  23459. /**
  23460. * Affects texture coordinates data to this target
  23461. * @param data defines the texture coordinates data to use
  23462. */
  23463. setUVs(data: Nullable<FloatArray>): void;
  23464. /**
  23465. * Gets the texture coordinates data stored in this target
  23466. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23467. */
  23468. getUVs(): Nullable<FloatArray>;
  23469. /**
  23470. * Clone the current target
  23471. * @returns a new MorphTarget
  23472. */
  23473. clone(): MorphTarget;
  23474. /**
  23475. * Serializes the current target into a Serialization object
  23476. * @returns the serialized object
  23477. */
  23478. serialize(): any;
  23479. /**
  23480. * Returns the string "MorphTarget"
  23481. * @returns "MorphTarget"
  23482. */
  23483. getClassName(): string;
  23484. /**
  23485. * Creates a new target from serialized data
  23486. * @param serializationObject defines the serialized data to use
  23487. * @returns a new MorphTarget
  23488. */
  23489. static Parse(serializationObject: any): MorphTarget;
  23490. /**
  23491. * Creates a MorphTarget from mesh data
  23492. * @param mesh defines the source mesh
  23493. * @param name defines the name to use for the new target
  23494. * @param influence defines the influence to attach to the target
  23495. * @returns a new MorphTarget
  23496. */
  23497. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23498. }
  23499. }
  23500. declare module "babylonjs/Morph/morphTargetManager" {
  23501. import { Nullable } from "babylonjs/types";
  23502. import { Scene } from "babylonjs/scene";
  23503. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23504. /**
  23505. * This class is used to deform meshes using morphing between different targets
  23506. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23507. */
  23508. export class MorphTargetManager {
  23509. private _targets;
  23510. private _targetInfluenceChangedObservers;
  23511. private _targetDataLayoutChangedObservers;
  23512. private _activeTargets;
  23513. private _scene;
  23514. private _influences;
  23515. private _supportsNormals;
  23516. private _supportsTangents;
  23517. private _supportsUVs;
  23518. private _vertexCount;
  23519. private _uniqueId;
  23520. private _tempInfluences;
  23521. /**
  23522. * Gets or sets a boolean indicating if normals must be morphed
  23523. */
  23524. enableNormalMorphing: boolean;
  23525. /**
  23526. * Gets or sets a boolean indicating if tangents must be morphed
  23527. */
  23528. enableTangentMorphing: boolean;
  23529. /**
  23530. * Gets or sets a boolean indicating if UV must be morphed
  23531. */
  23532. enableUVMorphing: boolean;
  23533. /**
  23534. * Creates a new MorphTargetManager
  23535. * @param scene defines the current scene
  23536. */
  23537. constructor(scene?: Nullable<Scene>);
  23538. /**
  23539. * Gets the unique ID of this manager
  23540. */
  23541. get uniqueId(): number;
  23542. /**
  23543. * Gets the number of vertices handled by this manager
  23544. */
  23545. get vertexCount(): number;
  23546. /**
  23547. * Gets a boolean indicating if this manager supports morphing of normals
  23548. */
  23549. get supportsNormals(): boolean;
  23550. /**
  23551. * Gets a boolean indicating if this manager supports morphing of tangents
  23552. */
  23553. get supportsTangents(): boolean;
  23554. /**
  23555. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23556. */
  23557. get supportsUVs(): boolean;
  23558. /**
  23559. * Gets the number of targets stored in this manager
  23560. */
  23561. get numTargets(): number;
  23562. /**
  23563. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23564. */
  23565. get numInfluencers(): number;
  23566. /**
  23567. * Gets the list of influences (one per target)
  23568. */
  23569. get influences(): Float32Array;
  23570. /**
  23571. * Gets the active target at specified index. An active target is a target with an influence > 0
  23572. * @param index defines the index to check
  23573. * @returns the requested target
  23574. */
  23575. getActiveTarget(index: number): MorphTarget;
  23576. /**
  23577. * Gets the target at specified index
  23578. * @param index defines the index to check
  23579. * @returns the requested target
  23580. */
  23581. getTarget(index: number): MorphTarget;
  23582. /**
  23583. * Add a new target to this manager
  23584. * @param target defines the target to add
  23585. */
  23586. addTarget(target: MorphTarget): void;
  23587. /**
  23588. * Removes a target from the manager
  23589. * @param target defines the target to remove
  23590. */
  23591. removeTarget(target: MorphTarget): void;
  23592. /**
  23593. * Clone the current manager
  23594. * @returns a new MorphTargetManager
  23595. */
  23596. clone(): MorphTargetManager;
  23597. /**
  23598. * Serializes the current manager into a Serialization object
  23599. * @returns the serialized object
  23600. */
  23601. serialize(): any;
  23602. private _syncActiveTargets;
  23603. /**
  23604. * Syncrhonize the targets with all the meshes using this morph target manager
  23605. */
  23606. synchronize(): void;
  23607. /**
  23608. * Creates a new MorphTargetManager from serialized data
  23609. * @param serializationObject defines the serialized data
  23610. * @param scene defines the hosting scene
  23611. * @returns the new MorphTargetManager
  23612. */
  23613. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23614. }
  23615. }
  23616. declare module "babylonjs/Meshes/meshLODLevel" {
  23617. import { Mesh } from "babylonjs/Meshes/mesh";
  23618. import { Nullable } from "babylonjs/types";
  23619. /**
  23620. * Class used to represent a specific level of detail of a mesh
  23621. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23622. */
  23623. export class MeshLODLevel {
  23624. /** Defines the distance where this level should start being displayed */
  23625. distance: number;
  23626. /** Defines the mesh to use to render this level */
  23627. mesh: Nullable<Mesh>;
  23628. /**
  23629. * Creates a new LOD level
  23630. * @param distance defines the distance where this level should star being displayed
  23631. * @param mesh defines the mesh to use to render this level
  23632. */
  23633. constructor(
  23634. /** Defines the distance where this level should start being displayed */
  23635. distance: number,
  23636. /** Defines the mesh to use to render this level */
  23637. mesh: Nullable<Mesh>);
  23638. }
  23639. }
  23640. declare module "babylonjs/Meshes/groundMesh" {
  23641. import { Scene } from "babylonjs/scene";
  23642. import { Vector3 } from "babylonjs/Maths/math.vector";
  23643. import { Mesh } from "babylonjs/Meshes/mesh";
  23644. /**
  23645. * Mesh representing the gorund
  23646. */
  23647. export class GroundMesh extends Mesh {
  23648. /** If octree should be generated */
  23649. generateOctree: boolean;
  23650. private _heightQuads;
  23651. /** @hidden */
  23652. _subdivisionsX: number;
  23653. /** @hidden */
  23654. _subdivisionsY: number;
  23655. /** @hidden */
  23656. _width: number;
  23657. /** @hidden */
  23658. _height: number;
  23659. /** @hidden */
  23660. _minX: number;
  23661. /** @hidden */
  23662. _maxX: number;
  23663. /** @hidden */
  23664. _minZ: number;
  23665. /** @hidden */
  23666. _maxZ: number;
  23667. constructor(name: string, scene: Scene);
  23668. /**
  23669. * "GroundMesh"
  23670. * @returns "GroundMesh"
  23671. */
  23672. getClassName(): string;
  23673. /**
  23674. * The minimum of x and y subdivisions
  23675. */
  23676. get subdivisions(): number;
  23677. /**
  23678. * X subdivisions
  23679. */
  23680. get subdivisionsX(): number;
  23681. /**
  23682. * Y subdivisions
  23683. */
  23684. get subdivisionsY(): number;
  23685. /**
  23686. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23687. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23688. * @param chunksCount the number of subdivisions for x and y
  23689. * @param octreeBlocksSize (Default: 32)
  23690. */
  23691. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23692. /**
  23693. * Returns a height (y) value in the Worl system :
  23694. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23695. * @param x x coordinate
  23696. * @param z z coordinate
  23697. * @returns the ground y position if (x, z) are outside the ground surface.
  23698. */
  23699. getHeightAtCoordinates(x: number, z: number): number;
  23700. /**
  23701. * Returns a normalized vector (Vector3) orthogonal to the ground
  23702. * at the ground coordinates (x, z) expressed in the World system.
  23703. * @param x x coordinate
  23704. * @param z z coordinate
  23705. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23706. */
  23707. getNormalAtCoordinates(x: number, z: number): Vector3;
  23708. /**
  23709. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23710. * at the ground coordinates (x, z) expressed in the World system.
  23711. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23712. * @param x x coordinate
  23713. * @param z z coordinate
  23714. * @param ref vector to store the result
  23715. * @returns the GroundMesh.
  23716. */
  23717. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23718. /**
  23719. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23720. * if the ground has been updated.
  23721. * This can be used in the render loop.
  23722. * @returns the GroundMesh.
  23723. */
  23724. updateCoordinateHeights(): GroundMesh;
  23725. private _getFacetAt;
  23726. private _initHeightQuads;
  23727. private _computeHeightQuads;
  23728. /**
  23729. * Serializes this ground mesh
  23730. * @param serializationObject object to write serialization to
  23731. */
  23732. serialize(serializationObject: any): void;
  23733. /**
  23734. * Parses a serialized ground mesh
  23735. * @param parsedMesh the serialized mesh
  23736. * @param scene the scene to create the ground mesh in
  23737. * @returns the created ground mesh
  23738. */
  23739. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23740. }
  23741. }
  23742. declare module "babylonjs/Physics/physicsJoint" {
  23743. import { Vector3 } from "babylonjs/Maths/math.vector";
  23744. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23745. /**
  23746. * Interface for Physics-Joint data
  23747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23748. */
  23749. export interface PhysicsJointData {
  23750. /**
  23751. * The main pivot of the joint
  23752. */
  23753. mainPivot?: Vector3;
  23754. /**
  23755. * The connected pivot of the joint
  23756. */
  23757. connectedPivot?: Vector3;
  23758. /**
  23759. * The main axis of the joint
  23760. */
  23761. mainAxis?: Vector3;
  23762. /**
  23763. * The connected axis of the joint
  23764. */
  23765. connectedAxis?: Vector3;
  23766. /**
  23767. * The collision of the joint
  23768. */
  23769. collision?: boolean;
  23770. /**
  23771. * Native Oimo/Cannon/Energy data
  23772. */
  23773. nativeParams?: any;
  23774. }
  23775. /**
  23776. * This is a holder class for the physics joint created by the physics plugin
  23777. * It holds a set of functions to control the underlying joint
  23778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23779. */
  23780. export class PhysicsJoint {
  23781. /**
  23782. * The type of the physics joint
  23783. */
  23784. type: number;
  23785. /**
  23786. * The data for the physics joint
  23787. */
  23788. jointData: PhysicsJointData;
  23789. private _physicsJoint;
  23790. protected _physicsPlugin: IPhysicsEnginePlugin;
  23791. /**
  23792. * Initializes the physics joint
  23793. * @param type The type of the physics joint
  23794. * @param jointData The data for the physics joint
  23795. */
  23796. constructor(
  23797. /**
  23798. * The type of the physics joint
  23799. */
  23800. type: number,
  23801. /**
  23802. * The data for the physics joint
  23803. */
  23804. jointData: PhysicsJointData);
  23805. /**
  23806. * Gets the physics joint
  23807. */
  23808. get physicsJoint(): any;
  23809. /**
  23810. * Sets the physics joint
  23811. */
  23812. set physicsJoint(newJoint: any);
  23813. /**
  23814. * Sets the physics plugin
  23815. */
  23816. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23817. /**
  23818. * Execute a function that is physics-plugin specific.
  23819. * @param {Function} func the function that will be executed.
  23820. * It accepts two parameters: the physics world and the physics joint
  23821. */
  23822. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23823. /**
  23824. * Distance-Joint type
  23825. */
  23826. static DistanceJoint: number;
  23827. /**
  23828. * Hinge-Joint type
  23829. */
  23830. static HingeJoint: number;
  23831. /**
  23832. * Ball-and-Socket joint type
  23833. */
  23834. static BallAndSocketJoint: number;
  23835. /**
  23836. * Wheel-Joint type
  23837. */
  23838. static WheelJoint: number;
  23839. /**
  23840. * Slider-Joint type
  23841. */
  23842. static SliderJoint: number;
  23843. /**
  23844. * Prismatic-Joint type
  23845. */
  23846. static PrismaticJoint: number;
  23847. /**
  23848. * Universal-Joint type
  23849. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23850. */
  23851. static UniversalJoint: number;
  23852. /**
  23853. * Hinge-Joint 2 type
  23854. */
  23855. static Hinge2Joint: number;
  23856. /**
  23857. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23858. */
  23859. static PointToPointJoint: number;
  23860. /**
  23861. * Spring-Joint type
  23862. */
  23863. static SpringJoint: number;
  23864. /**
  23865. * Lock-Joint type
  23866. */
  23867. static LockJoint: number;
  23868. }
  23869. /**
  23870. * A class representing a physics distance joint
  23871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23872. */
  23873. export class DistanceJoint extends PhysicsJoint {
  23874. /**
  23875. *
  23876. * @param jointData The data for the Distance-Joint
  23877. */
  23878. constructor(jointData: DistanceJointData);
  23879. /**
  23880. * Update the predefined distance.
  23881. * @param maxDistance The maximum preferred distance
  23882. * @param minDistance The minimum preferred distance
  23883. */
  23884. updateDistance(maxDistance: number, minDistance?: number): void;
  23885. }
  23886. /**
  23887. * Represents a Motor-Enabled Joint
  23888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23889. */
  23890. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23891. /**
  23892. * Initializes the Motor-Enabled Joint
  23893. * @param type The type of the joint
  23894. * @param jointData The physica joint data for the joint
  23895. */
  23896. constructor(type: number, jointData: PhysicsJointData);
  23897. /**
  23898. * Set the motor values.
  23899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23900. * @param force the force to apply
  23901. * @param maxForce max force for this motor.
  23902. */
  23903. setMotor(force?: number, maxForce?: number): void;
  23904. /**
  23905. * Set the motor's limits.
  23906. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23907. * @param upperLimit The upper limit of the motor
  23908. * @param lowerLimit The lower limit of the motor
  23909. */
  23910. setLimit(upperLimit: number, lowerLimit?: number): void;
  23911. }
  23912. /**
  23913. * This class represents a single physics Hinge-Joint
  23914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23915. */
  23916. export class HingeJoint extends MotorEnabledJoint {
  23917. /**
  23918. * Initializes the Hinge-Joint
  23919. * @param jointData The joint data for the Hinge-Joint
  23920. */
  23921. constructor(jointData: PhysicsJointData);
  23922. /**
  23923. * Set the motor values.
  23924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23925. * @param {number} force the force to apply
  23926. * @param {number} maxForce max force for this motor.
  23927. */
  23928. setMotor(force?: number, maxForce?: number): void;
  23929. /**
  23930. * Set the motor's limits.
  23931. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23932. * @param upperLimit The upper limit of the motor
  23933. * @param lowerLimit The lower limit of the motor
  23934. */
  23935. setLimit(upperLimit: number, lowerLimit?: number): void;
  23936. }
  23937. /**
  23938. * This class represents a dual hinge physics joint (same as wheel joint)
  23939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23940. */
  23941. export class Hinge2Joint extends MotorEnabledJoint {
  23942. /**
  23943. * Initializes the Hinge2-Joint
  23944. * @param jointData The joint data for the Hinge2-Joint
  23945. */
  23946. constructor(jointData: PhysicsJointData);
  23947. /**
  23948. * Set the motor values.
  23949. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23950. * @param {number} targetSpeed the speed the motor is to reach
  23951. * @param {number} maxForce max force for this motor.
  23952. * @param {motorIndex} the motor's index, 0 or 1.
  23953. */
  23954. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23955. /**
  23956. * Set the motor limits.
  23957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23958. * @param {number} upperLimit the upper limit
  23959. * @param {number} lowerLimit lower limit
  23960. * @param {motorIndex} the motor's index, 0 or 1.
  23961. */
  23962. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23963. }
  23964. /**
  23965. * Interface for a motor enabled joint
  23966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23967. */
  23968. export interface IMotorEnabledJoint {
  23969. /**
  23970. * Physics joint
  23971. */
  23972. physicsJoint: any;
  23973. /**
  23974. * Sets the motor of the motor-enabled joint
  23975. * @param force The force of the motor
  23976. * @param maxForce The maximum force of the motor
  23977. * @param motorIndex The index of the motor
  23978. */
  23979. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23980. /**
  23981. * Sets the limit of the motor
  23982. * @param upperLimit The upper limit of the motor
  23983. * @param lowerLimit The lower limit of the motor
  23984. * @param motorIndex The index of the motor
  23985. */
  23986. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23987. }
  23988. /**
  23989. * Joint data for a Distance-Joint
  23990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23991. */
  23992. export interface DistanceJointData extends PhysicsJointData {
  23993. /**
  23994. * Max distance the 2 joint objects can be apart
  23995. */
  23996. maxDistance: number;
  23997. }
  23998. /**
  23999. * Joint data from a spring joint
  24000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24001. */
  24002. export interface SpringJointData extends PhysicsJointData {
  24003. /**
  24004. * Length of the spring
  24005. */
  24006. length: number;
  24007. /**
  24008. * Stiffness of the spring
  24009. */
  24010. stiffness: number;
  24011. /**
  24012. * Damping of the spring
  24013. */
  24014. damping: number;
  24015. /** this callback will be called when applying the force to the impostors. */
  24016. forceApplicationCallback: () => void;
  24017. }
  24018. }
  24019. declare module "babylonjs/Physics/physicsRaycastResult" {
  24020. import { Vector3 } from "babylonjs/Maths/math.vector";
  24021. /**
  24022. * Holds the data for the raycast result
  24023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24024. */
  24025. export class PhysicsRaycastResult {
  24026. private _hasHit;
  24027. private _hitDistance;
  24028. private _hitNormalWorld;
  24029. private _hitPointWorld;
  24030. private _rayFromWorld;
  24031. private _rayToWorld;
  24032. /**
  24033. * Gets if there was a hit
  24034. */
  24035. get hasHit(): boolean;
  24036. /**
  24037. * Gets the distance from the hit
  24038. */
  24039. get hitDistance(): number;
  24040. /**
  24041. * Gets the hit normal/direction in the world
  24042. */
  24043. get hitNormalWorld(): Vector3;
  24044. /**
  24045. * Gets the hit point in the world
  24046. */
  24047. get hitPointWorld(): Vector3;
  24048. /**
  24049. * Gets the ray "start point" of the ray in the world
  24050. */
  24051. get rayFromWorld(): Vector3;
  24052. /**
  24053. * Gets the ray "end point" of the ray in the world
  24054. */
  24055. get rayToWorld(): Vector3;
  24056. /**
  24057. * Sets the hit data (normal & point in world space)
  24058. * @param hitNormalWorld defines the normal in world space
  24059. * @param hitPointWorld defines the point in world space
  24060. */
  24061. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24062. /**
  24063. * Sets the distance from the start point to the hit point
  24064. * @param distance
  24065. */
  24066. setHitDistance(distance: number): void;
  24067. /**
  24068. * Calculates the distance manually
  24069. */
  24070. calculateHitDistance(): void;
  24071. /**
  24072. * Resets all the values to default
  24073. * @param from The from point on world space
  24074. * @param to The to point on world space
  24075. */
  24076. reset(from?: Vector3, to?: Vector3): void;
  24077. }
  24078. /**
  24079. * Interface for the size containing width and height
  24080. */
  24081. interface IXYZ {
  24082. /**
  24083. * X
  24084. */
  24085. x: number;
  24086. /**
  24087. * Y
  24088. */
  24089. y: number;
  24090. /**
  24091. * Z
  24092. */
  24093. z: number;
  24094. }
  24095. }
  24096. declare module "babylonjs/Physics/IPhysicsEngine" {
  24097. import { Nullable } from "babylonjs/types";
  24098. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24100. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24101. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24102. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24103. /**
  24104. * Interface used to describe a physics joint
  24105. */
  24106. export interface PhysicsImpostorJoint {
  24107. /** Defines the main impostor to which the joint is linked */
  24108. mainImpostor: PhysicsImpostor;
  24109. /** Defines the impostor that is connected to the main impostor using this joint */
  24110. connectedImpostor: PhysicsImpostor;
  24111. /** Defines the joint itself */
  24112. joint: PhysicsJoint;
  24113. }
  24114. /** @hidden */
  24115. export interface IPhysicsEnginePlugin {
  24116. world: any;
  24117. name: string;
  24118. setGravity(gravity: Vector3): void;
  24119. setTimeStep(timeStep: number): void;
  24120. getTimeStep(): number;
  24121. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24122. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24123. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24124. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24125. removePhysicsBody(impostor: PhysicsImpostor): void;
  24126. generateJoint(joint: PhysicsImpostorJoint): void;
  24127. removeJoint(joint: PhysicsImpostorJoint): void;
  24128. isSupported(): boolean;
  24129. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24130. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24131. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24132. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24133. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24134. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24135. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24136. getBodyMass(impostor: PhysicsImpostor): number;
  24137. getBodyFriction(impostor: PhysicsImpostor): number;
  24138. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24139. getBodyRestitution(impostor: PhysicsImpostor): number;
  24140. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24141. getBodyPressure?(impostor: PhysicsImpostor): number;
  24142. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24143. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24144. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24145. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24146. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24147. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24148. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24149. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24150. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24151. sleepBody(impostor: PhysicsImpostor): void;
  24152. wakeUpBody(impostor: PhysicsImpostor): void;
  24153. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24154. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24155. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24156. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24157. getRadius(impostor: PhysicsImpostor): number;
  24158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24159. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24160. dispose(): void;
  24161. }
  24162. /**
  24163. * Interface used to define a physics engine
  24164. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24165. */
  24166. export interface IPhysicsEngine {
  24167. /**
  24168. * Gets the gravity vector used by the simulation
  24169. */
  24170. gravity: Vector3;
  24171. /**
  24172. * Sets the gravity vector used by the simulation
  24173. * @param gravity defines the gravity vector to use
  24174. */
  24175. setGravity(gravity: Vector3): void;
  24176. /**
  24177. * Set the time step of the physics engine.
  24178. * Default is 1/60.
  24179. * To slow it down, enter 1/600 for example.
  24180. * To speed it up, 1/30
  24181. * @param newTimeStep the new timestep to apply to this world.
  24182. */
  24183. setTimeStep(newTimeStep: number): void;
  24184. /**
  24185. * Get the time step of the physics engine.
  24186. * @returns the current time step
  24187. */
  24188. getTimeStep(): number;
  24189. /**
  24190. * Set the sub time step of the physics engine.
  24191. * Default is 0 meaning there is no sub steps
  24192. * To increase physics resolution precision, set a small value (like 1 ms)
  24193. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24194. */
  24195. setSubTimeStep(subTimeStep: number): void;
  24196. /**
  24197. * Get the sub time step of the physics engine.
  24198. * @returns the current sub time step
  24199. */
  24200. getSubTimeStep(): number;
  24201. /**
  24202. * Release all resources
  24203. */
  24204. dispose(): void;
  24205. /**
  24206. * Gets the name of the current physics plugin
  24207. * @returns the name of the plugin
  24208. */
  24209. getPhysicsPluginName(): string;
  24210. /**
  24211. * Adding a new impostor for the impostor tracking.
  24212. * This will be done by the impostor itself.
  24213. * @param impostor the impostor to add
  24214. */
  24215. addImpostor(impostor: PhysicsImpostor): void;
  24216. /**
  24217. * Remove an impostor from the engine.
  24218. * This impostor and its mesh will not longer be updated by the physics engine.
  24219. * @param impostor the impostor to remove
  24220. */
  24221. removeImpostor(impostor: PhysicsImpostor): void;
  24222. /**
  24223. * Add a joint to the physics engine
  24224. * @param mainImpostor defines the main impostor to which the joint is added.
  24225. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24226. * @param joint defines the joint that will connect both impostors.
  24227. */
  24228. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24229. /**
  24230. * Removes a joint from the simulation
  24231. * @param mainImpostor defines the impostor used with the joint
  24232. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24233. * @param joint defines the joint to remove
  24234. */
  24235. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24236. /**
  24237. * Gets the current plugin used to run the simulation
  24238. * @returns current plugin
  24239. */
  24240. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24241. /**
  24242. * Gets the list of physic impostors
  24243. * @returns an array of PhysicsImpostor
  24244. */
  24245. getImpostors(): Array<PhysicsImpostor>;
  24246. /**
  24247. * Gets the impostor for a physics enabled object
  24248. * @param object defines the object impersonated by the impostor
  24249. * @returns the PhysicsImpostor or null if not found
  24250. */
  24251. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24252. /**
  24253. * Gets the impostor for a physics body object
  24254. * @param body defines physics body used by the impostor
  24255. * @returns the PhysicsImpostor or null if not found
  24256. */
  24257. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24258. /**
  24259. * Does a raycast in the physics world
  24260. * @param from when should the ray start?
  24261. * @param to when should the ray end?
  24262. * @returns PhysicsRaycastResult
  24263. */
  24264. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24265. /**
  24266. * Called by the scene. No need to call it.
  24267. * @param delta defines the timespam between frames
  24268. */
  24269. _step(delta: number): void;
  24270. }
  24271. }
  24272. declare module "babylonjs/Physics/physicsImpostor" {
  24273. import { Nullable, IndicesArray } from "babylonjs/types";
  24274. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24277. import { Scene } from "babylonjs/scene";
  24278. import { Bone } from "babylonjs/Bones/bone";
  24279. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24280. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24281. import { Space } from "babylonjs/Maths/math.axis";
  24282. /**
  24283. * The interface for the physics imposter parameters
  24284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24285. */
  24286. export interface PhysicsImpostorParameters {
  24287. /**
  24288. * The mass of the physics imposter
  24289. */
  24290. mass: number;
  24291. /**
  24292. * The friction of the physics imposter
  24293. */
  24294. friction?: number;
  24295. /**
  24296. * The coefficient of restitution of the physics imposter
  24297. */
  24298. restitution?: number;
  24299. /**
  24300. * The native options of the physics imposter
  24301. */
  24302. nativeOptions?: any;
  24303. /**
  24304. * Specifies if the parent should be ignored
  24305. */
  24306. ignoreParent?: boolean;
  24307. /**
  24308. * Specifies if bi-directional transformations should be disabled
  24309. */
  24310. disableBidirectionalTransformation?: boolean;
  24311. /**
  24312. * The pressure inside the physics imposter, soft object only
  24313. */
  24314. pressure?: number;
  24315. /**
  24316. * The stiffness the physics imposter, soft object only
  24317. */
  24318. stiffness?: number;
  24319. /**
  24320. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24321. */
  24322. velocityIterations?: number;
  24323. /**
  24324. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24325. */
  24326. positionIterations?: number;
  24327. /**
  24328. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24329. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24330. * Add to fix multiple points
  24331. */
  24332. fixedPoints?: number;
  24333. /**
  24334. * The collision margin around a soft object
  24335. */
  24336. margin?: number;
  24337. /**
  24338. * The collision margin around a soft object
  24339. */
  24340. damping?: number;
  24341. /**
  24342. * The path for a rope based on an extrusion
  24343. */
  24344. path?: any;
  24345. /**
  24346. * The shape of an extrusion used for a rope based on an extrusion
  24347. */
  24348. shape?: any;
  24349. }
  24350. /**
  24351. * Interface for a physics-enabled object
  24352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24353. */
  24354. export interface IPhysicsEnabledObject {
  24355. /**
  24356. * The position of the physics-enabled object
  24357. */
  24358. position: Vector3;
  24359. /**
  24360. * The rotation of the physics-enabled object
  24361. */
  24362. rotationQuaternion: Nullable<Quaternion>;
  24363. /**
  24364. * The scale of the physics-enabled object
  24365. */
  24366. scaling: Vector3;
  24367. /**
  24368. * The rotation of the physics-enabled object
  24369. */
  24370. rotation?: Vector3;
  24371. /**
  24372. * The parent of the physics-enabled object
  24373. */
  24374. parent?: any;
  24375. /**
  24376. * The bounding info of the physics-enabled object
  24377. * @returns The bounding info of the physics-enabled object
  24378. */
  24379. getBoundingInfo(): BoundingInfo;
  24380. /**
  24381. * Computes the world matrix
  24382. * @param force Specifies if the world matrix should be computed by force
  24383. * @returns A world matrix
  24384. */
  24385. computeWorldMatrix(force: boolean): Matrix;
  24386. /**
  24387. * Gets the world matrix
  24388. * @returns A world matrix
  24389. */
  24390. getWorldMatrix?(): Matrix;
  24391. /**
  24392. * Gets the child meshes
  24393. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24394. * @returns An array of abstract meshes
  24395. */
  24396. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24397. /**
  24398. * Gets the vertex data
  24399. * @param kind The type of vertex data
  24400. * @returns A nullable array of numbers, or a float32 array
  24401. */
  24402. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24403. /**
  24404. * Gets the indices from the mesh
  24405. * @returns A nullable array of index arrays
  24406. */
  24407. getIndices?(): Nullable<IndicesArray>;
  24408. /**
  24409. * Gets the scene from the mesh
  24410. * @returns the indices array or null
  24411. */
  24412. getScene?(): Scene;
  24413. /**
  24414. * Gets the absolute position from the mesh
  24415. * @returns the absolute position
  24416. */
  24417. getAbsolutePosition(): Vector3;
  24418. /**
  24419. * Gets the absolute pivot point from the mesh
  24420. * @returns the absolute pivot point
  24421. */
  24422. getAbsolutePivotPoint(): Vector3;
  24423. /**
  24424. * Rotates the mesh
  24425. * @param axis The axis of rotation
  24426. * @param amount The amount of rotation
  24427. * @param space The space of the rotation
  24428. * @returns The rotation transform node
  24429. */
  24430. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24431. /**
  24432. * Translates the mesh
  24433. * @param axis The axis of translation
  24434. * @param distance The distance of translation
  24435. * @param space The space of the translation
  24436. * @returns The transform node
  24437. */
  24438. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24439. /**
  24440. * Sets the absolute position of the mesh
  24441. * @param absolutePosition The absolute position of the mesh
  24442. * @returns The transform node
  24443. */
  24444. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24445. /**
  24446. * Gets the class name of the mesh
  24447. * @returns The class name
  24448. */
  24449. getClassName(): string;
  24450. }
  24451. /**
  24452. * Represents a physics imposter
  24453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24454. */
  24455. export class PhysicsImpostor {
  24456. /**
  24457. * The physics-enabled object used as the physics imposter
  24458. */
  24459. object: IPhysicsEnabledObject;
  24460. /**
  24461. * The type of the physics imposter
  24462. */
  24463. type: number;
  24464. private _options;
  24465. private _scene?;
  24466. /**
  24467. * The default object size of the imposter
  24468. */
  24469. static DEFAULT_OBJECT_SIZE: Vector3;
  24470. /**
  24471. * The identity quaternion of the imposter
  24472. */
  24473. static IDENTITY_QUATERNION: Quaternion;
  24474. /** @hidden */
  24475. _pluginData: any;
  24476. private _physicsEngine;
  24477. private _physicsBody;
  24478. private _bodyUpdateRequired;
  24479. private _onBeforePhysicsStepCallbacks;
  24480. private _onAfterPhysicsStepCallbacks;
  24481. /** @hidden */
  24482. _onPhysicsCollideCallbacks: Array<{
  24483. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24484. otherImpostors: Array<PhysicsImpostor>;
  24485. }>;
  24486. private _deltaPosition;
  24487. private _deltaRotation;
  24488. private _deltaRotationConjugated;
  24489. /** @hidden */
  24490. _isFromLine: boolean;
  24491. private _parent;
  24492. private _isDisposed;
  24493. private static _tmpVecs;
  24494. private static _tmpQuat;
  24495. /**
  24496. * Specifies if the physics imposter is disposed
  24497. */
  24498. get isDisposed(): boolean;
  24499. /**
  24500. * Gets the mass of the physics imposter
  24501. */
  24502. get mass(): number;
  24503. set mass(value: number);
  24504. /**
  24505. * Gets the coefficient of friction
  24506. */
  24507. get friction(): number;
  24508. /**
  24509. * Sets the coefficient of friction
  24510. */
  24511. set friction(value: number);
  24512. /**
  24513. * Gets the coefficient of restitution
  24514. */
  24515. get restitution(): number;
  24516. /**
  24517. * Sets the coefficient of restitution
  24518. */
  24519. set restitution(value: number);
  24520. /**
  24521. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24522. */
  24523. get pressure(): number;
  24524. /**
  24525. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24526. */
  24527. set pressure(value: number);
  24528. /**
  24529. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24530. */
  24531. get stiffness(): number;
  24532. /**
  24533. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24534. */
  24535. set stiffness(value: number);
  24536. /**
  24537. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24538. */
  24539. get velocityIterations(): number;
  24540. /**
  24541. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24542. */
  24543. set velocityIterations(value: number);
  24544. /**
  24545. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24546. */
  24547. get positionIterations(): number;
  24548. /**
  24549. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24550. */
  24551. set positionIterations(value: number);
  24552. /**
  24553. * The unique id of the physics imposter
  24554. * set by the physics engine when adding this impostor to the array
  24555. */
  24556. uniqueId: number;
  24557. /**
  24558. * @hidden
  24559. */
  24560. soft: boolean;
  24561. /**
  24562. * @hidden
  24563. */
  24564. segments: number;
  24565. private _joints;
  24566. /**
  24567. * Initializes the physics imposter
  24568. * @param object The physics-enabled object used as the physics imposter
  24569. * @param type The type of the physics imposter
  24570. * @param _options The options for the physics imposter
  24571. * @param _scene The Babylon scene
  24572. */
  24573. constructor(
  24574. /**
  24575. * The physics-enabled object used as the physics imposter
  24576. */
  24577. object: IPhysicsEnabledObject,
  24578. /**
  24579. * The type of the physics imposter
  24580. */
  24581. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24582. /**
  24583. * This function will completly initialize this impostor.
  24584. * It will create a new body - but only if this mesh has no parent.
  24585. * If it has, this impostor will not be used other than to define the impostor
  24586. * of the child mesh.
  24587. * @hidden
  24588. */
  24589. _init(): void;
  24590. private _getPhysicsParent;
  24591. /**
  24592. * Should a new body be generated.
  24593. * @returns boolean specifying if body initialization is required
  24594. */
  24595. isBodyInitRequired(): boolean;
  24596. /**
  24597. * Sets the updated scaling
  24598. * @param updated Specifies if the scaling is updated
  24599. */
  24600. setScalingUpdated(): void;
  24601. /**
  24602. * Force a regeneration of this or the parent's impostor's body.
  24603. * Use under cautious - This will remove all joints already implemented.
  24604. */
  24605. forceUpdate(): void;
  24606. /**
  24607. * Gets the body that holds this impostor. Either its own, or its parent.
  24608. */
  24609. get physicsBody(): any;
  24610. /**
  24611. * Get the parent of the physics imposter
  24612. * @returns Physics imposter or null
  24613. */
  24614. get parent(): Nullable<PhysicsImpostor>;
  24615. /**
  24616. * Sets the parent of the physics imposter
  24617. */
  24618. set parent(value: Nullable<PhysicsImpostor>);
  24619. /**
  24620. * Set the physics body. Used mainly by the physics engine/plugin
  24621. */
  24622. set physicsBody(physicsBody: any);
  24623. /**
  24624. * Resets the update flags
  24625. */
  24626. resetUpdateFlags(): void;
  24627. /**
  24628. * Gets the object extend size
  24629. * @returns the object extend size
  24630. */
  24631. getObjectExtendSize(): Vector3;
  24632. /**
  24633. * Gets the object center
  24634. * @returns The object center
  24635. */
  24636. getObjectCenter(): Vector3;
  24637. /**
  24638. * Get a specific parameter from the options parameters
  24639. * @param paramName The object parameter name
  24640. * @returns The object parameter
  24641. */
  24642. getParam(paramName: string): any;
  24643. /**
  24644. * Sets a specific parameter in the options given to the physics plugin
  24645. * @param paramName The parameter name
  24646. * @param value The value of the parameter
  24647. */
  24648. setParam(paramName: string, value: number): void;
  24649. /**
  24650. * Specifically change the body's mass option. Won't recreate the physics body object
  24651. * @param mass The mass of the physics imposter
  24652. */
  24653. setMass(mass: number): void;
  24654. /**
  24655. * Gets the linear velocity
  24656. * @returns linear velocity or null
  24657. */
  24658. getLinearVelocity(): Nullable<Vector3>;
  24659. /**
  24660. * Sets the linear velocity
  24661. * @param velocity linear velocity or null
  24662. */
  24663. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24664. /**
  24665. * Gets the angular velocity
  24666. * @returns angular velocity or null
  24667. */
  24668. getAngularVelocity(): Nullable<Vector3>;
  24669. /**
  24670. * Sets the angular velocity
  24671. * @param velocity The velocity or null
  24672. */
  24673. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24674. /**
  24675. * Execute a function with the physics plugin native code
  24676. * Provide a function the will have two variables - the world object and the physics body object
  24677. * @param func The function to execute with the physics plugin native code
  24678. */
  24679. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24680. /**
  24681. * Register a function that will be executed before the physics world is stepping forward
  24682. * @param func The function to execute before the physics world is stepped forward
  24683. */
  24684. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24685. /**
  24686. * Unregister a function that will be executed before the physics world is stepping forward
  24687. * @param func The function to execute before the physics world is stepped forward
  24688. */
  24689. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24690. /**
  24691. * Register a function that will be executed after the physics step
  24692. * @param func The function to execute after physics step
  24693. */
  24694. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24695. /**
  24696. * Unregisters a function that will be executed after the physics step
  24697. * @param func The function to execute after physics step
  24698. */
  24699. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24700. /**
  24701. * register a function that will be executed when this impostor collides against a different body
  24702. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24703. * @param func Callback that is executed on collision
  24704. */
  24705. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24706. /**
  24707. * Unregisters the physics imposter on contact
  24708. * @param collideAgainst The physics object to collide against
  24709. * @param func Callback to execute on collision
  24710. */
  24711. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24712. private _tmpQuat;
  24713. private _tmpQuat2;
  24714. /**
  24715. * Get the parent rotation
  24716. * @returns The parent rotation
  24717. */
  24718. getParentsRotation(): Quaternion;
  24719. /**
  24720. * this function is executed by the physics engine.
  24721. */
  24722. beforeStep: () => void;
  24723. /**
  24724. * this function is executed by the physics engine
  24725. */
  24726. afterStep: () => void;
  24727. /**
  24728. * Legacy collision detection event support
  24729. */
  24730. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24731. /**
  24732. * event and body object due to cannon's event-based architecture.
  24733. */
  24734. onCollide: (e: {
  24735. body: any;
  24736. }) => void;
  24737. /**
  24738. * Apply a force
  24739. * @param force The force to apply
  24740. * @param contactPoint The contact point for the force
  24741. * @returns The physics imposter
  24742. */
  24743. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24744. /**
  24745. * Apply an impulse
  24746. * @param force The impulse force
  24747. * @param contactPoint The contact point for the impulse force
  24748. * @returns The physics imposter
  24749. */
  24750. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24751. /**
  24752. * A help function to create a joint
  24753. * @param otherImpostor A physics imposter used to create a joint
  24754. * @param jointType The type of joint
  24755. * @param jointData The data for the joint
  24756. * @returns The physics imposter
  24757. */
  24758. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24759. /**
  24760. * Add a joint to this impostor with a different impostor
  24761. * @param otherImpostor A physics imposter used to add a joint
  24762. * @param joint The joint to add
  24763. * @returns The physics imposter
  24764. */
  24765. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24766. /**
  24767. * Add an anchor to a cloth impostor
  24768. * @param otherImpostor rigid impostor to anchor to
  24769. * @param width ratio across width from 0 to 1
  24770. * @param height ratio up height from 0 to 1
  24771. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24772. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24773. * @returns impostor the soft imposter
  24774. */
  24775. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24776. /**
  24777. * Add a hook to a rope impostor
  24778. * @param otherImpostor rigid impostor to anchor to
  24779. * @param length ratio across rope from 0 to 1
  24780. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24781. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24782. * @returns impostor the rope imposter
  24783. */
  24784. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24785. /**
  24786. * Will keep this body still, in a sleep mode.
  24787. * @returns the physics imposter
  24788. */
  24789. sleep(): PhysicsImpostor;
  24790. /**
  24791. * Wake the body up.
  24792. * @returns The physics imposter
  24793. */
  24794. wakeUp(): PhysicsImpostor;
  24795. /**
  24796. * Clones the physics imposter
  24797. * @param newObject The physics imposter clones to this physics-enabled object
  24798. * @returns A nullable physics imposter
  24799. */
  24800. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24801. /**
  24802. * Disposes the physics imposter
  24803. */
  24804. dispose(): void;
  24805. /**
  24806. * Sets the delta position
  24807. * @param position The delta position amount
  24808. */
  24809. setDeltaPosition(position: Vector3): void;
  24810. /**
  24811. * Sets the delta rotation
  24812. * @param rotation The delta rotation amount
  24813. */
  24814. setDeltaRotation(rotation: Quaternion): void;
  24815. /**
  24816. * Gets the box size of the physics imposter and stores the result in the input parameter
  24817. * @param result Stores the box size
  24818. * @returns The physics imposter
  24819. */
  24820. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24821. /**
  24822. * Gets the radius of the physics imposter
  24823. * @returns Radius of the physics imposter
  24824. */
  24825. getRadius(): number;
  24826. /**
  24827. * Sync a bone with this impostor
  24828. * @param bone The bone to sync to the impostor.
  24829. * @param boneMesh The mesh that the bone is influencing.
  24830. * @param jointPivot The pivot of the joint / bone in local space.
  24831. * @param distToJoint Optional distance from the impostor to the joint.
  24832. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24833. */
  24834. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24835. /**
  24836. * Sync impostor to a bone
  24837. * @param bone The bone that the impostor will be synced to.
  24838. * @param boneMesh The mesh that the bone is influencing.
  24839. * @param jointPivot The pivot of the joint / bone in local space.
  24840. * @param distToJoint Optional distance from the impostor to the joint.
  24841. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24842. * @param boneAxis Optional vector3 axis the bone is aligned with
  24843. */
  24844. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24845. /**
  24846. * No-Imposter type
  24847. */
  24848. static NoImpostor: number;
  24849. /**
  24850. * Sphere-Imposter type
  24851. */
  24852. static SphereImpostor: number;
  24853. /**
  24854. * Box-Imposter type
  24855. */
  24856. static BoxImpostor: number;
  24857. /**
  24858. * Plane-Imposter type
  24859. */
  24860. static PlaneImpostor: number;
  24861. /**
  24862. * Mesh-imposter type
  24863. */
  24864. static MeshImpostor: number;
  24865. /**
  24866. * Capsule-Impostor type (Ammo.js plugin only)
  24867. */
  24868. static CapsuleImpostor: number;
  24869. /**
  24870. * Cylinder-Imposter type
  24871. */
  24872. static CylinderImpostor: number;
  24873. /**
  24874. * Particle-Imposter type
  24875. */
  24876. static ParticleImpostor: number;
  24877. /**
  24878. * Heightmap-Imposter type
  24879. */
  24880. static HeightmapImpostor: number;
  24881. /**
  24882. * ConvexHull-Impostor type (Ammo.js plugin only)
  24883. */
  24884. static ConvexHullImpostor: number;
  24885. /**
  24886. * Custom-Imposter type (Ammo.js plugin only)
  24887. */
  24888. static CustomImpostor: number;
  24889. /**
  24890. * Rope-Imposter type
  24891. */
  24892. static RopeImpostor: number;
  24893. /**
  24894. * Cloth-Imposter type
  24895. */
  24896. static ClothImpostor: number;
  24897. /**
  24898. * Softbody-Imposter type
  24899. */
  24900. static SoftbodyImpostor: number;
  24901. }
  24902. }
  24903. declare module "babylonjs/Meshes/mesh" {
  24904. import { Observable } from "babylonjs/Misc/observable";
  24905. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24906. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24907. import { Camera } from "babylonjs/Cameras/camera";
  24908. import { Scene } from "babylonjs/scene";
  24909. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24910. import { Color4 } from "babylonjs/Maths/math.color";
  24911. import { Engine } from "babylonjs/Engines/engine";
  24912. import { Node } from "babylonjs/node";
  24913. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24914. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24915. import { Buffer } from "babylonjs/Meshes/buffer";
  24916. import { Geometry } from "babylonjs/Meshes/geometry";
  24917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24918. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24919. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24920. import { Effect } from "babylonjs/Materials/effect";
  24921. import { Material } from "babylonjs/Materials/material";
  24922. import { Skeleton } from "babylonjs/Bones/skeleton";
  24923. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24924. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24925. import { Path3D } from "babylonjs/Maths/math.path";
  24926. import { Plane } from "babylonjs/Maths/math.plane";
  24927. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24928. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24929. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24930. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24931. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24932. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24933. /**
  24934. * @hidden
  24935. **/
  24936. export class _CreationDataStorage {
  24937. closePath?: boolean;
  24938. closeArray?: boolean;
  24939. idx: number[];
  24940. dashSize: number;
  24941. gapSize: number;
  24942. path3D: Path3D;
  24943. pathArray: Vector3[][];
  24944. arc: number;
  24945. radius: number;
  24946. cap: number;
  24947. tessellation: number;
  24948. }
  24949. /**
  24950. * @hidden
  24951. **/
  24952. class _InstanceDataStorage {
  24953. visibleInstances: any;
  24954. batchCache: _InstancesBatch;
  24955. instancesBufferSize: number;
  24956. instancesBuffer: Nullable<Buffer>;
  24957. instancesData: Float32Array;
  24958. overridenInstanceCount: number;
  24959. isFrozen: boolean;
  24960. previousBatch: Nullable<_InstancesBatch>;
  24961. hardwareInstancedRendering: boolean;
  24962. sideOrientation: number;
  24963. manualUpdate: boolean;
  24964. }
  24965. /**
  24966. * @hidden
  24967. **/
  24968. export class _InstancesBatch {
  24969. mustReturn: boolean;
  24970. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24971. renderSelf: boolean[];
  24972. hardwareInstancedRendering: boolean[];
  24973. }
  24974. /**
  24975. * Class used to represent renderable models
  24976. */
  24977. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24978. /**
  24979. * Mesh side orientation : usually the external or front surface
  24980. */
  24981. static readonly FRONTSIDE: number;
  24982. /**
  24983. * Mesh side orientation : usually the internal or back surface
  24984. */
  24985. static readonly BACKSIDE: number;
  24986. /**
  24987. * Mesh side orientation : both internal and external or front and back surfaces
  24988. */
  24989. static readonly DOUBLESIDE: number;
  24990. /**
  24991. * Mesh side orientation : by default, `FRONTSIDE`
  24992. */
  24993. static readonly DEFAULTSIDE: number;
  24994. /**
  24995. * Mesh cap setting : no cap
  24996. */
  24997. static readonly NO_CAP: number;
  24998. /**
  24999. * Mesh cap setting : one cap at the beginning of the mesh
  25000. */
  25001. static readonly CAP_START: number;
  25002. /**
  25003. * Mesh cap setting : one cap at the end of the mesh
  25004. */
  25005. static readonly CAP_END: number;
  25006. /**
  25007. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25008. */
  25009. static readonly CAP_ALL: number;
  25010. /**
  25011. * Mesh pattern setting : no flip or rotate
  25012. */
  25013. static readonly NO_FLIP: number;
  25014. /**
  25015. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25016. */
  25017. static readonly FLIP_TILE: number;
  25018. /**
  25019. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25020. */
  25021. static readonly ROTATE_TILE: number;
  25022. /**
  25023. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25024. */
  25025. static readonly FLIP_ROW: number;
  25026. /**
  25027. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25028. */
  25029. static readonly ROTATE_ROW: number;
  25030. /**
  25031. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25032. */
  25033. static readonly FLIP_N_ROTATE_TILE: number;
  25034. /**
  25035. * Mesh pattern setting : rotate pattern and rotate
  25036. */
  25037. static readonly FLIP_N_ROTATE_ROW: number;
  25038. /**
  25039. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25040. */
  25041. static readonly CENTER: number;
  25042. /**
  25043. * Mesh tile positioning : part tiles on left
  25044. */
  25045. static readonly LEFT: number;
  25046. /**
  25047. * Mesh tile positioning : part tiles on right
  25048. */
  25049. static readonly RIGHT: number;
  25050. /**
  25051. * Mesh tile positioning : part tiles on top
  25052. */
  25053. static readonly TOP: number;
  25054. /**
  25055. * Mesh tile positioning : part tiles on bottom
  25056. */
  25057. static readonly BOTTOM: number;
  25058. /**
  25059. * Gets the default side orientation.
  25060. * @param orientation the orientation to value to attempt to get
  25061. * @returns the default orientation
  25062. * @hidden
  25063. */
  25064. static _GetDefaultSideOrientation(orientation?: number): number;
  25065. private _internalMeshDataInfo;
  25066. /**
  25067. * An event triggered before rendering the mesh
  25068. */
  25069. get onBeforeRenderObservable(): Observable<Mesh>;
  25070. /**
  25071. * An event triggered before binding the mesh
  25072. */
  25073. get onBeforeBindObservable(): Observable<Mesh>;
  25074. /**
  25075. * An event triggered after rendering the mesh
  25076. */
  25077. get onAfterRenderObservable(): Observable<Mesh>;
  25078. /**
  25079. * An event triggered before drawing the mesh
  25080. */
  25081. get onBeforeDrawObservable(): Observable<Mesh>;
  25082. private _onBeforeDrawObserver;
  25083. /**
  25084. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25085. */
  25086. set onBeforeDraw(callback: () => void);
  25087. get hasInstances(): boolean;
  25088. /**
  25089. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25090. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25091. */
  25092. delayLoadState: number;
  25093. /**
  25094. * Gets the list of instances created from this mesh
  25095. * it is not supposed to be modified manually.
  25096. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25097. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25098. */
  25099. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25100. /**
  25101. * Gets the file containing delay loading data for this mesh
  25102. */
  25103. delayLoadingFile: string;
  25104. /** @hidden */
  25105. _binaryInfo: any;
  25106. /**
  25107. * User defined function used to change how LOD level selection is done
  25108. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25109. */
  25110. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25111. /**
  25112. * Gets or sets the morph target manager
  25113. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25114. */
  25115. get morphTargetManager(): Nullable<MorphTargetManager>;
  25116. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25117. /** @hidden */
  25118. _creationDataStorage: Nullable<_CreationDataStorage>;
  25119. /** @hidden */
  25120. _geometry: Nullable<Geometry>;
  25121. /** @hidden */
  25122. _delayInfo: Array<string>;
  25123. /** @hidden */
  25124. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25125. /** @hidden */
  25126. _instanceDataStorage: _InstanceDataStorage;
  25127. private _effectiveMaterial;
  25128. /** @hidden */
  25129. _shouldGenerateFlatShading: boolean;
  25130. /** @hidden */
  25131. _originalBuilderSideOrientation: number;
  25132. /**
  25133. * Use this property to change the original side orientation defined at construction time
  25134. */
  25135. overrideMaterialSideOrientation: Nullable<number>;
  25136. /**
  25137. * Gets the source mesh (the one used to clone this one from)
  25138. */
  25139. get source(): Nullable<Mesh>;
  25140. /**
  25141. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25142. */
  25143. get isUnIndexed(): boolean;
  25144. set isUnIndexed(value: boolean);
  25145. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25146. get worldMatrixInstancedBuffer(): Float32Array;
  25147. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25148. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25149. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25150. /**
  25151. * @constructor
  25152. * @param name The value used by scene.getMeshByName() to do a lookup.
  25153. * @param scene The scene to add this mesh to.
  25154. * @param parent The parent of this mesh, if it has one
  25155. * @param source An optional Mesh from which geometry is shared, cloned.
  25156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25157. * When false, achieved by calling a clone(), also passing False.
  25158. * This will make creation of children, recursive.
  25159. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25160. */
  25161. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25162. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25163. doNotInstantiate: boolean;
  25164. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25165. /**
  25166. * Gets the class name
  25167. * @returns the string "Mesh".
  25168. */
  25169. getClassName(): string;
  25170. /** @hidden */
  25171. get _isMesh(): boolean;
  25172. /**
  25173. * Returns a description of this mesh
  25174. * @param fullDetails define if full details about this mesh must be used
  25175. * @returns a descriptive string representing this mesh
  25176. */
  25177. toString(fullDetails?: boolean): string;
  25178. /** @hidden */
  25179. _unBindEffect(): void;
  25180. /**
  25181. * Gets a boolean indicating if this mesh has LOD
  25182. */
  25183. get hasLODLevels(): boolean;
  25184. /**
  25185. * Gets the list of MeshLODLevel associated with the current mesh
  25186. * @returns an array of MeshLODLevel
  25187. */
  25188. getLODLevels(): MeshLODLevel[];
  25189. private _sortLODLevels;
  25190. /**
  25191. * Add a mesh as LOD level triggered at the given distance.
  25192. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25193. * @param distance The distance from the center of the object to show this level
  25194. * @param mesh The mesh to be added as LOD level (can be null)
  25195. * @return This mesh (for chaining)
  25196. */
  25197. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25198. /**
  25199. * Returns the LOD level mesh at the passed distance or null if not found.
  25200. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25201. * @param distance The distance from the center of the object to show this level
  25202. * @returns a Mesh or `null`
  25203. */
  25204. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25205. /**
  25206. * Remove a mesh from the LOD array
  25207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25208. * @param mesh defines the mesh to be removed
  25209. * @return This mesh (for chaining)
  25210. */
  25211. removeLODLevel(mesh: Mesh): Mesh;
  25212. /**
  25213. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25214. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25215. * @param camera defines the camera to use to compute distance
  25216. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25217. * @return This mesh (for chaining)
  25218. */
  25219. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25220. /**
  25221. * Gets the mesh internal Geometry object
  25222. */
  25223. get geometry(): Nullable<Geometry>;
  25224. /**
  25225. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25226. * @returns the total number of vertices
  25227. */
  25228. getTotalVertices(): number;
  25229. /**
  25230. * Returns the content of an associated vertex buffer
  25231. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25232. * - VertexBuffer.PositionKind
  25233. * - VertexBuffer.UVKind
  25234. * - VertexBuffer.UV2Kind
  25235. * - VertexBuffer.UV3Kind
  25236. * - VertexBuffer.UV4Kind
  25237. * - VertexBuffer.UV5Kind
  25238. * - VertexBuffer.UV6Kind
  25239. * - VertexBuffer.ColorKind
  25240. * - VertexBuffer.MatricesIndicesKind
  25241. * - VertexBuffer.MatricesIndicesExtraKind
  25242. * - VertexBuffer.MatricesWeightsKind
  25243. * - VertexBuffer.MatricesWeightsExtraKind
  25244. * @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
  25245. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25246. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25247. */
  25248. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25249. /**
  25250. * Returns the mesh VertexBuffer object from the requested `kind`
  25251. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25252. * - VertexBuffer.PositionKind
  25253. * - VertexBuffer.NormalKind
  25254. * - VertexBuffer.UVKind
  25255. * - VertexBuffer.UV2Kind
  25256. * - VertexBuffer.UV3Kind
  25257. * - VertexBuffer.UV4Kind
  25258. * - VertexBuffer.UV5Kind
  25259. * - VertexBuffer.UV6Kind
  25260. * - VertexBuffer.ColorKind
  25261. * - VertexBuffer.MatricesIndicesKind
  25262. * - VertexBuffer.MatricesIndicesExtraKind
  25263. * - VertexBuffer.MatricesWeightsKind
  25264. * - VertexBuffer.MatricesWeightsExtraKind
  25265. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25266. */
  25267. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25268. /**
  25269. * Tests if a specific vertex buffer is associated with this mesh
  25270. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25271. * - VertexBuffer.PositionKind
  25272. * - VertexBuffer.NormalKind
  25273. * - VertexBuffer.UVKind
  25274. * - VertexBuffer.UV2Kind
  25275. * - VertexBuffer.UV3Kind
  25276. * - VertexBuffer.UV4Kind
  25277. * - VertexBuffer.UV5Kind
  25278. * - VertexBuffer.UV6Kind
  25279. * - VertexBuffer.ColorKind
  25280. * - VertexBuffer.MatricesIndicesKind
  25281. * - VertexBuffer.MatricesIndicesExtraKind
  25282. * - VertexBuffer.MatricesWeightsKind
  25283. * - VertexBuffer.MatricesWeightsExtraKind
  25284. * @returns a boolean
  25285. */
  25286. isVerticesDataPresent(kind: string): boolean;
  25287. /**
  25288. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25289. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25290. * - VertexBuffer.PositionKind
  25291. * - VertexBuffer.UVKind
  25292. * - VertexBuffer.UV2Kind
  25293. * - VertexBuffer.UV3Kind
  25294. * - VertexBuffer.UV4Kind
  25295. * - VertexBuffer.UV5Kind
  25296. * - VertexBuffer.UV6Kind
  25297. * - VertexBuffer.ColorKind
  25298. * - VertexBuffer.MatricesIndicesKind
  25299. * - VertexBuffer.MatricesIndicesExtraKind
  25300. * - VertexBuffer.MatricesWeightsKind
  25301. * - VertexBuffer.MatricesWeightsExtraKind
  25302. * @returns a boolean
  25303. */
  25304. isVertexBufferUpdatable(kind: string): boolean;
  25305. /**
  25306. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25307. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25308. * - VertexBuffer.PositionKind
  25309. * - VertexBuffer.NormalKind
  25310. * - VertexBuffer.UVKind
  25311. * - VertexBuffer.UV2Kind
  25312. * - VertexBuffer.UV3Kind
  25313. * - VertexBuffer.UV4Kind
  25314. * - VertexBuffer.UV5Kind
  25315. * - VertexBuffer.UV6Kind
  25316. * - VertexBuffer.ColorKind
  25317. * - VertexBuffer.MatricesIndicesKind
  25318. * - VertexBuffer.MatricesIndicesExtraKind
  25319. * - VertexBuffer.MatricesWeightsKind
  25320. * - VertexBuffer.MatricesWeightsExtraKind
  25321. * @returns an array of strings
  25322. */
  25323. getVerticesDataKinds(): string[];
  25324. /**
  25325. * Returns a positive integer : the total number of indices in this mesh geometry.
  25326. * @returns the numner of indices or zero if the mesh has no geometry.
  25327. */
  25328. getTotalIndices(): number;
  25329. /**
  25330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25331. * @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.
  25332. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25333. * @returns the indices array or an empty array if the mesh has no geometry
  25334. */
  25335. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25336. get isBlocked(): boolean;
  25337. /**
  25338. * Determine if the current mesh is ready to be rendered
  25339. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25340. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25341. * @returns true if all associated assets are ready (material, textures, shaders)
  25342. */
  25343. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25344. /**
  25345. * 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.
  25346. */
  25347. get areNormalsFrozen(): boolean;
  25348. /**
  25349. * 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.
  25350. * @returns the current mesh
  25351. */
  25352. freezeNormals(): Mesh;
  25353. /**
  25354. * 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
  25355. * @returns the current mesh
  25356. */
  25357. unfreezeNormals(): Mesh;
  25358. /**
  25359. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25360. */
  25361. set overridenInstanceCount(count: number);
  25362. /** @hidden */
  25363. _preActivate(): Mesh;
  25364. /** @hidden */
  25365. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25366. /** @hidden */
  25367. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25368. /**
  25369. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25370. * This means the mesh underlying bounding box and sphere are recomputed.
  25371. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25372. * @returns the current mesh
  25373. */
  25374. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25375. /** @hidden */
  25376. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25377. /**
  25378. * This function will subdivide the mesh into multiple submeshes
  25379. * @param count defines the expected number of submeshes
  25380. */
  25381. subdivide(count: number): void;
  25382. /**
  25383. * Copy a FloatArray into a specific associated vertex buffer
  25384. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25385. * - VertexBuffer.PositionKind
  25386. * - VertexBuffer.UVKind
  25387. * - VertexBuffer.UV2Kind
  25388. * - VertexBuffer.UV3Kind
  25389. * - VertexBuffer.UV4Kind
  25390. * - VertexBuffer.UV5Kind
  25391. * - VertexBuffer.UV6Kind
  25392. * - VertexBuffer.ColorKind
  25393. * - VertexBuffer.MatricesIndicesKind
  25394. * - VertexBuffer.MatricesIndicesExtraKind
  25395. * - VertexBuffer.MatricesWeightsKind
  25396. * - VertexBuffer.MatricesWeightsExtraKind
  25397. * @param data defines the data source
  25398. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25399. * @param stride defines the data stride size (can be null)
  25400. * @returns the current mesh
  25401. */
  25402. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25403. /**
  25404. * Delete a vertex buffer associated with this mesh
  25405. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25406. * - VertexBuffer.PositionKind
  25407. * - VertexBuffer.UVKind
  25408. * - VertexBuffer.UV2Kind
  25409. * - VertexBuffer.UV3Kind
  25410. * - VertexBuffer.UV4Kind
  25411. * - VertexBuffer.UV5Kind
  25412. * - VertexBuffer.UV6Kind
  25413. * - VertexBuffer.ColorKind
  25414. * - VertexBuffer.MatricesIndicesKind
  25415. * - VertexBuffer.MatricesIndicesExtraKind
  25416. * - VertexBuffer.MatricesWeightsKind
  25417. * - VertexBuffer.MatricesWeightsExtraKind
  25418. */
  25419. removeVerticesData(kind: string): void;
  25420. /**
  25421. * Flags an associated vertex buffer as updatable
  25422. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25423. * - VertexBuffer.PositionKind
  25424. * - VertexBuffer.UVKind
  25425. * - VertexBuffer.UV2Kind
  25426. * - VertexBuffer.UV3Kind
  25427. * - VertexBuffer.UV4Kind
  25428. * - VertexBuffer.UV5Kind
  25429. * - VertexBuffer.UV6Kind
  25430. * - VertexBuffer.ColorKind
  25431. * - VertexBuffer.MatricesIndicesKind
  25432. * - VertexBuffer.MatricesIndicesExtraKind
  25433. * - VertexBuffer.MatricesWeightsKind
  25434. * - VertexBuffer.MatricesWeightsExtraKind
  25435. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25436. */
  25437. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25438. /**
  25439. * Sets the mesh global Vertex Buffer
  25440. * @param buffer defines the buffer to use
  25441. * @returns the current mesh
  25442. */
  25443. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25444. /**
  25445. * Update a specific associated vertex buffer
  25446. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25447. * - VertexBuffer.PositionKind
  25448. * - VertexBuffer.UVKind
  25449. * - VertexBuffer.UV2Kind
  25450. * - VertexBuffer.UV3Kind
  25451. * - VertexBuffer.UV4Kind
  25452. * - VertexBuffer.UV5Kind
  25453. * - VertexBuffer.UV6Kind
  25454. * - VertexBuffer.ColorKind
  25455. * - VertexBuffer.MatricesIndicesKind
  25456. * - VertexBuffer.MatricesIndicesExtraKind
  25457. * - VertexBuffer.MatricesWeightsKind
  25458. * - VertexBuffer.MatricesWeightsExtraKind
  25459. * @param data defines the data source
  25460. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25461. * @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)
  25462. * @returns the current mesh
  25463. */
  25464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25465. /**
  25466. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25467. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25468. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25469. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25470. * @returns the current mesh
  25471. */
  25472. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25473. /**
  25474. * Creates a un-shared specific occurence of the geometry for the mesh.
  25475. * @returns the current mesh
  25476. */
  25477. makeGeometryUnique(): Mesh;
  25478. /**
  25479. * Set the index buffer of this mesh
  25480. * @param indices defines the source data
  25481. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25482. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25483. * @returns the current mesh
  25484. */
  25485. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25486. /**
  25487. * Update the current index buffer
  25488. * @param indices defines the source data
  25489. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25490. * @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)
  25491. * @returns the current mesh
  25492. */
  25493. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25494. /**
  25495. * Invert the geometry to move from a right handed system to a left handed one.
  25496. * @returns the current mesh
  25497. */
  25498. toLeftHanded(): Mesh;
  25499. /** @hidden */
  25500. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25501. /** @hidden */
  25502. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25503. /**
  25504. * Registers for this mesh a javascript function called just before the rendering process
  25505. * @param func defines the function to call before rendering this mesh
  25506. * @returns the current mesh
  25507. */
  25508. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25509. /**
  25510. * Disposes a previously registered javascript function called before the rendering
  25511. * @param func defines the function to remove
  25512. * @returns the current mesh
  25513. */
  25514. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25515. /**
  25516. * Registers for this mesh a javascript function called just after the rendering is complete
  25517. * @param func defines the function to call after rendering this mesh
  25518. * @returns the current mesh
  25519. */
  25520. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25521. /**
  25522. * Disposes a previously registered javascript function called after the rendering.
  25523. * @param func defines the function to remove
  25524. * @returns the current mesh
  25525. */
  25526. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25527. /** @hidden */
  25528. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25529. /** @hidden */
  25530. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25531. /** @hidden */
  25532. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25533. /** @hidden */
  25534. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25535. /** @hidden */
  25536. _rebuild(): void;
  25537. /** @hidden */
  25538. _freeze(): void;
  25539. /** @hidden */
  25540. _unFreeze(): void;
  25541. /**
  25542. * 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
  25543. * @param subMesh defines the subMesh to render
  25544. * @param enableAlphaMode defines if alpha mode can be changed
  25545. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25546. * @returns the current mesh
  25547. */
  25548. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25549. private _onBeforeDraw;
  25550. /**
  25551. * Renormalize the mesh and patch it up if there are no weights
  25552. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25553. * However in the case of zero weights then we set just a single influence to 1.
  25554. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25555. */
  25556. cleanMatrixWeights(): void;
  25557. private normalizeSkinFourWeights;
  25558. private normalizeSkinWeightsAndExtra;
  25559. /**
  25560. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25561. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25562. * the user know there was an issue with importing the mesh
  25563. * @returns a validation object with skinned, valid and report string
  25564. */
  25565. validateSkinning(): {
  25566. skinned: boolean;
  25567. valid: boolean;
  25568. report: string;
  25569. };
  25570. /** @hidden */
  25571. _checkDelayState(): Mesh;
  25572. private _queueLoad;
  25573. /**
  25574. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25575. * A mesh is in the frustum if its bounding box intersects the frustum
  25576. * @param frustumPlanes defines the frustum to test
  25577. * @returns true if the mesh is in the frustum planes
  25578. */
  25579. isInFrustum(frustumPlanes: Plane[]): boolean;
  25580. /**
  25581. * Sets the mesh material by the material or multiMaterial `id` property
  25582. * @param id is a string identifying the material or the multiMaterial
  25583. * @returns the current mesh
  25584. */
  25585. setMaterialByID(id: string): Mesh;
  25586. /**
  25587. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25588. * @returns an array of IAnimatable
  25589. */
  25590. getAnimatables(): IAnimatable[];
  25591. /**
  25592. * Modifies the mesh geometry according to the passed transformation matrix.
  25593. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25594. * The mesh normals are modified using the same transformation.
  25595. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25596. * @param transform defines the transform matrix to use
  25597. * @see http://doc.babylonjs.com/resources/baking_transformations
  25598. * @returns the current mesh
  25599. */
  25600. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25601. /**
  25602. * Modifies the mesh geometry according to its own current World Matrix.
  25603. * The mesh World Matrix is then reset.
  25604. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25605. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25606. * @see http://doc.babylonjs.com/resources/baking_transformations
  25607. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25608. * @returns the current mesh
  25609. */
  25610. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25611. /** @hidden */
  25612. get _positions(): Nullable<Vector3[]>;
  25613. /** @hidden */
  25614. _resetPointsArrayCache(): Mesh;
  25615. /** @hidden */
  25616. _generatePointsArray(): boolean;
  25617. /**
  25618. * Returns a new Mesh object generated from the current mesh properties.
  25619. * This method must not get confused with createInstance()
  25620. * @param name is a string, the name given to the new mesh
  25621. * @param newParent can be any Node object (default `null`)
  25622. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25623. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25624. * @returns a new mesh
  25625. */
  25626. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25627. /**
  25628. * Releases resources associated with this mesh.
  25629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25631. */
  25632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25633. /** @hidden */
  25634. _disposeInstanceSpecificData(): void;
  25635. /**
  25636. * Modifies the mesh geometry according to a displacement map.
  25637. * 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.
  25638. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25639. * @param url is a string, the URL from the image file is to be downloaded.
  25640. * @param minHeight is the lower limit of the displacement.
  25641. * @param maxHeight is the upper limit of the displacement.
  25642. * @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.
  25643. * @param uvOffset is an optional vector2 used to offset UV.
  25644. * @param uvScale is an optional vector2 used to scale UV.
  25645. * @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.
  25646. * @returns the Mesh.
  25647. */
  25648. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25649. /**
  25650. * Modifies the mesh geometry according to a displacementMap buffer.
  25651. * 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.
  25652. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25653. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25654. * @param heightMapWidth is the width of the buffer image.
  25655. * @param heightMapHeight is the height of the buffer image.
  25656. * @param minHeight is the lower limit of the displacement.
  25657. * @param maxHeight is the upper limit of the displacement.
  25658. * @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.
  25659. * @param uvOffset is an optional vector2 used to offset UV.
  25660. * @param uvScale is an optional vector2 used to scale UV.
  25661. * @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.
  25662. * @returns the Mesh.
  25663. */
  25664. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25665. /**
  25666. * Modify the mesh to get a flat shading rendering.
  25667. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25668. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25669. * @returns current mesh
  25670. */
  25671. convertToFlatShadedMesh(): Mesh;
  25672. /**
  25673. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25674. * In other words, more vertices, no more indices and a single bigger VBO.
  25675. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25676. * @returns current mesh
  25677. */
  25678. convertToUnIndexedMesh(): Mesh;
  25679. /**
  25680. * Inverses facet orientations.
  25681. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25682. * @param flipNormals will also inverts the normals
  25683. * @returns current mesh
  25684. */
  25685. flipFaces(flipNormals?: boolean): Mesh;
  25686. /**
  25687. * Increase the number of facets and hence vertices in a mesh
  25688. * Vertex normals are interpolated from existing vertex normals
  25689. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25690. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25691. */
  25692. increaseVertices(numberPerEdge: number): void;
  25693. /**
  25694. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25695. * This will undo any application of covertToFlatShadedMesh
  25696. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25697. */
  25698. forceSharedVertices(): void;
  25699. /** @hidden */
  25700. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25701. /** @hidden */
  25702. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25703. /**
  25704. * Creates a new InstancedMesh object from the mesh model.
  25705. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25706. * @param name defines the name of the new instance
  25707. * @returns a new InstancedMesh
  25708. */
  25709. createInstance(name: string): InstancedMesh;
  25710. /**
  25711. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25712. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25713. * @returns the current mesh
  25714. */
  25715. synchronizeInstances(): Mesh;
  25716. /**
  25717. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25718. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25719. * This should be used together with the simplification to avoid disappearing triangles.
  25720. * @param successCallback an optional success callback to be called after the optimization finished.
  25721. * @returns the current mesh
  25722. */
  25723. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25724. /**
  25725. * Serialize current mesh
  25726. * @param serializationObject defines the object which will receive the serialization data
  25727. */
  25728. serialize(serializationObject: any): void;
  25729. /** @hidden */
  25730. _syncGeometryWithMorphTargetManager(): void;
  25731. /** @hidden */
  25732. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25733. /**
  25734. * Returns a new Mesh object parsed from the source provided.
  25735. * @param parsedMesh is the source
  25736. * @param scene defines the hosting scene
  25737. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25738. * @returns a new Mesh
  25739. */
  25740. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25741. /**
  25742. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25744. * @param name defines the name of the mesh to create
  25745. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25746. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25747. * @param closePath creates a seam between the first and the last points of each path of the path array
  25748. * @param offset is taken in account only if the `pathArray` is containing a single path
  25749. * @param scene defines the hosting scene
  25750. * @param updatable defines if the mesh must be flagged as updatable
  25751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25752. * @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)
  25753. * @returns a new Mesh
  25754. */
  25755. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25756. /**
  25757. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25758. * @param name defines the name of the mesh to create
  25759. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25760. * @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
  25761. * @param scene defines the hosting scene
  25762. * @param updatable defines if the mesh must be flagged as updatable
  25763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25764. * @returns a new Mesh
  25765. */
  25766. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25767. /**
  25768. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25769. * @param name defines the name of the mesh to create
  25770. * @param size sets the size (float) of each box side (default 1)
  25771. * @param scene defines the hosting scene
  25772. * @param updatable defines if the mesh must be flagged as updatable
  25773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25774. * @returns a new Mesh
  25775. */
  25776. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25777. /**
  25778. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25779. * @param name defines the name of the mesh to create
  25780. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25781. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25782. * @param scene defines the hosting scene
  25783. * @param updatable defines if the mesh must be flagged as updatable
  25784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25785. * @returns a new Mesh
  25786. */
  25787. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25788. /**
  25789. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25790. * @param name defines the name of the mesh to create
  25791. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25792. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25793. * @param scene defines the hosting scene
  25794. * @returns a new Mesh
  25795. */
  25796. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25797. /**
  25798. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25799. * @param name defines the name of the mesh to create
  25800. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25801. * @param diameterTop set the top cap diameter (floats, default 1)
  25802. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25803. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25804. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25805. * @param scene defines the hosting scene
  25806. * @param updatable defines if the mesh must be flagged as updatable
  25807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25808. * @returns a new Mesh
  25809. */
  25810. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25811. /**
  25812. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25813. * @param name defines the name of the mesh to create
  25814. * @param diameter sets the diameter size (float) of the torus (default 1)
  25815. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25816. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25817. * @param scene defines the hosting scene
  25818. * @param updatable defines if the mesh must be flagged as updatable
  25819. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25820. * @returns a new Mesh
  25821. */
  25822. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25823. /**
  25824. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25825. * @param name defines the name of the mesh to create
  25826. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25827. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25828. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25829. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25830. * @param p the number of windings on X axis (positive integers, default 2)
  25831. * @param q the number of windings on Y axis (positive integers, default 3)
  25832. * @param scene defines the hosting scene
  25833. * @param updatable defines if the mesh must be flagged as updatable
  25834. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25835. * @returns a new Mesh
  25836. */
  25837. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25838. /**
  25839. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25840. * @param name defines the name of the mesh to create
  25841. * @param points is an array successive Vector3
  25842. * @param scene defines the hosting scene
  25843. * @param updatable defines if the mesh must be flagged as updatable
  25844. * @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).
  25845. * @returns a new Mesh
  25846. */
  25847. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25848. /**
  25849. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25850. * @param name defines the name of the mesh to create
  25851. * @param points is an array successive Vector3
  25852. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25853. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25854. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25855. * @param scene defines the hosting scene
  25856. * @param updatable defines if the mesh must be flagged as updatable
  25857. * @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)
  25858. * @returns a new Mesh
  25859. */
  25860. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25861. /**
  25862. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25863. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25864. * 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.
  25865. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25866. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25867. * Remember you can only change the shape positions, not their number when updating a polygon.
  25868. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25869. * @param name defines the name of the mesh to create
  25870. * @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
  25871. * @param scene defines the hosting scene
  25872. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25873. * @param updatable defines if the mesh must be flagged as updatable
  25874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25875. * @param earcutInjection can be used to inject your own earcut reference
  25876. * @returns a new Mesh
  25877. */
  25878. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25879. /**
  25880. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25881. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25882. * @param name defines the name of the mesh to create
  25883. * @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
  25884. * @param depth defines the height of extrusion
  25885. * @param scene defines the hosting scene
  25886. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25887. * @param updatable defines if the mesh must be flagged as updatable
  25888. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25889. * @param earcutInjection can be used to inject your own earcut reference
  25890. * @returns a new Mesh
  25891. */
  25892. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25893. /**
  25894. * Creates an extruded shape mesh.
  25895. * 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
  25896. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25897. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25898. * @param name defines the name of the mesh to create
  25899. * @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
  25900. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25901. * @param scale is the value to scale the shape
  25902. * @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
  25903. * @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
  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. * @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)
  25908. * @returns a new Mesh
  25909. */
  25910. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25911. /**
  25912. * Creates an custom extruded shape mesh.
  25913. * The custom extrusion is a parametric shape.
  25914. * It has no predefined shape. Its final shape will depend on the input parameters.
  25915. * Please consider using the same method from the MeshBuilder class instead
  25916. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25917. * @param name defines the name of the mesh to create
  25918. * @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
  25919. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25920. * @param scaleFunction is a custom Javascript function called on each path point
  25921. * @param rotationFunction is a custom Javascript function called on each path point
  25922. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25923. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25924. * @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
  25925. * @param scene defines the hosting scene
  25926. * @param updatable defines if the mesh must be flagged as updatable
  25927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25928. * @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)
  25929. * @returns a new Mesh
  25930. */
  25931. 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;
  25932. /**
  25933. * Creates lathe mesh.
  25934. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25935. * Please consider using the same method from the MeshBuilder class instead
  25936. * @param name defines the name of the mesh to create
  25937. * @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
  25938. * @param radius is the radius value of the lathe
  25939. * @param tessellation is the side number of the lathe.
  25940. * @param scene defines the hosting scene
  25941. * @param updatable defines if the mesh must be flagged as updatable
  25942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25943. * @returns a new Mesh
  25944. */
  25945. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25946. /**
  25947. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25948. * @param name defines the name of the mesh to create
  25949. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25950. * @param scene defines the hosting scene
  25951. * @param updatable defines if the mesh must be flagged as updatable
  25952. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25953. * @returns a new Mesh
  25954. */
  25955. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25956. /**
  25957. * Creates a ground mesh.
  25958. * Please consider using the same method from the MeshBuilder class instead
  25959. * @param name defines the name of the mesh to create
  25960. * @param width set the width of the ground
  25961. * @param height set the height of the ground
  25962. * @param subdivisions sets the number of subdivisions per side
  25963. * @param scene defines the hosting scene
  25964. * @param updatable defines if the mesh must be flagged as updatable
  25965. * @returns a new Mesh
  25966. */
  25967. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25968. /**
  25969. * Creates a tiled ground mesh.
  25970. * Please consider using the same method from the MeshBuilder class instead
  25971. * @param name defines the name of the mesh to create
  25972. * @param xmin set the ground minimum X coordinate
  25973. * @param zmin set the ground minimum Y coordinate
  25974. * @param xmax set the ground maximum X coordinate
  25975. * @param zmax set the ground maximum Z coordinate
  25976. * @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
  25977. * @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
  25978. * @param scene defines the hosting scene
  25979. * @param updatable defines if the mesh must be flagged as updatable
  25980. * @returns a new Mesh
  25981. */
  25982. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25983. w: number;
  25984. h: number;
  25985. }, precision: {
  25986. w: number;
  25987. h: number;
  25988. }, scene: Scene, updatable?: boolean): Mesh;
  25989. /**
  25990. * Creates a ground mesh from a height map.
  25991. * Please consider using the same method from the MeshBuilder class instead
  25992. * @see http://doc.babylonjs.com/babylon101/height_map
  25993. * @param name defines the name of the mesh to create
  25994. * @param url sets the URL of the height map image resource
  25995. * @param width set the ground width size
  25996. * @param height set the ground height size
  25997. * @param subdivisions sets the number of subdivision per side
  25998. * @param minHeight is the minimum altitude on the ground
  25999. * @param maxHeight is the maximum altitude on the ground
  26000. * @param scene defines the hosting scene
  26001. * @param updatable defines if the mesh must be flagged as updatable
  26002. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26003. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26004. * @returns a new Mesh
  26005. */
  26006. 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;
  26007. /**
  26008. * Creates a tube mesh.
  26009. * The tube is a parametric shape.
  26010. * It has no predefined shape. Its final shape will depend on the input parameters.
  26011. * Please consider using the same method from the MeshBuilder class instead
  26012. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26013. * @param name defines the name of the mesh to create
  26014. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26015. * @param radius sets the tube radius size
  26016. * @param tessellation is the number of sides on the tubular surface
  26017. * @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
  26018. * @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
  26019. * @param scene defines the hosting scene
  26020. * @param updatable defines if the mesh must be flagged as updatable
  26021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26022. * @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)
  26023. * @returns a new Mesh
  26024. */
  26025. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26026. (i: number, distance: number): number;
  26027. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26028. /**
  26029. * Creates a polyhedron mesh.
  26030. * Please consider using the same method from the MeshBuilder class instead.
  26031. * * 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
  26032. * * The parameter `size` (positive float, default 1) sets the polygon size
  26033. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26034. * * 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`
  26035. * * 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
  26036. * * 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)`)
  26037. * * 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
  26038. * * 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
  26039. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26040. * * If you create a double-sided mesh, you can choose what parts of 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
  26041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26042. * @param name defines the name of the mesh to create
  26043. * @param options defines the options used to create the mesh
  26044. * @param scene defines the hosting scene
  26045. * @returns a new Mesh
  26046. */
  26047. static CreatePolyhedron(name: string, options: {
  26048. type?: number;
  26049. size?: number;
  26050. sizeX?: number;
  26051. sizeY?: number;
  26052. sizeZ?: number;
  26053. custom?: any;
  26054. faceUV?: Vector4[];
  26055. faceColors?: Color4[];
  26056. updatable?: boolean;
  26057. sideOrientation?: number;
  26058. }, scene: Scene): Mesh;
  26059. /**
  26060. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26061. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26062. * * 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`)
  26063. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26064. * * 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
  26065. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26066. * * If you create a double-sided mesh, you can choose what parts of 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
  26067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26068. * @param name defines the name of the mesh
  26069. * @param options defines the options used to create the mesh
  26070. * @param scene defines the hosting scene
  26071. * @returns a new Mesh
  26072. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26073. */
  26074. static CreateIcoSphere(name: string, options: {
  26075. radius?: number;
  26076. flat?: boolean;
  26077. subdivisions?: number;
  26078. sideOrientation?: number;
  26079. updatable?: boolean;
  26080. }, scene: Scene): Mesh;
  26081. /**
  26082. * Creates a decal mesh.
  26083. * Please consider using the same method from the MeshBuilder class instead.
  26084. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26085. * @param name defines the name of the mesh
  26086. * @param sourceMesh defines the mesh receiving the decal
  26087. * @param position sets the position of the decal in world coordinates
  26088. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26089. * @param size sets the decal scaling
  26090. * @param angle sets the angle to rotate the decal
  26091. * @returns a new Mesh
  26092. */
  26093. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26094. /**
  26095. * Prepare internal position array for software CPU skinning
  26096. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26097. */
  26098. setPositionsForCPUSkinning(): Float32Array;
  26099. /**
  26100. * Prepare internal normal array for software CPU skinning
  26101. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26102. */
  26103. setNormalsForCPUSkinning(): Float32Array;
  26104. /**
  26105. * Updates the vertex buffer by applying transformation from the bones
  26106. * @param skeleton defines the skeleton to apply to current mesh
  26107. * @returns the current mesh
  26108. */
  26109. applySkeleton(skeleton: Skeleton): Mesh;
  26110. /**
  26111. * 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
  26112. * @param meshes defines the list of meshes to scan
  26113. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26114. */
  26115. static MinMax(meshes: AbstractMesh[]): {
  26116. min: Vector3;
  26117. max: Vector3;
  26118. };
  26119. /**
  26120. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26121. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26122. * @returns a vector3
  26123. */
  26124. static Center(meshesOrMinMaxVector: {
  26125. min: Vector3;
  26126. max: Vector3;
  26127. } | AbstractMesh[]): Vector3;
  26128. /**
  26129. * Merge the array of meshes into a single mesh for performance reasons.
  26130. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26131. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26132. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26133. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26134. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26135. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26136. * @returns a new mesh
  26137. */
  26138. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26139. /** @hidden */
  26140. addInstance(instance: InstancedMesh): void;
  26141. /** @hidden */
  26142. removeInstance(instance: InstancedMesh): void;
  26143. }
  26144. }
  26145. declare module "babylonjs/Cameras/camera" {
  26146. import { SmartArray } from "babylonjs/Misc/smartArray";
  26147. import { Observable } from "babylonjs/Misc/observable";
  26148. import { Nullable } from "babylonjs/types";
  26149. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26150. import { Scene } from "babylonjs/scene";
  26151. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26152. import { Node } from "babylonjs/node";
  26153. import { Mesh } from "babylonjs/Meshes/mesh";
  26154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26155. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26156. import { Viewport } from "babylonjs/Maths/math.viewport";
  26157. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26158. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26159. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26160. import { Ray } from "babylonjs/Culling/ray";
  26161. /**
  26162. * This is the base class of all the camera used in the application.
  26163. * @see http://doc.babylonjs.com/features/cameras
  26164. */
  26165. export class Camera extends Node {
  26166. /** @hidden */
  26167. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26168. /**
  26169. * This is the default projection mode used by the cameras.
  26170. * It helps recreating a feeling of perspective and better appreciate depth.
  26171. * This is the best way to simulate real life cameras.
  26172. */
  26173. static readonly PERSPECTIVE_CAMERA: number;
  26174. /**
  26175. * This helps creating camera with an orthographic mode.
  26176. * 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.
  26177. */
  26178. static readonly ORTHOGRAPHIC_CAMERA: number;
  26179. /**
  26180. * This is the default FOV mode for perspective cameras.
  26181. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26182. */
  26183. static readonly FOVMODE_VERTICAL_FIXED: number;
  26184. /**
  26185. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26186. */
  26187. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26188. /**
  26189. * This specifies ther is no need for a camera rig.
  26190. * Basically only one eye is rendered corresponding to the camera.
  26191. */
  26192. static readonly RIG_MODE_NONE: number;
  26193. /**
  26194. * Simulates a camera Rig with one blue eye and one red eye.
  26195. * This can be use with 3d blue and red glasses.
  26196. */
  26197. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26198. /**
  26199. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26200. */
  26201. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26202. /**
  26203. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26204. */
  26205. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26206. /**
  26207. * Defines that both eyes of the camera will be rendered over under each other.
  26208. */
  26209. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26210. /**
  26211. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26212. */
  26213. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26214. /**
  26215. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26216. */
  26217. static readonly RIG_MODE_VR: number;
  26218. /**
  26219. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26220. */
  26221. static readonly RIG_MODE_WEBVR: number;
  26222. /**
  26223. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26224. */
  26225. static readonly RIG_MODE_CUSTOM: number;
  26226. /**
  26227. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26228. */
  26229. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26230. /**
  26231. * Define the input manager associated with the camera.
  26232. */
  26233. inputs: CameraInputsManager<Camera>;
  26234. /** @hidden */
  26235. _position: Vector3;
  26236. /**
  26237. * Define the current local position of the camera in the scene
  26238. */
  26239. get position(): Vector3;
  26240. set position(newPosition: Vector3);
  26241. /**
  26242. * The vector the camera should consider as up.
  26243. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26244. */
  26245. upVector: Vector3;
  26246. /**
  26247. * Define the current limit on the left side for an orthographic camera
  26248. * In scene unit
  26249. */
  26250. orthoLeft: Nullable<number>;
  26251. /**
  26252. * Define the current limit on the right side for an orthographic camera
  26253. * In scene unit
  26254. */
  26255. orthoRight: Nullable<number>;
  26256. /**
  26257. * Define the current limit on the bottom side for an orthographic camera
  26258. * In scene unit
  26259. */
  26260. orthoBottom: Nullable<number>;
  26261. /**
  26262. * Define the current limit on the top side for an orthographic camera
  26263. * In scene unit
  26264. */
  26265. orthoTop: Nullable<number>;
  26266. /**
  26267. * Field Of View is set in Radians. (default is 0.8)
  26268. */
  26269. fov: number;
  26270. /**
  26271. * Define the minimum distance the camera can see from.
  26272. * This is important to note that the depth buffer are not infinite and the closer it starts
  26273. * the more your scene might encounter depth fighting issue.
  26274. */
  26275. minZ: number;
  26276. /**
  26277. * Define the maximum distance the camera can see to.
  26278. * This is important to note that the depth buffer are not infinite and the further it end
  26279. * the more your scene might encounter depth fighting issue.
  26280. */
  26281. maxZ: number;
  26282. /**
  26283. * Define the default inertia of the camera.
  26284. * This helps giving a smooth feeling to the camera movement.
  26285. */
  26286. inertia: number;
  26287. /**
  26288. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26289. */
  26290. mode: number;
  26291. /**
  26292. * Define whether the camera is intermediate.
  26293. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26294. */
  26295. isIntermediate: boolean;
  26296. /**
  26297. * Define the viewport of the camera.
  26298. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26299. */
  26300. viewport: Viewport;
  26301. /**
  26302. * Restricts the camera to viewing objects with the same layerMask.
  26303. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26304. */
  26305. layerMask: number;
  26306. /**
  26307. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26308. */
  26309. fovMode: number;
  26310. /**
  26311. * Rig mode of the camera.
  26312. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26313. * This is normally controlled byt the camera themselves as internal use.
  26314. */
  26315. cameraRigMode: number;
  26316. /**
  26317. * Defines the distance between both "eyes" in case of a RIG
  26318. */
  26319. interaxialDistance: number;
  26320. /**
  26321. * Defines if stereoscopic rendering is done side by side or over under.
  26322. */
  26323. isStereoscopicSideBySide: boolean;
  26324. /**
  26325. * 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
  26326. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26327. * else in the scene. (Eg. security camera)
  26328. *
  26329. * 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)
  26330. */
  26331. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26332. /**
  26333. * When set, the camera will render to this render target instead of the default canvas
  26334. *
  26335. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26336. */
  26337. outputRenderTarget: Nullable<RenderTargetTexture>;
  26338. /**
  26339. * Observable triggered when the camera view matrix has changed.
  26340. */
  26341. onViewMatrixChangedObservable: Observable<Camera>;
  26342. /**
  26343. * Observable triggered when the camera Projection matrix has changed.
  26344. */
  26345. onProjectionMatrixChangedObservable: Observable<Camera>;
  26346. /**
  26347. * Observable triggered when the inputs have been processed.
  26348. */
  26349. onAfterCheckInputsObservable: Observable<Camera>;
  26350. /**
  26351. * Observable triggered when reset has been called and applied to the camera.
  26352. */
  26353. onRestoreStateObservable: Observable<Camera>;
  26354. /**
  26355. * Is this camera a part of a rig system?
  26356. */
  26357. isRigCamera: boolean;
  26358. /**
  26359. * If isRigCamera set to true this will be set with the parent camera.
  26360. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26361. */
  26362. rigParent?: Camera;
  26363. /** @hidden */
  26364. _cameraRigParams: any;
  26365. /** @hidden */
  26366. _rigCameras: Camera[];
  26367. /** @hidden */
  26368. _rigPostProcess: Nullable<PostProcess>;
  26369. protected _webvrViewMatrix: Matrix;
  26370. /** @hidden */
  26371. _skipRendering: boolean;
  26372. /** @hidden */
  26373. _projectionMatrix: Matrix;
  26374. /** @hidden */
  26375. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26376. /** @hidden */
  26377. _activeMeshes: SmartArray<AbstractMesh>;
  26378. protected _globalPosition: Vector3;
  26379. /** @hidden */
  26380. _computedViewMatrix: Matrix;
  26381. private _doNotComputeProjectionMatrix;
  26382. private _transformMatrix;
  26383. private _frustumPlanes;
  26384. private _refreshFrustumPlanes;
  26385. private _storedFov;
  26386. private _stateStored;
  26387. /**
  26388. * Instantiates a new camera object.
  26389. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26390. * @see http://doc.babylonjs.com/features/cameras
  26391. * @param name Defines the name of the camera in the scene
  26392. * @param position Defines the position of the camera
  26393. * @param scene Defines the scene the camera belongs too
  26394. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26395. */
  26396. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26397. /**
  26398. * Store current camera state (fov, position, etc..)
  26399. * @returns the camera
  26400. */
  26401. storeState(): Camera;
  26402. /**
  26403. * Restores the camera state values if it has been stored. You must call storeState() first
  26404. */
  26405. protected _restoreStateValues(): boolean;
  26406. /**
  26407. * Restored camera state. You must call storeState() first.
  26408. * @returns true if restored and false otherwise
  26409. */
  26410. restoreState(): boolean;
  26411. /**
  26412. * Gets the class name of the camera.
  26413. * @returns the class name
  26414. */
  26415. getClassName(): string;
  26416. /** @hidden */
  26417. readonly _isCamera: boolean;
  26418. /**
  26419. * Gets a string representation of the camera useful for debug purpose.
  26420. * @param fullDetails Defines that a more verboe level of logging is required
  26421. * @returns the string representation
  26422. */
  26423. toString(fullDetails?: boolean): string;
  26424. /**
  26425. * Gets the current world space position of the camera.
  26426. */
  26427. get globalPosition(): Vector3;
  26428. /**
  26429. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26430. * @returns the active meshe list
  26431. */
  26432. getActiveMeshes(): SmartArray<AbstractMesh>;
  26433. /**
  26434. * Check whether a mesh is part of the current active mesh list of the camera
  26435. * @param mesh Defines the mesh to check
  26436. * @returns true if active, false otherwise
  26437. */
  26438. isActiveMesh(mesh: Mesh): boolean;
  26439. /**
  26440. * Is this camera ready to be used/rendered
  26441. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26442. * @return true if the camera is ready
  26443. */
  26444. isReady(completeCheck?: boolean): boolean;
  26445. /** @hidden */
  26446. _initCache(): void;
  26447. /** @hidden */
  26448. _updateCache(ignoreParentClass?: boolean): void;
  26449. /** @hidden */
  26450. _isSynchronized(): boolean;
  26451. /** @hidden */
  26452. _isSynchronizedViewMatrix(): boolean;
  26453. /** @hidden */
  26454. _isSynchronizedProjectionMatrix(): boolean;
  26455. /**
  26456. * Attach the input controls to a specific dom element to get the input from.
  26457. * @param element Defines the element the controls should be listened from
  26458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26459. */
  26460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26461. /**
  26462. * Detach the current controls from the specified dom element.
  26463. * @param element Defines the element to stop listening the inputs from
  26464. */
  26465. detachControl(element: HTMLElement): void;
  26466. /**
  26467. * Update the camera state according to the different inputs gathered during the frame.
  26468. */
  26469. update(): void;
  26470. /** @hidden */
  26471. _checkInputs(): void;
  26472. /** @hidden */
  26473. get rigCameras(): Camera[];
  26474. /**
  26475. * Gets the post process used by the rig cameras
  26476. */
  26477. get rigPostProcess(): Nullable<PostProcess>;
  26478. /**
  26479. * Internal, gets the first post proces.
  26480. * @returns the first post process to be run on this camera.
  26481. */
  26482. _getFirstPostProcess(): Nullable<PostProcess>;
  26483. private _cascadePostProcessesToRigCams;
  26484. /**
  26485. * Attach a post process to the camera.
  26486. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26487. * @param postProcess The post process to attach to the camera
  26488. * @param insertAt The position of the post process in case several of them are in use in the scene
  26489. * @returns the position the post process has been inserted at
  26490. */
  26491. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26492. /**
  26493. * Detach a post process to the camera.
  26494. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26495. * @param postProcess The post process to detach from the camera
  26496. */
  26497. detachPostProcess(postProcess: PostProcess): void;
  26498. /**
  26499. * Gets the current world matrix of the camera
  26500. */
  26501. getWorldMatrix(): Matrix;
  26502. /** @hidden */
  26503. _getViewMatrix(): Matrix;
  26504. /**
  26505. * Gets the current view matrix of the camera.
  26506. * @param force forces the camera to recompute the matrix without looking at the cached state
  26507. * @returns the view matrix
  26508. */
  26509. getViewMatrix(force?: boolean): Matrix;
  26510. /**
  26511. * Freeze the projection matrix.
  26512. * It will prevent the cache check of the camera projection compute and can speed up perf
  26513. * if no parameter of the camera are meant to change
  26514. * @param projection Defines manually a projection if necessary
  26515. */
  26516. freezeProjectionMatrix(projection?: Matrix): void;
  26517. /**
  26518. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26519. */
  26520. unfreezeProjectionMatrix(): void;
  26521. /**
  26522. * Gets the current projection matrix of the camera.
  26523. * @param force forces the camera to recompute the matrix without looking at the cached state
  26524. * @returns the projection matrix
  26525. */
  26526. getProjectionMatrix(force?: boolean): Matrix;
  26527. /**
  26528. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26529. * @returns a Matrix
  26530. */
  26531. getTransformationMatrix(): Matrix;
  26532. private _updateFrustumPlanes;
  26533. /**
  26534. * Checks if a cullable object (mesh...) is in the camera frustum
  26535. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26536. * @param target The object to check
  26537. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26538. * @returns true if the object is in frustum otherwise false
  26539. */
  26540. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26541. /**
  26542. * Checks if a cullable object (mesh...) is in the camera frustum
  26543. * Unlike isInFrustum this cheks the full bounding box
  26544. * @param target The object to check
  26545. * @returns true if the object is in frustum otherwise false
  26546. */
  26547. isCompletelyInFrustum(target: ICullable): boolean;
  26548. /**
  26549. * Gets a ray in the forward direction from the camera.
  26550. * @param length Defines the length of the ray to create
  26551. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26552. * @param origin Defines the start point of the ray which defaults to the camera position
  26553. * @returns the forward ray
  26554. */
  26555. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26556. /**
  26557. * Releases resources associated with this node.
  26558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26560. */
  26561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26562. /** @hidden */
  26563. _isLeftCamera: boolean;
  26564. /**
  26565. * Gets the left camera of a rig setup in case of Rigged Camera
  26566. */
  26567. get isLeftCamera(): boolean;
  26568. /** @hidden */
  26569. _isRightCamera: boolean;
  26570. /**
  26571. * Gets the right camera of a rig setup in case of Rigged Camera
  26572. */
  26573. get isRightCamera(): boolean;
  26574. /**
  26575. * Gets the left camera of a rig setup in case of Rigged Camera
  26576. */
  26577. get leftCamera(): Nullable<FreeCamera>;
  26578. /**
  26579. * Gets the right camera of a rig setup in case of Rigged Camera
  26580. */
  26581. get rightCamera(): Nullable<FreeCamera>;
  26582. /**
  26583. * Gets the left camera target of a rig setup in case of Rigged Camera
  26584. * @returns the target position
  26585. */
  26586. getLeftTarget(): Nullable<Vector3>;
  26587. /**
  26588. * Gets the right camera target of a rig setup in case of Rigged Camera
  26589. * @returns the target position
  26590. */
  26591. getRightTarget(): Nullable<Vector3>;
  26592. /**
  26593. * @hidden
  26594. */
  26595. setCameraRigMode(mode: number, rigParams: any): void;
  26596. /** @hidden */
  26597. static _setStereoscopicRigMode(camera: Camera): void;
  26598. /** @hidden */
  26599. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26600. /** @hidden */
  26601. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26602. /** @hidden */
  26603. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26604. /** @hidden */
  26605. _getVRProjectionMatrix(): Matrix;
  26606. protected _updateCameraRotationMatrix(): void;
  26607. protected _updateWebVRCameraRotationMatrix(): void;
  26608. /**
  26609. * This function MUST be overwritten by the different WebVR cameras available.
  26610. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26611. * @hidden
  26612. */
  26613. _getWebVRProjectionMatrix(): Matrix;
  26614. /**
  26615. * This function MUST be overwritten by the different WebVR cameras available.
  26616. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26617. * @hidden
  26618. */
  26619. _getWebVRViewMatrix(): Matrix;
  26620. /** @hidden */
  26621. setCameraRigParameter(name: string, value: any): void;
  26622. /**
  26623. * needs to be overridden by children so sub has required properties to be copied
  26624. * @hidden
  26625. */
  26626. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26627. /**
  26628. * May need to be overridden by children
  26629. * @hidden
  26630. */
  26631. _updateRigCameras(): void;
  26632. /** @hidden */
  26633. _setupInputs(): void;
  26634. /**
  26635. * Serialiaze the camera setup to a json represention
  26636. * @returns the JSON representation
  26637. */
  26638. serialize(): any;
  26639. /**
  26640. * Clones the current camera.
  26641. * @param name The cloned camera name
  26642. * @returns the cloned camera
  26643. */
  26644. clone(name: string): Camera;
  26645. /**
  26646. * Gets the direction of the camera relative to a given local axis.
  26647. * @param localAxis Defines the reference axis to provide a relative direction.
  26648. * @return the direction
  26649. */
  26650. getDirection(localAxis: Vector3): Vector3;
  26651. /**
  26652. * Returns the current camera absolute rotation
  26653. */
  26654. get absoluteRotation(): Quaternion;
  26655. /**
  26656. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26657. * @param localAxis Defines the reference axis to provide a relative direction.
  26658. * @param result Defines the vector to store the result in
  26659. */
  26660. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26661. /**
  26662. * Gets a camera constructor for a given camera type
  26663. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26664. * @param name The name of the camera the result will be able to instantiate
  26665. * @param scene The scene the result will construct the camera in
  26666. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26667. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26668. * @returns a factory method to construc the camera
  26669. */
  26670. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26671. /**
  26672. * Compute the world matrix of the camera.
  26673. * @returns the camera world matrix
  26674. */
  26675. computeWorldMatrix(): Matrix;
  26676. /**
  26677. * Parse a JSON and creates the camera from the parsed information
  26678. * @param parsedCamera The JSON to parse
  26679. * @param scene The scene to instantiate the camera in
  26680. * @returns the newly constructed camera
  26681. */
  26682. static Parse(parsedCamera: any, scene: Scene): Camera;
  26683. }
  26684. }
  26685. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26686. import { Nullable } from "babylonjs/types";
  26687. import { Scene } from "babylonjs/scene";
  26688. import { Vector4 } from "babylonjs/Maths/math.vector";
  26689. import { Mesh } from "babylonjs/Meshes/mesh";
  26690. /**
  26691. * Class containing static functions to help procedurally build meshes
  26692. */
  26693. export class DiscBuilder {
  26694. /**
  26695. * Creates a plane polygonal mesh. By default, this is a disc
  26696. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26697. * * 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
  26698. * * 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
  26699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26702. * @param name defines the name of the mesh
  26703. * @param options defines the options used to create the mesh
  26704. * @param scene defines the hosting scene
  26705. * @returns the plane polygonal mesh
  26706. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26707. */
  26708. static CreateDisc(name: string, options: {
  26709. radius?: number;
  26710. tessellation?: number;
  26711. arc?: number;
  26712. updatable?: boolean;
  26713. sideOrientation?: number;
  26714. frontUVs?: Vector4;
  26715. backUVs?: Vector4;
  26716. }, scene?: Nullable<Scene>): Mesh;
  26717. }
  26718. }
  26719. declare module "babylonjs/Materials/fresnelParameters" {
  26720. import { Color3 } from "babylonjs/Maths/math.color";
  26721. /**
  26722. * This represents all the required information to add a fresnel effect on a material:
  26723. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26724. */
  26725. export class FresnelParameters {
  26726. private _isEnabled;
  26727. /**
  26728. * Define if the fresnel effect is enable or not.
  26729. */
  26730. get isEnabled(): boolean;
  26731. set isEnabled(value: boolean);
  26732. /**
  26733. * Define the color used on edges (grazing angle)
  26734. */
  26735. leftColor: Color3;
  26736. /**
  26737. * Define the color used on center
  26738. */
  26739. rightColor: Color3;
  26740. /**
  26741. * Define bias applied to computed fresnel term
  26742. */
  26743. bias: number;
  26744. /**
  26745. * Defined the power exponent applied to fresnel term
  26746. */
  26747. power: number;
  26748. /**
  26749. * Clones the current fresnel and its valuues
  26750. * @returns a clone fresnel configuration
  26751. */
  26752. clone(): FresnelParameters;
  26753. /**
  26754. * Serializes the current fresnel parameters to a JSON representation.
  26755. * @return the JSON serialization
  26756. */
  26757. serialize(): any;
  26758. /**
  26759. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26760. * @param parsedFresnelParameters Define the JSON representation
  26761. * @returns the parsed parameters
  26762. */
  26763. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26764. }
  26765. }
  26766. declare module "babylonjs/Materials/pushMaterial" {
  26767. import { Nullable } from "babylonjs/types";
  26768. import { Scene } from "babylonjs/scene";
  26769. import { Matrix } from "babylonjs/Maths/math.vector";
  26770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26771. import { Mesh } from "babylonjs/Meshes/mesh";
  26772. import { Material } from "babylonjs/Materials/material";
  26773. import { Effect } from "babylonjs/Materials/effect";
  26774. /**
  26775. * Base class of materials working in push mode in babylon JS
  26776. * @hidden
  26777. */
  26778. export class PushMaterial extends Material {
  26779. protected _activeEffect: Effect;
  26780. protected _normalMatrix: Matrix;
  26781. /**
  26782. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26783. * This means that the material can keep using a previous shader while a new one is being compiled.
  26784. * This is mostly used when shader parallel compilation is supported (true by default)
  26785. */
  26786. allowShaderHotSwapping: boolean;
  26787. constructor(name: string, scene: Scene);
  26788. getEffect(): Effect;
  26789. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26790. /**
  26791. * Binds the given world matrix to the active effect
  26792. *
  26793. * @param world the matrix to bind
  26794. */
  26795. bindOnlyWorldMatrix(world: Matrix): void;
  26796. /**
  26797. * Binds the given normal matrix to the active effect
  26798. *
  26799. * @param normalMatrix the matrix to bind
  26800. */
  26801. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26802. bind(world: Matrix, mesh?: Mesh): void;
  26803. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26804. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26805. }
  26806. }
  26807. declare module "babylonjs/Materials/materialFlags" {
  26808. /**
  26809. * This groups all the flags used to control the materials channel.
  26810. */
  26811. export class MaterialFlags {
  26812. private static _DiffuseTextureEnabled;
  26813. /**
  26814. * Are diffuse textures enabled in the application.
  26815. */
  26816. static get DiffuseTextureEnabled(): boolean;
  26817. static set DiffuseTextureEnabled(value: boolean);
  26818. private static _AmbientTextureEnabled;
  26819. /**
  26820. * Are ambient textures enabled in the application.
  26821. */
  26822. static get AmbientTextureEnabled(): boolean;
  26823. static set AmbientTextureEnabled(value: boolean);
  26824. private static _OpacityTextureEnabled;
  26825. /**
  26826. * Are opacity textures enabled in the application.
  26827. */
  26828. static get OpacityTextureEnabled(): boolean;
  26829. static set OpacityTextureEnabled(value: boolean);
  26830. private static _ReflectionTextureEnabled;
  26831. /**
  26832. * Are reflection textures enabled in the application.
  26833. */
  26834. static get ReflectionTextureEnabled(): boolean;
  26835. static set ReflectionTextureEnabled(value: boolean);
  26836. private static _EmissiveTextureEnabled;
  26837. /**
  26838. * Are emissive textures enabled in the application.
  26839. */
  26840. static get EmissiveTextureEnabled(): boolean;
  26841. static set EmissiveTextureEnabled(value: boolean);
  26842. private static _SpecularTextureEnabled;
  26843. /**
  26844. * Are specular textures enabled in the application.
  26845. */
  26846. static get SpecularTextureEnabled(): boolean;
  26847. static set SpecularTextureEnabled(value: boolean);
  26848. private static _BumpTextureEnabled;
  26849. /**
  26850. * Are bump textures enabled in the application.
  26851. */
  26852. static get BumpTextureEnabled(): boolean;
  26853. static set BumpTextureEnabled(value: boolean);
  26854. private static _LightmapTextureEnabled;
  26855. /**
  26856. * Are lightmap textures enabled in the application.
  26857. */
  26858. static get LightmapTextureEnabled(): boolean;
  26859. static set LightmapTextureEnabled(value: boolean);
  26860. private static _RefractionTextureEnabled;
  26861. /**
  26862. * Are refraction textures enabled in the application.
  26863. */
  26864. static get RefractionTextureEnabled(): boolean;
  26865. static set RefractionTextureEnabled(value: boolean);
  26866. private static _ColorGradingTextureEnabled;
  26867. /**
  26868. * Are color grading textures enabled in the application.
  26869. */
  26870. static get ColorGradingTextureEnabled(): boolean;
  26871. static set ColorGradingTextureEnabled(value: boolean);
  26872. private static _FresnelEnabled;
  26873. /**
  26874. * Are fresnels enabled in the application.
  26875. */
  26876. static get FresnelEnabled(): boolean;
  26877. static set FresnelEnabled(value: boolean);
  26878. private static _ClearCoatTextureEnabled;
  26879. /**
  26880. * Are clear coat textures enabled in the application.
  26881. */
  26882. static get ClearCoatTextureEnabled(): boolean;
  26883. static set ClearCoatTextureEnabled(value: boolean);
  26884. private static _ClearCoatBumpTextureEnabled;
  26885. /**
  26886. * Are clear coat bump textures enabled in the application.
  26887. */
  26888. static get ClearCoatBumpTextureEnabled(): boolean;
  26889. static set ClearCoatBumpTextureEnabled(value: boolean);
  26890. private static _ClearCoatTintTextureEnabled;
  26891. /**
  26892. * Are clear coat tint textures enabled in the application.
  26893. */
  26894. static get ClearCoatTintTextureEnabled(): boolean;
  26895. static set ClearCoatTintTextureEnabled(value: boolean);
  26896. private static _SheenTextureEnabled;
  26897. /**
  26898. * Are sheen textures enabled in the application.
  26899. */
  26900. static get SheenTextureEnabled(): boolean;
  26901. static set SheenTextureEnabled(value: boolean);
  26902. private static _AnisotropicTextureEnabled;
  26903. /**
  26904. * Are anisotropic textures enabled in the application.
  26905. */
  26906. static get AnisotropicTextureEnabled(): boolean;
  26907. static set AnisotropicTextureEnabled(value: boolean);
  26908. private static _ThicknessTextureEnabled;
  26909. /**
  26910. * Are thickness textures enabled in the application.
  26911. */
  26912. static get ThicknessTextureEnabled(): boolean;
  26913. static set ThicknessTextureEnabled(value: boolean);
  26914. }
  26915. }
  26916. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26917. /** @hidden */
  26918. export var defaultFragmentDeclaration: {
  26919. name: string;
  26920. shader: string;
  26921. };
  26922. }
  26923. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26924. /** @hidden */
  26925. export var defaultUboDeclaration: {
  26926. name: string;
  26927. shader: string;
  26928. };
  26929. }
  26930. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26931. /** @hidden */
  26932. export var lightFragmentDeclaration: {
  26933. name: string;
  26934. shader: string;
  26935. };
  26936. }
  26937. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26938. /** @hidden */
  26939. export var lightUboDeclaration: {
  26940. name: string;
  26941. shader: string;
  26942. };
  26943. }
  26944. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26945. /** @hidden */
  26946. export var lightsFragmentFunctions: {
  26947. name: string;
  26948. shader: string;
  26949. };
  26950. }
  26951. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26952. /** @hidden */
  26953. export var shadowsFragmentFunctions: {
  26954. name: string;
  26955. shader: string;
  26956. };
  26957. }
  26958. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26959. /** @hidden */
  26960. export var fresnelFunction: {
  26961. name: string;
  26962. shader: string;
  26963. };
  26964. }
  26965. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26966. /** @hidden */
  26967. export var reflectionFunction: {
  26968. name: string;
  26969. shader: string;
  26970. };
  26971. }
  26972. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26973. /** @hidden */
  26974. export var bumpFragmentFunctions: {
  26975. name: string;
  26976. shader: string;
  26977. };
  26978. }
  26979. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26980. /** @hidden */
  26981. export var logDepthDeclaration: {
  26982. name: string;
  26983. shader: string;
  26984. };
  26985. }
  26986. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26987. /** @hidden */
  26988. export var bumpFragment: {
  26989. name: string;
  26990. shader: string;
  26991. };
  26992. }
  26993. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26994. /** @hidden */
  26995. export var depthPrePass: {
  26996. name: string;
  26997. shader: string;
  26998. };
  26999. }
  27000. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27001. /** @hidden */
  27002. export var lightFragment: {
  27003. name: string;
  27004. shader: string;
  27005. };
  27006. }
  27007. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27008. /** @hidden */
  27009. export var logDepthFragment: {
  27010. name: string;
  27011. shader: string;
  27012. };
  27013. }
  27014. declare module "babylonjs/Shaders/default.fragment" {
  27015. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27016. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27017. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27018. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27019. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27020. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27021. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27022. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27023. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27024. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27025. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27026. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27027. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27028. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27029. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27030. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27031. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27032. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27033. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27034. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27035. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27036. /** @hidden */
  27037. export var defaultPixelShader: {
  27038. name: string;
  27039. shader: string;
  27040. };
  27041. }
  27042. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27043. /** @hidden */
  27044. export var defaultVertexDeclaration: {
  27045. name: string;
  27046. shader: string;
  27047. };
  27048. }
  27049. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27050. /** @hidden */
  27051. export var bumpVertexDeclaration: {
  27052. name: string;
  27053. shader: string;
  27054. };
  27055. }
  27056. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27057. /** @hidden */
  27058. export var bumpVertex: {
  27059. name: string;
  27060. shader: string;
  27061. };
  27062. }
  27063. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27064. /** @hidden */
  27065. export var fogVertex: {
  27066. name: string;
  27067. shader: string;
  27068. };
  27069. }
  27070. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27071. /** @hidden */
  27072. export var shadowsVertex: {
  27073. name: string;
  27074. shader: string;
  27075. };
  27076. }
  27077. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27078. /** @hidden */
  27079. export var pointCloudVertex: {
  27080. name: string;
  27081. shader: string;
  27082. };
  27083. }
  27084. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27085. /** @hidden */
  27086. export var logDepthVertex: {
  27087. name: string;
  27088. shader: string;
  27089. };
  27090. }
  27091. declare module "babylonjs/Shaders/default.vertex" {
  27092. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27093. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27094. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27095. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27096. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27097. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27099. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27100. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27101. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27102. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27103. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27104. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27105. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27106. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27107. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27108. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27109. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27110. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27111. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27112. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27113. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27114. /** @hidden */
  27115. export var defaultVertexShader: {
  27116. name: string;
  27117. shader: string;
  27118. };
  27119. }
  27120. declare module "babylonjs/Materials/standardMaterial" {
  27121. import { SmartArray } from "babylonjs/Misc/smartArray";
  27122. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27123. import { Nullable } from "babylonjs/types";
  27124. import { Scene } from "babylonjs/scene";
  27125. import { Matrix } from "babylonjs/Maths/math.vector";
  27126. import { Color3 } from "babylonjs/Maths/math.color";
  27127. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27129. import { Mesh } from "babylonjs/Meshes/mesh";
  27130. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27131. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27132. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27133. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27134. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27135. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27137. import "babylonjs/Shaders/default.fragment";
  27138. import "babylonjs/Shaders/default.vertex";
  27139. /** @hidden */
  27140. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27141. MAINUV1: boolean;
  27142. MAINUV2: boolean;
  27143. DIFFUSE: boolean;
  27144. DIFFUSEDIRECTUV: number;
  27145. AMBIENT: boolean;
  27146. AMBIENTDIRECTUV: number;
  27147. OPACITY: boolean;
  27148. OPACITYDIRECTUV: number;
  27149. OPACITYRGB: boolean;
  27150. REFLECTION: boolean;
  27151. EMISSIVE: boolean;
  27152. EMISSIVEDIRECTUV: number;
  27153. SPECULAR: boolean;
  27154. SPECULARDIRECTUV: number;
  27155. BUMP: boolean;
  27156. BUMPDIRECTUV: number;
  27157. PARALLAX: boolean;
  27158. PARALLAXOCCLUSION: boolean;
  27159. SPECULAROVERALPHA: boolean;
  27160. CLIPPLANE: boolean;
  27161. CLIPPLANE2: boolean;
  27162. CLIPPLANE3: boolean;
  27163. CLIPPLANE4: boolean;
  27164. CLIPPLANE5: boolean;
  27165. CLIPPLANE6: boolean;
  27166. ALPHATEST: boolean;
  27167. DEPTHPREPASS: boolean;
  27168. ALPHAFROMDIFFUSE: boolean;
  27169. POINTSIZE: boolean;
  27170. FOG: boolean;
  27171. SPECULARTERM: boolean;
  27172. DIFFUSEFRESNEL: boolean;
  27173. OPACITYFRESNEL: boolean;
  27174. REFLECTIONFRESNEL: boolean;
  27175. REFRACTIONFRESNEL: boolean;
  27176. EMISSIVEFRESNEL: boolean;
  27177. FRESNEL: boolean;
  27178. NORMAL: boolean;
  27179. UV1: boolean;
  27180. UV2: boolean;
  27181. VERTEXCOLOR: boolean;
  27182. VERTEXALPHA: boolean;
  27183. NUM_BONE_INFLUENCERS: number;
  27184. BonesPerMesh: number;
  27185. BONETEXTURE: boolean;
  27186. INSTANCES: boolean;
  27187. GLOSSINESS: boolean;
  27188. ROUGHNESS: boolean;
  27189. EMISSIVEASILLUMINATION: boolean;
  27190. LINKEMISSIVEWITHDIFFUSE: boolean;
  27191. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27192. LIGHTMAP: boolean;
  27193. LIGHTMAPDIRECTUV: number;
  27194. OBJECTSPACE_NORMALMAP: boolean;
  27195. USELIGHTMAPASSHADOWMAP: boolean;
  27196. REFLECTIONMAP_3D: boolean;
  27197. REFLECTIONMAP_SPHERICAL: boolean;
  27198. REFLECTIONMAP_PLANAR: boolean;
  27199. REFLECTIONMAP_CUBIC: boolean;
  27200. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27201. REFLECTIONMAP_PROJECTION: boolean;
  27202. REFLECTIONMAP_SKYBOX: boolean;
  27203. REFLECTIONMAP_EXPLICIT: boolean;
  27204. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27205. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27206. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27207. INVERTCUBICMAP: boolean;
  27208. LOGARITHMICDEPTH: boolean;
  27209. REFRACTION: boolean;
  27210. REFRACTIONMAP_3D: boolean;
  27211. REFLECTIONOVERALPHA: boolean;
  27212. TWOSIDEDLIGHTING: boolean;
  27213. SHADOWFLOAT: boolean;
  27214. MORPHTARGETS: boolean;
  27215. MORPHTARGETS_NORMAL: boolean;
  27216. MORPHTARGETS_TANGENT: boolean;
  27217. MORPHTARGETS_UV: boolean;
  27218. NUM_MORPH_INFLUENCERS: number;
  27219. NONUNIFORMSCALING: boolean;
  27220. PREMULTIPLYALPHA: boolean;
  27221. IMAGEPROCESSING: boolean;
  27222. VIGNETTE: boolean;
  27223. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27224. VIGNETTEBLENDMODEOPAQUE: boolean;
  27225. TONEMAPPING: boolean;
  27226. TONEMAPPING_ACES: boolean;
  27227. CONTRAST: boolean;
  27228. COLORCURVES: boolean;
  27229. COLORGRADING: boolean;
  27230. COLORGRADING3D: boolean;
  27231. SAMPLER3DGREENDEPTH: boolean;
  27232. SAMPLER3DBGRMAP: boolean;
  27233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27234. MULTIVIEW: boolean;
  27235. /**
  27236. * If the reflection texture on this material is in linear color space
  27237. * @hidden
  27238. */
  27239. IS_REFLECTION_LINEAR: boolean;
  27240. /**
  27241. * If the refraction texture on this material is in linear color space
  27242. * @hidden
  27243. */
  27244. IS_REFRACTION_LINEAR: boolean;
  27245. EXPOSURE: boolean;
  27246. constructor();
  27247. setReflectionMode(modeToEnable: string): void;
  27248. }
  27249. /**
  27250. * This is the default material used in Babylon. It is the best trade off between quality
  27251. * and performances.
  27252. * @see http://doc.babylonjs.com/babylon101/materials
  27253. */
  27254. export class StandardMaterial extends PushMaterial {
  27255. private _diffuseTexture;
  27256. /**
  27257. * The basic texture of the material as viewed under a light.
  27258. */
  27259. diffuseTexture: Nullable<BaseTexture>;
  27260. private _ambientTexture;
  27261. /**
  27262. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27263. */
  27264. ambientTexture: Nullable<BaseTexture>;
  27265. private _opacityTexture;
  27266. /**
  27267. * Define the transparency of the material from a texture.
  27268. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27269. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27270. */
  27271. opacityTexture: Nullable<BaseTexture>;
  27272. private _reflectionTexture;
  27273. /**
  27274. * Define the texture used to display the reflection.
  27275. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27276. */
  27277. reflectionTexture: Nullable<BaseTexture>;
  27278. private _emissiveTexture;
  27279. /**
  27280. * Define texture of the material as if self lit.
  27281. * This will be mixed in the final result even in the absence of light.
  27282. */
  27283. emissiveTexture: Nullable<BaseTexture>;
  27284. private _specularTexture;
  27285. /**
  27286. * Define how the color and intensity of the highlight given by the light in the material.
  27287. */
  27288. specularTexture: Nullable<BaseTexture>;
  27289. private _bumpTexture;
  27290. /**
  27291. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27292. * 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.
  27293. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27294. */
  27295. bumpTexture: Nullable<BaseTexture>;
  27296. private _lightmapTexture;
  27297. /**
  27298. * Complex lighting can be computationally expensive to compute at runtime.
  27299. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27300. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27301. */
  27302. lightmapTexture: Nullable<BaseTexture>;
  27303. private _refractionTexture;
  27304. /**
  27305. * Define the texture used to display the refraction.
  27306. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27307. */
  27308. refractionTexture: Nullable<BaseTexture>;
  27309. /**
  27310. * The color of the material lit by the environmental background lighting.
  27311. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27312. */
  27313. ambientColor: Color3;
  27314. /**
  27315. * The basic color of the material as viewed under a light.
  27316. */
  27317. diffuseColor: Color3;
  27318. /**
  27319. * Define how the color and intensity of the highlight given by the light in the material.
  27320. */
  27321. specularColor: Color3;
  27322. /**
  27323. * Define the color of the material as if self lit.
  27324. * This will be mixed in the final result even in the absence of light.
  27325. */
  27326. emissiveColor: Color3;
  27327. /**
  27328. * Defines how sharp are the highlights in the material.
  27329. * The bigger the value the sharper giving a more glossy feeling to the result.
  27330. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27331. */
  27332. specularPower: number;
  27333. private _useAlphaFromDiffuseTexture;
  27334. /**
  27335. * Does the transparency come from the diffuse texture alpha channel.
  27336. */
  27337. useAlphaFromDiffuseTexture: boolean;
  27338. private _useEmissiveAsIllumination;
  27339. /**
  27340. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27341. */
  27342. useEmissiveAsIllumination: boolean;
  27343. private _linkEmissiveWithDiffuse;
  27344. /**
  27345. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27346. * the emissive level when the final color is close to one.
  27347. */
  27348. linkEmissiveWithDiffuse: boolean;
  27349. private _useSpecularOverAlpha;
  27350. /**
  27351. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27352. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27353. */
  27354. useSpecularOverAlpha: boolean;
  27355. private _useReflectionOverAlpha;
  27356. /**
  27357. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27358. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27359. */
  27360. useReflectionOverAlpha: boolean;
  27361. private _disableLighting;
  27362. /**
  27363. * Does lights from the scene impacts this material.
  27364. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27365. */
  27366. disableLighting: boolean;
  27367. private _useObjectSpaceNormalMap;
  27368. /**
  27369. * Allows using an object space normal map (instead of tangent space).
  27370. */
  27371. useObjectSpaceNormalMap: boolean;
  27372. private _useParallax;
  27373. /**
  27374. * Is parallax enabled or not.
  27375. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27376. */
  27377. useParallax: boolean;
  27378. private _useParallaxOcclusion;
  27379. /**
  27380. * Is parallax occlusion enabled or not.
  27381. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27382. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27383. */
  27384. useParallaxOcclusion: boolean;
  27385. /**
  27386. * 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.
  27387. */
  27388. parallaxScaleBias: number;
  27389. private _roughness;
  27390. /**
  27391. * Helps to define how blurry the reflections should appears in the material.
  27392. */
  27393. roughness: number;
  27394. /**
  27395. * In case of refraction, define the value of the index of refraction.
  27396. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27397. */
  27398. indexOfRefraction: number;
  27399. /**
  27400. * Invert the refraction texture alongside the y axis.
  27401. * It can be useful with procedural textures or probe for instance.
  27402. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27403. */
  27404. invertRefractionY: boolean;
  27405. /**
  27406. * Defines the alpha limits in alpha test mode.
  27407. */
  27408. alphaCutOff: number;
  27409. private _useLightmapAsShadowmap;
  27410. /**
  27411. * In case of light mapping, define whether the map contains light or shadow informations.
  27412. */
  27413. useLightmapAsShadowmap: boolean;
  27414. private _diffuseFresnelParameters;
  27415. /**
  27416. * Define the diffuse fresnel parameters of the material.
  27417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27418. */
  27419. diffuseFresnelParameters: FresnelParameters;
  27420. private _opacityFresnelParameters;
  27421. /**
  27422. * Define the opacity fresnel parameters of the material.
  27423. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27424. */
  27425. opacityFresnelParameters: FresnelParameters;
  27426. private _reflectionFresnelParameters;
  27427. /**
  27428. * Define the reflection fresnel parameters of the material.
  27429. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27430. */
  27431. reflectionFresnelParameters: FresnelParameters;
  27432. private _refractionFresnelParameters;
  27433. /**
  27434. * Define the refraction fresnel parameters of the material.
  27435. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27436. */
  27437. refractionFresnelParameters: FresnelParameters;
  27438. private _emissiveFresnelParameters;
  27439. /**
  27440. * Define the emissive fresnel parameters of the material.
  27441. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27442. */
  27443. emissiveFresnelParameters: FresnelParameters;
  27444. private _useReflectionFresnelFromSpecular;
  27445. /**
  27446. * If true automatically deducts the fresnels values from the material specularity.
  27447. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27448. */
  27449. useReflectionFresnelFromSpecular: boolean;
  27450. private _useGlossinessFromSpecularMapAlpha;
  27451. /**
  27452. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27453. */
  27454. useGlossinessFromSpecularMapAlpha: boolean;
  27455. private _maxSimultaneousLights;
  27456. /**
  27457. * Defines the maximum number of lights that can be used in the material
  27458. */
  27459. maxSimultaneousLights: number;
  27460. private _invertNormalMapX;
  27461. /**
  27462. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27463. */
  27464. invertNormalMapX: boolean;
  27465. private _invertNormalMapY;
  27466. /**
  27467. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27468. */
  27469. invertNormalMapY: boolean;
  27470. private _twoSidedLighting;
  27471. /**
  27472. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27473. */
  27474. twoSidedLighting: boolean;
  27475. /**
  27476. * Default configuration related to image processing available in the standard Material.
  27477. */
  27478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27479. /**
  27480. * Gets the image processing configuration used either in this material.
  27481. */
  27482. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27483. /**
  27484. * Sets the Default image processing configuration used either in the this material.
  27485. *
  27486. * If sets to null, the scene one is in use.
  27487. */
  27488. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27489. /**
  27490. * Keep track of the image processing observer to allow dispose and replace.
  27491. */
  27492. private _imageProcessingObserver;
  27493. /**
  27494. * Attaches a new image processing configuration to the Standard Material.
  27495. * @param configuration
  27496. */
  27497. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27498. /**
  27499. * Gets wether the color curves effect is enabled.
  27500. */
  27501. get cameraColorCurvesEnabled(): boolean;
  27502. /**
  27503. * Sets wether the color curves effect is enabled.
  27504. */
  27505. set cameraColorCurvesEnabled(value: boolean);
  27506. /**
  27507. * Gets wether the color grading effect is enabled.
  27508. */
  27509. get cameraColorGradingEnabled(): boolean;
  27510. /**
  27511. * Gets wether the color grading effect is enabled.
  27512. */
  27513. set cameraColorGradingEnabled(value: boolean);
  27514. /**
  27515. * Gets wether tonemapping is enabled or not.
  27516. */
  27517. get cameraToneMappingEnabled(): boolean;
  27518. /**
  27519. * Sets wether tonemapping is enabled or not
  27520. */
  27521. set cameraToneMappingEnabled(value: boolean);
  27522. /**
  27523. * The camera exposure used on this material.
  27524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27525. * This corresponds to a photographic exposure.
  27526. */
  27527. get cameraExposure(): number;
  27528. /**
  27529. * The camera exposure used on this material.
  27530. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27531. * This corresponds to a photographic exposure.
  27532. */
  27533. set cameraExposure(value: number);
  27534. /**
  27535. * Gets The camera contrast used on this material.
  27536. */
  27537. get cameraContrast(): number;
  27538. /**
  27539. * Sets The camera contrast used on this material.
  27540. */
  27541. set cameraContrast(value: number);
  27542. /**
  27543. * Gets the Color Grading 2D Lookup Texture.
  27544. */
  27545. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27546. /**
  27547. * Sets the Color Grading 2D Lookup Texture.
  27548. */
  27549. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27550. /**
  27551. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27552. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27553. * 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;
  27554. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27555. */
  27556. get cameraColorCurves(): Nullable<ColorCurves>;
  27557. /**
  27558. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27559. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27560. * 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;
  27561. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27562. */
  27563. set cameraColorCurves(value: Nullable<ColorCurves>);
  27564. /**
  27565. * Custom callback helping to override the default shader used in the material.
  27566. */
  27567. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27568. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27569. protected _worldViewProjectionMatrix: Matrix;
  27570. protected _globalAmbientColor: Color3;
  27571. protected _useLogarithmicDepth: boolean;
  27572. protected _rebuildInParallel: boolean;
  27573. /**
  27574. * Instantiates a new standard material.
  27575. * This is the default material used in Babylon. It is the best trade off between quality
  27576. * and performances.
  27577. * @see http://doc.babylonjs.com/babylon101/materials
  27578. * @param name Define the name of the material in the scene
  27579. * @param scene Define the scene the material belong to
  27580. */
  27581. constructor(name: string, scene: Scene);
  27582. /**
  27583. * Gets a boolean indicating that current material needs to register RTT
  27584. */
  27585. get hasRenderTargetTextures(): boolean;
  27586. /**
  27587. * Gets the current class name of the material e.g. "StandardMaterial"
  27588. * Mainly use in serialization.
  27589. * @returns the class name
  27590. */
  27591. getClassName(): string;
  27592. /**
  27593. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27594. * You can try switching to logarithmic depth.
  27595. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27596. */
  27597. get useLogarithmicDepth(): boolean;
  27598. set useLogarithmicDepth(value: boolean);
  27599. /**
  27600. * Specifies if the material will require alpha blending
  27601. * @returns a boolean specifying if alpha blending is needed
  27602. */
  27603. needAlphaBlending(): boolean;
  27604. /**
  27605. * Specifies if this material should be rendered in alpha test mode
  27606. * @returns a boolean specifying if an alpha test is needed.
  27607. */
  27608. needAlphaTesting(): boolean;
  27609. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27610. /**
  27611. * Get the texture used for alpha test purpose.
  27612. * @returns the diffuse texture in case of the standard material.
  27613. */
  27614. getAlphaTestTexture(): Nullable<BaseTexture>;
  27615. /**
  27616. * Get if the submesh is ready to be used and all its information available.
  27617. * Child classes can use it to update shaders
  27618. * @param mesh defines the mesh to check
  27619. * @param subMesh defines which submesh to check
  27620. * @param useInstances specifies that instances should be used
  27621. * @returns a boolean indicating that the submesh is ready or not
  27622. */
  27623. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27624. /**
  27625. * Builds the material UBO layouts.
  27626. * Used internally during the effect preparation.
  27627. */
  27628. buildUniformLayout(): void;
  27629. /**
  27630. * Unbinds the material from the mesh
  27631. */
  27632. unbind(): void;
  27633. /**
  27634. * Binds the submesh to this material by preparing the effect and shader to draw
  27635. * @param world defines the world transformation matrix
  27636. * @param mesh defines the mesh containing the submesh
  27637. * @param subMesh defines the submesh to bind the material to
  27638. */
  27639. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27640. /**
  27641. * Get the list of animatables in the material.
  27642. * @returns the list of animatables object used in the material
  27643. */
  27644. getAnimatables(): IAnimatable[];
  27645. /**
  27646. * Gets the active textures from the material
  27647. * @returns an array of textures
  27648. */
  27649. getActiveTextures(): BaseTexture[];
  27650. /**
  27651. * Specifies if the material uses a texture
  27652. * @param texture defines the texture to check against the material
  27653. * @returns a boolean specifying if the material uses the texture
  27654. */
  27655. hasTexture(texture: BaseTexture): boolean;
  27656. /**
  27657. * Disposes the material
  27658. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27659. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27660. */
  27661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27662. /**
  27663. * Makes a duplicate of the material, and gives it a new name
  27664. * @param name defines the new name for the duplicated material
  27665. * @returns the cloned material
  27666. */
  27667. clone(name: string): StandardMaterial;
  27668. /**
  27669. * Serializes this material in a JSON representation
  27670. * @returns the serialized material object
  27671. */
  27672. serialize(): any;
  27673. /**
  27674. * Creates a standard material from parsed material data
  27675. * @param source defines the JSON representation of the material
  27676. * @param scene defines the hosting scene
  27677. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27678. * @returns a new standard material
  27679. */
  27680. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27681. /**
  27682. * Are diffuse textures enabled in the application.
  27683. */
  27684. static get DiffuseTextureEnabled(): boolean;
  27685. static set DiffuseTextureEnabled(value: boolean);
  27686. /**
  27687. * Are ambient textures enabled in the application.
  27688. */
  27689. static get AmbientTextureEnabled(): boolean;
  27690. static set AmbientTextureEnabled(value: boolean);
  27691. /**
  27692. * Are opacity textures enabled in the application.
  27693. */
  27694. static get OpacityTextureEnabled(): boolean;
  27695. static set OpacityTextureEnabled(value: boolean);
  27696. /**
  27697. * Are reflection textures enabled in the application.
  27698. */
  27699. static get ReflectionTextureEnabled(): boolean;
  27700. static set ReflectionTextureEnabled(value: boolean);
  27701. /**
  27702. * Are emissive textures enabled in the application.
  27703. */
  27704. static get EmissiveTextureEnabled(): boolean;
  27705. static set EmissiveTextureEnabled(value: boolean);
  27706. /**
  27707. * Are specular textures enabled in the application.
  27708. */
  27709. static get SpecularTextureEnabled(): boolean;
  27710. static set SpecularTextureEnabled(value: boolean);
  27711. /**
  27712. * Are bump textures enabled in the application.
  27713. */
  27714. static get BumpTextureEnabled(): boolean;
  27715. static set BumpTextureEnabled(value: boolean);
  27716. /**
  27717. * Are lightmap textures enabled in the application.
  27718. */
  27719. static get LightmapTextureEnabled(): boolean;
  27720. static set LightmapTextureEnabled(value: boolean);
  27721. /**
  27722. * Are refraction textures enabled in the application.
  27723. */
  27724. static get RefractionTextureEnabled(): boolean;
  27725. static set RefractionTextureEnabled(value: boolean);
  27726. /**
  27727. * Are color grading textures enabled in the application.
  27728. */
  27729. static get ColorGradingTextureEnabled(): boolean;
  27730. static set ColorGradingTextureEnabled(value: boolean);
  27731. /**
  27732. * Are fresnels enabled in the application.
  27733. */
  27734. static get FresnelEnabled(): boolean;
  27735. static set FresnelEnabled(value: boolean);
  27736. }
  27737. }
  27738. declare module "babylonjs/Particles/solidParticleSystem" {
  27739. import { Nullable } from "babylonjs/types";
  27740. import { Vector3 } from "babylonjs/Maths/math.vector";
  27741. import { Mesh } from "babylonjs/Meshes/mesh";
  27742. import { Scene, IDisposable } from "babylonjs/scene";
  27743. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27744. import { Material } from "babylonjs/Materials/material";
  27745. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27746. /**
  27747. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27748. *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.
  27749. * The SPS is also a particle system. It provides some methods to manage the particles.
  27750. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27751. *
  27752. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27753. */
  27754. export class SolidParticleSystem implements IDisposable {
  27755. /**
  27756. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27757. * Example : var p = SPS.particles[i];
  27758. */
  27759. particles: SolidParticle[];
  27760. /**
  27761. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27762. */
  27763. nbParticles: number;
  27764. /**
  27765. * If the particles must ever face the camera (default false). Useful for planar particles.
  27766. */
  27767. billboard: boolean;
  27768. /**
  27769. * Recompute normals when adding a shape
  27770. */
  27771. recomputeNormals: boolean;
  27772. /**
  27773. * This a counter ofr your own usage. It's not set by any SPS functions.
  27774. */
  27775. counter: number;
  27776. /**
  27777. * The SPS name. This name is also given to the underlying mesh.
  27778. */
  27779. name: string;
  27780. /**
  27781. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27782. */
  27783. mesh: Mesh;
  27784. /**
  27785. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27786. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27787. */
  27788. vars: any;
  27789. /**
  27790. * This array is populated when the SPS is set as 'pickable'.
  27791. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27792. * Each element of this array is an object `{idx: int, faceId: int}`.
  27793. * `idx` is the picked particle index in the `SPS.particles` array
  27794. * `faceId` is the picked face index counted within this particle.
  27795. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27796. */
  27797. pickedParticles: {
  27798. idx: number;
  27799. faceId: number;
  27800. }[];
  27801. /**
  27802. * This array is populated when `enableDepthSort` is set to true.
  27803. * Each element of this array is an instance of the class DepthSortedParticle.
  27804. */
  27805. depthSortedParticles: DepthSortedParticle[];
  27806. /**
  27807. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27808. * @hidden
  27809. */
  27810. _bSphereOnly: boolean;
  27811. /**
  27812. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27813. * @hidden
  27814. */
  27815. _bSphereRadiusFactor: number;
  27816. private _scene;
  27817. private _positions;
  27818. private _indices;
  27819. private _normals;
  27820. private _colors;
  27821. private _uvs;
  27822. private _indices32;
  27823. private _positions32;
  27824. private _normals32;
  27825. private _fixedNormal32;
  27826. private _colors32;
  27827. private _uvs32;
  27828. private _index;
  27829. private _updatable;
  27830. private _pickable;
  27831. private _isVisibilityBoxLocked;
  27832. private _alwaysVisible;
  27833. private _depthSort;
  27834. private _expandable;
  27835. private _shapeCounter;
  27836. private _copy;
  27837. private _color;
  27838. private _computeParticleColor;
  27839. private _computeParticleTexture;
  27840. private _computeParticleRotation;
  27841. private _computeParticleVertex;
  27842. private _computeBoundingBox;
  27843. private _depthSortParticles;
  27844. private _camera;
  27845. private _mustUnrotateFixedNormals;
  27846. private _particlesIntersect;
  27847. private _needs32Bits;
  27848. private _isNotBuilt;
  27849. private _lastParticleId;
  27850. private _idxOfId;
  27851. private _multimaterialEnabled;
  27852. private _useModelMaterial;
  27853. private _indicesByMaterial;
  27854. private _materialIndexes;
  27855. private _depthSortFunction;
  27856. private _materialSortFunction;
  27857. private _materials;
  27858. private _multimaterial;
  27859. private _materialIndexesById;
  27860. private _defaultMaterial;
  27861. private _autoUpdateSubMeshes;
  27862. /**
  27863. * Creates a SPS (Solid Particle System) object.
  27864. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27865. * @param scene (Scene) is the scene in which the SPS is added.
  27866. * @param options defines the options of the sps e.g.
  27867. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27868. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27869. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27870. * * 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.
  27871. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27872. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27873. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27874. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27875. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27876. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27877. */
  27878. constructor(name: string, scene: Scene, options?: {
  27879. updatable?: boolean;
  27880. isPickable?: boolean;
  27881. enableDepthSort?: boolean;
  27882. particleIntersection?: boolean;
  27883. boundingSphereOnly?: boolean;
  27884. bSphereRadiusFactor?: number;
  27885. expandable?: boolean;
  27886. useModelMaterial?: boolean;
  27887. enableMultiMaterial?: boolean;
  27888. });
  27889. /**
  27890. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27891. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27892. * @returns the created mesh
  27893. */
  27894. buildMesh(): Mesh;
  27895. /**
  27896. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27897. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27898. * Thus the particles generated from `digest()` have their property `position` set yet.
  27899. * @param mesh ( Mesh ) is the mesh to be digested
  27900. * @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
  27901. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27902. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27903. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27904. * @returns the current SPS
  27905. */
  27906. digest(mesh: Mesh, options?: {
  27907. facetNb?: number;
  27908. number?: number;
  27909. delta?: number;
  27910. storage?: [];
  27911. }): SolidParticleSystem;
  27912. /**
  27913. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27914. * @hidden
  27915. */
  27916. private _unrotateFixedNormals;
  27917. /**
  27918. * Resets the temporary working copy particle
  27919. * @hidden
  27920. */
  27921. private _resetCopy;
  27922. /**
  27923. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27924. * @param p the current index in the positions array to be updated
  27925. * @param ind the current index in the indices array
  27926. * @param shape a Vector3 array, the shape geometry
  27927. * @param positions the positions array to be updated
  27928. * @param meshInd the shape indices array
  27929. * @param indices the indices array to be updated
  27930. * @param meshUV the shape uv array
  27931. * @param uvs the uv array to be updated
  27932. * @param meshCol the shape color array
  27933. * @param colors the color array to be updated
  27934. * @param meshNor the shape normals array
  27935. * @param normals the normals array to be updated
  27936. * @param idx the particle index
  27937. * @param idxInShape the particle index in its shape
  27938. * @param options the addShape() method passed options
  27939. * @model the particle model
  27940. * @hidden
  27941. */
  27942. private _meshBuilder;
  27943. /**
  27944. * Returns a shape Vector3 array from positions float array
  27945. * @param positions float array
  27946. * @returns a vector3 array
  27947. * @hidden
  27948. */
  27949. private _posToShape;
  27950. /**
  27951. * Returns a shapeUV array from a float uvs (array deep copy)
  27952. * @param uvs as a float array
  27953. * @returns a shapeUV array
  27954. * @hidden
  27955. */
  27956. private _uvsToShapeUV;
  27957. /**
  27958. * Adds a new particle object in the particles array
  27959. * @param idx particle index in particles array
  27960. * @param id particle id
  27961. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27962. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27963. * @param model particle ModelShape object
  27964. * @param shapeId model shape identifier
  27965. * @param idxInShape index of the particle in the current model
  27966. * @param bInfo model bounding info object
  27967. * @param storage target storage array, if any
  27968. * @hidden
  27969. */
  27970. private _addParticle;
  27971. /**
  27972. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27973. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27974. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27975. * @param nb (positive integer) the number of particles to be created from this model
  27976. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27977. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27978. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27979. * @returns the number of shapes in the system
  27980. */
  27981. addShape(mesh: Mesh, nb: number, options?: {
  27982. positionFunction?: any;
  27983. vertexFunction?: any;
  27984. storage?: [];
  27985. }): number;
  27986. /**
  27987. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27988. * @hidden
  27989. */
  27990. private _rebuildParticle;
  27991. /**
  27992. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27993. * @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.
  27994. * @returns the SPS.
  27995. */
  27996. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27997. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27998. * Returns an array with the removed particles.
  27999. * 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.
  28000. * The SPS can't be empty so at least one particle needs to remain in place.
  28001. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28002. * @param start index of the first particle to remove
  28003. * @param end index of the last particle to remove (included)
  28004. * @returns an array populated with the removed particles
  28005. */
  28006. removeParticles(start: number, end: number): SolidParticle[];
  28007. /**
  28008. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28009. * @param solidParticleArray an array populated with Solid Particles objects
  28010. * @returns the SPS
  28011. */
  28012. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28013. /**
  28014. * Creates a new particle and modifies the SPS mesh geometry :
  28015. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28016. * - calls _addParticle() to populate the particle array
  28017. * factorized code from addShape() and insertParticlesFromArray()
  28018. * @param idx particle index in the particles array
  28019. * @param i particle index in its shape
  28020. * @param modelShape particle ModelShape object
  28021. * @param shape shape vertex array
  28022. * @param meshInd shape indices array
  28023. * @param meshUV shape uv array
  28024. * @param meshCol shape color array
  28025. * @param meshNor shape normals array
  28026. * @param bbInfo shape bounding info
  28027. * @param storage target particle storage
  28028. * @options addShape() passed options
  28029. * @hidden
  28030. */
  28031. private _insertNewParticle;
  28032. /**
  28033. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28034. * This method calls `updateParticle()` for each particle of the SPS.
  28035. * For an animated SPS, it is usually called within the render loop.
  28036. * 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.
  28037. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28038. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28039. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28040. * @returns the SPS.
  28041. */
  28042. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28043. /**
  28044. * Disposes the SPS.
  28045. */
  28046. dispose(): void;
  28047. /**
  28048. * Returns a SolidParticle object from its identifier : particle.id
  28049. * @param id (integer) the particle Id
  28050. * @returns the searched particle or null if not found in the SPS.
  28051. */
  28052. getParticleById(id: number): Nullable<SolidParticle>;
  28053. /**
  28054. * Returns a new array populated with the particles having the passed shapeId.
  28055. * @param shapeId (integer) the shape identifier
  28056. * @returns a new solid particle array
  28057. */
  28058. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28059. /**
  28060. * Populates the passed array "ref" with the particles having the passed shapeId.
  28061. * @param shapeId the shape identifier
  28062. * @returns the SPS
  28063. * @param ref
  28064. */
  28065. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28066. /**
  28067. * Computes the required SubMeshes according the materials assigned to the particles.
  28068. * @returns the solid particle system.
  28069. * Does nothing if called before the SPS mesh is built.
  28070. */
  28071. computeSubMeshes(): SolidParticleSystem;
  28072. /**
  28073. * Sorts the solid particles by material when MultiMaterial is enabled.
  28074. * Updates the indices32 array.
  28075. * Updates the indicesByMaterial array.
  28076. * Updates the mesh indices array.
  28077. * @returns the SPS
  28078. * @hidden
  28079. */
  28080. private _sortParticlesByMaterial;
  28081. /**
  28082. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28083. * @hidden
  28084. */
  28085. private _setMaterialIndexesById;
  28086. /**
  28087. * Returns an array with unique values of Materials from the passed array
  28088. * @param array the material array to be checked and filtered
  28089. * @hidden
  28090. */
  28091. private _filterUniqueMaterialId;
  28092. /**
  28093. * Sets a new Standard Material as _defaultMaterial if not already set.
  28094. * @hidden
  28095. */
  28096. private _setDefaultMaterial;
  28097. /**
  28098. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28099. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28100. * @returns the SPS.
  28101. */
  28102. refreshVisibleSize(): SolidParticleSystem;
  28103. /**
  28104. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28105. * @param size the size (float) of the visibility box
  28106. * note : this doesn't lock the SPS mesh bounding box.
  28107. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28108. */
  28109. setVisibilityBox(size: number): void;
  28110. /**
  28111. * Gets whether the SPS as always visible or not
  28112. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28113. */
  28114. get isAlwaysVisible(): boolean;
  28115. /**
  28116. * Sets the SPS as always visible or not
  28117. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28118. */
  28119. set isAlwaysVisible(val: boolean);
  28120. /**
  28121. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28122. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28123. */
  28124. set isVisibilityBoxLocked(val: boolean);
  28125. /**
  28126. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28127. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28128. */
  28129. get isVisibilityBoxLocked(): boolean;
  28130. /**
  28131. * Tells to `setParticles()` to compute the particle rotations or not.
  28132. * Default value : true. The SPS is faster when it's set to false.
  28133. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28134. */
  28135. set computeParticleRotation(val: boolean);
  28136. /**
  28137. * Tells to `setParticles()` to compute the particle colors or not.
  28138. * Default value : true. The SPS is faster when it's set to false.
  28139. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28140. */
  28141. set computeParticleColor(val: boolean);
  28142. set computeParticleTexture(val: boolean);
  28143. /**
  28144. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28145. * Default value : false. The SPS is faster when it's set to false.
  28146. * Note : the particle custom vertex positions aren't stored values.
  28147. */
  28148. set computeParticleVertex(val: boolean);
  28149. /**
  28150. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28151. */
  28152. set computeBoundingBox(val: boolean);
  28153. /**
  28154. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28155. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28156. * Default : `true`
  28157. */
  28158. set depthSortParticles(val: boolean);
  28159. /**
  28160. * Gets if `setParticles()` computes the particle rotations or not.
  28161. * Default value : true. The SPS is faster when it's set to false.
  28162. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28163. */
  28164. get computeParticleRotation(): boolean;
  28165. /**
  28166. * Gets if `setParticles()` computes the particle colors or not.
  28167. * Default value : true. The SPS is faster when it's set to false.
  28168. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28169. */
  28170. get computeParticleColor(): boolean;
  28171. /**
  28172. * Gets if `setParticles()` computes the particle textures or not.
  28173. * Default value : true. The SPS is faster when it's set to false.
  28174. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28175. */
  28176. get computeParticleTexture(): boolean;
  28177. /**
  28178. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28179. * Default value : false. The SPS is faster when it's set to false.
  28180. * Note : the particle custom vertex positions aren't stored values.
  28181. */
  28182. get computeParticleVertex(): boolean;
  28183. /**
  28184. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28185. */
  28186. get computeBoundingBox(): boolean;
  28187. /**
  28188. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28189. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28190. * Default : `true`
  28191. */
  28192. get depthSortParticles(): boolean;
  28193. /**
  28194. * Gets if the SPS is created as expandable at construction time.
  28195. * Default : `false`
  28196. */
  28197. get expandable(): boolean;
  28198. /**
  28199. * Gets if the SPS supports the Multi Materials
  28200. */
  28201. get multimaterialEnabled(): boolean;
  28202. /**
  28203. * Gets if the SPS uses the model materials for its own multimaterial.
  28204. */
  28205. get useModelMaterial(): boolean;
  28206. /**
  28207. * The SPS used material array.
  28208. */
  28209. get materials(): Material[];
  28210. /**
  28211. * Sets the SPS MultiMaterial from the passed materials.
  28212. * Note : the passed array is internally copied and not used then by reference.
  28213. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28214. */
  28215. setMultiMaterial(materials: Material[]): void;
  28216. /**
  28217. * The SPS computed multimaterial object
  28218. */
  28219. get multimaterial(): MultiMaterial;
  28220. set multimaterial(mm: MultiMaterial);
  28221. /**
  28222. * If the subMeshes must be updated on the next call to setParticles()
  28223. */
  28224. get autoUpdateSubMeshes(): boolean;
  28225. set autoUpdateSubMeshes(val: boolean);
  28226. /**
  28227. * This function does nothing. It may be overwritten to set all the particle first values.
  28228. * The SPS doesn't call this function, you may have to call it by your own.
  28229. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28230. */
  28231. initParticles(): void;
  28232. /**
  28233. * This function does nothing. It may be overwritten to recycle a particle.
  28234. * The SPS doesn't call this function, you may have to call it by your own.
  28235. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28236. * @param particle The particle to recycle
  28237. * @returns the recycled particle
  28238. */
  28239. recycleParticle(particle: SolidParticle): SolidParticle;
  28240. /**
  28241. * Updates a particle : this function should be overwritten by the user.
  28242. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28243. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28244. * @example : just set a particle position or velocity and recycle conditions
  28245. * @param particle The particle to update
  28246. * @returns the updated particle
  28247. */
  28248. updateParticle(particle: SolidParticle): SolidParticle;
  28249. /**
  28250. * Updates a vertex of a particle : it can be overwritten by the user.
  28251. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28252. * @param particle the current particle
  28253. * @param vertex the current index of the current particle
  28254. * @param pt the index of the current vertex in the particle shape
  28255. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28256. * @example : just set a vertex particle position
  28257. * @returns the updated vertex
  28258. */
  28259. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28260. /**
  28261. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28262. * This does nothing and may be overwritten by the user.
  28263. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28264. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28265. * @param update the boolean update value actually passed to setParticles()
  28266. */
  28267. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28268. /**
  28269. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28270. * This will be passed three parameters.
  28271. * This does nothing and may be overwritten by the user.
  28272. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28273. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28274. * @param update the boolean update value actually passed to setParticles()
  28275. */
  28276. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28277. }
  28278. }
  28279. declare module "babylonjs/Particles/solidParticle" {
  28280. import { Nullable } from "babylonjs/types";
  28281. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28282. import { Color4 } from "babylonjs/Maths/math.color";
  28283. import { Mesh } from "babylonjs/Meshes/mesh";
  28284. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28285. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28286. import { Plane } from "babylonjs/Maths/math.plane";
  28287. import { Material } from "babylonjs/Materials/material";
  28288. /**
  28289. * Represents one particle of a solid particle system.
  28290. */
  28291. export class SolidParticle {
  28292. /**
  28293. * particle global index
  28294. */
  28295. idx: number;
  28296. /**
  28297. * particle identifier
  28298. */
  28299. id: number;
  28300. /**
  28301. * The color of the particle
  28302. */
  28303. color: Nullable<Color4>;
  28304. /**
  28305. * The world space position of the particle.
  28306. */
  28307. position: Vector3;
  28308. /**
  28309. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28310. */
  28311. rotation: Vector3;
  28312. /**
  28313. * The world space rotation quaternion of the particle.
  28314. */
  28315. rotationQuaternion: Nullable<Quaternion>;
  28316. /**
  28317. * The scaling of the particle.
  28318. */
  28319. scaling: Vector3;
  28320. /**
  28321. * The uvs of the particle.
  28322. */
  28323. uvs: Vector4;
  28324. /**
  28325. * The current speed of the particle.
  28326. */
  28327. velocity: Vector3;
  28328. /**
  28329. * The pivot point in the particle local space.
  28330. */
  28331. pivot: Vector3;
  28332. /**
  28333. * Must the particle be translated from its pivot point in its local space ?
  28334. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28335. * Default : false
  28336. */
  28337. translateFromPivot: boolean;
  28338. /**
  28339. * Is the particle active or not ?
  28340. */
  28341. alive: boolean;
  28342. /**
  28343. * Is the particle visible or not ?
  28344. */
  28345. isVisible: boolean;
  28346. /**
  28347. * Index of this particle in the global "positions" array (Internal use)
  28348. * @hidden
  28349. */
  28350. _pos: number;
  28351. /**
  28352. * @hidden Index of this particle in the global "indices" array (Internal use)
  28353. */
  28354. _ind: number;
  28355. /**
  28356. * @hidden ModelShape of this particle (Internal use)
  28357. */
  28358. _model: ModelShape;
  28359. /**
  28360. * ModelShape id of this particle
  28361. */
  28362. shapeId: number;
  28363. /**
  28364. * Index of the particle in its shape id
  28365. */
  28366. idxInShape: number;
  28367. /**
  28368. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28369. */
  28370. _modelBoundingInfo: BoundingInfo;
  28371. /**
  28372. * @hidden Particle BoundingInfo object (Internal use)
  28373. */
  28374. _boundingInfo: BoundingInfo;
  28375. /**
  28376. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28377. */
  28378. _sps: SolidParticleSystem;
  28379. /**
  28380. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28381. */
  28382. _stillInvisible: boolean;
  28383. /**
  28384. * @hidden Last computed particle rotation matrix
  28385. */
  28386. _rotationMatrix: number[];
  28387. /**
  28388. * Parent particle Id, if any.
  28389. * Default null.
  28390. */
  28391. parentId: Nullable<number>;
  28392. /**
  28393. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28394. */
  28395. materialIndex: Nullable<number>;
  28396. /**
  28397. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28398. * The possible values are :
  28399. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28400. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28401. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28402. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28403. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28404. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28405. * */
  28406. cullingStrategy: number;
  28407. /**
  28408. * @hidden Internal global position in the SPS.
  28409. */
  28410. _globalPosition: Vector3;
  28411. /**
  28412. * Creates a Solid Particle object.
  28413. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28414. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28415. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28416. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28417. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28418. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28419. * @param shapeId (integer) is the model shape identifier in the SPS.
  28420. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28421. * @param sps defines the sps it is associated to
  28422. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28423. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28424. */
  28425. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28426. /**
  28427. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28428. * @param target the particle target
  28429. * @returns the current particle
  28430. */
  28431. copyToRef(target: SolidParticle): SolidParticle;
  28432. /**
  28433. * Legacy support, changed scale to scaling
  28434. */
  28435. get scale(): Vector3;
  28436. /**
  28437. * Legacy support, changed scale to scaling
  28438. */
  28439. set scale(scale: Vector3);
  28440. /**
  28441. * Legacy support, changed quaternion to rotationQuaternion
  28442. */
  28443. get quaternion(): Nullable<Quaternion>;
  28444. /**
  28445. * Legacy support, changed quaternion to rotationQuaternion
  28446. */
  28447. set quaternion(q: Nullable<Quaternion>);
  28448. /**
  28449. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28450. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28451. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28452. * @returns true if it intersects
  28453. */
  28454. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28455. /**
  28456. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28457. * A particle is in the frustum if its bounding box intersects the frustum
  28458. * @param frustumPlanes defines the frustum to test
  28459. * @returns true if the particle is in the frustum planes
  28460. */
  28461. isInFrustum(frustumPlanes: Plane[]): boolean;
  28462. /**
  28463. * get the rotation matrix of the particle
  28464. * @hidden
  28465. */
  28466. getRotationMatrix(m: Matrix): void;
  28467. }
  28468. /**
  28469. * Represents the shape of the model used by one particle of a solid particle system.
  28470. * SPS internal tool, don't use it manually.
  28471. */
  28472. export class ModelShape {
  28473. /**
  28474. * The shape id
  28475. * @hidden
  28476. */
  28477. shapeID: number;
  28478. /**
  28479. * flat array of model positions (internal use)
  28480. * @hidden
  28481. */
  28482. _shape: Vector3[];
  28483. /**
  28484. * flat array of model UVs (internal use)
  28485. * @hidden
  28486. */
  28487. _shapeUV: number[];
  28488. /**
  28489. * color array of the model
  28490. * @hidden
  28491. */
  28492. _shapeColors: number[];
  28493. /**
  28494. * indices array of the model
  28495. * @hidden
  28496. */
  28497. _indices: number[];
  28498. /**
  28499. * normals array of the model
  28500. * @hidden
  28501. */
  28502. _normals: number[];
  28503. /**
  28504. * length of the shape in the model indices array (internal use)
  28505. * @hidden
  28506. */
  28507. _indicesLength: number;
  28508. /**
  28509. * Custom position function (internal use)
  28510. * @hidden
  28511. */
  28512. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28513. /**
  28514. * Custom vertex function (internal use)
  28515. * @hidden
  28516. */
  28517. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28518. /**
  28519. * Model material (internal use)
  28520. * @hidden
  28521. */
  28522. _material: Nullable<Material>;
  28523. /**
  28524. * 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.
  28525. * SPS internal tool, don't use it manually.
  28526. * @hidden
  28527. */
  28528. 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>);
  28529. }
  28530. /**
  28531. * Represents a Depth Sorted Particle in the solid particle system.
  28532. * @hidden
  28533. */
  28534. export class DepthSortedParticle {
  28535. /**
  28536. * Index of the particle in the "indices" array
  28537. */
  28538. ind: number;
  28539. /**
  28540. * Length of the particle shape in the "indices" array
  28541. */
  28542. indicesLength: number;
  28543. /**
  28544. * Squared distance from the particle to the camera
  28545. */
  28546. sqDistance: number;
  28547. /**
  28548. * Material index when used with MultiMaterials
  28549. */
  28550. materialIndex: number;
  28551. /**
  28552. * Creates a new sorted particle
  28553. * @param materialIndex
  28554. */
  28555. constructor(ind: number, indLength: number, materialIndex: number);
  28556. }
  28557. }
  28558. declare module "babylonjs/Collisions/meshCollisionData" {
  28559. import { Collider } from "babylonjs/Collisions/collider";
  28560. import { Vector3 } from "babylonjs/Maths/math.vector";
  28561. import { Nullable } from "babylonjs/types";
  28562. import { Observer } from "babylonjs/Misc/observable";
  28563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28564. /**
  28565. * @hidden
  28566. */
  28567. export class _MeshCollisionData {
  28568. _checkCollisions: boolean;
  28569. _collisionMask: number;
  28570. _collisionGroup: number;
  28571. _collider: Nullable<Collider>;
  28572. _oldPositionForCollisions: Vector3;
  28573. _diffPositionForCollisions: Vector3;
  28574. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28575. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28576. }
  28577. }
  28578. declare module "babylonjs/Meshes/abstractMesh" {
  28579. import { Observable } from "babylonjs/Misc/observable";
  28580. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28581. import { Camera } from "babylonjs/Cameras/camera";
  28582. import { Scene, IDisposable } from "babylonjs/scene";
  28583. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28584. import { Node } from "babylonjs/node";
  28585. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28586. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28587. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28588. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28589. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28590. import { Material } from "babylonjs/Materials/material";
  28591. import { Light } from "babylonjs/Lights/light";
  28592. import { Skeleton } from "babylonjs/Bones/skeleton";
  28593. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28594. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28595. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28596. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28597. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28598. import { Plane } from "babylonjs/Maths/math.plane";
  28599. import { Ray } from "babylonjs/Culling/ray";
  28600. import { Collider } from "babylonjs/Collisions/collider";
  28601. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28602. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28603. /** @hidden */
  28604. class _FacetDataStorage {
  28605. facetPositions: Vector3[];
  28606. facetNormals: Vector3[];
  28607. facetPartitioning: number[][];
  28608. facetNb: number;
  28609. partitioningSubdivisions: number;
  28610. partitioningBBoxRatio: number;
  28611. facetDataEnabled: boolean;
  28612. facetParameters: any;
  28613. bbSize: Vector3;
  28614. subDiv: {
  28615. max: number;
  28616. X: number;
  28617. Y: number;
  28618. Z: number;
  28619. };
  28620. facetDepthSort: boolean;
  28621. facetDepthSortEnabled: boolean;
  28622. depthSortedIndices: IndicesArray;
  28623. depthSortedFacets: {
  28624. ind: number;
  28625. sqDistance: number;
  28626. }[];
  28627. facetDepthSortFunction: (f1: {
  28628. ind: number;
  28629. sqDistance: number;
  28630. }, f2: {
  28631. ind: number;
  28632. sqDistance: number;
  28633. }) => number;
  28634. facetDepthSortFrom: Vector3;
  28635. facetDepthSortOrigin: Vector3;
  28636. invertedMatrix: Matrix;
  28637. }
  28638. /**
  28639. * @hidden
  28640. **/
  28641. class _InternalAbstractMeshDataInfo {
  28642. _hasVertexAlpha: boolean;
  28643. _useVertexColors: boolean;
  28644. _numBoneInfluencers: number;
  28645. _applyFog: boolean;
  28646. _receiveShadows: boolean;
  28647. _facetData: _FacetDataStorage;
  28648. _visibility: number;
  28649. _skeleton: Nullable<Skeleton>;
  28650. _layerMask: number;
  28651. _computeBonesUsingShaders: boolean;
  28652. _isActive: boolean;
  28653. _onlyForInstances: boolean;
  28654. _isActiveIntermediate: boolean;
  28655. _onlyForInstancesIntermediate: boolean;
  28656. _actAsRegularMesh: boolean;
  28657. }
  28658. /**
  28659. * Class used to store all common mesh properties
  28660. */
  28661. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28662. /** No occlusion */
  28663. static OCCLUSION_TYPE_NONE: number;
  28664. /** Occlusion set to optimisitic */
  28665. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28666. /** Occlusion set to strict */
  28667. static OCCLUSION_TYPE_STRICT: number;
  28668. /** Use an accurante occlusion algorithm */
  28669. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28670. /** Use a conservative occlusion algorithm */
  28671. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28672. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28673. * Test order :
  28674. * Is the bounding sphere outside the frustum ?
  28675. * If not, are the bounding box vertices outside the frustum ?
  28676. * It not, then the cullable object is in the frustum.
  28677. */
  28678. static readonly CULLINGSTRATEGY_STANDARD: number;
  28679. /** Culling strategy : Bounding Sphere Only.
  28680. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28681. * It's also less accurate than the standard because some not visible objects can still be selected.
  28682. * Test : is the bounding sphere outside the frustum ?
  28683. * If not, then the cullable object is in the frustum.
  28684. */
  28685. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28686. /** Culling strategy : Optimistic Inclusion.
  28687. * This in an inclusion test first, then the standard exclusion test.
  28688. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28689. * 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.
  28690. * Anyway, it's as accurate as the standard strategy.
  28691. * Test :
  28692. * Is the cullable object bounding sphere center in the frustum ?
  28693. * If not, apply the default culling strategy.
  28694. */
  28695. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28696. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28697. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28698. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28699. * 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.
  28700. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28701. * Test :
  28702. * Is the cullable object bounding sphere center in the frustum ?
  28703. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28704. */
  28705. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28706. /**
  28707. * No billboard
  28708. */
  28709. static get BILLBOARDMODE_NONE(): number;
  28710. /** Billboard on X axis */
  28711. static get BILLBOARDMODE_X(): number;
  28712. /** Billboard on Y axis */
  28713. static get BILLBOARDMODE_Y(): number;
  28714. /** Billboard on Z axis */
  28715. static get BILLBOARDMODE_Z(): number;
  28716. /** Billboard on all axes */
  28717. static get BILLBOARDMODE_ALL(): number;
  28718. /** Billboard on using position instead of orientation */
  28719. static get BILLBOARDMODE_USE_POSITION(): number;
  28720. /** @hidden */
  28721. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28722. /**
  28723. * The culling strategy to use to check whether the mesh must be rendered or not.
  28724. * This value can be changed at any time and will be used on the next render mesh selection.
  28725. * The possible values are :
  28726. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28727. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28728. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28729. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28730. * Please read each static variable documentation to get details about the culling process.
  28731. * */
  28732. cullingStrategy: number;
  28733. /**
  28734. * Gets the number of facets in the mesh
  28735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28736. */
  28737. get facetNb(): number;
  28738. /**
  28739. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28741. */
  28742. get partitioningSubdivisions(): number;
  28743. set partitioningSubdivisions(nb: number);
  28744. /**
  28745. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28746. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28748. */
  28749. get partitioningBBoxRatio(): number;
  28750. set partitioningBBoxRatio(ratio: number);
  28751. /**
  28752. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28753. * Works only for updatable meshes.
  28754. * Doesn't work with multi-materials
  28755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28756. */
  28757. get mustDepthSortFacets(): boolean;
  28758. set mustDepthSortFacets(sort: boolean);
  28759. /**
  28760. * The location (Vector3) where the facet depth sort must be computed from.
  28761. * By default, the active camera position.
  28762. * Used only when facet depth sort is enabled
  28763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28764. */
  28765. get facetDepthSortFrom(): Vector3;
  28766. set facetDepthSortFrom(location: Vector3);
  28767. /**
  28768. * gets a boolean indicating if facetData is enabled
  28769. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28770. */
  28771. get isFacetDataEnabled(): boolean;
  28772. /** @hidden */
  28773. _updateNonUniformScalingState(value: boolean): boolean;
  28774. /**
  28775. * An event triggered when this mesh collides with another one
  28776. */
  28777. onCollideObservable: Observable<AbstractMesh>;
  28778. /** Set a function to call when this mesh collides with another one */
  28779. set onCollide(callback: () => void);
  28780. /**
  28781. * An event triggered when the collision's position changes
  28782. */
  28783. onCollisionPositionChangeObservable: Observable<Vector3>;
  28784. /** Set a function to call when the collision's position changes */
  28785. set onCollisionPositionChange(callback: () => void);
  28786. /**
  28787. * An event triggered when material is changed
  28788. */
  28789. onMaterialChangedObservable: Observable<AbstractMesh>;
  28790. /**
  28791. * Gets or sets the orientation for POV movement & rotation
  28792. */
  28793. definedFacingForward: boolean;
  28794. /** @hidden */
  28795. _occlusionQuery: Nullable<WebGLQuery>;
  28796. /** @hidden */
  28797. _renderingGroup: Nullable<RenderingGroup>;
  28798. /**
  28799. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28800. */
  28801. get visibility(): number;
  28802. /**
  28803. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28804. */
  28805. set visibility(value: number);
  28806. /** Gets or sets the alpha index used to sort transparent meshes
  28807. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28808. */
  28809. alphaIndex: number;
  28810. /**
  28811. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28812. */
  28813. isVisible: boolean;
  28814. /**
  28815. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28816. */
  28817. isPickable: boolean;
  28818. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28819. showSubMeshesBoundingBox: boolean;
  28820. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28821. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28822. */
  28823. isBlocker: boolean;
  28824. /**
  28825. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28826. */
  28827. enablePointerMoveEvents: boolean;
  28828. /**
  28829. * Specifies the rendering group id for this mesh (0 by default)
  28830. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28831. */
  28832. renderingGroupId: number;
  28833. private _material;
  28834. /** Gets or sets current material */
  28835. get material(): Nullable<Material>;
  28836. set material(value: Nullable<Material>);
  28837. /**
  28838. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28839. * @see http://doc.babylonjs.com/babylon101/shadows
  28840. */
  28841. get receiveShadows(): boolean;
  28842. set receiveShadows(value: boolean);
  28843. /** Defines color to use when rendering outline */
  28844. outlineColor: Color3;
  28845. /** Define width to use when rendering outline */
  28846. outlineWidth: number;
  28847. /** Defines color to use when rendering overlay */
  28848. overlayColor: Color3;
  28849. /** Defines alpha to use when rendering overlay */
  28850. overlayAlpha: number;
  28851. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28852. get hasVertexAlpha(): boolean;
  28853. set hasVertexAlpha(value: boolean);
  28854. /** 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) */
  28855. get useVertexColors(): boolean;
  28856. set useVertexColors(value: boolean);
  28857. /**
  28858. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28859. */
  28860. get computeBonesUsingShaders(): boolean;
  28861. set computeBonesUsingShaders(value: boolean);
  28862. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28863. get numBoneInfluencers(): number;
  28864. set numBoneInfluencers(value: number);
  28865. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28866. get applyFog(): boolean;
  28867. set applyFog(value: boolean);
  28868. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28869. useOctreeForRenderingSelection: boolean;
  28870. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28871. useOctreeForPicking: boolean;
  28872. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28873. useOctreeForCollisions: boolean;
  28874. /**
  28875. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28876. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28877. */
  28878. get layerMask(): number;
  28879. set layerMask(value: number);
  28880. /**
  28881. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28882. */
  28883. alwaysSelectAsActiveMesh: boolean;
  28884. /**
  28885. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28886. */
  28887. doNotSyncBoundingInfo: boolean;
  28888. /**
  28889. * Gets or sets the current action manager
  28890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28891. */
  28892. actionManager: Nullable<AbstractActionManager>;
  28893. private _meshCollisionData;
  28894. /**
  28895. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28896. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28897. */
  28898. ellipsoid: Vector3;
  28899. /**
  28900. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28902. */
  28903. ellipsoidOffset: Vector3;
  28904. /**
  28905. * Gets or sets a collision mask used to mask collisions (default is -1).
  28906. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28907. */
  28908. get collisionMask(): number;
  28909. set collisionMask(mask: number);
  28910. /**
  28911. * Gets or sets the current collision group mask (-1 by default).
  28912. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28913. */
  28914. get collisionGroup(): number;
  28915. set collisionGroup(mask: number);
  28916. /**
  28917. * Defines edge width used when edgesRenderer is enabled
  28918. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28919. */
  28920. edgesWidth: number;
  28921. /**
  28922. * Defines edge color used when edgesRenderer is enabled
  28923. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28924. */
  28925. edgesColor: Color4;
  28926. /** @hidden */
  28927. _edgesRenderer: Nullable<IEdgesRenderer>;
  28928. /** @hidden */
  28929. _masterMesh: Nullable<AbstractMesh>;
  28930. /** @hidden */
  28931. _boundingInfo: Nullable<BoundingInfo>;
  28932. /** @hidden */
  28933. _renderId: number;
  28934. /**
  28935. * Gets or sets the list of subMeshes
  28936. * @see http://doc.babylonjs.com/how_to/multi_materials
  28937. */
  28938. subMeshes: SubMesh[];
  28939. /** @hidden */
  28940. _intersectionsInProgress: AbstractMesh[];
  28941. /** @hidden */
  28942. _unIndexed: boolean;
  28943. /** @hidden */
  28944. _lightSources: Light[];
  28945. /** Gets the list of lights affecting that mesh */
  28946. get lightSources(): Light[];
  28947. /** @hidden */
  28948. get _positions(): Nullable<Vector3[]>;
  28949. /** @hidden */
  28950. _waitingData: {
  28951. lods: Nullable<any>;
  28952. actions: Nullable<any>;
  28953. freezeWorldMatrix: Nullable<boolean>;
  28954. };
  28955. /** @hidden */
  28956. _bonesTransformMatrices: Nullable<Float32Array>;
  28957. /** @hidden */
  28958. _transformMatrixTexture: Nullable<RawTexture>;
  28959. /**
  28960. * Gets or sets a skeleton to apply skining transformations
  28961. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28962. */
  28963. set skeleton(value: Nullable<Skeleton>);
  28964. get skeleton(): Nullable<Skeleton>;
  28965. /**
  28966. * An event triggered when the mesh is rebuilt.
  28967. */
  28968. onRebuildObservable: Observable<AbstractMesh>;
  28969. /**
  28970. * Creates a new AbstractMesh
  28971. * @param name defines the name of the mesh
  28972. * @param scene defines the hosting scene
  28973. */
  28974. constructor(name: string, scene?: Nullable<Scene>);
  28975. /**
  28976. * Returns the string "AbstractMesh"
  28977. * @returns "AbstractMesh"
  28978. */
  28979. getClassName(): string;
  28980. /**
  28981. * Gets a string representation of the current mesh
  28982. * @param fullDetails defines a boolean indicating if full details must be included
  28983. * @returns a string representation of the current mesh
  28984. */
  28985. toString(fullDetails?: boolean): string;
  28986. /**
  28987. * @hidden
  28988. */
  28989. protected _getEffectiveParent(): Nullable<Node>;
  28990. /** @hidden */
  28991. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28992. /** @hidden */
  28993. _rebuild(): void;
  28994. /** @hidden */
  28995. _resyncLightSources(): void;
  28996. /** @hidden */
  28997. _resyncLightSource(light: Light): void;
  28998. /** @hidden */
  28999. _unBindEffect(): void;
  29000. /** @hidden */
  29001. _removeLightSource(light: Light, dispose: boolean): void;
  29002. private _markSubMeshesAsDirty;
  29003. /** @hidden */
  29004. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29005. /** @hidden */
  29006. _markSubMeshesAsAttributesDirty(): void;
  29007. /** @hidden */
  29008. _markSubMeshesAsMiscDirty(): void;
  29009. /**
  29010. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29011. */
  29012. get scaling(): Vector3;
  29013. set scaling(newScaling: Vector3);
  29014. /**
  29015. * Returns true if the mesh is blocked. Implemented by child classes
  29016. */
  29017. get isBlocked(): boolean;
  29018. /**
  29019. * Returns the mesh itself by default. Implemented by child classes
  29020. * @param camera defines the camera to use to pick the right LOD level
  29021. * @returns the currentAbstractMesh
  29022. */
  29023. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29024. /**
  29025. * Returns 0 by default. Implemented by child classes
  29026. * @returns an integer
  29027. */
  29028. getTotalVertices(): number;
  29029. /**
  29030. * Returns a positive integer : the total number of indices in this mesh geometry.
  29031. * @returns the numner of indices or zero if the mesh has no geometry.
  29032. */
  29033. getTotalIndices(): number;
  29034. /**
  29035. * Returns null by default. Implemented by child classes
  29036. * @returns null
  29037. */
  29038. getIndices(): Nullable<IndicesArray>;
  29039. /**
  29040. * Returns the array of the requested vertex data kind. Implemented by child classes
  29041. * @param kind defines the vertex data kind to use
  29042. * @returns null
  29043. */
  29044. getVerticesData(kind: string): Nullable<FloatArray>;
  29045. /**
  29046. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29047. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29048. * Note that a new underlying VertexBuffer object is created each call.
  29049. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29050. * @param kind defines vertex data kind:
  29051. * * VertexBuffer.PositionKind
  29052. * * VertexBuffer.UVKind
  29053. * * VertexBuffer.UV2Kind
  29054. * * VertexBuffer.UV3Kind
  29055. * * VertexBuffer.UV4Kind
  29056. * * VertexBuffer.UV5Kind
  29057. * * VertexBuffer.UV6Kind
  29058. * * VertexBuffer.ColorKind
  29059. * * VertexBuffer.MatricesIndicesKind
  29060. * * VertexBuffer.MatricesIndicesExtraKind
  29061. * * VertexBuffer.MatricesWeightsKind
  29062. * * VertexBuffer.MatricesWeightsExtraKind
  29063. * @param data defines the data source
  29064. * @param updatable defines if the data must be flagged as updatable (or static)
  29065. * @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
  29066. * @returns the current mesh
  29067. */
  29068. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29069. /**
  29070. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29071. * If the mesh has no geometry, it is simply returned as it is.
  29072. * @param kind defines vertex data kind:
  29073. * * VertexBuffer.PositionKind
  29074. * * VertexBuffer.UVKind
  29075. * * VertexBuffer.UV2Kind
  29076. * * VertexBuffer.UV3Kind
  29077. * * VertexBuffer.UV4Kind
  29078. * * VertexBuffer.UV5Kind
  29079. * * VertexBuffer.UV6Kind
  29080. * * VertexBuffer.ColorKind
  29081. * * VertexBuffer.MatricesIndicesKind
  29082. * * VertexBuffer.MatricesIndicesExtraKind
  29083. * * VertexBuffer.MatricesWeightsKind
  29084. * * VertexBuffer.MatricesWeightsExtraKind
  29085. * @param data defines the data source
  29086. * @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
  29087. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29088. * @returns the current mesh
  29089. */
  29090. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29091. /**
  29092. * Sets the mesh indices,
  29093. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29094. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29095. * @param totalVertices Defines the total number of vertices
  29096. * @returns the current mesh
  29097. */
  29098. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29099. /**
  29100. * Gets a boolean indicating if specific vertex data is present
  29101. * @param kind defines the vertex data kind to use
  29102. * @returns true is data kind is present
  29103. */
  29104. isVerticesDataPresent(kind: string): boolean;
  29105. /**
  29106. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29107. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29108. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29109. * @returns a BoundingInfo
  29110. */
  29111. getBoundingInfo(): BoundingInfo;
  29112. /**
  29113. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29114. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29115. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29116. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29117. * @returns the current mesh
  29118. */
  29119. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29120. /**
  29121. * Overwrite the current bounding info
  29122. * @param boundingInfo defines the new bounding info
  29123. * @returns the current mesh
  29124. */
  29125. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29126. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29127. get useBones(): boolean;
  29128. /** @hidden */
  29129. _preActivate(): void;
  29130. /** @hidden */
  29131. _preActivateForIntermediateRendering(renderId: number): void;
  29132. /** @hidden */
  29133. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29134. /** @hidden */
  29135. _postActivate(): void;
  29136. /** @hidden */
  29137. _freeze(): void;
  29138. /** @hidden */
  29139. _unFreeze(): void;
  29140. /**
  29141. * Gets the current world matrix
  29142. * @returns a Matrix
  29143. */
  29144. getWorldMatrix(): Matrix;
  29145. /** @hidden */
  29146. _getWorldMatrixDeterminant(): number;
  29147. /**
  29148. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29149. */
  29150. get isAnInstance(): boolean;
  29151. /**
  29152. * Gets a boolean indicating if this mesh has instances
  29153. */
  29154. get hasInstances(): boolean;
  29155. /**
  29156. * Perform relative position change from the point of view of behind the front of the mesh.
  29157. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29158. * Supports definition of mesh facing forward or backward
  29159. * @param amountRight defines the distance on the right axis
  29160. * @param amountUp defines the distance on the up axis
  29161. * @param amountForward defines the distance on the forward axis
  29162. * @returns the current mesh
  29163. */
  29164. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29165. /**
  29166. * Calculate relative position change from the point of view of behind the front of the mesh.
  29167. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29168. * Supports definition of mesh facing forward or backward
  29169. * @param amountRight defines the distance on the right axis
  29170. * @param amountUp defines the distance on the up axis
  29171. * @param amountForward defines the distance on the forward axis
  29172. * @returns the new displacement vector
  29173. */
  29174. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29175. /**
  29176. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29177. * Supports definition of mesh facing forward or backward
  29178. * @param flipBack defines the flip
  29179. * @param twirlClockwise defines the twirl
  29180. * @param tiltRight defines the tilt
  29181. * @returns the current mesh
  29182. */
  29183. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29184. /**
  29185. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29186. * Supports definition of mesh facing forward or backward.
  29187. * @param flipBack defines the flip
  29188. * @param twirlClockwise defines the twirl
  29189. * @param tiltRight defines the tilt
  29190. * @returns the new rotation vector
  29191. */
  29192. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29193. /**
  29194. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29195. * This means the mesh underlying bounding box and sphere are recomputed.
  29196. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29197. * @returns the current mesh
  29198. */
  29199. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29200. /** @hidden */
  29201. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29202. /** @hidden */
  29203. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29204. /** @hidden */
  29205. _updateBoundingInfo(): AbstractMesh;
  29206. /** @hidden */
  29207. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29208. /** @hidden */
  29209. protected _afterComputeWorldMatrix(): void;
  29210. /** @hidden */
  29211. get _effectiveMesh(): AbstractMesh;
  29212. /**
  29213. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29214. * A mesh is in the frustum if its bounding box intersects the frustum
  29215. * @param frustumPlanes defines the frustum to test
  29216. * @returns true if the mesh is in the frustum planes
  29217. */
  29218. isInFrustum(frustumPlanes: Plane[]): boolean;
  29219. /**
  29220. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29221. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29222. * @param frustumPlanes defines the frustum to test
  29223. * @returns true if the mesh is completely in the frustum planes
  29224. */
  29225. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29226. /**
  29227. * True if the mesh intersects another mesh or a SolidParticle object
  29228. * @param mesh defines a target mesh or SolidParticle to test
  29229. * @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)
  29230. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29231. * @returns true if there is an intersection
  29232. */
  29233. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29234. /**
  29235. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29236. * @param point defines the point to test
  29237. * @returns true if there is an intersection
  29238. */
  29239. intersectsPoint(point: Vector3): boolean;
  29240. /**
  29241. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29242. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29243. */
  29244. get checkCollisions(): boolean;
  29245. set checkCollisions(collisionEnabled: boolean);
  29246. /**
  29247. * Gets Collider object used to compute collisions (not physics)
  29248. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29249. */
  29250. get collider(): Nullable<Collider>;
  29251. /**
  29252. * Move the mesh using collision engine
  29253. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29254. * @param displacement defines the requested displacement vector
  29255. * @returns the current mesh
  29256. */
  29257. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29258. private _onCollisionPositionChange;
  29259. /** @hidden */
  29260. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29261. /** @hidden */
  29262. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29263. /** @hidden */
  29264. _checkCollision(collider: Collider): AbstractMesh;
  29265. /** @hidden */
  29266. _generatePointsArray(): boolean;
  29267. /**
  29268. * Checks if the passed Ray intersects with the mesh
  29269. * @param ray defines the ray to use
  29270. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29271. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29272. * @returns the picking info
  29273. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29274. */
  29275. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29276. /**
  29277. * Clones the current mesh
  29278. * @param name defines the mesh name
  29279. * @param newParent defines the new mesh parent
  29280. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29281. * @returns the new mesh
  29282. */
  29283. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29284. /**
  29285. * Disposes all the submeshes of the current meshnp
  29286. * @returns the current mesh
  29287. */
  29288. releaseSubMeshes(): AbstractMesh;
  29289. /**
  29290. * Releases resources associated with this abstract mesh.
  29291. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29292. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29293. */
  29294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29295. /**
  29296. * Adds the passed mesh as a child to the current mesh
  29297. * @param mesh defines the child mesh
  29298. * @returns the current mesh
  29299. */
  29300. addChild(mesh: AbstractMesh): AbstractMesh;
  29301. /**
  29302. * Removes the passed mesh from the current mesh children list
  29303. * @param mesh defines the child mesh
  29304. * @returns the current mesh
  29305. */
  29306. removeChild(mesh: AbstractMesh): AbstractMesh;
  29307. /** @hidden */
  29308. private _initFacetData;
  29309. /**
  29310. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29311. * This method can be called within the render loop.
  29312. * 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
  29313. * @returns the current mesh
  29314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29315. */
  29316. updateFacetData(): AbstractMesh;
  29317. /**
  29318. * Returns the facetLocalNormals array.
  29319. * The normals are expressed in the mesh local spac
  29320. * @returns an array of Vector3
  29321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29322. */
  29323. getFacetLocalNormals(): Vector3[];
  29324. /**
  29325. * Returns the facetLocalPositions array.
  29326. * The facet positions are expressed in the mesh local space
  29327. * @returns an array of Vector3
  29328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29329. */
  29330. getFacetLocalPositions(): Vector3[];
  29331. /**
  29332. * Returns the facetLocalPartioning array
  29333. * @returns an array of array of numbers
  29334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29335. */
  29336. getFacetLocalPartitioning(): number[][];
  29337. /**
  29338. * Returns the i-th facet position in the world system.
  29339. * This method allocates a new Vector3 per call
  29340. * @param i defines the facet index
  29341. * @returns a new Vector3
  29342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29343. */
  29344. getFacetPosition(i: number): Vector3;
  29345. /**
  29346. * Sets the reference Vector3 with the i-th facet position in the world system
  29347. * @param i defines the facet index
  29348. * @param ref defines the target vector
  29349. * @returns the current mesh
  29350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29351. */
  29352. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29353. /**
  29354. * Returns the i-th facet normal in the world system.
  29355. * This method allocates a new Vector3 per call
  29356. * @param i defines the facet index
  29357. * @returns a new Vector3
  29358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29359. */
  29360. getFacetNormal(i: number): Vector3;
  29361. /**
  29362. * Sets the reference Vector3 with the i-th facet normal in the world system
  29363. * @param i defines the facet index
  29364. * @param ref defines the target vector
  29365. * @returns the current mesh
  29366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29367. */
  29368. getFacetNormalToRef(i: number, ref: Vector3): this;
  29369. /**
  29370. * 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)
  29371. * @param x defines x coordinate
  29372. * @param y defines y coordinate
  29373. * @param z defines z coordinate
  29374. * @returns the array of facet indexes
  29375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29376. */
  29377. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29378. /**
  29379. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29380. * @param projected sets as the (x,y,z) world projection on the facet
  29381. * @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
  29382. * @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
  29383. * @param x defines x coordinate
  29384. * @param y defines y coordinate
  29385. * @param z defines z coordinate
  29386. * @returns the face index if found (or null instead)
  29387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29388. */
  29389. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29390. /**
  29391. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29392. * @param projected sets as the (x,y,z) local projection on the facet
  29393. * @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
  29394. * @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
  29395. * @param x defines x coordinate
  29396. * @param y defines y coordinate
  29397. * @param z defines z coordinate
  29398. * @returns the face index if found (or null instead)
  29399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29400. */
  29401. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29402. /**
  29403. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29404. * @returns the parameters
  29405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29406. */
  29407. getFacetDataParameters(): any;
  29408. /**
  29409. * Disables the feature FacetData and frees the related memory
  29410. * @returns the current mesh
  29411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29412. */
  29413. disableFacetData(): AbstractMesh;
  29414. /**
  29415. * Updates the AbstractMesh indices array
  29416. * @param indices defines the data source
  29417. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29418. * @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)
  29419. * @returns the current mesh
  29420. */
  29421. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29422. /**
  29423. * Creates new normals data for the mesh
  29424. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29425. * @returns the current mesh
  29426. */
  29427. createNormals(updatable: boolean): AbstractMesh;
  29428. /**
  29429. * Align the mesh with a normal
  29430. * @param normal defines the normal to use
  29431. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29432. * @returns the current mesh
  29433. */
  29434. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29435. /** @hidden */
  29436. _checkOcclusionQuery(): boolean;
  29437. /**
  29438. * Disables the mesh edge rendering mode
  29439. * @returns the currentAbstractMesh
  29440. */
  29441. disableEdgesRendering(): AbstractMesh;
  29442. /**
  29443. * Enables the edge rendering mode on the mesh.
  29444. * This mode makes the mesh edges visible
  29445. * @param epsilon defines the maximal distance between two angles to detect a face
  29446. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29447. * @returns the currentAbstractMesh
  29448. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29449. */
  29450. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29451. }
  29452. }
  29453. declare module "babylonjs/Actions/actionEvent" {
  29454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29455. import { Nullable } from "babylonjs/types";
  29456. import { Sprite } from "babylonjs/Sprites/sprite";
  29457. import { Scene } from "babylonjs/scene";
  29458. import { Vector2 } from "babylonjs/Maths/math.vector";
  29459. /**
  29460. * Interface used to define ActionEvent
  29461. */
  29462. export interface IActionEvent {
  29463. /** The mesh or sprite that triggered the action */
  29464. source: any;
  29465. /** The X mouse cursor position at the time of the event */
  29466. pointerX: number;
  29467. /** The Y mouse cursor position at the time of the event */
  29468. pointerY: number;
  29469. /** The mesh that is currently pointed at (can be null) */
  29470. meshUnderPointer: Nullable<AbstractMesh>;
  29471. /** the original (browser) event that triggered the ActionEvent */
  29472. sourceEvent?: any;
  29473. /** additional data for the event */
  29474. additionalData?: any;
  29475. }
  29476. /**
  29477. * ActionEvent is the event being sent when an action is triggered.
  29478. */
  29479. export class ActionEvent implements IActionEvent {
  29480. /** The mesh or sprite that triggered the action */
  29481. source: any;
  29482. /** The X mouse cursor position at the time of the event */
  29483. pointerX: number;
  29484. /** The Y mouse cursor position at the time of the event */
  29485. pointerY: number;
  29486. /** The mesh that is currently pointed at (can be null) */
  29487. meshUnderPointer: Nullable<AbstractMesh>;
  29488. /** the original (browser) event that triggered the ActionEvent */
  29489. sourceEvent?: any;
  29490. /** additional data for the event */
  29491. additionalData?: any;
  29492. /**
  29493. * Creates a new ActionEvent
  29494. * @param source The mesh or sprite that triggered the action
  29495. * @param pointerX The X mouse cursor position at the time of the event
  29496. * @param pointerY The Y mouse cursor position at the time of the event
  29497. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29498. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29499. * @param additionalData additional data for the event
  29500. */
  29501. constructor(
  29502. /** The mesh or sprite that triggered the action */
  29503. source: any,
  29504. /** The X mouse cursor position at the time of the event */
  29505. pointerX: number,
  29506. /** The Y mouse cursor position at the time of the event */
  29507. pointerY: number,
  29508. /** The mesh that is currently pointed at (can be null) */
  29509. meshUnderPointer: Nullable<AbstractMesh>,
  29510. /** the original (browser) event that triggered the ActionEvent */
  29511. sourceEvent?: any,
  29512. /** additional data for the event */
  29513. additionalData?: any);
  29514. /**
  29515. * Helper function to auto-create an ActionEvent from a source mesh.
  29516. * @param source The source mesh that triggered the event
  29517. * @param evt The original (browser) event
  29518. * @param additionalData additional data for the event
  29519. * @returns the new ActionEvent
  29520. */
  29521. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29522. /**
  29523. * Helper function to auto-create an ActionEvent from a source sprite
  29524. * @param source The source sprite that triggered the event
  29525. * @param scene Scene associated with the sprite
  29526. * @param evt The original (browser) event
  29527. * @param additionalData additional data for the event
  29528. * @returns the new ActionEvent
  29529. */
  29530. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29531. /**
  29532. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29533. * @param scene the scene where the event occurred
  29534. * @param evt The original (browser) event
  29535. * @returns the new ActionEvent
  29536. */
  29537. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29538. /**
  29539. * Helper function to auto-create an ActionEvent from a primitive
  29540. * @param prim defines the target primitive
  29541. * @param pointerPos defines the pointer position
  29542. * @param evt The original (browser) event
  29543. * @param additionalData additional data for the event
  29544. * @returns the new ActionEvent
  29545. */
  29546. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29547. }
  29548. }
  29549. declare module "babylonjs/Actions/abstractActionManager" {
  29550. import { IDisposable } from "babylonjs/scene";
  29551. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29552. import { IAction } from "babylonjs/Actions/action";
  29553. import { Nullable } from "babylonjs/types";
  29554. /**
  29555. * Abstract class used to decouple action Manager from scene and meshes.
  29556. * Do not instantiate.
  29557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29558. */
  29559. export abstract class AbstractActionManager implements IDisposable {
  29560. /** Gets the list of active triggers */
  29561. static Triggers: {
  29562. [key: string]: number;
  29563. };
  29564. /** Gets the cursor to use when hovering items */
  29565. hoverCursor: string;
  29566. /** Gets the list of actions */
  29567. actions: IAction[];
  29568. /**
  29569. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29570. */
  29571. isRecursive: boolean;
  29572. /**
  29573. * Releases all associated resources
  29574. */
  29575. abstract dispose(): void;
  29576. /**
  29577. * Does this action manager has pointer triggers
  29578. */
  29579. abstract get hasPointerTriggers(): boolean;
  29580. /**
  29581. * Does this action manager has pick triggers
  29582. */
  29583. abstract get hasPickTriggers(): boolean;
  29584. /**
  29585. * Process a specific trigger
  29586. * @param trigger defines the trigger to process
  29587. * @param evt defines the event details to be processed
  29588. */
  29589. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29590. /**
  29591. * Does this action manager handles actions of any of the given triggers
  29592. * @param triggers defines the triggers to be tested
  29593. * @return a boolean indicating whether one (or more) of the triggers is handled
  29594. */
  29595. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29596. /**
  29597. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29598. * speed.
  29599. * @param triggerA defines the trigger to be tested
  29600. * @param triggerB defines the trigger to be tested
  29601. * @return a boolean indicating whether one (or more) of the triggers is handled
  29602. */
  29603. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29604. /**
  29605. * Does this action manager handles actions of a given trigger
  29606. * @param trigger defines the trigger to be tested
  29607. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29608. * @return whether the trigger is handled
  29609. */
  29610. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29611. /**
  29612. * Serialize this manager to a JSON object
  29613. * @param name defines the property name to store this manager
  29614. * @returns a JSON representation of this manager
  29615. */
  29616. abstract serialize(name: string): any;
  29617. /**
  29618. * Registers an action to this action manager
  29619. * @param action defines the action to be registered
  29620. * @return the action amended (prepared) after registration
  29621. */
  29622. abstract registerAction(action: IAction): Nullable<IAction>;
  29623. /**
  29624. * Unregisters an action to this action manager
  29625. * @param action defines the action to be unregistered
  29626. * @return a boolean indicating whether the action has been unregistered
  29627. */
  29628. abstract unregisterAction(action: IAction): Boolean;
  29629. /**
  29630. * Does exist one action manager with at least one trigger
  29631. **/
  29632. static get HasTriggers(): boolean;
  29633. /**
  29634. * Does exist one action manager with at least one pick trigger
  29635. **/
  29636. static get HasPickTriggers(): boolean;
  29637. /**
  29638. * Does exist one action manager that handles actions of a given trigger
  29639. * @param trigger defines the trigger to be tested
  29640. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29641. **/
  29642. static HasSpecificTrigger(trigger: number): boolean;
  29643. }
  29644. }
  29645. declare module "babylonjs/node" {
  29646. import { Scene } from "babylonjs/scene";
  29647. import { Nullable } from "babylonjs/types";
  29648. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29649. import { Engine } from "babylonjs/Engines/engine";
  29650. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29651. import { Observable } from "babylonjs/Misc/observable";
  29652. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29653. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29654. import { Animatable } from "babylonjs/Animations/animatable";
  29655. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29656. import { Animation } from "babylonjs/Animations/animation";
  29657. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29659. /**
  29660. * Defines how a node can be built from a string name.
  29661. */
  29662. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29663. /**
  29664. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29665. */
  29666. export class Node implements IBehaviorAware<Node> {
  29667. /** @hidden */
  29668. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29669. private static _NodeConstructors;
  29670. /**
  29671. * Add a new node constructor
  29672. * @param type defines the type name of the node to construct
  29673. * @param constructorFunc defines the constructor function
  29674. */
  29675. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29676. /**
  29677. * Returns a node constructor based on type name
  29678. * @param type defines the type name
  29679. * @param name defines the new node name
  29680. * @param scene defines the hosting scene
  29681. * @param options defines optional options to transmit to constructors
  29682. * @returns the new constructor or null
  29683. */
  29684. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29685. /**
  29686. * Gets or sets the name of the node
  29687. */
  29688. name: string;
  29689. /**
  29690. * Gets or sets the id of the node
  29691. */
  29692. id: string;
  29693. /**
  29694. * Gets or sets the unique id of the node
  29695. */
  29696. uniqueId: number;
  29697. /**
  29698. * Gets or sets a string used to store user defined state for the node
  29699. */
  29700. state: string;
  29701. /**
  29702. * Gets or sets an object used to store user defined information for the node
  29703. */
  29704. metadata: any;
  29705. /**
  29706. * For internal use only. Please do not use.
  29707. */
  29708. reservedDataStore: any;
  29709. /**
  29710. * List of inspectable custom properties (used by the Inspector)
  29711. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29712. */
  29713. inspectableCustomProperties: IInspectable[];
  29714. private _doNotSerialize;
  29715. /**
  29716. * Gets or sets a boolean used to define if the node must be serialized
  29717. */
  29718. get doNotSerialize(): boolean;
  29719. set doNotSerialize(value: boolean);
  29720. /** @hidden */
  29721. _isDisposed: boolean;
  29722. /**
  29723. * Gets a list of Animations associated with the node
  29724. */
  29725. animations: import("babylonjs/Animations/animation").Animation[];
  29726. protected _ranges: {
  29727. [name: string]: Nullable<AnimationRange>;
  29728. };
  29729. /**
  29730. * Callback raised when the node is ready to be used
  29731. */
  29732. onReady: Nullable<(node: Node) => void>;
  29733. private _isEnabled;
  29734. private _isParentEnabled;
  29735. private _isReady;
  29736. /** @hidden */
  29737. _currentRenderId: number;
  29738. private _parentUpdateId;
  29739. /** @hidden */
  29740. _childUpdateId: number;
  29741. /** @hidden */
  29742. _waitingParentId: Nullable<string>;
  29743. /** @hidden */
  29744. _scene: Scene;
  29745. /** @hidden */
  29746. _cache: any;
  29747. private _parentNode;
  29748. private _children;
  29749. /** @hidden */
  29750. _worldMatrix: Matrix;
  29751. /** @hidden */
  29752. _worldMatrixDeterminant: number;
  29753. /** @hidden */
  29754. _worldMatrixDeterminantIsDirty: boolean;
  29755. /** @hidden */
  29756. private _sceneRootNodesIndex;
  29757. /**
  29758. * Gets a boolean indicating if the node has been disposed
  29759. * @returns true if the node was disposed
  29760. */
  29761. isDisposed(): boolean;
  29762. /**
  29763. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29764. * @see https://doc.babylonjs.com/how_to/parenting
  29765. */
  29766. set parent(parent: Nullable<Node>);
  29767. get parent(): Nullable<Node>;
  29768. /** @hidden */
  29769. _addToSceneRootNodes(): void;
  29770. /** @hidden */
  29771. _removeFromSceneRootNodes(): void;
  29772. private _animationPropertiesOverride;
  29773. /**
  29774. * Gets or sets the animation properties override
  29775. */
  29776. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29777. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29778. /**
  29779. * Gets a string idenfifying the name of the class
  29780. * @returns "Node" string
  29781. */
  29782. getClassName(): string;
  29783. /** @hidden */
  29784. readonly _isNode: boolean;
  29785. /**
  29786. * An event triggered when the mesh is disposed
  29787. */
  29788. onDisposeObservable: Observable<Node>;
  29789. private _onDisposeObserver;
  29790. /**
  29791. * Sets a callback that will be raised when the node will be disposed
  29792. */
  29793. set onDispose(callback: () => void);
  29794. /**
  29795. * Creates a new Node
  29796. * @param name the name and id to be given to this node
  29797. * @param scene the scene this node will be added to
  29798. */
  29799. constructor(name: string, scene?: Nullable<Scene>);
  29800. /**
  29801. * Gets the scene of the node
  29802. * @returns a scene
  29803. */
  29804. getScene(): Scene;
  29805. /**
  29806. * Gets the engine of the node
  29807. * @returns a Engine
  29808. */
  29809. getEngine(): Engine;
  29810. private _behaviors;
  29811. /**
  29812. * Attach a behavior to the node
  29813. * @see http://doc.babylonjs.com/features/behaviour
  29814. * @param behavior defines the behavior to attach
  29815. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29816. * @returns the current Node
  29817. */
  29818. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29819. /**
  29820. * Remove an attached behavior
  29821. * @see http://doc.babylonjs.com/features/behaviour
  29822. * @param behavior defines the behavior to attach
  29823. * @returns the current Node
  29824. */
  29825. removeBehavior(behavior: Behavior<Node>): Node;
  29826. /**
  29827. * Gets the list of attached behaviors
  29828. * @see http://doc.babylonjs.com/features/behaviour
  29829. */
  29830. get behaviors(): Behavior<Node>[];
  29831. /**
  29832. * Gets an attached behavior by name
  29833. * @param name defines the name of the behavior to look for
  29834. * @see http://doc.babylonjs.com/features/behaviour
  29835. * @returns null if behavior was not found else the requested behavior
  29836. */
  29837. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29838. /**
  29839. * Returns the latest update of the World matrix
  29840. * @returns a Matrix
  29841. */
  29842. getWorldMatrix(): Matrix;
  29843. /** @hidden */
  29844. _getWorldMatrixDeterminant(): number;
  29845. /**
  29846. * Returns directly the latest state of the mesh World matrix.
  29847. * A Matrix is returned.
  29848. */
  29849. get worldMatrixFromCache(): Matrix;
  29850. /** @hidden */
  29851. _initCache(): void;
  29852. /** @hidden */
  29853. updateCache(force?: boolean): void;
  29854. /** @hidden */
  29855. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29856. /** @hidden */
  29857. _updateCache(ignoreParentClass?: boolean): void;
  29858. /** @hidden */
  29859. _isSynchronized(): boolean;
  29860. /** @hidden */
  29861. _markSyncedWithParent(): void;
  29862. /** @hidden */
  29863. isSynchronizedWithParent(): boolean;
  29864. /** @hidden */
  29865. isSynchronized(): boolean;
  29866. /**
  29867. * Is this node ready to be used/rendered
  29868. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29869. * @return true if the node is ready
  29870. */
  29871. isReady(completeCheck?: boolean): boolean;
  29872. /**
  29873. * Is this node enabled?
  29874. * 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
  29875. * @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
  29876. * @return whether this node (and its parent) is enabled
  29877. */
  29878. isEnabled(checkAncestors?: boolean): boolean;
  29879. /** @hidden */
  29880. protected _syncParentEnabledState(): void;
  29881. /**
  29882. * Set the enabled state of this node
  29883. * @param value defines the new enabled state
  29884. */
  29885. setEnabled(value: boolean): void;
  29886. /**
  29887. * Is this node a descendant of the given node?
  29888. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29889. * @param ancestor defines the parent node to inspect
  29890. * @returns a boolean indicating if this node is a descendant of the given node
  29891. */
  29892. isDescendantOf(ancestor: Node): boolean;
  29893. /** @hidden */
  29894. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29895. /**
  29896. * Will return all nodes that have this node as ascendant
  29897. * @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
  29898. * @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
  29899. * @return all children nodes of all types
  29900. */
  29901. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29902. /**
  29903. * Get all child-meshes of this node
  29904. * @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)
  29905. * @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
  29906. * @returns an array of AbstractMesh
  29907. */
  29908. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29909. /**
  29910. * Get all direct children of this node
  29911. * @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
  29912. * @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)
  29913. * @returns an array of Node
  29914. */
  29915. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29916. /** @hidden */
  29917. _setReady(state: boolean): void;
  29918. /**
  29919. * Get an animation by name
  29920. * @param name defines the name of the animation to look for
  29921. * @returns null if not found else the requested animation
  29922. */
  29923. getAnimationByName(name: string): Nullable<Animation>;
  29924. /**
  29925. * Creates an animation range for this node
  29926. * @param name defines the name of the range
  29927. * @param from defines the starting key
  29928. * @param to defines the end key
  29929. */
  29930. createAnimationRange(name: string, from: number, to: number): void;
  29931. /**
  29932. * Delete a specific animation range
  29933. * @param name defines the name of the range to delete
  29934. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29935. */
  29936. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29937. /**
  29938. * Get an animation range by name
  29939. * @param name defines the name of the animation range to look for
  29940. * @returns null if not found else the requested animation range
  29941. */
  29942. getAnimationRange(name: string): Nullable<AnimationRange>;
  29943. /**
  29944. * Gets the list of all animation ranges defined on this node
  29945. * @returns an array
  29946. */
  29947. getAnimationRanges(): Nullable<AnimationRange>[];
  29948. /**
  29949. * Will start the animation sequence
  29950. * @param name defines the range frames for animation sequence
  29951. * @param loop defines if the animation should loop (false by default)
  29952. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29953. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29954. * @returns the object created for this animation. If range does not exist, it will return null
  29955. */
  29956. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29957. /**
  29958. * Serialize animation ranges into a JSON compatible object
  29959. * @returns serialization object
  29960. */
  29961. serializeAnimationRanges(): any;
  29962. /**
  29963. * Computes the world matrix of the node
  29964. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29965. * @returns the world matrix
  29966. */
  29967. computeWorldMatrix(force?: boolean): Matrix;
  29968. /**
  29969. * Releases resources associated with this node.
  29970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29972. */
  29973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29974. /**
  29975. * Parse animation range data from a serialization object and store them into a given node
  29976. * @param node defines where to store the animation ranges
  29977. * @param parsedNode defines the serialization object to read data from
  29978. * @param scene defines the hosting scene
  29979. */
  29980. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29981. /**
  29982. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29983. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29984. * @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
  29985. * @returns the new bounding vectors
  29986. */
  29987. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29988. min: Vector3;
  29989. max: Vector3;
  29990. };
  29991. }
  29992. }
  29993. declare module "babylonjs/Animations/animation" {
  29994. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29995. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29996. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29997. import { Nullable } from "babylonjs/types";
  29998. import { Scene } from "babylonjs/scene";
  29999. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30000. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30001. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30002. import { Node } from "babylonjs/node";
  30003. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30004. import { Size } from "babylonjs/Maths/math.size";
  30005. import { Animatable } from "babylonjs/Animations/animatable";
  30006. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30007. /**
  30008. * @hidden
  30009. */
  30010. export class _IAnimationState {
  30011. key: number;
  30012. repeatCount: number;
  30013. workValue?: any;
  30014. loopMode?: number;
  30015. offsetValue?: any;
  30016. highLimitValue?: any;
  30017. }
  30018. /**
  30019. * Class used to store any kind of animation
  30020. */
  30021. export class Animation {
  30022. /**Name of the animation */
  30023. name: string;
  30024. /**Property to animate */
  30025. targetProperty: string;
  30026. /**The frames per second of the animation */
  30027. framePerSecond: number;
  30028. /**The data type of the animation */
  30029. dataType: number;
  30030. /**The loop mode of the animation */
  30031. loopMode?: number | undefined;
  30032. /**Specifies if blending should be enabled */
  30033. enableBlending?: boolean | undefined;
  30034. /**
  30035. * Use matrix interpolation instead of using direct key value when animating matrices
  30036. */
  30037. static AllowMatricesInterpolation: boolean;
  30038. /**
  30039. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30040. */
  30041. static AllowMatrixDecomposeForInterpolation: boolean;
  30042. /**
  30043. * Stores the key frames of the animation
  30044. */
  30045. private _keys;
  30046. /**
  30047. * Stores the easing function of the animation
  30048. */
  30049. private _easingFunction;
  30050. /**
  30051. * @hidden Internal use only
  30052. */
  30053. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30054. /**
  30055. * The set of event that will be linked to this animation
  30056. */
  30057. private _events;
  30058. /**
  30059. * Stores an array of target property paths
  30060. */
  30061. targetPropertyPath: string[];
  30062. /**
  30063. * Stores the blending speed of the animation
  30064. */
  30065. blendingSpeed: number;
  30066. /**
  30067. * Stores the animation ranges for the animation
  30068. */
  30069. private _ranges;
  30070. /**
  30071. * @hidden Internal use
  30072. */
  30073. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30074. /**
  30075. * Sets up an animation
  30076. * @param property The property to animate
  30077. * @param animationType The animation type to apply
  30078. * @param framePerSecond The frames per second of the animation
  30079. * @param easingFunction The easing function used in the animation
  30080. * @returns The created animation
  30081. */
  30082. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30083. /**
  30084. * Create and start an animation on a node
  30085. * @param name defines the name of the global animation that will be run on all nodes
  30086. * @param node defines the root node where the animation will take place
  30087. * @param targetProperty defines property to animate
  30088. * @param framePerSecond defines the number of frame per second yo use
  30089. * @param totalFrame defines the number of frames in total
  30090. * @param from defines the initial value
  30091. * @param to defines the final value
  30092. * @param loopMode defines which loop mode you want to use (off by default)
  30093. * @param easingFunction defines the easing function to use (linear by default)
  30094. * @param onAnimationEnd defines the callback to call when animation end
  30095. * @returns the animatable created for this animation
  30096. */
  30097. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30098. /**
  30099. * Create and start an animation on a node and its descendants
  30100. * @param name defines the name of the global animation that will be run on all nodes
  30101. * @param node defines the root node where the animation will take place
  30102. * @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
  30103. * @param targetProperty defines property to animate
  30104. * @param framePerSecond defines the number of frame per second to use
  30105. * @param totalFrame defines the number of frames in total
  30106. * @param from defines the initial value
  30107. * @param to defines the final value
  30108. * @param loopMode defines which loop mode you want to use (off by default)
  30109. * @param easingFunction defines the easing function to use (linear by default)
  30110. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30111. * @returns the list of animatables created for all nodes
  30112. * @example https://www.babylonjs-playground.com/#MH0VLI
  30113. */
  30114. 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[]>;
  30115. /**
  30116. * Creates a new animation, merges it with the existing animations and starts it
  30117. * @param name Name of the animation
  30118. * @param node Node which contains the scene that begins the animations
  30119. * @param targetProperty Specifies which property to animate
  30120. * @param framePerSecond The frames per second of the animation
  30121. * @param totalFrame The total number of frames
  30122. * @param from The frame at the beginning of the animation
  30123. * @param to The frame at the end of the animation
  30124. * @param loopMode Specifies the loop mode of the animation
  30125. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30126. * @param onAnimationEnd Callback to run once the animation is complete
  30127. * @returns Nullable animation
  30128. */
  30129. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30130. /**
  30131. * Transition property of an host to the target Value
  30132. * @param property The property to transition
  30133. * @param targetValue The target Value of the property
  30134. * @param host The object where the property to animate belongs
  30135. * @param scene Scene used to run the animation
  30136. * @param frameRate Framerate (in frame/s) to use
  30137. * @param transition The transition type we want to use
  30138. * @param duration The duration of the animation, in milliseconds
  30139. * @param onAnimationEnd Callback trigger at the end of the animation
  30140. * @returns Nullable animation
  30141. */
  30142. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30143. /**
  30144. * Return the array of runtime animations currently using this animation
  30145. */
  30146. get runtimeAnimations(): RuntimeAnimation[];
  30147. /**
  30148. * Specifies if any of the runtime animations are currently running
  30149. */
  30150. get hasRunningRuntimeAnimations(): boolean;
  30151. /**
  30152. * Initializes the animation
  30153. * @param name Name of the animation
  30154. * @param targetProperty Property to animate
  30155. * @param framePerSecond The frames per second of the animation
  30156. * @param dataType The data type of the animation
  30157. * @param loopMode The loop mode of the animation
  30158. * @param enableBlending Specifies if blending should be enabled
  30159. */
  30160. constructor(
  30161. /**Name of the animation */
  30162. name: string,
  30163. /**Property to animate */
  30164. targetProperty: string,
  30165. /**The frames per second of the animation */
  30166. framePerSecond: number,
  30167. /**The data type of the animation */
  30168. dataType: number,
  30169. /**The loop mode of the animation */
  30170. loopMode?: number | undefined,
  30171. /**Specifies if blending should be enabled */
  30172. enableBlending?: boolean | undefined);
  30173. /**
  30174. * Converts the animation to a string
  30175. * @param fullDetails support for multiple levels of logging within scene loading
  30176. * @returns String form of the animation
  30177. */
  30178. toString(fullDetails?: boolean): string;
  30179. /**
  30180. * Add an event to this animation
  30181. * @param event Event to add
  30182. */
  30183. addEvent(event: AnimationEvent): void;
  30184. /**
  30185. * Remove all events found at the given frame
  30186. * @param frame The frame to remove events from
  30187. */
  30188. removeEvents(frame: number): void;
  30189. /**
  30190. * Retrieves all the events from the animation
  30191. * @returns Events from the animation
  30192. */
  30193. getEvents(): AnimationEvent[];
  30194. /**
  30195. * Creates an animation range
  30196. * @param name Name of the animation range
  30197. * @param from Starting frame of the animation range
  30198. * @param to Ending frame of the animation
  30199. */
  30200. createRange(name: string, from: number, to: number): void;
  30201. /**
  30202. * Deletes an animation range by name
  30203. * @param name Name of the animation range to delete
  30204. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30205. */
  30206. deleteRange(name: string, deleteFrames?: boolean): void;
  30207. /**
  30208. * Gets the animation range by name, or null if not defined
  30209. * @param name Name of the animation range
  30210. * @returns Nullable animation range
  30211. */
  30212. getRange(name: string): Nullable<AnimationRange>;
  30213. /**
  30214. * Gets the key frames from the animation
  30215. * @returns The key frames of the animation
  30216. */
  30217. getKeys(): Array<IAnimationKey>;
  30218. /**
  30219. * Gets the highest frame rate of the animation
  30220. * @returns Highest frame rate of the animation
  30221. */
  30222. getHighestFrame(): number;
  30223. /**
  30224. * Gets the easing function of the animation
  30225. * @returns Easing function of the animation
  30226. */
  30227. getEasingFunction(): IEasingFunction;
  30228. /**
  30229. * Sets the easing function of the animation
  30230. * @param easingFunction A custom mathematical formula for animation
  30231. */
  30232. setEasingFunction(easingFunction: EasingFunction): void;
  30233. /**
  30234. * Interpolates a scalar linearly
  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. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30241. /**
  30242. * Interpolates a scalar 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 Interpolated scalar value
  30249. */
  30250. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30251. /**
  30252. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  30257. */
  30258. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30259. /**
  30260. * Interpolates a quaternion cubically
  30261. * @param startValue Start value of the animation curve
  30262. * @param outTangent End tangent of the animation curve
  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 quaternion value
  30267. */
  30268. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30269. /**
  30270. * Interpolates a Vector3 linearl
  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 scalar value
  30275. */
  30276. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30277. /**
  30278. * Interpolates a Vector3 cubically
  30279. * @param startValue Start value of the animation curve
  30280. * @param outTangent End tangent of the animation
  30281. * @param endValue End value of the animation curve
  30282. * @param inTangent Start tangent of the animation curve
  30283. * @param gradient Scalar amount to interpolate
  30284. * @returns InterpolatedVector3 value
  30285. */
  30286. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30287. /**
  30288. * Interpolates a Vector2 linearly
  30289. * @param startValue Start value of the animation curve
  30290. * @param endValue End value of the animation curve
  30291. * @param gradient Scalar amount to interpolate
  30292. * @returns Interpolated Vector2 value
  30293. */
  30294. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30295. /**
  30296. * Interpolates a Vector2 cubically
  30297. * @param startValue Start value of the animation curve
  30298. * @param outTangent End tangent of the animation
  30299. * @param endValue End value of the animation curve
  30300. * @param inTangent Start tangent of the animation curve
  30301. * @param gradient Scalar amount to interpolate
  30302. * @returns Interpolated Vector2 value
  30303. */
  30304. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30305. /**
  30306. * Interpolates a size linearly
  30307. * @param startValue Start value of the animation curve
  30308. * @param endValue End value of the animation curve
  30309. * @param gradient Scalar amount to interpolate
  30310. * @returns Interpolated Size value
  30311. */
  30312. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30313. /**
  30314. * Interpolates a Color3 linearly
  30315. * @param startValue Start value of the animation curve
  30316. * @param endValue End value of the animation curve
  30317. * @param gradient Scalar amount to interpolate
  30318. * @returns Interpolated Color3 value
  30319. */
  30320. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30321. /**
  30322. * Interpolates a Color4 linearly
  30323. * @param startValue Start value of the animation curve
  30324. * @param endValue End value of the animation curve
  30325. * @param gradient Scalar amount to interpolate
  30326. * @returns Interpolated Color3 value
  30327. */
  30328. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30329. /**
  30330. * @hidden Internal use only
  30331. */
  30332. _getKeyValue(value: any): any;
  30333. /**
  30334. * @hidden Internal use only
  30335. */
  30336. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30337. /**
  30338. * Defines the function to use to interpolate matrices
  30339. * @param startValue defines the start matrix
  30340. * @param endValue defines the end matrix
  30341. * @param gradient defines the gradient between both matrices
  30342. * @param result defines an optional target matrix where to store the interpolation
  30343. * @returns the interpolated matrix
  30344. */
  30345. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30346. /**
  30347. * Makes a copy of the animation
  30348. * @returns Cloned animation
  30349. */
  30350. clone(): Animation;
  30351. /**
  30352. * Sets the key frames of the animation
  30353. * @param values The animation key frames to set
  30354. */
  30355. setKeys(values: Array<IAnimationKey>): void;
  30356. /**
  30357. * Serializes the animation to an object
  30358. * @returns Serialized object
  30359. */
  30360. serialize(): any;
  30361. /**
  30362. * Float animation type
  30363. */
  30364. static readonly ANIMATIONTYPE_FLOAT: number;
  30365. /**
  30366. * Vector3 animation type
  30367. */
  30368. static readonly ANIMATIONTYPE_VECTOR3: number;
  30369. /**
  30370. * Quaternion animation type
  30371. */
  30372. static readonly ANIMATIONTYPE_QUATERNION: number;
  30373. /**
  30374. * Matrix animation type
  30375. */
  30376. static readonly ANIMATIONTYPE_MATRIX: number;
  30377. /**
  30378. * Color3 animation type
  30379. */
  30380. static readonly ANIMATIONTYPE_COLOR3: number;
  30381. /**
  30382. * Color3 animation type
  30383. */
  30384. static readonly ANIMATIONTYPE_COLOR4: number;
  30385. /**
  30386. * Vector2 animation type
  30387. */
  30388. static readonly ANIMATIONTYPE_VECTOR2: number;
  30389. /**
  30390. * Size animation type
  30391. */
  30392. static readonly ANIMATIONTYPE_SIZE: number;
  30393. /**
  30394. * Relative Loop Mode
  30395. */
  30396. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30397. /**
  30398. * Cycle Loop Mode
  30399. */
  30400. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30401. /**
  30402. * Constant Loop Mode
  30403. */
  30404. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30405. /** @hidden */
  30406. static _UniversalLerp(left: any, right: any, amount: number): any;
  30407. /**
  30408. * Parses an animation object and creates an animation
  30409. * @param parsedAnimation Parsed animation object
  30410. * @returns Animation object
  30411. */
  30412. static Parse(parsedAnimation: any): Animation;
  30413. /**
  30414. * Appends the serialized animations from the source animations
  30415. * @param source Source containing the animations
  30416. * @param destination Target to store the animations
  30417. */
  30418. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30419. }
  30420. }
  30421. declare module "babylonjs/Animations/animatable.interface" {
  30422. import { Nullable } from "babylonjs/types";
  30423. import { Animation } from "babylonjs/Animations/animation";
  30424. /**
  30425. * Interface containing an array of animations
  30426. */
  30427. export interface IAnimatable {
  30428. /**
  30429. * Array of animations
  30430. */
  30431. animations: Nullable<Array<Animation>>;
  30432. }
  30433. }
  30434. declare module "babylonjs/Misc/decorators" {
  30435. import { Nullable } from "babylonjs/types";
  30436. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30437. import { Scene } from "babylonjs/scene";
  30438. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30439. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30443. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30444. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30446. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30447. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30448. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30449. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30450. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30451. /**
  30452. * Decorator used to define property that can be serialized as reference to a camera
  30453. * @param sourceName defines the name of the property to decorate
  30454. */
  30455. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30456. /**
  30457. * Class used to help serialization objects
  30458. */
  30459. export class SerializationHelper {
  30460. /** @hidden */
  30461. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30462. /** @hidden */
  30463. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30464. /** @hidden */
  30465. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30466. /** @hidden */
  30467. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30468. /**
  30469. * Appends the serialized animations from the source animations
  30470. * @param source Source containing the animations
  30471. * @param destination Target to store the animations
  30472. */
  30473. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30474. /**
  30475. * Static function used to serialized a specific entity
  30476. * @param entity defines the entity to serialize
  30477. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30478. * @returns a JSON compatible object representing the serialization of the entity
  30479. */
  30480. static Serialize<T>(entity: T, serializationObject?: any): any;
  30481. /**
  30482. * Creates a new entity from a serialization data object
  30483. * @param creationFunction defines a function used to instanciated the new entity
  30484. * @param source defines the source serialization data
  30485. * @param scene defines the hosting scene
  30486. * @param rootUrl defines the root url for resources
  30487. * @returns a new entity
  30488. */
  30489. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30490. /**
  30491. * Clones an object
  30492. * @param creationFunction defines the function used to instanciate the new object
  30493. * @param source defines the source object
  30494. * @returns the cloned object
  30495. */
  30496. static Clone<T>(creationFunction: () => T, source: T): T;
  30497. /**
  30498. * Instanciates a new object based on a source one (some data will be shared between both object)
  30499. * @param creationFunction defines the function used to instanciate the new object
  30500. * @param source defines the source object
  30501. * @returns the new object
  30502. */
  30503. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30504. }
  30505. }
  30506. declare module "babylonjs/Misc/guid" {
  30507. /**
  30508. * Class used to manipulate GUIDs
  30509. */
  30510. export class GUID {
  30511. /**
  30512. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30513. * Be aware Math.random() could cause collisions, but:
  30514. * "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"
  30515. * @returns a pseudo random id
  30516. */
  30517. static RandomId(): string;
  30518. }
  30519. }
  30520. declare module "babylonjs/Materials/Textures/baseTexture" {
  30521. import { Observable } from "babylonjs/Misc/observable";
  30522. import { Nullable } from "babylonjs/types";
  30523. import { Scene } from "babylonjs/scene";
  30524. import { Matrix } from "babylonjs/Maths/math.vector";
  30525. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30526. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30527. import { ISize } from "babylonjs/Maths/math.size";
  30528. import "babylonjs/Misc/fileTools";
  30529. /**
  30530. * Base class of all the textures in babylon.
  30531. * It groups all the common properties the materials, post process, lights... might need
  30532. * in order to make a correct use of the texture.
  30533. */
  30534. export class BaseTexture implements IAnimatable {
  30535. /**
  30536. * Default anisotropic filtering level for the application.
  30537. * It is set to 4 as a good tradeoff between perf and quality.
  30538. */
  30539. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30540. /**
  30541. * Gets or sets the unique id of the texture
  30542. */
  30543. uniqueId: number;
  30544. /**
  30545. * Define the name of the texture.
  30546. */
  30547. name: string;
  30548. /**
  30549. * Gets or sets an object used to store user defined information.
  30550. */
  30551. metadata: any;
  30552. /**
  30553. * For internal use only. Please do not use.
  30554. */
  30555. reservedDataStore: any;
  30556. private _hasAlpha;
  30557. /**
  30558. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30559. */
  30560. set hasAlpha(value: boolean);
  30561. get hasAlpha(): boolean;
  30562. /**
  30563. * Defines if the alpha value should be determined via the rgb values.
  30564. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30565. */
  30566. getAlphaFromRGB: boolean;
  30567. /**
  30568. * Intensity or strength of the texture.
  30569. * It is commonly used by materials to fine tune the intensity of the texture
  30570. */
  30571. level: number;
  30572. /**
  30573. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30574. * This is part of the texture as textures usually maps to one uv set.
  30575. */
  30576. coordinatesIndex: number;
  30577. private _coordinatesMode;
  30578. /**
  30579. * How a texture is mapped.
  30580. *
  30581. * | Value | Type | Description |
  30582. * | ----- | ----------------------------------- | ----------- |
  30583. * | 0 | EXPLICIT_MODE | |
  30584. * | 1 | SPHERICAL_MODE | |
  30585. * | 2 | PLANAR_MODE | |
  30586. * | 3 | CUBIC_MODE | |
  30587. * | 4 | PROJECTION_MODE | |
  30588. * | 5 | SKYBOX_MODE | |
  30589. * | 6 | INVCUBIC_MODE | |
  30590. * | 7 | EQUIRECTANGULAR_MODE | |
  30591. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30592. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30593. */
  30594. set coordinatesMode(value: number);
  30595. get coordinatesMode(): number;
  30596. /**
  30597. * | Value | Type | Description |
  30598. * | ----- | ------------------ | ----------- |
  30599. * | 0 | CLAMP_ADDRESSMODE | |
  30600. * | 1 | WRAP_ADDRESSMODE | |
  30601. * | 2 | MIRROR_ADDRESSMODE | |
  30602. */
  30603. wrapU: number;
  30604. /**
  30605. * | Value | Type | Description |
  30606. * | ----- | ------------------ | ----------- |
  30607. * | 0 | CLAMP_ADDRESSMODE | |
  30608. * | 1 | WRAP_ADDRESSMODE | |
  30609. * | 2 | MIRROR_ADDRESSMODE | |
  30610. */
  30611. wrapV: number;
  30612. /**
  30613. * | Value | Type | Description |
  30614. * | ----- | ------------------ | ----------- |
  30615. * | 0 | CLAMP_ADDRESSMODE | |
  30616. * | 1 | WRAP_ADDRESSMODE | |
  30617. * | 2 | MIRROR_ADDRESSMODE | |
  30618. */
  30619. wrapR: number;
  30620. /**
  30621. * With compliant hardware and browser (supporting anisotropic filtering)
  30622. * this defines the level of anisotropic filtering in the texture.
  30623. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30624. */
  30625. anisotropicFilteringLevel: number;
  30626. /**
  30627. * Define if the texture is a cube texture or if false a 2d texture.
  30628. */
  30629. get isCube(): boolean;
  30630. set isCube(value: boolean);
  30631. /**
  30632. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30633. */
  30634. get is3D(): boolean;
  30635. set is3D(value: boolean);
  30636. /**
  30637. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30638. */
  30639. get is2DArray(): boolean;
  30640. set is2DArray(value: boolean);
  30641. /**
  30642. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30643. * HDR texture are usually stored in linear space.
  30644. * This only impacts the PBR and Background materials
  30645. */
  30646. gammaSpace: boolean;
  30647. /**
  30648. * Gets or sets whether or not the texture contains RGBD data.
  30649. */
  30650. get isRGBD(): boolean;
  30651. set isRGBD(value: boolean);
  30652. /**
  30653. * Is Z inverted in the texture (useful in a cube texture).
  30654. */
  30655. invertZ: boolean;
  30656. /**
  30657. * Are mip maps generated for this texture or not.
  30658. */
  30659. get noMipmap(): boolean;
  30660. /**
  30661. * @hidden
  30662. */
  30663. lodLevelInAlpha: boolean;
  30664. /**
  30665. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30666. */
  30667. get lodGenerationOffset(): number;
  30668. set lodGenerationOffset(value: number);
  30669. /**
  30670. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30671. */
  30672. get lodGenerationScale(): number;
  30673. set lodGenerationScale(value: number);
  30674. /**
  30675. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30676. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30677. * average roughness values.
  30678. */
  30679. get linearSpecularLOD(): boolean;
  30680. set linearSpecularLOD(value: boolean);
  30681. /**
  30682. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30683. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30684. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30685. */
  30686. get irradianceTexture(): Nullable<BaseTexture>;
  30687. set irradianceTexture(value: Nullable<BaseTexture>);
  30688. /**
  30689. * Define if the texture is a render target.
  30690. */
  30691. isRenderTarget: boolean;
  30692. /**
  30693. * Define the unique id of the texture in the scene.
  30694. */
  30695. get uid(): string;
  30696. /**
  30697. * Return a string representation of the texture.
  30698. * @returns the texture as a string
  30699. */
  30700. toString(): string;
  30701. /**
  30702. * Get the class name of the texture.
  30703. * @returns "BaseTexture"
  30704. */
  30705. getClassName(): string;
  30706. /**
  30707. * Define the list of animation attached to the texture.
  30708. */
  30709. animations: import("babylonjs/Animations/animation").Animation[];
  30710. /**
  30711. * An event triggered when the texture is disposed.
  30712. */
  30713. onDisposeObservable: Observable<BaseTexture>;
  30714. private _onDisposeObserver;
  30715. /**
  30716. * Callback triggered when the texture has been disposed.
  30717. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30718. */
  30719. set onDispose(callback: () => void);
  30720. /**
  30721. * Define the current state of the loading sequence when in delayed load mode.
  30722. */
  30723. delayLoadState: number;
  30724. private _scene;
  30725. /** @hidden */
  30726. _texture: Nullable<InternalTexture>;
  30727. private _uid;
  30728. /**
  30729. * Define if the texture is preventinga material to render or not.
  30730. * If not and the texture is not ready, the engine will use a default black texture instead.
  30731. */
  30732. get isBlocking(): boolean;
  30733. /**
  30734. * Instantiates a new BaseTexture.
  30735. * Base class of all the textures in babylon.
  30736. * It groups all the common properties the materials, post process, lights... might need
  30737. * in order to make a correct use of the texture.
  30738. * @param scene Define the scene the texture blongs to
  30739. */
  30740. constructor(scene: Nullable<Scene>);
  30741. /**
  30742. * Get the scene the texture belongs to.
  30743. * @returns the scene or null if undefined
  30744. */
  30745. getScene(): Nullable<Scene>;
  30746. /**
  30747. * Get the texture transform matrix used to offset tile the texture for istance.
  30748. * @returns the transformation matrix
  30749. */
  30750. getTextureMatrix(): Matrix;
  30751. /**
  30752. * Get the texture reflection matrix used to rotate/transform the reflection.
  30753. * @returns the reflection matrix
  30754. */
  30755. getReflectionTextureMatrix(): Matrix;
  30756. /**
  30757. * Get the underlying lower level texture from Babylon.
  30758. * @returns the insternal texture
  30759. */
  30760. getInternalTexture(): Nullable<InternalTexture>;
  30761. /**
  30762. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30763. * @returns true if ready or not blocking
  30764. */
  30765. isReadyOrNotBlocking(): boolean;
  30766. /**
  30767. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30768. * @returns true if fully ready
  30769. */
  30770. isReady(): boolean;
  30771. private _cachedSize;
  30772. /**
  30773. * Get the size of the texture.
  30774. * @returns the texture size.
  30775. */
  30776. getSize(): ISize;
  30777. /**
  30778. * Get the base size of the texture.
  30779. * It can be different from the size if the texture has been resized for POT for instance
  30780. * @returns the base size
  30781. */
  30782. getBaseSize(): ISize;
  30783. /**
  30784. * Update the sampling mode of the texture.
  30785. * Default is Trilinear mode.
  30786. *
  30787. * | Value | Type | Description |
  30788. * | ----- | ------------------ | ----------- |
  30789. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30790. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30791. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30792. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30793. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30794. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30795. * | 7 | NEAREST_LINEAR | |
  30796. * | 8 | NEAREST_NEAREST | |
  30797. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30798. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30799. * | 11 | LINEAR_LINEAR | |
  30800. * | 12 | LINEAR_NEAREST | |
  30801. *
  30802. * > _mag_: magnification filter (close to the viewer)
  30803. * > _min_: minification filter (far from the viewer)
  30804. * > _mip_: filter used between mip map levels
  30805. *@param samplingMode Define the new sampling mode of the texture
  30806. */
  30807. updateSamplingMode(samplingMode: number): void;
  30808. /**
  30809. * Scales the texture if is `canRescale()`
  30810. * @param ratio the resize factor we want to use to rescale
  30811. */
  30812. scale(ratio: number): void;
  30813. /**
  30814. * Get if the texture can rescale.
  30815. */
  30816. get canRescale(): boolean;
  30817. /** @hidden */
  30818. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30819. /** @hidden */
  30820. _rebuild(): void;
  30821. /**
  30822. * Triggers the load sequence in delayed load mode.
  30823. */
  30824. delayLoad(): void;
  30825. /**
  30826. * Clones the texture.
  30827. * @returns the cloned texture
  30828. */
  30829. clone(): Nullable<BaseTexture>;
  30830. /**
  30831. * Get the texture underlying type (INT, FLOAT...)
  30832. */
  30833. get textureType(): number;
  30834. /**
  30835. * Get the texture underlying format (RGB, RGBA...)
  30836. */
  30837. get textureFormat(): number;
  30838. /**
  30839. * Indicates that textures need to be re-calculated for all materials
  30840. */
  30841. protected _markAllSubMeshesAsTexturesDirty(): void;
  30842. /**
  30843. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30844. * This will returns an RGBA array buffer containing either in values (0-255) or
  30845. * float values (0-1) depending of the underlying buffer type.
  30846. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30847. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30848. * @param buffer defines a user defined buffer to fill with data (can be null)
  30849. * @returns The Array buffer containing the pixels data.
  30850. */
  30851. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30852. /**
  30853. * Release and destroy the underlying lower level texture aka internalTexture.
  30854. */
  30855. releaseInternalTexture(): void;
  30856. /** @hidden */
  30857. get _lodTextureHigh(): Nullable<BaseTexture>;
  30858. /** @hidden */
  30859. get _lodTextureMid(): Nullable<BaseTexture>;
  30860. /** @hidden */
  30861. get _lodTextureLow(): Nullable<BaseTexture>;
  30862. /**
  30863. * Dispose the texture and release its associated resources.
  30864. */
  30865. dispose(): void;
  30866. /**
  30867. * Serialize the texture into a JSON representation that can be parsed later on.
  30868. * @returns the JSON representation of the texture
  30869. */
  30870. serialize(): any;
  30871. /**
  30872. * Helper function to be called back once a list of texture contains only ready textures.
  30873. * @param textures Define the list of textures to wait for
  30874. * @param callback Define the callback triggered once the entire list will be ready
  30875. */
  30876. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30877. }
  30878. }
  30879. declare module "babylonjs/Materials/effect" {
  30880. import { Observable } from "babylonjs/Misc/observable";
  30881. import { Nullable } from "babylonjs/types";
  30882. import { IDisposable } from "babylonjs/scene";
  30883. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30884. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30885. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30886. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30887. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30888. import { Engine } from "babylonjs/Engines/engine";
  30889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30892. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30893. /**
  30894. * Options to be used when creating an effect.
  30895. */
  30896. export interface IEffectCreationOptions {
  30897. /**
  30898. * Atrributes that will be used in the shader.
  30899. */
  30900. attributes: string[];
  30901. /**
  30902. * Uniform varible names that will be set in the shader.
  30903. */
  30904. uniformsNames: string[];
  30905. /**
  30906. * Uniform buffer variable names that will be set in the shader.
  30907. */
  30908. uniformBuffersNames: string[];
  30909. /**
  30910. * Sampler texture variable names that will be set in the shader.
  30911. */
  30912. samplers: string[];
  30913. /**
  30914. * Define statements that will be set in the shader.
  30915. */
  30916. defines: any;
  30917. /**
  30918. * Possible fallbacks for this effect to improve performance when needed.
  30919. */
  30920. fallbacks: Nullable<IEffectFallbacks>;
  30921. /**
  30922. * Callback that will be called when the shader is compiled.
  30923. */
  30924. onCompiled: Nullable<(effect: Effect) => void>;
  30925. /**
  30926. * Callback that will be called if an error occurs during shader compilation.
  30927. */
  30928. onError: Nullable<(effect: Effect, errors: string) => void>;
  30929. /**
  30930. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30931. */
  30932. indexParameters?: any;
  30933. /**
  30934. * Max number of lights that can be used in the shader.
  30935. */
  30936. maxSimultaneousLights?: number;
  30937. /**
  30938. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30939. */
  30940. transformFeedbackVaryings?: Nullable<string[]>;
  30941. }
  30942. /**
  30943. * Effect containing vertex and fragment shader that can be executed on an object.
  30944. */
  30945. export class Effect implements IDisposable {
  30946. /**
  30947. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30948. */
  30949. static ShadersRepository: string;
  30950. /**
  30951. * Enable logging of the shader code when a compilation error occurs
  30952. */
  30953. static LogShaderCodeOnCompilationError: boolean;
  30954. /**
  30955. * Name of the effect.
  30956. */
  30957. name: any;
  30958. /**
  30959. * String container all the define statements that should be set on the shader.
  30960. */
  30961. defines: string;
  30962. /**
  30963. * Callback that will be called when the shader is compiled.
  30964. */
  30965. onCompiled: Nullable<(effect: Effect) => void>;
  30966. /**
  30967. * Callback that will be called if an error occurs during shader compilation.
  30968. */
  30969. onError: Nullable<(effect: Effect, errors: string) => void>;
  30970. /**
  30971. * Callback that will be called when effect is bound.
  30972. */
  30973. onBind: Nullable<(effect: Effect) => void>;
  30974. /**
  30975. * Unique ID of the effect.
  30976. */
  30977. uniqueId: number;
  30978. /**
  30979. * Observable that will be called when the shader is compiled.
  30980. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30981. */
  30982. onCompileObservable: Observable<Effect>;
  30983. /**
  30984. * Observable that will be called if an error occurs during shader compilation.
  30985. */
  30986. onErrorObservable: Observable<Effect>;
  30987. /** @hidden */
  30988. _onBindObservable: Nullable<Observable<Effect>>;
  30989. /**
  30990. * @hidden
  30991. * Specifies if the effect was previously ready
  30992. */
  30993. _wasPreviouslyReady: boolean;
  30994. /**
  30995. * Observable that will be called when effect is bound.
  30996. */
  30997. get onBindObservable(): Observable<Effect>;
  30998. /** @hidden */
  30999. _bonesComputationForcedToCPU: boolean;
  31000. private static _uniqueIdSeed;
  31001. private _engine;
  31002. private _uniformBuffersNames;
  31003. private _uniformsNames;
  31004. private _samplerList;
  31005. private _samplers;
  31006. private _isReady;
  31007. private _compilationError;
  31008. private _allFallbacksProcessed;
  31009. private _attributesNames;
  31010. private _attributes;
  31011. private _attributeLocationByName;
  31012. private _uniforms;
  31013. /**
  31014. * Key for the effect.
  31015. * @hidden
  31016. */
  31017. _key: string;
  31018. private _indexParameters;
  31019. private _fallbacks;
  31020. private _vertexSourceCode;
  31021. private _fragmentSourceCode;
  31022. private _vertexSourceCodeOverride;
  31023. private _fragmentSourceCodeOverride;
  31024. private _transformFeedbackVaryings;
  31025. /**
  31026. * Compiled shader to webGL program.
  31027. * @hidden
  31028. */
  31029. _pipelineContext: Nullable<IPipelineContext>;
  31030. private _valueCache;
  31031. private static _baseCache;
  31032. /**
  31033. * Instantiates an effect.
  31034. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31035. * @param baseName Name of the effect.
  31036. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31037. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31038. * @param samplers List of sampler variables that will be passed to the shader.
  31039. * @param engine Engine to be used to render the effect
  31040. * @param defines Define statements to be added to the shader.
  31041. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31042. * @param onCompiled Callback that will be called when the shader is compiled.
  31043. * @param onError Callback that will be called if an error occurs during shader compilation.
  31044. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31045. */
  31046. 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);
  31047. private _useFinalCode;
  31048. /**
  31049. * Unique key for this effect
  31050. */
  31051. get key(): string;
  31052. /**
  31053. * If the effect has been compiled and prepared.
  31054. * @returns if the effect is compiled and prepared.
  31055. */
  31056. isReady(): boolean;
  31057. private _isReadyInternal;
  31058. /**
  31059. * The engine the effect was initialized with.
  31060. * @returns the engine.
  31061. */
  31062. getEngine(): Engine;
  31063. /**
  31064. * The pipeline context for this effect
  31065. * @returns the associated pipeline context
  31066. */
  31067. getPipelineContext(): Nullable<IPipelineContext>;
  31068. /**
  31069. * The set of names of attribute variables for the shader.
  31070. * @returns An array of attribute names.
  31071. */
  31072. getAttributesNames(): string[];
  31073. /**
  31074. * Returns the attribute at the given index.
  31075. * @param index The index of the attribute.
  31076. * @returns The location of the attribute.
  31077. */
  31078. getAttributeLocation(index: number): number;
  31079. /**
  31080. * Returns the attribute based on the name of the variable.
  31081. * @param name of the attribute to look up.
  31082. * @returns the attribute location.
  31083. */
  31084. getAttributeLocationByName(name: string): number;
  31085. /**
  31086. * The number of attributes.
  31087. * @returns the numnber of attributes.
  31088. */
  31089. getAttributesCount(): number;
  31090. /**
  31091. * Gets the index of a uniform variable.
  31092. * @param uniformName of the uniform to look up.
  31093. * @returns the index.
  31094. */
  31095. getUniformIndex(uniformName: string): number;
  31096. /**
  31097. * Returns the attribute based on the name of the variable.
  31098. * @param uniformName of the uniform to look up.
  31099. * @returns the location of the uniform.
  31100. */
  31101. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31102. /**
  31103. * Returns an array of sampler variable names
  31104. * @returns The array of sampler variable neames.
  31105. */
  31106. getSamplers(): string[];
  31107. /**
  31108. * The error from the last compilation.
  31109. * @returns the error string.
  31110. */
  31111. getCompilationError(): string;
  31112. /**
  31113. * Gets a boolean indicating that all fallbacks were used during compilation
  31114. * @returns true if all fallbacks were used
  31115. */
  31116. allFallbacksProcessed(): boolean;
  31117. /**
  31118. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31119. * @param func The callback to be used.
  31120. */
  31121. executeWhenCompiled(func: (effect: Effect) => void): void;
  31122. private _checkIsReady;
  31123. private _loadShader;
  31124. /**
  31125. * Recompiles the webGL program
  31126. * @param vertexSourceCode The source code for the vertex shader.
  31127. * @param fragmentSourceCode The source code for the fragment shader.
  31128. * @param onCompiled Callback called when completed.
  31129. * @param onError Callback called on error.
  31130. * @hidden
  31131. */
  31132. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31133. /**
  31134. * Prepares the effect
  31135. * @hidden
  31136. */
  31137. _prepareEffect(): void;
  31138. private _getShaderCodeAndErrorLine;
  31139. private _processCompilationErrors;
  31140. /**
  31141. * Checks if the effect is supported. (Must be called after compilation)
  31142. */
  31143. get isSupported(): boolean;
  31144. /**
  31145. * Binds a texture to the engine to be used as output of the shader.
  31146. * @param channel Name of the output variable.
  31147. * @param texture Texture to bind.
  31148. * @hidden
  31149. */
  31150. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31151. /**
  31152. * Sets a texture on the engine to be used in the shader.
  31153. * @param channel Name of the sampler variable.
  31154. * @param texture Texture to set.
  31155. */
  31156. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31157. /**
  31158. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31159. * @param channel Name of the sampler variable.
  31160. * @param texture Texture to set.
  31161. */
  31162. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31163. /**
  31164. * Sets an array of textures on the engine to be used in the shader.
  31165. * @param channel Name of the variable.
  31166. * @param textures Textures to set.
  31167. */
  31168. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31169. /**
  31170. * 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)
  31171. * @param channel Name of the sampler variable.
  31172. * @param postProcess Post process to get the input texture from.
  31173. */
  31174. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31175. /**
  31176. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31177. * 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)
  31178. * @param channel Name of the sampler variable.
  31179. * @param postProcess Post process to get the output texture from.
  31180. */
  31181. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31182. /** @hidden */
  31183. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31184. /** @hidden */
  31185. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31186. /** @hidden */
  31187. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31188. /** @hidden */
  31189. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31190. /**
  31191. * Binds a buffer to a uniform.
  31192. * @param buffer Buffer to bind.
  31193. * @param name Name of the uniform variable to bind to.
  31194. */
  31195. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31196. /**
  31197. * Binds block to a uniform.
  31198. * @param blockName Name of the block to bind.
  31199. * @param index Index to bind.
  31200. */
  31201. bindUniformBlock(blockName: string, index: number): void;
  31202. /**
  31203. * Sets an interger value on a uniform variable.
  31204. * @param uniformName Name of the variable.
  31205. * @param value Value to be set.
  31206. * @returns this effect.
  31207. */
  31208. setInt(uniformName: string, value: number): Effect;
  31209. /**
  31210. * Sets an int array on a uniform variable.
  31211. * @param uniformName Name of the variable.
  31212. * @param array array to be set.
  31213. * @returns this effect.
  31214. */
  31215. setIntArray(uniformName: string, array: Int32Array): Effect;
  31216. /**
  31217. * 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)
  31218. * @param uniformName Name of the variable.
  31219. * @param array array to be set.
  31220. * @returns this effect.
  31221. */
  31222. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31223. /**
  31224. * 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)
  31225. * @param uniformName Name of the variable.
  31226. * @param array array to be set.
  31227. * @returns this effect.
  31228. */
  31229. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31230. /**
  31231. * 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)
  31232. * @param uniformName Name of the variable.
  31233. * @param array array to be set.
  31234. * @returns this effect.
  31235. */
  31236. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31237. /**
  31238. * Sets an float array on a uniform variable.
  31239. * @param uniformName Name of the variable.
  31240. * @param array array to be set.
  31241. * @returns this effect.
  31242. */
  31243. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31244. /**
  31245. * 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)
  31246. * @param uniformName Name of the variable.
  31247. * @param array array to be set.
  31248. * @returns this effect.
  31249. */
  31250. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31251. /**
  31252. * 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)
  31253. * @param uniformName Name of the variable.
  31254. * @param array array to be set.
  31255. * @returns this effect.
  31256. */
  31257. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31258. /**
  31259. * 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)
  31260. * @param uniformName Name of the variable.
  31261. * @param array array to be set.
  31262. * @returns this effect.
  31263. */
  31264. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31265. /**
  31266. * Sets an array on a uniform variable.
  31267. * @param uniformName Name of the variable.
  31268. * @param array array to be set.
  31269. * @returns this effect.
  31270. */
  31271. setArray(uniformName: string, array: number[]): Effect;
  31272. /**
  31273. * 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)
  31274. * @param uniformName Name of the variable.
  31275. * @param array array to be set.
  31276. * @returns this effect.
  31277. */
  31278. setArray2(uniformName: string, array: number[]): Effect;
  31279. /**
  31280. * 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)
  31281. * @param uniformName Name of the variable.
  31282. * @param array array to be set.
  31283. * @returns this effect.
  31284. */
  31285. setArray3(uniformName: string, array: number[]): Effect;
  31286. /**
  31287. * 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)
  31288. * @param uniformName Name of the variable.
  31289. * @param array array to be set.
  31290. * @returns this effect.
  31291. */
  31292. setArray4(uniformName: string, array: number[]): Effect;
  31293. /**
  31294. * Sets matrices on a uniform variable.
  31295. * @param uniformName Name of the variable.
  31296. * @param matrices matrices to be set.
  31297. * @returns this effect.
  31298. */
  31299. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31300. /**
  31301. * Sets matrix on a uniform variable.
  31302. * @param uniformName Name of the variable.
  31303. * @param matrix matrix to be set.
  31304. * @returns this effect.
  31305. */
  31306. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31307. /**
  31308. * 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)
  31309. * @param uniformName Name of the variable.
  31310. * @param matrix matrix to be set.
  31311. * @returns this effect.
  31312. */
  31313. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31314. /**
  31315. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31316. * @param uniformName Name of the variable.
  31317. * @param matrix matrix to be set.
  31318. * @returns this effect.
  31319. */
  31320. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31321. /**
  31322. * Sets a float on a uniform variable.
  31323. * @param uniformName Name of the variable.
  31324. * @param value value to be set.
  31325. * @returns this effect.
  31326. */
  31327. setFloat(uniformName: string, value: number): Effect;
  31328. /**
  31329. * Sets a boolean on a uniform variable.
  31330. * @param uniformName Name of the variable.
  31331. * @param bool value to be set.
  31332. * @returns this effect.
  31333. */
  31334. setBool(uniformName: string, bool: boolean): Effect;
  31335. /**
  31336. * Sets a Vector2 on a uniform variable.
  31337. * @param uniformName Name of the variable.
  31338. * @param vector2 vector2 to be set.
  31339. * @returns this effect.
  31340. */
  31341. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31342. /**
  31343. * Sets a float2 on a uniform variable.
  31344. * @param uniformName Name of the variable.
  31345. * @param x First float in float2.
  31346. * @param y Second float in float2.
  31347. * @returns this effect.
  31348. */
  31349. setFloat2(uniformName: string, x: number, y: number): Effect;
  31350. /**
  31351. * Sets a Vector3 on a uniform variable.
  31352. * @param uniformName Name of the variable.
  31353. * @param vector3 Value to be set.
  31354. * @returns this effect.
  31355. */
  31356. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31357. /**
  31358. * Sets a float3 on a uniform variable.
  31359. * @param uniformName Name of the variable.
  31360. * @param x First float in float3.
  31361. * @param y Second float in float3.
  31362. * @param z Third float in float3.
  31363. * @returns this effect.
  31364. */
  31365. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31366. /**
  31367. * Sets a Vector4 on a uniform variable.
  31368. * @param uniformName Name of the variable.
  31369. * @param vector4 Value to be set.
  31370. * @returns this effect.
  31371. */
  31372. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31373. /**
  31374. * Sets a float4 on a uniform variable.
  31375. * @param uniformName Name of the variable.
  31376. * @param x First float in float4.
  31377. * @param y Second float in float4.
  31378. * @param z Third float in float4.
  31379. * @param w Fourth float in float4.
  31380. * @returns this effect.
  31381. */
  31382. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31383. /**
  31384. * Sets a Color3 on a uniform variable.
  31385. * @param uniformName Name of the variable.
  31386. * @param color3 Value to be set.
  31387. * @returns this effect.
  31388. */
  31389. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31390. /**
  31391. * Sets a Color4 on a uniform variable.
  31392. * @param uniformName Name of the variable.
  31393. * @param color3 Value to be set.
  31394. * @param alpha Alpha value to be set.
  31395. * @returns this effect.
  31396. */
  31397. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31398. /**
  31399. * Sets a Color4 on a uniform variable
  31400. * @param uniformName defines the name of the variable
  31401. * @param color4 defines the value to be set
  31402. * @returns this effect.
  31403. */
  31404. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31405. /** Release all associated resources */
  31406. dispose(): void;
  31407. /**
  31408. * This function will add a new shader to the shader store
  31409. * @param name the name of the shader
  31410. * @param pixelShader optional pixel shader content
  31411. * @param vertexShader optional vertex shader content
  31412. */
  31413. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31414. /**
  31415. * Store of each shader (The can be looked up using effect.key)
  31416. */
  31417. static ShadersStore: {
  31418. [key: string]: string;
  31419. };
  31420. /**
  31421. * Store of each included file for a shader (The can be looked up using effect.key)
  31422. */
  31423. static IncludesShadersStore: {
  31424. [key: string]: string;
  31425. };
  31426. /**
  31427. * Resets the cache of effects.
  31428. */
  31429. static ResetCache(): void;
  31430. }
  31431. }
  31432. declare module "babylonjs/Engines/engineCapabilities" {
  31433. /**
  31434. * Interface used to describe the capabilities of the engine relatively to the current browser
  31435. */
  31436. export interface EngineCapabilities {
  31437. /** Maximum textures units per fragment shader */
  31438. maxTexturesImageUnits: number;
  31439. /** Maximum texture units per vertex shader */
  31440. maxVertexTextureImageUnits: number;
  31441. /** Maximum textures units in the entire pipeline */
  31442. maxCombinedTexturesImageUnits: number;
  31443. /** Maximum texture size */
  31444. maxTextureSize: number;
  31445. /** Maximum texture samples */
  31446. maxSamples?: number;
  31447. /** Maximum cube texture size */
  31448. maxCubemapTextureSize: number;
  31449. /** Maximum render texture size */
  31450. maxRenderTextureSize: number;
  31451. /** Maximum number of vertex attributes */
  31452. maxVertexAttribs: number;
  31453. /** Maximum number of varyings */
  31454. maxVaryingVectors: number;
  31455. /** Maximum number of uniforms per vertex shader */
  31456. maxVertexUniformVectors: number;
  31457. /** Maximum number of uniforms per fragment shader */
  31458. maxFragmentUniformVectors: number;
  31459. /** Defines if standard derivates (dx/dy) are supported */
  31460. standardDerivatives: boolean;
  31461. /** Defines if s3tc texture compression is supported */
  31462. s3tc?: WEBGL_compressed_texture_s3tc;
  31463. /** Defines if pvrtc texture compression is supported */
  31464. pvrtc: any;
  31465. /** Defines if etc1 texture compression is supported */
  31466. etc1: any;
  31467. /** Defines if etc2 texture compression is supported */
  31468. etc2: any;
  31469. /** Defines if astc texture compression is supported */
  31470. astc: any;
  31471. /** Defines if float textures are supported */
  31472. textureFloat: boolean;
  31473. /** Defines if vertex array objects are supported */
  31474. vertexArrayObject: boolean;
  31475. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31476. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31477. /** Gets the maximum level of anisotropy supported */
  31478. maxAnisotropy: number;
  31479. /** Defines if instancing is supported */
  31480. instancedArrays: boolean;
  31481. /** Defines if 32 bits indices are supported */
  31482. uintIndices: boolean;
  31483. /** Defines if high precision shaders are supported */
  31484. highPrecisionShaderSupported: boolean;
  31485. /** Defines if depth reading in the fragment shader is supported */
  31486. fragmentDepthSupported: boolean;
  31487. /** Defines if float texture linear filtering is supported*/
  31488. textureFloatLinearFiltering: boolean;
  31489. /** Defines if rendering to float textures is supported */
  31490. textureFloatRender: boolean;
  31491. /** Defines if half float textures are supported*/
  31492. textureHalfFloat: boolean;
  31493. /** Defines if half float texture linear filtering is supported*/
  31494. textureHalfFloatLinearFiltering: boolean;
  31495. /** Defines if rendering to half float textures is supported */
  31496. textureHalfFloatRender: boolean;
  31497. /** Defines if textureLOD shader command is supported */
  31498. textureLOD: boolean;
  31499. /** Defines if draw buffers extension is supported */
  31500. drawBuffersExtension: boolean;
  31501. /** Defines if depth textures are supported */
  31502. depthTextureExtension: boolean;
  31503. /** Defines if float color buffer are supported */
  31504. colorBufferFloat: boolean;
  31505. /** Gets disjoint timer query extension (null if not supported) */
  31506. timerQuery?: EXT_disjoint_timer_query;
  31507. /** Defines if timestamp can be used with timer query */
  31508. canUseTimestampForTimerQuery: boolean;
  31509. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31510. multiview?: any;
  31511. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31512. oculusMultiview?: any;
  31513. /** Function used to let the system compiles shaders in background */
  31514. parallelShaderCompile?: {
  31515. COMPLETION_STATUS_KHR: number;
  31516. };
  31517. /** Max number of texture samples for MSAA */
  31518. maxMSAASamples: number;
  31519. /** Defines if the blend min max extension is supported */
  31520. blendMinMax: boolean;
  31521. }
  31522. }
  31523. declare module "babylonjs/States/depthCullingState" {
  31524. import { Nullable } from "babylonjs/types";
  31525. /**
  31526. * @hidden
  31527. **/
  31528. export class DepthCullingState {
  31529. private _isDepthTestDirty;
  31530. private _isDepthMaskDirty;
  31531. private _isDepthFuncDirty;
  31532. private _isCullFaceDirty;
  31533. private _isCullDirty;
  31534. private _isZOffsetDirty;
  31535. private _isFrontFaceDirty;
  31536. private _depthTest;
  31537. private _depthMask;
  31538. private _depthFunc;
  31539. private _cull;
  31540. private _cullFace;
  31541. private _zOffset;
  31542. private _frontFace;
  31543. /**
  31544. * Initializes the state.
  31545. */
  31546. constructor();
  31547. get isDirty(): boolean;
  31548. get zOffset(): number;
  31549. set zOffset(value: number);
  31550. get cullFace(): Nullable<number>;
  31551. set cullFace(value: Nullable<number>);
  31552. get cull(): Nullable<boolean>;
  31553. set cull(value: Nullable<boolean>);
  31554. get depthFunc(): Nullable<number>;
  31555. set depthFunc(value: Nullable<number>);
  31556. get depthMask(): boolean;
  31557. set depthMask(value: boolean);
  31558. get depthTest(): boolean;
  31559. set depthTest(value: boolean);
  31560. get frontFace(): Nullable<number>;
  31561. set frontFace(value: Nullable<number>);
  31562. reset(): void;
  31563. apply(gl: WebGLRenderingContext): void;
  31564. }
  31565. }
  31566. declare module "babylonjs/States/stencilState" {
  31567. /**
  31568. * @hidden
  31569. **/
  31570. export class StencilState {
  31571. /** 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 */
  31572. static readonly ALWAYS: number;
  31573. /** Passed to stencilOperation to specify that stencil value must be kept */
  31574. static readonly KEEP: number;
  31575. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31576. static readonly REPLACE: number;
  31577. private _isStencilTestDirty;
  31578. private _isStencilMaskDirty;
  31579. private _isStencilFuncDirty;
  31580. private _isStencilOpDirty;
  31581. private _stencilTest;
  31582. private _stencilMask;
  31583. private _stencilFunc;
  31584. private _stencilFuncRef;
  31585. private _stencilFuncMask;
  31586. private _stencilOpStencilFail;
  31587. private _stencilOpDepthFail;
  31588. private _stencilOpStencilDepthPass;
  31589. get isDirty(): boolean;
  31590. get stencilFunc(): number;
  31591. set stencilFunc(value: number);
  31592. get stencilFuncRef(): number;
  31593. set stencilFuncRef(value: number);
  31594. get stencilFuncMask(): number;
  31595. set stencilFuncMask(value: number);
  31596. get stencilOpStencilFail(): number;
  31597. set stencilOpStencilFail(value: number);
  31598. get stencilOpDepthFail(): number;
  31599. set stencilOpDepthFail(value: number);
  31600. get stencilOpStencilDepthPass(): number;
  31601. set stencilOpStencilDepthPass(value: number);
  31602. get stencilMask(): number;
  31603. set stencilMask(value: number);
  31604. get stencilTest(): boolean;
  31605. set stencilTest(value: boolean);
  31606. constructor();
  31607. reset(): void;
  31608. apply(gl: WebGLRenderingContext): void;
  31609. }
  31610. }
  31611. declare module "babylonjs/States/alphaCullingState" {
  31612. /**
  31613. * @hidden
  31614. **/
  31615. export class AlphaState {
  31616. private _isAlphaBlendDirty;
  31617. private _isBlendFunctionParametersDirty;
  31618. private _isBlendEquationParametersDirty;
  31619. private _isBlendConstantsDirty;
  31620. private _alphaBlend;
  31621. private _blendFunctionParameters;
  31622. private _blendEquationParameters;
  31623. private _blendConstants;
  31624. /**
  31625. * Initializes the state.
  31626. */
  31627. constructor();
  31628. get isDirty(): boolean;
  31629. get alphaBlend(): boolean;
  31630. set alphaBlend(value: boolean);
  31631. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31632. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31633. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31634. reset(): void;
  31635. apply(gl: WebGLRenderingContext): void;
  31636. }
  31637. }
  31638. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31639. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31640. /** @hidden */
  31641. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31642. attributeProcessor(attribute: string): string;
  31643. varyingProcessor(varying: string, isFragment: boolean): string;
  31644. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31645. }
  31646. }
  31647. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31648. /**
  31649. * Interface for attribute information associated with buffer instanciation
  31650. */
  31651. export interface InstancingAttributeInfo {
  31652. /**
  31653. * Name of the GLSL attribute
  31654. * if attribute index is not specified, this is used to retrieve the index from the effect
  31655. */
  31656. attributeName: string;
  31657. /**
  31658. * Index/offset of the attribute in the vertex shader
  31659. * if not specified, this will be computes from the name.
  31660. */
  31661. index?: number;
  31662. /**
  31663. * size of the attribute, 1, 2, 3 or 4
  31664. */
  31665. attributeSize: number;
  31666. /**
  31667. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31668. */
  31669. offset: number;
  31670. /**
  31671. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31672. * default to 1
  31673. */
  31674. divisor?: number;
  31675. /**
  31676. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31677. * default is FLOAT
  31678. */
  31679. attributeType?: number;
  31680. /**
  31681. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31682. */
  31683. normalized?: boolean;
  31684. }
  31685. }
  31686. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31687. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31688. import { Nullable } from "babylonjs/types";
  31689. module "babylonjs/Engines/thinEngine" {
  31690. interface ThinEngine {
  31691. /**
  31692. * Update a video texture
  31693. * @param texture defines the texture to update
  31694. * @param video defines the video element to use
  31695. * @param invertY defines if data must be stored with Y axis inverted
  31696. */
  31697. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31698. }
  31699. }
  31700. }
  31701. declare module "babylonjs/Materials/Textures/videoTexture" {
  31702. import { Observable } from "babylonjs/Misc/observable";
  31703. import { Nullable } from "babylonjs/types";
  31704. import { Scene } from "babylonjs/scene";
  31705. import { Texture } from "babylonjs/Materials/Textures/texture";
  31706. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31707. /**
  31708. * Settings for finer control over video usage
  31709. */
  31710. export interface VideoTextureSettings {
  31711. /**
  31712. * Applies `autoplay` to video, if specified
  31713. */
  31714. autoPlay?: boolean;
  31715. /**
  31716. * Applies `loop` to video, if specified
  31717. */
  31718. loop?: boolean;
  31719. /**
  31720. * Automatically updates internal texture from video at every frame in the render loop
  31721. */
  31722. autoUpdateTexture: boolean;
  31723. /**
  31724. * Image src displayed during the video loading or until the user interacts with the video.
  31725. */
  31726. poster?: string;
  31727. }
  31728. /**
  31729. * If you want to display a video in your scene, this is the special texture for that.
  31730. * This special texture works similar to other textures, with the exception of a few parameters.
  31731. * @see https://doc.babylonjs.com/how_to/video_texture
  31732. */
  31733. export class VideoTexture extends Texture {
  31734. /**
  31735. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31736. */
  31737. readonly autoUpdateTexture: boolean;
  31738. /**
  31739. * The video instance used by the texture internally
  31740. */
  31741. readonly video: HTMLVideoElement;
  31742. private _onUserActionRequestedObservable;
  31743. /**
  31744. * Event triggerd when a dom action is required by the user to play the video.
  31745. * This happens due to recent changes in browser policies preventing video to auto start.
  31746. */
  31747. get onUserActionRequestedObservable(): Observable<Texture>;
  31748. private _generateMipMaps;
  31749. private _engine;
  31750. private _stillImageCaptured;
  31751. private _displayingPosterTexture;
  31752. private _settings;
  31753. private _createInternalTextureOnEvent;
  31754. private _frameId;
  31755. private _currentSrc;
  31756. /**
  31757. * Creates a video texture.
  31758. * If you want to display a video in your scene, this is the special texture for that.
  31759. * This special texture works similar to other textures, with the exception of a few parameters.
  31760. * @see https://doc.babylonjs.com/how_to/video_texture
  31761. * @param name optional name, will detect from video source, if not defined
  31762. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31763. * @param scene is obviously the current scene.
  31764. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31765. * @param invertY is false by default but can be used to invert video on Y axis
  31766. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31767. * @param settings allows finer control over video usage
  31768. */
  31769. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31770. private _getName;
  31771. private _getVideo;
  31772. private _createInternalTexture;
  31773. private reset;
  31774. /**
  31775. * @hidden Internal method to initiate `update`.
  31776. */
  31777. _rebuild(): void;
  31778. /**
  31779. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31780. */
  31781. update(): void;
  31782. /**
  31783. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31784. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31785. */
  31786. updateTexture(isVisible: boolean): void;
  31787. protected _updateInternalTexture: () => void;
  31788. /**
  31789. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31790. * @param url New url.
  31791. */
  31792. updateURL(url: string): void;
  31793. /**
  31794. * Clones the texture.
  31795. * @returns the cloned texture
  31796. */
  31797. clone(): VideoTexture;
  31798. /**
  31799. * Dispose the texture and release its associated resources.
  31800. */
  31801. dispose(): void;
  31802. /**
  31803. * Creates a video texture straight from a stream.
  31804. * @param scene Define the scene the texture should be created in
  31805. * @param stream Define the stream the texture should be created from
  31806. * @returns The created video texture as a promise
  31807. */
  31808. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31809. /**
  31810. * Creates a video texture straight from your WebCam video feed.
  31811. * @param scene Define the scene the texture should be created in
  31812. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31813. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31814. * @returns The created video texture as a promise
  31815. */
  31816. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31817. minWidth: number;
  31818. maxWidth: number;
  31819. minHeight: number;
  31820. maxHeight: number;
  31821. deviceId: string;
  31822. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31823. /**
  31824. * Creates a video texture straight from your WebCam video feed.
  31825. * @param scene Define the scene the texture should be created in
  31826. * @param onReady Define a callback to triggered once the texture will be ready
  31827. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31828. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31829. */
  31830. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31831. minWidth: number;
  31832. maxWidth: number;
  31833. minHeight: number;
  31834. maxHeight: number;
  31835. deviceId: string;
  31836. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31837. }
  31838. }
  31839. declare module "babylonjs/Engines/thinEngine" {
  31840. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31841. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31842. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31843. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31844. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31845. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31846. import { Observable } from "babylonjs/Misc/observable";
  31847. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31848. import { StencilState } from "babylonjs/States/stencilState";
  31849. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31850. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31851. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31852. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31853. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31854. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31855. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31856. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31857. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31859. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31860. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31861. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31862. import { WebRequest } from "babylonjs/Misc/webRequest";
  31863. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31864. /**
  31865. * Defines the interface used by objects working like Scene
  31866. * @hidden
  31867. */
  31868. export interface ISceneLike {
  31869. _addPendingData(data: any): void;
  31870. _removePendingData(data: any): void;
  31871. offlineProvider: IOfflineProvider;
  31872. }
  31873. /** Interface defining initialization parameters for Engine class */
  31874. export interface EngineOptions extends WebGLContextAttributes {
  31875. /**
  31876. * Defines if the engine should no exceed a specified device ratio
  31877. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31878. */
  31879. limitDeviceRatio?: number;
  31880. /**
  31881. * Defines if webvr should be enabled automatically
  31882. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31883. */
  31884. autoEnableWebVR?: boolean;
  31885. /**
  31886. * Defines if webgl2 should be turned off even if supported
  31887. * @see http://doc.babylonjs.com/features/webgl2
  31888. */
  31889. disableWebGL2Support?: boolean;
  31890. /**
  31891. * Defines if webaudio should be initialized as well
  31892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31893. */
  31894. audioEngine?: boolean;
  31895. /**
  31896. * Defines if animations should run using a deterministic lock step
  31897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31898. */
  31899. deterministicLockstep?: boolean;
  31900. /** Defines the maximum steps to use with deterministic lock step mode */
  31901. lockstepMaxSteps?: number;
  31902. /** Defines the seconds between each deterministic lock step */
  31903. timeStep?: number;
  31904. /**
  31905. * Defines that engine should ignore context lost events
  31906. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31907. */
  31908. doNotHandleContextLost?: boolean;
  31909. /**
  31910. * Defines that engine should ignore modifying touch action attribute and style
  31911. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31912. */
  31913. doNotHandleTouchAction?: boolean;
  31914. /**
  31915. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31916. */
  31917. useHighPrecisionFloats?: boolean;
  31918. }
  31919. /**
  31920. * The base engine class (root of all engines)
  31921. */
  31922. export class ThinEngine {
  31923. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31924. static ExceptionList: ({
  31925. key: string;
  31926. capture: string;
  31927. captureConstraint: number;
  31928. targets: string[];
  31929. } | {
  31930. key: string;
  31931. capture: null;
  31932. captureConstraint: null;
  31933. targets: string[];
  31934. })[];
  31935. /** @hidden */
  31936. static _TextureLoaders: IInternalTextureLoader[];
  31937. /**
  31938. * Returns the current npm package of the sdk
  31939. */
  31940. static get NpmPackage(): string;
  31941. /**
  31942. * Returns the current version of the framework
  31943. */
  31944. static get Version(): string;
  31945. /**
  31946. * Returns a string describing the current engine
  31947. */
  31948. get description(): string;
  31949. /**
  31950. * Gets or sets the epsilon value used by collision engine
  31951. */
  31952. static CollisionsEpsilon: number;
  31953. /**
  31954. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31955. */
  31956. static get ShadersRepository(): string;
  31957. static set ShadersRepository(value: string);
  31958. /** @hidden */
  31959. _shaderProcessor: IShaderProcessor;
  31960. /**
  31961. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31962. */
  31963. forcePOTTextures: boolean;
  31964. /**
  31965. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31966. */
  31967. isFullscreen: boolean;
  31968. /**
  31969. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31970. */
  31971. cullBackFaces: boolean;
  31972. /**
  31973. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31974. */
  31975. renderEvenInBackground: boolean;
  31976. /**
  31977. * Gets or sets a boolean indicating that cache can be kept between frames
  31978. */
  31979. preventCacheWipeBetweenFrames: boolean;
  31980. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31981. validateShaderPrograms: boolean;
  31982. /**
  31983. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31984. * This can provide greater z depth for distant objects.
  31985. */
  31986. useReverseDepthBuffer: boolean;
  31987. /**
  31988. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31989. */
  31990. disableUniformBuffers: boolean;
  31991. /** @hidden */
  31992. _uniformBuffers: UniformBuffer[];
  31993. /**
  31994. * Gets a boolean indicating that the engine supports uniform buffers
  31995. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31996. */
  31997. get supportsUniformBuffers(): boolean;
  31998. /** @hidden */
  31999. _gl: WebGLRenderingContext;
  32000. /** @hidden */
  32001. _webGLVersion: number;
  32002. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32003. protected _windowIsBackground: boolean;
  32004. protected _creationOptions: EngineOptions;
  32005. protected _highPrecisionShadersAllowed: boolean;
  32006. /** @hidden */
  32007. get _shouldUseHighPrecisionShader(): boolean;
  32008. /**
  32009. * Gets a boolean indicating that only power of 2 textures are supported
  32010. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32011. */
  32012. get needPOTTextures(): boolean;
  32013. /** @hidden */
  32014. _badOS: boolean;
  32015. /** @hidden */
  32016. _badDesktopOS: boolean;
  32017. private _hardwareScalingLevel;
  32018. /** @hidden */
  32019. _caps: EngineCapabilities;
  32020. private _isStencilEnable;
  32021. private _glVersion;
  32022. private _glRenderer;
  32023. private _glVendor;
  32024. /** @hidden */
  32025. _videoTextureSupported: boolean;
  32026. protected _renderingQueueLaunched: boolean;
  32027. protected _activeRenderLoops: (() => void)[];
  32028. /**
  32029. * Observable signaled when a context lost event is raised
  32030. */
  32031. onContextLostObservable: Observable<ThinEngine>;
  32032. /**
  32033. * Observable signaled when a context restored event is raised
  32034. */
  32035. onContextRestoredObservable: Observable<ThinEngine>;
  32036. private _onContextLost;
  32037. private _onContextRestored;
  32038. protected _contextWasLost: boolean;
  32039. /** @hidden */
  32040. _doNotHandleContextLost: boolean;
  32041. /**
  32042. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32044. */
  32045. get doNotHandleContextLost(): boolean;
  32046. set doNotHandleContextLost(value: boolean);
  32047. /**
  32048. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32049. */
  32050. disableVertexArrayObjects: boolean;
  32051. /** @hidden */
  32052. protected _colorWrite: boolean;
  32053. /** @hidden */
  32054. protected _colorWriteChanged: boolean;
  32055. /** @hidden */
  32056. protected _depthCullingState: DepthCullingState;
  32057. /** @hidden */
  32058. protected _stencilState: StencilState;
  32059. /** @hidden */
  32060. _alphaState: AlphaState;
  32061. /** @hidden */
  32062. _alphaMode: number;
  32063. /** @hidden */
  32064. _alphaEquation: number;
  32065. /** @hidden */
  32066. _internalTexturesCache: InternalTexture[];
  32067. /** @hidden */
  32068. protected _activeChannel: number;
  32069. private _currentTextureChannel;
  32070. /** @hidden */
  32071. protected _boundTexturesCache: {
  32072. [key: string]: Nullable<InternalTexture>;
  32073. };
  32074. /** @hidden */
  32075. protected _currentEffect: Nullable<Effect>;
  32076. /** @hidden */
  32077. protected _currentProgram: Nullable<WebGLProgram>;
  32078. private _compiledEffects;
  32079. private _vertexAttribArraysEnabled;
  32080. /** @hidden */
  32081. protected _cachedViewport: Nullable<IViewportLike>;
  32082. private _cachedVertexArrayObject;
  32083. /** @hidden */
  32084. protected _cachedVertexBuffers: any;
  32085. /** @hidden */
  32086. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32087. /** @hidden */
  32088. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32089. /** @hidden */
  32090. _currentRenderTarget: Nullable<InternalTexture>;
  32091. private _uintIndicesCurrentlySet;
  32092. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32093. /** @hidden */
  32094. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32095. private _currentBufferPointers;
  32096. private _currentInstanceLocations;
  32097. private _currentInstanceBuffers;
  32098. private _textureUnits;
  32099. /** @hidden */
  32100. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32101. /** @hidden */
  32102. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32103. /** @hidden */
  32104. _boundRenderFunction: any;
  32105. private _vaoRecordInProgress;
  32106. private _mustWipeVertexAttributes;
  32107. private _emptyTexture;
  32108. private _emptyCubeTexture;
  32109. private _emptyTexture3D;
  32110. private _emptyTexture2DArray;
  32111. /** @hidden */
  32112. _frameHandler: number;
  32113. private _nextFreeTextureSlots;
  32114. private _maxSimultaneousTextures;
  32115. private _activeRequests;
  32116. protected _texturesSupported: string[];
  32117. /** @hidden */
  32118. _textureFormatInUse: Nullable<string>;
  32119. protected get _supportsHardwareTextureRescaling(): boolean;
  32120. private _framebufferDimensionsObject;
  32121. /**
  32122. * sets the object from which width and height will be taken from when getting render width and height
  32123. * Will fallback to the gl object
  32124. * @param dimensions the framebuffer width and height that will be used.
  32125. */
  32126. set framebufferDimensionsObject(dimensions: Nullable<{
  32127. framebufferWidth: number;
  32128. framebufferHeight: number;
  32129. }>);
  32130. /**
  32131. * Gets the list of texture formats supported
  32132. */
  32133. get texturesSupported(): Array<string>;
  32134. /**
  32135. * Gets the list of texture formats in use
  32136. */
  32137. get textureFormatInUse(): Nullable<string>;
  32138. /**
  32139. * Gets the current viewport
  32140. */
  32141. get currentViewport(): Nullable<IViewportLike>;
  32142. /**
  32143. * Gets the default empty texture
  32144. */
  32145. get emptyTexture(): InternalTexture;
  32146. /**
  32147. * Gets the default empty 3D texture
  32148. */
  32149. get emptyTexture3D(): InternalTexture;
  32150. /**
  32151. * Gets the default empty 2D array texture
  32152. */
  32153. get emptyTexture2DArray(): InternalTexture;
  32154. /**
  32155. * Gets the default empty cube texture
  32156. */
  32157. get emptyCubeTexture(): InternalTexture;
  32158. /**
  32159. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32160. */
  32161. readonly premultipliedAlpha: boolean;
  32162. /**
  32163. * Observable event triggered before each texture is initialized
  32164. */
  32165. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32166. /**
  32167. * Creates a new engine
  32168. * @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
  32169. * @param antialias defines enable antialiasing (default: false)
  32170. * @param options defines further options to be sent to the getContext() function
  32171. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32172. */
  32173. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32174. private _rebuildInternalTextures;
  32175. private _rebuildEffects;
  32176. /**
  32177. * Gets a boolean indicating if all created effects are ready
  32178. * @returns true if all effects are ready
  32179. */
  32180. areAllEffectsReady(): boolean;
  32181. protected _rebuildBuffers(): void;
  32182. private _initGLContext;
  32183. /**
  32184. * Gets version of the current webGL context
  32185. */
  32186. get webGLVersion(): number;
  32187. /**
  32188. * Gets a string idenfifying the name of the class
  32189. * @returns "Engine" string
  32190. */
  32191. getClassName(): string;
  32192. /**
  32193. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32194. */
  32195. get isStencilEnable(): boolean;
  32196. /** @hidden */
  32197. _prepareWorkingCanvas(): void;
  32198. /**
  32199. * Reset the texture cache to empty state
  32200. */
  32201. resetTextureCache(): void;
  32202. /**
  32203. * Gets an object containing information about the current webGL context
  32204. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32205. */
  32206. getGlInfo(): {
  32207. vendor: string;
  32208. renderer: string;
  32209. version: string;
  32210. };
  32211. /**
  32212. * Defines the hardware scaling level.
  32213. * By default the hardware scaling level is computed from the window device ratio.
  32214. * 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.
  32215. * @param level defines the level to use
  32216. */
  32217. setHardwareScalingLevel(level: number): void;
  32218. /**
  32219. * Gets the current hardware scaling level.
  32220. * By default the hardware scaling level is computed from the window device ratio.
  32221. * 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.
  32222. * @returns a number indicating the current hardware scaling level
  32223. */
  32224. getHardwareScalingLevel(): number;
  32225. /**
  32226. * Gets the list of loaded textures
  32227. * @returns an array containing all loaded textures
  32228. */
  32229. getLoadedTexturesCache(): InternalTexture[];
  32230. /**
  32231. * Gets the object containing all engine capabilities
  32232. * @returns the EngineCapabilities object
  32233. */
  32234. getCaps(): EngineCapabilities;
  32235. /**
  32236. * stop executing a render loop function and remove it from the execution array
  32237. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32238. */
  32239. stopRenderLoop(renderFunction?: () => void): void;
  32240. /** @hidden */
  32241. _renderLoop(): void;
  32242. /**
  32243. * Gets the HTML canvas attached with the current webGL context
  32244. * @returns a HTML canvas
  32245. */
  32246. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32247. /**
  32248. * Gets host window
  32249. * @returns the host window object
  32250. */
  32251. getHostWindow(): Nullable<Window>;
  32252. /**
  32253. * Gets the current render width
  32254. * @param useScreen defines if screen size must be used (or the current render target if any)
  32255. * @returns a number defining the current render width
  32256. */
  32257. getRenderWidth(useScreen?: boolean): number;
  32258. /**
  32259. * Gets the current render height
  32260. * @param useScreen defines if screen size must be used (or the current render target if any)
  32261. * @returns a number defining the current render height
  32262. */
  32263. getRenderHeight(useScreen?: boolean): number;
  32264. /**
  32265. * Can be used to override the current requestAnimationFrame requester.
  32266. * @hidden
  32267. */
  32268. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32269. /**
  32270. * Register and execute a render loop. The engine can have more than one render function
  32271. * @param renderFunction defines the function to continuously execute
  32272. */
  32273. runRenderLoop(renderFunction: () => void): void;
  32274. /**
  32275. * Clear the current render buffer or the current render target (if any is set up)
  32276. * @param color defines the color to use
  32277. * @param backBuffer defines if the back buffer must be cleared
  32278. * @param depth defines if the depth buffer must be cleared
  32279. * @param stencil defines if the stencil buffer must be cleared
  32280. */
  32281. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32282. private _viewportCached;
  32283. /** @hidden */
  32284. _viewport(x: number, y: number, width: number, height: number): void;
  32285. /**
  32286. * Set the WebGL's viewport
  32287. * @param viewport defines the viewport element to be used
  32288. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32289. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32290. */
  32291. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32292. /**
  32293. * Begin a new frame
  32294. */
  32295. beginFrame(): void;
  32296. /**
  32297. * Enf the current frame
  32298. */
  32299. endFrame(): void;
  32300. /**
  32301. * Resize the view according to the canvas' size
  32302. */
  32303. resize(): void;
  32304. /**
  32305. * Force a specific size of the canvas
  32306. * @param width defines the new canvas' width
  32307. * @param height defines the new canvas' height
  32308. */
  32309. setSize(width: number, height: number): void;
  32310. /**
  32311. * Binds the frame buffer to the specified texture.
  32312. * @param texture The texture to render to or null for the default canvas
  32313. * @param faceIndex The face of the texture to render to in case of cube texture
  32314. * @param requiredWidth The width of the target to render to
  32315. * @param requiredHeight The height of the target to render to
  32316. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32317. * @param lodLevel defines the lod level to bind to the frame buffer
  32318. * @param layer defines the 2d array index to bind to frame buffer to
  32319. */
  32320. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32321. /** @hidden */
  32322. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32323. /**
  32324. * Unbind the current render target texture from the webGL context
  32325. * @param texture defines the render target texture to unbind
  32326. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32327. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32328. */
  32329. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32330. /**
  32331. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32332. */
  32333. flushFramebuffer(): void;
  32334. /**
  32335. * Unbind the current render target and bind the default framebuffer
  32336. */
  32337. restoreDefaultFramebuffer(): void;
  32338. /** @hidden */
  32339. protected _resetVertexBufferBinding(): void;
  32340. /**
  32341. * Creates a vertex buffer
  32342. * @param data the data for the vertex buffer
  32343. * @returns the new WebGL static buffer
  32344. */
  32345. createVertexBuffer(data: DataArray): DataBuffer;
  32346. private _createVertexBuffer;
  32347. /**
  32348. * Creates a dynamic vertex buffer
  32349. * @param data the data for the dynamic vertex buffer
  32350. * @returns the new WebGL dynamic buffer
  32351. */
  32352. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32353. protected _resetIndexBufferBinding(): void;
  32354. /**
  32355. * Creates a new index buffer
  32356. * @param indices defines the content of the index buffer
  32357. * @param updatable defines if the index buffer must be updatable
  32358. * @returns a new webGL buffer
  32359. */
  32360. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32361. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32362. /**
  32363. * Bind a webGL buffer to the webGL context
  32364. * @param buffer defines the buffer to bind
  32365. */
  32366. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32367. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32368. private bindBuffer;
  32369. /**
  32370. * update the bound buffer with the given data
  32371. * @param data defines the data to update
  32372. */
  32373. updateArrayBuffer(data: Float32Array): void;
  32374. private _vertexAttribPointer;
  32375. /** @hidden */
  32376. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32377. private _bindVertexBuffersAttributes;
  32378. /**
  32379. * Records a vertex array object
  32380. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32381. * @param vertexBuffers defines the list of vertex buffers to store
  32382. * @param indexBuffer defines the index buffer to store
  32383. * @param effect defines the effect to store
  32384. * @returns the new vertex array object
  32385. */
  32386. recordVertexArrayObject(vertexBuffers: {
  32387. [key: string]: VertexBuffer;
  32388. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32389. /**
  32390. * Bind a specific vertex array object
  32391. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32392. * @param vertexArrayObject defines the vertex array object to bind
  32393. * @param indexBuffer defines the index buffer to bind
  32394. */
  32395. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32396. /**
  32397. * Bind webGl buffers directly to the webGL context
  32398. * @param vertexBuffer defines the vertex buffer to bind
  32399. * @param indexBuffer defines the index buffer to bind
  32400. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32401. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32402. * @param effect defines the effect associated with the vertex buffer
  32403. */
  32404. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32405. private _unbindVertexArrayObject;
  32406. /**
  32407. * Bind a list of vertex buffers to the webGL context
  32408. * @param vertexBuffers defines the list of vertex buffers to bind
  32409. * @param indexBuffer defines the index buffer to bind
  32410. * @param effect defines the effect associated with the vertex buffers
  32411. */
  32412. bindBuffers(vertexBuffers: {
  32413. [key: string]: Nullable<VertexBuffer>;
  32414. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32415. /**
  32416. * Unbind all instance attributes
  32417. */
  32418. unbindInstanceAttributes(): void;
  32419. /**
  32420. * Release and free the memory of a vertex array object
  32421. * @param vao defines the vertex array object to delete
  32422. */
  32423. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32424. /** @hidden */
  32425. _releaseBuffer(buffer: DataBuffer): boolean;
  32426. protected _deleteBuffer(buffer: DataBuffer): void;
  32427. /**
  32428. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32429. * @param instancesBuffer defines the webGL buffer to update and bind
  32430. * @param data defines the data to store in the buffer
  32431. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32432. */
  32433. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32434. /**
  32435. * Bind the content of a webGL buffer used with instantiation
  32436. * @param instancesBuffer defines the webGL buffer to bind
  32437. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32438. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32439. */
  32440. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32441. /**
  32442. * Disable the instance attribute corresponding to the name in parameter
  32443. * @param name defines the name of the attribute to disable
  32444. */
  32445. disableInstanceAttributeByName(name: string): void;
  32446. /**
  32447. * Disable the instance attribute corresponding to the location in parameter
  32448. * @param attributeLocation defines the attribute location of the attribute to disable
  32449. */
  32450. disableInstanceAttribute(attributeLocation: number): void;
  32451. /**
  32452. * Disable the attribute corresponding to the location in parameter
  32453. * @param attributeLocation defines the attribute location of the attribute to disable
  32454. */
  32455. disableAttributeByIndex(attributeLocation: number): void;
  32456. /**
  32457. * Send a draw order
  32458. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32459. * @param indexStart defines the starting index
  32460. * @param indexCount defines the number of index to draw
  32461. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32462. */
  32463. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32464. /**
  32465. * Draw a list of points
  32466. * @param verticesStart defines the index of first vertex to draw
  32467. * @param verticesCount defines the count of vertices to draw
  32468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32469. */
  32470. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32471. /**
  32472. * Draw a list of unindexed primitives
  32473. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32474. * @param verticesStart defines the index of first vertex to draw
  32475. * @param verticesCount defines the count of vertices to draw
  32476. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32477. */
  32478. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32479. /**
  32480. * Draw a list of indexed primitives
  32481. * @param fillMode defines the primitive to use
  32482. * @param indexStart defines the starting index
  32483. * @param indexCount defines the number of index to draw
  32484. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32485. */
  32486. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32487. /**
  32488. * Draw a list of unindexed primitives
  32489. * @param fillMode defines the primitive to use
  32490. * @param verticesStart defines the index of first vertex to draw
  32491. * @param verticesCount defines the count of vertices to draw
  32492. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32493. */
  32494. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32495. private _drawMode;
  32496. /** @hidden */
  32497. protected _reportDrawCall(): void;
  32498. /** @hidden */
  32499. _releaseEffect(effect: Effect): void;
  32500. /** @hidden */
  32501. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32502. /**
  32503. * Create a new effect (used to store vertex/fragment shaders)
  32504. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32505. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32506. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32507. * @param samplers defines an array of string used to represent textures
  32508. * @param defines defines the string containing the defines to use to compile the shaders
  32509. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32510. * @param onCompiled defines a function to call when the effect creation is successful
  32511. * @param onError defines a function to call when the effect creation has failed
  32512. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32513. * @returns the new Effect
  32514. */
  32515. 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;
  32516. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32517. private _compileShader;
  32518. private _compileRawShader;
  32519. /** @hidden */
  32520. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32521. /**
  32522. * Directly creates a webGL program
  32523. * @param pipelineContext defines the pipeline context to attach to
  32524. * @param vertexCode defines the vertex shader code to use
  32525. * @param fragmentCode defines the fragment shader code to use
  32526. * @param context defines the webGL context to use (if not set, the current one will be used)
  32527. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32528. * @returns the new webGL program
  32529. */
  32530. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32531. /**
  32532. * Creates a webGL program
  32533. * @param pipelineContext defines the pipeline context to attach to
  32534. * @param vertexCode defines the vertex shader code to use
  32535. * @param fragmentCode defines the fragment shader code to use
  32536. * @param defines defines the string containing the defines to use to compile the shaders
  32537. * @param context defines the webGL context to use (if not set, the current one will be used)
  32538. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32539. * @returns the new webGL program
  32540. */
  32541. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32542. /**
  32543. * Creates a new pipeline context
  32544. * @returns the new pipeline
  32545. */
  32546. createPipelineContext(): IPipelineContext;
  32547. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32548. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32549. /** @hidden */
  32550. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32551. /** @hidden */
  32552. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32553. /** @hidden */
  32554. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32555. /**
  32556. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32557. * @param pipelineContext defines the pipeline context to use
  32558. * @param uniformsNames defines the list of uniform names
  32559. * @returns an array of webGL uniform locations
  32560. */
  32561. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32562. /**
  32563. * Gets the lsit of active attributes for a given webGL program
  32564. * @param pipelineContext defines the pipeline context to use
  32565. * @param attributesNames defines the list of attribute names to get
  32566. * @returns an array of indices indicating the offset of each attribute
  32567. */
  32568. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32569. /**
  32570. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32571. * @param effect defines the effect to activate
  32572. */
  32573. enableEffect(effect: Nullable<Effect>): void;
  32574. /**
  32575. * Set the value of an uniform to a number (int)
  32576. * @param uniform defines the webGL uniform location where to store the value
  32577. * @param value defines the int number to store
  32578. */
  32579. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32580. /**
  32581. * Set the value of an uniform to an array of int32
  32582. * @param uniform defines the webGL uniform location where to store the value
  32583. * @param array defines the array of int32 to store
  32584. */
  32585. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32586. /**
  32587. * Set the value of an uniform to an array of int32 (stored as vec2)
  32588. * @param uniform defines the webGL uniform location where to store the value
  32589. * @param array defines the array of int32 to store
  32590. */
  32591. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32592. /**
  32593. * Set the value of an uniform to an array of int32 (stored as vec3)
  32594. * @param uniform defines the webGL uniform location where to store the value
  32595. * @param array defines the array of int32 to store
  32596. */
  32597. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32598. /**
  32599. * Set the value of an uniform to an array of int32 (stored as vec4)
  32600. * @param uniform defines the webGL uniform location where to store the value
  32601. * @param array defines the array of int32 to store
  32602. */
  32603. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32604. /**
  32605. * Set the value of an uniform to an array of number
  32606. * @param uniform defines the webGL uniform location where to store the value
  32607. * @param array defines the array of number to store
  32608. */
  32609. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32610. /**
  32611. * Set the value of an uniform to an array of number (stored as vec2)
  32612. * @param uniform defines the webGL uniform location where to store the value
  32613. * @param array defines the array of number to store
  32614. */
  32615. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32616. /**
  32617. * Set the value of an uniform to an array of number (stored as vec3)
  32618. * @param uniform defines the webGL uniform location where to store the value
  32619. * @param array defines the array of number to store
  32620. */
  32621. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32622. /**
  32623. * Set the value of an uniform to an array of number (stored as vec4)
  32624. * @param uniform defines the webGL uniform location where to store the value
  32625. * @param array defines the array of number to store
  32626. */
  32627. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32628. /**
  32629. * Set the value of an uniform to an array of float32 (stored as matrices)
  32630. * @param uniform defines the webGL uniform location where to store the value
  32631. * @param matrices defines the array of float32 to store
  32632. */
  32633. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32634. /**
  32635. * Set the value of an uniform to a matrix (3x3)
  32636. * @param uniform defines the webGL uniform location where to store the value
  32637. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32638. */
  32639. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32640. /**
  32641. * Set the value of an uniform to a matrix (2x2)
  32642. * @param uniform defines the webGL uniform location where to store the value
  32643. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32644. */
  32645. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32646. /**
  32647. * Set the value of an uniform to a number (float)
  32648. * @param uniform defines the webGL uniform location where to store the value
  32649. * @param value defines the float number to store
  32650. */
  32651. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32652. /**
  32653. * Set the value of an uniform to a vec2
  32654. * @param uniform defines the webGL uniform location where to store the value
  32655. * @param x defines the 1st component of the value
  32656. * @param y defines the 2nd component of the value
  32657. */
  32658. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32659. /**
  32660. * Set the value of an uniform to a vec3
  32661. * @param uniform defines the webGL uniform location where to store the value
  32662. * @param x defines the 1st component of the value
  32663. * @param y defines the 2nd component of the value
  32664. * @param z defines the 3rd component of the value
  32665. */
  32666. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32667. /**
  32668. * Set the value of an uniform to a vec4
  32669. * @param uniform defines the webGL uniform location where to store the value
  32670. * @param x defines the 1st component of the value
  32671. * @param y defines the 2nd component of the value
  32672. * @param z defines the 3rd component of the value
  32673. * @param w defines the 4th component of the value
  32674. */
  32675. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32676. /**
  32677. * Apply all cached states (depth, culling, stencil and alpha)
  32678. */
  32679. applyStates(): void;
  32680. /**
  32681. * Enable or disable color writing
  32682. * @param enable defines the state to set
  32683. */
  32684. setColorWrite(enable: boolean): void;
  32685. /**
  32686. * Gets a boolean indicating if color writing is enabled
  32687. * @returns the current color writing state
  32688. */
  32689. getColorWrite(): boolean;
  32690. /**
  32691. * Gets the depth culling state manager
  32692. */
  32693. get depthCullingState(): DepthCullingState;
  32694. /**
  32695. * Gets the alpha state manager
  32696. */
  32697. get alphaState(): AlphaState;
  32698. /**
  32699. * Gets the stencil state manager
  32700. */
  32701. get stencilState(): StencilState;
  32702. /**
  32703. * Clears the list of texture accessible through engine.
  32704. * This can help preventing texture load conflict due to name collision.
  32705. */
  32706. clearInternalTexturesCache(): void;
  32707. /**
  32708. * Force the entire cache to be cleared
  32709. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32710. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32711. */
  32712. wipeCaches(bruteForce?: boolean): void;
  32713. /** @hidden */
  32714. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32715. min: number;
  32716. mag: number;
  32717. };
  32718. /** @hidden */
  32719. _createTexture(): WebGLTexture;
  32720. /**
  32721. * Usually called from Texture.ts.
  32722. * Passed information to create a WebGLTexture
  32723. * @param urlArg defines a value which contains one of the following:
  32724. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32725. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32726. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32728. * @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)
  32729. * @param scene needed for loading to the correct scene
  32730. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32731. * @param onLoad optional callback to be called upon successful completion
  32732. * @param onError optional callback to be called upon failure
  32733. * @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
  32734. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32735. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32736. * @param forcedExtension defines the extension to use to pick the right loader
  32737. * @param mimeType defines an optional mime type
  32738. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32739. */
  32740. 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;
  32741. /**
  32742. * Loads an image as an HTMLImageElement.
  32743. * @param input url string, ArrayBuffer, or Blob to load
  32744. * @param onLoad callback called when the image successfully loads
  32745. * @param onError callback called when the image fails to load
  32746. * @param offlineProvider offline provider for caching
  32747. * @param mimeType optional mime type
  32748. * @returns the HTMLImageElement of the loaded image
  32749. * @hidden
  32750. */
  32751. 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>;
  32752. /**
  32753. * @hidden
  32754. */
  32755. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32756. /**
  32757. * Creates a raw texture
  32758. * @param data defines the data to store in the texture
  32759. * @param width defines the width of the texture
  32760. * @param height defines the height of the texture
  32761. * @param format defines the format of the data
  32762. * @param generateMipMaps defines if the engine should generate the mip levels
  32763. * @param invertY defines if data must be stored with Y axis inverted
  32764. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32765. * @param compression defines the compression used (null by default)
  32766. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32767. * @returns the raw texture inside an InternalTexture
  32768. */
  32769. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32770. /**
  32771. * Creates a new raw cube texture
  32772. * @param data defines the array of data to use to create each face
  32773. * @param size defines the size of the textures
  32774. * @param format defines the format of the data
  32775. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32776. * @param generateMipMaps defines if the engine should generate the mip levels
  32777. * @param invertY defines if data must be stored with Y axis inverted
  32778. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32779. * @param compression defines the compression used (null by default)
  32780. * @returns the cube texture as an InternalTexture
  32781. */
  32782. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32783. /**
  32784. * Creates a new raw 3D texture
  32785. * @param data defines the data used to create the texture
  32786. * @param width defines the width of the texture
  32787. * @param height defines the height of the texture
  32788. * @param depth defines the depth of the texture
  32789. * @param format defines the format of the texture
  32790. * @param generateMipMaps defines if the engine must generate mip levels
  32791. * @param invertY defines if data must be stored with Y axis inverted
  32792. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32793. * @param compression defines the compressed used (can be null)
  32794. * @param textureType defines the compressed used (can be null)
  32795. * @returns a new raw 3D texture (stored in an InternalTexture)
  32796. */
  32797. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32798. /**
  32799. * Creates a new raw 2D array texture
  32800. * @param data defines the data used to create the texture
  32801. * @param width defines the width of the texture
  32802. * @param height defines the height of the texture
  32803. * @param depth defines the number of layers of the texture
  32804. * @param format defines the format of the texture
  32805. * @param generateMipMaps defines if the engine must generate mip levels
  32806. * @param invertY defines if data must be stored with Y axis inverted
  32807. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32808. * @param compression defines the compressed used (can be null)
  32809. * @param textureType defines the compressed used (can be null)
  32810. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32811. */
  32812. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32813. private _unpackFlipYCached;
  32814. /**
  32815. * In case you are sharing the context with other applications, it might
  32816. * be interested to not cache the unpack flip y state to ensure a consistent
  32817. * value would be set.
  32818. */
  32819. enableUnpackFlipYCached: boolean;
  32820. /** @hidden */
  32821. _unpackFlipY(value: boolean): void;
  32822. /** @hidden */
  32823. _getUnpackAlignement(): number;
  32824. private _getTextureTarget;
  32825. /**
  32826. * Update the sampling mode of a given texture
  32827. * @param samplingMode defines the required sampling mode
  32828. * @param texture defines the texture to update
  32829. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32830. */
  32831. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32832. /**
  32833. * Update the sampling mode of a given texture
  32834. * @param texture defines the texture to update
  32835. * @param wrapU defines the texture wrap mode of the u coordinates
  32836. * @param wrapV defines the texture wrap mode of the v coordinates
  32837. * @param wrapR defines the texture wrap mode of the r coordinates
  32838. */
  32839. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32840. /** @hidden */
  32841. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32842. width: number;
  32843. height: number;
  32844. layers?: number;
  32845. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32846. /** @hidden */
  32847. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32848. /** @hidden */
  32849. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32850. /**
  32851. * Update a portion of an internal texture
  32852. * @param texture defines the texture to update
  32853. * @param imageData defines the data to store into the texture
  32854. * @param xOffset defines the x coordinates of the update rectangle
  32855. * @param yOffset defines the y coordinates of the update rectangle
  32856. * @param width defines the width of the update rectangle
  32857. * @param height defines the height of the update rectangle
  32858. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32859. * @param lod defines the lod level to update (0 by default)
  32860. */
  32861. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32862. /** @hidden */
  32863. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32864. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32865. private _prepareWebGLTexture;
  32866. /** @hidden */
  32867. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32868. private _getDepthStencilBuffer;
  32869. /** @hidden */
  32870. _releaseFramebufferObjects(texture: InternalTexture): void;
  32871. /** @hidden */
  32872. _releaseTexture(texture: InternalTexture): void;
  32873. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32874. protected _setProgram(program: WebGLProgram): void;
  32875. protected _boundUniforms: {
  32876. [key: number]: WebGLUniformLocation;
  32877. };
  32878. /**
  32879. * Binds an effect to the webGL context
  32880. * @param effect defines the effect to bind
  32881. */
  32882. bindSamplers(effect: Effect): void;
  32883. private _activateCurrentTexture;
  32884. /** @hidden */
  32885. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32886. /** @hidden */
  32887. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32888. /**
  32889. * Unbind all textures from the webGL context
  32890. */
  32891. unbindAllTextures(): void;
  32892. /**
  32893. * Sets a texture to the according uniform.
  32894. * @param channel The texture channel
  32895. * @param uniform The uniform to set
  32896. * @param texture The texture to apply
  32897. */
  32898. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32899. private _bindSamplerUniformToChannel;
  32900. private _getTextureWrapMode;
  32901. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32902. /**
  32903. * Sets an array of texture to the webGL context
  32904. * @param channel defines the channel where the texture array must be set
  32905. * @param uniform defines the associated uniform location
  32906. * @param textures defines the array of textures to bind
  32907. */
  32908. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32909. /** @hidden */
  32910. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32911. private _setTextureParameterFloat;
  32912. private _setTextureParameterInteger;
  32913. /**
  32914. * Unbind all vertex attributes from the webGL context
  32915. */
  32916. unbindAllAttributes(): void;
  32917. /**
  32918. * 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
  32919. */
  32920. releaseEffects(): void;
  32921. /**
  32922. * Dispose and release all associated resources
  32923. */
  32924. dispose(): void;
  32925. /**
  32926. * Attach a new callback raised when context lost event is fired
  32927. * @param callback defines the callback to call
  32928. */
  32929. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32930. /**
  32931. * Attach a new callback raised when context restored event is fired
  32932. * @param callback defines the callback to call
  32933. */
  32934. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32935. /**
  32936. * Get the current error code of the webGL context
  32937. * @returns the error code
  32938. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32939. */
  32940. getError(): number;
  32941. private _canRenderToFloatFramebuffer;
  32942. private _canRenderToHalfFloatFramebuffer;
  32943. private _canRenderToFramebuffer;
  32944. /** @hidden */
  32945. _getWebGLTextureType(type: number): number;
  32946. /** @hidden */
  32947. _getInternalFormat(format: number): number;
  32948. /** @hidden */
  32949. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32950. /** @hidden */
  32951. _getRGBAMultiSampleBufferFormat(type: number): number;
  32952. /** @hidden */
  32953. _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;
  32954. /**
  32955. * Loads a file from a url
  32956. * @param url url to load
  32957. * @param onSuccess callback called when the file successfully loads
  32958. * @param onProgress callback called while file is loading (if the server supports this mode)
  32959. * @param offlineProvider defines the offline provider for caching
  32960. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32961. * @param onError callback called when the file fails to load
  32962. * @returns a file request object
  32963. * @hidden
  32964. */
  32965. 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;
  32966. /**
  32967. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32968. * @param x defines the x coordinate of the rectangle where pixels must be read
  32969. * @param y defines the y coordinate of the rectangle where pixels must be read
  32970. * @param width defines the width of the rectangle where pixels must be read
  32971. * @param height defines the height of the rectangle where pixels must be read
  32972. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32973. * @returns a Uint8Array containing RGBA colors
  32974. */
  32975. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32976. private static _isSupported;
  32977. /**
  32978. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32979. * @returns true if the engine can be created
  32980. * @ignorenaming
  32981. */
  32982. static isSupported(): boolean;
  32983. /**
  32984. * Find the next highest power of two.
  32985. * @param x Number to start search from.
  32986. * @return Next highest power of two.
  32987. */
  32988. static CeilingPOT(x: number): number;
  32989. /**
  32990. * Find the next lowest power of two.
  32991. * @param x Number to start search from.
  32992. * @return Next lowest power of two.
  32993. */
  32994. static FloorPOT(x: number): number;
  32995. /**
  32996. * Find the nearest power of two.
  32997. * @param x Number to start search from.
  32998. * @return Next nearest power of two.
  32999. */
  33000. static NearestPOT(x: number): number;
  33001. /**
  33002. * Get the closest exponent of two
  33003. * @param value defines the value to approximate
  33004. * @param max defines the maximum value to return
  33005. * @param mode defines how to define the closest value
  33006. * @returns closest exponent of two of the given value
  33007. */
  33008. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33009. /**
  33010. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33011. * @param func - the function to be called
  33012. * @param requester - the object that will request the next frame. Falls back to window.
  33013. * @returns frame number
  33014. */
  33015. static QueueNewFrame(func: () => void, requester?: any): number;
  33016. /**
  33017. * Gets host document
  33018. * @returns the host document object
  33019. */
  33020. getHostDocument(): Nullable<Document>;
  33021. }
  33022. }
  33023. declare module "babylonjs/Maths/sphericalPolynomial" {
  33024. import { Vector3 } from "babylonjs/Maths/math.vector";
  33025. import { Color3 } from "babylonjs/Maths/math.color";
  33026. /**
  33027. * Class representing spherical harmonics coefficients to the 3rd degree
  33028. */
  33029. export class SphericalHarmonics {
  33030. /**
  33031. * Defines whether or not the harmonics have been prescaled for rendering.
  33032. */
  33033. preScaled: boolean;
  33034. /**
  33035. * The l0,0 coefficients of the spherical harmonics
  33036. */
  33037. l00: Vector3;
  33038. /**
  33039. * The l1,-1 coefficients of the spherical harmonics
  33040. */
  33041. l1_1: Vector3;
  33042. /**
  33043. * The l1,0 coefficients of the spherical harmonics
  33044. */
  33045. l10: Vector3;
  33046. /**
  33047. * The l1,1 coefficients of the spherical harmonics
  33048. */
  33049. l11: Vector3;
  33050. /**
  33051. * The l2,-2 coefficients of the spherical harmonics
  33052. */
  33053. l2_2: Vector3;
  33054. /**
  33055. * The l2,-1 coefficients of the spherical harmonics
  33056. */
  33057. l2_1: Vector3;
  33058. /**
  33059. * The l2,0 coefficients of the spherical harmonics
  33060. */
  33061. l20: Vector3;
  33062. /**
  33063. * The l2,1 coefficients of the spherical harmonics
  33064. */
  33065. l21: Vector3;
  33066. /**
  33067. * The l2,2 coefficients of the spherical harmonics
  33068. */
  33069. l22: Vector3;
  33070. /**
  33071. * Adds a light to the spherical harmonics
  33072. * @param direction the direction of the light
  33073. * @param color the color of the light
  33074. * @param deltaSolidAngle the delta solid angle of the light
  33075. */
  33076. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33077. /**
  33078. * Scales the spherical harmonics by the given amount
  33079. * @param scale the amount to scale
  33080. */
  33081. scaleInPlace(scale: number): void;
  33082. /**
  33083. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33084. *
  33085. * ```
  33086. * E_lm = A_l * L_lm
  33087. * ```
  33088. *
  33089. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33090. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33091. * the scaling factors are given in equation 9.
  33092. */
  33093. convertIncidentRadianceToIrradiance(): void;
  33094. /**
  33095. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33096. *
  33097. * ```
  33098. * L = (1/pi) * E * rho
  33099. * ```
  33100. *
  33101. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33102. */
  33103. convertIrradianceToLambertianRadiance(): void;
  33104. /**
  33105. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33106. * required operations at run time.
  33107. *
  33108. * This is simply done by scaling back the SH with Ylm constants parameter.
  33109. * The trigonometric part being applied by the shader at run time.
  33110. */
  33111. preScaleForRendering(): void;
  33112. /**
  33113. * Constructs a spherical harmonics from an array.
  33114. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33115. * @returns the spherical harmonics
  33116. */
  33117. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33118. /**
  33119. * Gets the spherical harmonics from polynomial
  33120. * @param polynomial the spherical polynomial
  33121. * @returns the spherical harmonics
  33122. */
  33123. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33124. }
  33125. /**
  33126. * Class representing spherical polynomial coefficients to the 3rd degree
  33127. */
  33128. export class SphericalPolynomial {
  33129. private _harmonics;
  33130. /**
  33131. * The spherical harmonics used to create the polynomials.
  33132. */
  33133. get preScaledHarmonics(): SphericalHarmonics;
  33134. /**
  33135. * The x coefficients of the spherical polynomial
  33136. */
  33137. x: Vector3;
  33138. /**
  33139. * The y coefficients of the spherical polynomial
  33140. */
  33141. y: Vector3;
  33142. /**
  33143. * The z coefficients of the spherical polynomial
  33144. */
  33145. z: Vector3;
  33146. /**
  33147. * The xx coefficients of the spherical polynomial
  33148. */
  33149. xx: Vector3;
  33150. /**
  33151. * The yy coefficients of the spherical polynomial
  33152. */
  33153. yy: Vector3;
  33154. /**
  33155. * The zz coefficients of the spherical polynomial
  33156. */
  33157. zz: Vector3;
  33158. /**
  33159. * The xy coefficients of the spherical polynomial
  33160. */
  33161. xy: Vector3;
  33162. /**
  33163. * The yz coefficients of the spherical polynomial
  33164. */
  33165. yz: Vector3;
  33166. /**
  33167. * The zx coefficients of the spherical polynomial
  33168. */
  33169. zx: Vector3;
  33170. /**
  33171. * Adds an ambient color to the spherical polynomial
  33172. * @param color the color to add
  33173. */
  33174. addAmbient(color: Color3): void;
  33175. /**
  33176. * Scales the spherical polynomial by the given amount
  33177. * @param scale the amount to scale
  33178. */
  33179. scaleInPlace(scale: number): void;
  33180. /**
  33181. * Gets the spherical polynomial from harmonics
  33182. * @param harmonics the spherical harmonics
  33183. * @returns the spherical polynomial
  33184. */
  33185. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33186. /**
  33187. * Constructs a spherical polynomial from an array.
  33188. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33189. * @returns the spherical polynomial
  33190. */
  33191. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33192. }
  33193. }
  33194. declare module "babylonjs/Materials/Textures/internalTexture" {
  33195. import { Observable } from "babylonjs/Misc/observable";
  33196. import { Nullable, int } from "babylonjs/types";
  33197. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33199. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33200. /**
  33201. * Defines the source of the internal texture
  33202. */
  33203. export enum InternalTextureSource {
  33204. /**
  33205. * The source of the texture data is unknown
  33206. */
  33207. Unknown = 0,
  33208. /**
  33209. * Texture data comes from an URL
  33210. */
  33211. Url = 1,
  33212. /**
  33213. * Texture data is only used for temporary storage
  33214. */
  33215. Temp = 2,
  33216. /**
  33217. * Texture data comes from raw data (ArrayBuffer)
  33218. */
  33219. Raw = 3,
  33220. /**
  33221. * Texture content is dynamic (video or dynamic texture)
  33222. */
  33223. Dynamic = 4,
  33224. /**
  33225. * Texture content is generated by rendering to it
  33226. */
  33227. RenderTarget = 5,
  33228. /**
  33229. * Texture content is part of a multi render target process
  33230. */
  33231. MultiRenderTarget = 6,
  33232. /**
  33233. * Texture data comes from a cube data file
  33234. */
  33235. Cube = 7,
  33236. /**
  33237. * Texture data comes from a raw cube data
  33238. */
  33239. CubeRaw = 8,
  33240. /**
  33241. * Texture data come from a prefiltered cube data file
  33242. */
  33243. CubePrefiltered = 9,
  33244. /**
  33245. * Texture content is raw 3D data
  33246. */
  33247. Raw3D = 10,
  33248. /**
  33249. * Texture content is raw 2D array data
  33250. */
  33251. Raw2DArray = 11,
  33252. /**
  33253. * Texture content is a depth texture
  33254. */
  33255. Depth = 12,
  33256. /**
  33257. * Texture data comes from a raw cube data encoded with RGBD
  33258. */
  33259. CubeRawRGBD = 13
  33260. }
  33261. /**
  33262. * Class used to store data associated with WebGL texture data for the engine
  33263. * This class should not be used directly
  33264. */
  33265. export class InternalTexture {
  33266. /** @hidden */
  33267. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33268. /**
  33269. * Defines if the texture is ready
  33270. */
  33271. isReady: boolean;
  33272. /**
  33273. * Defines if the texture is a cube texture
  33274. */
  33275. isCube: boolean;
  33276. /**
  33277. * Defines if the texture contains 3D data
  33278. */
  33279. is3D: boolean;
  33280. /**
  33281. * Defines if the texture contains 2D array data
  33282. */
  33283. is2DArray: boolean;
  33284. /**
  33285. * Defines if the texture contains multiview data
  33286. */
  33287. isMultiview: boolean;
  33288. /**
  33289. * Gets the URL used to load this texture
  33290. */
  33291. url: string;
  33292. /**
  33293. * Gets the sampling mode of the texture
  33294. */
  33295. samplingMode: number;
  33296. /**
  33297. * Gets a boolean indicating if the texture needs mipmaps generation
  33298. */
  33299. generateMipMaps: boolean;
  33300. /**
  33301. * Gets the number of samples used by the texture (WebGL2+ only)
  33302. */
  33303. samples: number;
  33304. /**
  33305. * Gets the type of the texture (int, float...)
  33306. */
  33307. type: number;
  33308. /**
  33309. * Gets the format of the texture (RGB, RGBA...)
  33310. */
  33311. format: number;
  33312. /**
  33313. * Observable called when the texture is loaded
  33314. */
  33315. onLoadedObservable: Observable<InternalTexture>;
  33316. /**
  33317. * Gets the width of the texture
  33318. */
  33319. width: number;
  33320. /**
  33321. * Gets the height of the texture
  33322. */
  33323. height: number;
  33324. /**
  33325. * Gets the depth of the texture
  33326. */
  33327. depth: number;
  33328. /**
  33329. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33330. */
  33331. baseWidth: number;
  33332. /**
  33333. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33334. */
  33335. baseHeight: number;
  33336. /**
  33337. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33338. */
  33339. baseDepth: number;
  33340. /**
  33341. * Gets a boolean indicating if the texture is inverted on Y axis
  33342. */
  33343. invertY: boolean;
  33344. /** @hidden */
  33345. _invertVScale: boolean;
  33346. /** @hidden */
  33347. _associatedChannel: number;
  33348. /** @hidden */
  33349. _source: InternalTextureSource;
  33350. /** @hidden */
  33351. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33352. /** @hidden */
  33353. _bufferView: Nullable<ArrayBufferView>;
  33354. /** @hidden */
  33355. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33356. /** @hidden */
  33357. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33358. /** @hidden */
  33359. _size: number;
  33360. /** @hidden */
  33361. _extension: string;
  33362. /** @hidden */
  33363. _files: Nullable<string[]>;
  33364. /** @hidden */
  33365. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33366. /** @hidden */
  33367. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33368. /** @hidden */
  33369. _framebuffer: Nullable<WebGLFramebuffer>;
  33370. /** @hidden */
  33371. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33372. /** @hidden */
  33373. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33374. /** @hidden */
  33375. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33376. /** @hidden */
  33377. _attachments: Nullable<number[]>;
  33378. /** @hidden */
  33379. _cachedCoordinatesMode: Nullable<number>;
  33380. /** @hidden */
  33381. _cachedWrapU: Nullable<number>;
  33382. /** @hidden */
  33383. _cachedWrapV: Nullable<number>;
  33384. /** @hidden */
  33385. _cachedWrapR: Nullable<number>;
  33386. /** @hidden */
  33387. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33388. /** @hidden */
  33389. _isDisabled: boolean;
  33390. /** @hidden */
  33391. _compression: Nullable<string>;
  33392. /** @hidden */
  33393. _generateStencilBuffer: boolean;
  33394. /** @hidden */
  33395. _generateDepthBuffer: boolean;
  33396. /** @hidden */
  33397. _comparisonFunction: number;
  33398. /** @hidden */
  33399. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33400. /** @hidden */
  33401. _lodGenerationScale: number;
  33402. /** @hidden */
  33403. _lodGenerationOffset: number;
  33404. /** @hidden */
  33405. _depthStencilTexture: Nullable<InternalTexture>;
  33406. /** @hidden */
  33407. _colorTextureArray: Nullable<WebGLTexture>;
  33408. /** @hidden */
  33409. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33410. /** @hidden */
  33411. _lodTextureHigh: Nullable<BaseTexture>;
  33412. /** @hidden */
  33413. _lodTextureMid: Nullable<BaseTexture>;
  33414. /** @hidden */
  33415. _lodTextureLow: Nullable<BaseTexture>;
  33416. /** @hidden */
  33417. _isRGBD: boolean;
  33418. /** @hidden */
  33419. _linearSpecularLOD: boolean;
  33420. /** @hidden */
  33421. _irradianceTexture: Nullable<BaseTexture>;
  33422. /** @hidden */
  33423. _webGLTexture: Nullable<WebGLTexture>;
  33424. /** @hidden */
  33425. _references: number;
  33426. private _engine;
  33427. /**
  33428. * Gets the Engine the texture belongs to.
  33429. * @returns The babylon engine
  33430. */
  33431. getEngine(): ThinEngine;
  33432. /**
  33433. * Gets the data source type of the texture
  33434. */
  33435. get source(): InternalTextureSource;
  33436. /**
  33437. * Creates a new InternalTexture
  33438. * @param engine defines the engine to use
  33439. * @param source defines the type of data that will be used
  33440. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33441. */
  33442. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33443. /**
  33444. * Increments the number of references (ie. the number of Texture that point to it)
  33445. */
  33446. incrementReferences(): void;
  33447. /**
  33448. * Change the size of the texture (not the size of the content)
  33449. * @param width defines the new width
  33450. * @param height defines the new height
  33451. * @param depth defines the new depth (1 by default)
  33452. */
  33453. updateSize(width: int, height: int, depth?: int): void;
  33454. /** @hidden */
  33455. _rebuild(): void;
  33456. /** @hidden */
  33457. _swapAndDie(target: InternalTexture): void;
  33458. /**
  33459. * Dispose the current allocated resources
  33460. */
  33461. dispose(): void;
  33462. }
  33463. }
  33464. declare module "babylonjs/Audio/analyser" {
  33465. import { Scene } from "babylonjs/scene";
  33466. /**
  33467. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33469. */
  33470. export class Analyser {
  33471. /**
  33472. * Gets or sets the smoothing
  33473. * @ignorenaming
  33474. */
  33475. SMOOTHING: number;
  33476. /**
  33477. * Gets or sets the FFT table size
  33478. * @ignorenaming
  33479. */
  33480. FFT_SIZE: number;
  33481. /**
  33482. * Gets or sets the bar graph amplitude
  33483. * @ignorenaming
  33484. */
  33485. BARGRAPHAMPLITUDE: number;
  33486. /**
  33487. * Gets or sets the position of the debug canvas
  33488. * @ignorenaming
  33489. */
  33490. DEBUGCANVASPOS: {
  33491. x: number;
  33492. y: number;
  33493. };
  33494. /**
  33495. * Gets or sets the debug canvas size
  33496. * @ignorenaming
  33497. */
  33498. DEBUGCANVASSIZE: {
  33499. width: number;
  33500. height: number;
  33501. };
  33502. private _byteFreqs;
  33503. private _byteTime;
  33504. private _floatFreqs;
  33505. private _webAudioAnalyser;
  33506. private _debugCanvas;
  33507. private _debugCanvasContext;
  33508. private _scene;
  33509. private _registerFunc;
  33510. private _audioEngine;
  33511. /**
  33512. * Creates a new analyser
  33513. * @param scene defines hosting scene
  33514. */
  33515. constructor(scene: Scene);
  33516. /**
  33517. * Get the number of data values you will have to play with for the visualization
  33518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33519. * @returns a number
  33520. */
  33521. getFrequencyBinCount(): number;
  33522. /**
  33523. * Gets the current frequency data as a byte array
  33524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33525. * @returns a Uint8Array
  33526. */
  33527. getByteFrequencyData(): Uint8Array;
  33528. /**
  33529. * Gets the current waveform as a byte array
  33530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33531. * @returns a Uint8Array
  33532. */
  33533. getByteTimeDomainData(): Uint8Array;
  33534. /**
  33535. * Gets the current frequency data as a float array
  33536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33537. * @returns a Float32Array
  33538. */
  33539. getFloatFrequencyData(): Float32Array;
  33540. /**
  33541. * Renders the debug canvas
  33542. */
  33543. drawDebugCanvas(): void;
  33544. /**
  33545. * Stops rendering the debug canvas and removes it
  33546. */
  33547. stopDebugCanvas(): void;
  33548. /**
  33549. * Connects two audio nodes
  33550. * @param inputAudioNode defines first node to connect
  33551. * @param outputAudioNode defines second node to connect
  33552. */
  33553. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33554. /**
  33555. * Releases all associated resources
  33556. */
  33557. dispose(): void;
  33558. }
  33559. }
  33560. declare module "babylonjs/Audio/audioEngine" {
  33561. import { IDisposable } from "babylonjs/scene";
  33562. import { Analyser } from "babylonjs/Audio/analyser";
  33563. import { Nullable } from "babylonjs/types";
  33564. import { Observable } from "babylonjs/Misc/observable";
  33565. /**
  33566. * This represents an audio engine and it is responsible
  33567. * to play, synchronize and analyse sounds throughout the application.
  33568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33569. */
  33570. export interface IAudioEngine extends IDisposable {
  33571. /**
  33572. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33573. */
  33574. readonly canUseWebAudio: boolean;
  33575. /**
  33576. * Gets the current AudioContext if available.
  33577. */
  33578. readonly audioContext: Nullable<AudioContext>;
  33579. /**
  33580. * The master gain node defines the global audio volume of your audio engine.
  33581. */
  33582. readonly masterGain: GainNode;
  33583. /**
  33584. * Gets whether or not mp3 are supported by your browser.
  33585. */
  33586. readonly isMP3supported: boolean;
  33587. /**
  33588. * Gets whether or not ogg are supported by your browser.
  33589. */
  33590. readonly isOGGsupported: boolean;
  33591. /**
  33592. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33593. * @ignoreNaming
  33594. */
  33595. WarnedWebAudioUnsupported: boolean;
  33596. /**
  33597. * Defines if the audio engine relies on a custom unlocked button.
  33598. * In this case, the embedded button will not be displayed.
  33599. */
  33600. useCustomUnlockedButton: boolean;
  33601. /**
  33602. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33603. */
  33604. readonly unlocked: boolean;
  33605. /**
  33606. * Event raised when audio has been unlocked on the browser.
  33607. */
  33608. onAudioUnlockedObservable: Observable<AudioEngine>;
  33609. /**
  33610. * Event raised when audio has been locked on the browser.
  33611. */
  33612. onAudioLockedObservable: Observable<AudioEngine>;
  33613. /**
  33614. * Flags the audio engine in Locked state.
  33615. * This happens due to new browser policies preventing audio to autoplay.
  33616. */
  33617. lock(): void;
  33618. /**
  33619. * Unlocks the audio engine once a user action has been done on the dom.
  33620. * This is helpful to resume play once browser policies have been satisfied.
  33621. */
  33622. unlock(): void;
  33623. /**
  33624. * Gets the global volume sets on the master gain.
  33625. * @returns the global volume if set or -1 otherwise
  33626. */
  33627. getGlobalVolume(): number;
  33628. /**
  33629. * Sets the global volume of your experience (sets on the master gain).
  33630. * @param newVolume Defines the new global volume of the application
  33631. */
  33632. setGlobalVolume(newVolume: number): void;
  33633. /**
  33634. * Connect the audio engine to an audio analyser allowing some amazing
  33635. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33637. * @param analyser The analyser to connect to the engine
  33638. */
  33639. connectToAnalyser(analyser: Analyser): void;
  33640. }
  33641. /**
  33642. * This represents the default audio engine used in babylon.
  33643. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33645. */
  33646. export class AudioEngine implements IAudioEngine {
  33647. private _audioContext;
  33648. private _audioContextInitialized;
  33649. private _muteButton;
  33650. private _hostElement;
  33651. /**
  33652. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33653. */
  33654. canUseWebAudio: boolean;
  33655. /**
  33656. * The master gain node defines the global audio volume of your audio engine.
  33657. */
  33658. masterGain: GainNode;
  33659. /**
  33660. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33661. * @ignoreNaming
  33662. */
  33663. WarnedWebAudioUnsupported: boolean;
  33664. /**
  33665. * Gets whether or not mp3 are supported by your browser.
  33666. */
  33667. isMP3supported: boolean;
  33668. /**
  33669. * Gets whether or not ogg are supported by your browser.
  33670. */
  33671. isOGGsupported: boolean;
  33672. /**
  33673. * Gets whether audio has been unlocked on the device.
  33674. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33675. * a user interaction has happened.
  33676. */
  33677. unlocked: boolean;
  33678. /**
  33679. * Defines if the audio engine relies on a custom unlocked button.
  33680. * In this case, the embedded button will not be displayed.
  33681. */
  33682. useCustomUnlockedButton: boolean;
  33683. /**
  33684. * Event raised when audio has been unlocked on the browser.
  33685. */
  33686. onAudioUnlockedObservable: Observable<AudioEngine>;
  33687. /**
  33688. * Event raised when audio has been locked on the browser.
  33689. */
  33690. onAudioLockedObservable: Observable<AudioEngine>;
  33691. /**
  33692. * Gets the current AudioContext if available.
  33693. */
  33694. get audioContext(): Nullable<AudioContext>;
  33695. private _connectedAnalyser;
  33696. /**
  33697. * Instantiates a new audio engine.
  33698. *
  33699. * There should be only one per page as some browsers restrict the number
  33700. * of audio contexts you can create.
  33701. * @param hostElement defines the host element where to display the mute icon if necessary
  33702. */
  33703. constructor(hostElement?: Nullable<HTMLElement>);
  33704. /**
  33705. * Flags the audio engine in Locked state.
  33706. * This happens due to new browser policies preventing audio to autoplay.
  33707. */
  33708. lock(): void;
  33709. /**
  33710. * Unlocks the audio engine once a user action has been done on the dom.
  33711. * This is helpful to resume play once browser policies have been satisfied.
  33712. */
  33713. unlock(): void;
  33714. private _resumeAudioContext;
  33715. private _initializeAudioContext;
  33716. private _tryToRun;
  33717. private _triggerRunningState;
  33718. private _triggerSuspendedState;
  33719. private _displayMuteButton;
  33720. private _moveButtonToTopLeft;
  33721. private _onResize;
  33722. private _hideMuteButton;
  33723. /**
  33724. * Destroy and release the resources associated with the audio ccontext.
  33725. */
  33726. dispose(): void;
  33727. /**
  33728. * Gets the global volume sets on the master gain.
  33729. * @returns the global volume if set or -1 otherwise
  33730. */
  33731. getGlobalVolume(): number;
  33732. /**
  33733. * Sets the global volume of your experience (sets on the master gain).
  33734. * @param newVolume Defines the new global volume of the application
  33735. */
  33736. setGlobalVolume(newVolume: number): void;
  33737. /**
  33738. * Connect the audio engine to an audio analyser allowing some amazing
  33739. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33741. * @param analyser The analyser to connect to the engine
  33742. */
  33743. connectToAnalyser(analyser: Analyser): void;
  33744. }
  33745. }
  33746. declare module "babylonjs/Loading/loadingScreen" {
  33747. /**
  33748. * Interface used to present a loading screen while loading a scene
  33749. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33750. */
  33751. export interface ILoadingScreen {
  33752. /**
  33753. * Function called to display the loading screen
  33754. */
  33755. displayLoadingUI: () => void;
  33756. /**
  33757. * Function called to hide the loading screen
  33758. */
  33759. hideLoadingUI: () => void;
  33760. /**
  33761. * Gets or sets the color to use for the background
  33762. */
  33763. loadingUIBackgroundColor: string;
  33764. /**
  33765. * Gets or sets the text to display while loading
  33766. */
  33767. loadingUIText: string;
  33768. }
  33769. /**
  33770. * Class used for the default loading screen
  33771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33772. */
  33773. export class DefaultLoadingScreen implements ILoadingScreen {
  33774. private _renderingCanvas;
  33775. private _loadingText;
  33776. private _loadingDivBackgroundColor;
  33777. private _loadingDiv;
  33778. private _loadingTextDiv;
  33779. /** Gets or sets the logo url to use for the default loading screen */
  33780. static DefaultLogoUrl: string;
  33781. /** Gets or sets the spinner url to use for the default loading screen */
  33782. static DefaultSpinnerUrl: string;
  33783. /**
  33784. * Creates a new default loading screen
  33785. * @param _renderingCanvas defines the canvas used to render the scene
  33786. * @param _loadingText defines the default text to display
  33787. * @param _loadingDivBackgroundColor defines the default background color
  33788. */
  33789. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33790. /**
  33791. * Function called to display the loading screen
  33792. */
  33793. displayLoadingUI(): void;
  33794. /**
  33795. * Function called to hide the loading screen
  33796. */
  33797. hideLoadingUI(): void;
  33798. /**
  33799. * Gets or sets the text to display while loading
  33800. */
  33801. set loadingUIText(text: string);
  33802. get loadingUIText(): string;
  33803. /**
  33804. * Gets or sets the color to use for the background
  33805. */
  33806. get loadingUIBackgroundColor(): string;
  33807. set loadingUIBackgroundColor(color: string);
  33808. private _resizeLoadingUI;
  33809. }
  33810. }
  33811. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33812. /**
  33813. * Interface for any object that can request an animation frame
  33814. */
  33815. export interface ICustomAnimationFrameRequester {
  33816. /**
  33817. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33818. */
  33819. renderFunction?: Function;
  33820. /**
  33821. * Called to request the next frame to render to
  33822. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33823. */
  33824. requestAnimationFrame: Function;
  33825. /**
  33826. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33827. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33828. */
  33829. requestID?: number;
  33830. }
  33831. }
  33832. declare module "babylonjs/Misc/performanceMonitor" {
  33833. /**
  33834. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33835. */
  33836. export class PerformanceMonitor {
  33837. private _enabled;
  33838. private _rollingFrameTime;
  33839. private _lastFrameTimeMs;
  33840. /**
  33841. * constructor
  33842. * @param frameSampleSize The number of samples required to saturate the sliding window
  33843. */
  33844. constructor(frameSampleSize?: number);
  33845. /**
  33846. * Samples current frame
  33847. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33848. */
  33849. sampleFrame(timeMs?: number): void;
  33850. /**
  33851. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33852. */
  33853. get averageFrameTime(): number;
  33854. /**
  33855. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33856. */
  33857. get averageFrameTimeVariance(): number;
  33858. /**
  33859. * Returns the frame time of the most recent frame
  33860. */
  33861. get instantaneousFrameTime(): number;
  33862. /**
  33863. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33864. */
  33865. get averageFPS(): number;
  33866. /**
  33867. * Returns the average framerate in frames per second using the most recent frame time
  33868. */
  33869. get instantaneousFPS(): number;
  33870. /**
  33871. * Returns true if enough samples have been taken to completely fill the sliding window
  33872. */
  33873. get isSaturated(): boolean;
  33874. /**
  33875. * Enables contributions to the sliding window sample set
  33876. */
  33877. enable(): void;
  33878. /**
  33879. * Disables contributions to the sliding window sample set
  33880. * Samples will not be interpolated over the disabled period
  33881. */
  33882. disable(): void;
  33883. /**
  33884. * Returns true if sampling is enabled
  33885. */
  33886. get isEnabled(): boolean;
  33887. /**
  33888. * Resets performance monitor
  33889. */
  33890. reset(): void;
  33891. }
  33892. /**
  33893. * RollingAverage
  33894. *
  33895. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33896. */
  33897. export class RollingAverage {
  33898. /**
  33899. * Current average
  33900. */
  33901. average: number;
  33902. /**
  33903. * Current variance
  33904. */
  33905. variance: number;
  33906. protected _samples: Array<number>;
  33907. protected _sampleCount: number;
  33908. protected _pos: number;
  33909. protected _m2: number;
  33910. /**
  33911. * constructor
  33912. * @param length The number of samples required to saturate the sliding window
  33913. */
  33914. constructor(length: number);
  33915. /**
  33916. * Adds a sample to the sample set
  33917. * @param v The sample value
  33918. */
  33919. add(v: number): void;
  33920. /**
  33921. * Returns previously added values or null if outside of history or outside the sliding window domain
  33922. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33923. * @return Value previously recorded with add() or null if outside of range
  33924. */
  33925. history(i: number): number;
  33926. /**
  33927. * Returns true if enough samples have been taken to completely fill the sliding window
  33928. * @return true if sample-set saturated
  33929. */
  33930. isSaturated(): boolean;
  33931. /**
  33932. * Resets the rolling average (equivalent to 0 samples taken so far)
  33933. */
  33934. reset(): void;
  33935. /**
  33936. * Wraps a value around the sample range boundaries
  33937. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33938. * @return Wrapped position in sample range
  33939. */
  33940. protected _wrapPosition(i: number): number;
  33941. }
  33942. }
  33943. declare module "babylonjs/Misc/perfCounter" {
  33944. /**
  33945. * This class is used to track a performance counter which is number based.
  33946. * The user has access to many properties which give statistics of different nature.
  33947. *
  33948. * The implementer can track two kinds of Performance Counter: time and count.
  33949. * 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.
  33950. * 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.
  33951. */
  33952. export class PerfCounter {
  33953. /**
  33954. * Gets or sets a global boolean to turn on and off all the counters
  33955. */
  33956. static Enabled: boolean;
  33957. /**
  33958. * Returns the smallest value ever
  33959. */
  33960. get min(): number;
  33961. /**
  33962. * Returns the biggest value ever
  33963. */
  33964. get max(): number;
  33965. /**
  33966. * Returns the average value since the performance counter is running
  33967. */
  33968. get average(): number;
  33969. /**
  33970. * Returns the average value of the last second the counter was monitored
  33971. */
  33972. get lastSecAverage(): number;
  33973. /**
  33974. * Returns the current value
  33975. */
  33976. get current(): number;
  33977. /**
  33978. * Gets the accumulated total
  33979. */
  33980. get total(): number;
  33981. /**
  33982. * Gets the total value count
  33983. */
  33984. get count(): number;
  33985. /**
  33986. * Creates a new counter
  33987. */
  33988. constructor();
  33989. /**
  33990. * Call this method to start monitoring a new frame.
  33991. * 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.
  33992. */
  33993. fetchNewFrame(): void;
  33994. /**
  33995. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33996. * @param newCount the count value to add to the monitored count
  33997. * @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.
  33998. */
  33999. addCount(newCount: number, fetchResult: boolean): void;
  34000. /**
  34001. * Start monitoring this performance counter
  34002. */
  34003. beginMonitoring(): void;
  34004. /**
  34005. * Compute the time lapsed since the previous beginMonitoring() call.
  34006. * @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
  34007. */
  34008. endMonitoring(newFrame?: boolean): void;
  34009. private _fetchResult;
  34010. private _startMonitoringTime;
  34011. private _min;
  34012. private _max;
  34013. private _average;
  34014. private _current;
  34015. private _totalValueCount;
  34016. private _totalAccumulated;
  34017. private _lastSecAverage;
  34018. private _lastSecAccumulated;
  34019. private _lastSecTime;
  34020. private _lastSecValueCount;
  34021. }
  34022. }
  34023. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34024. module "babylonjs/Engines/thinEngine" {
  34025. interface ThinEngine {
  34026. /**
  34027. * Sets alpha constants used by some alpha blending modes
  34028. * @param r defines the red component
  34029. * @param g defines the green component
  34030. * @param b defines the blue component
  34031. * @param a defines the alpha component
  34032. */
  34033. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34034. /**
  34035. * Sets the current alpha mode
  34036. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34037. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34038. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34039. */
  34040. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34041. /**
  34042. * Gets the current alpha mode
  34043. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34044. * @returns the current alpha mode
  34045. */
  34046. getAlphaMode(): number;
  34047. /**
  34048. * Sets the current alpha equation
  34049. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34050. */
  34051. setAlphaEquation(equation: number): void;
  34052. /**
  34053. * Gets the current alpha equation.
  34054. * @returns the current alpha equation
  34055. */
  34056. getAlphaEquation(): number;
  34057. }
  34058. }
  34059. }
  34060. declare module "babylonjs/Engines/engine" {
  34061. import { Observable } from "babylonjs/Misc/observable";
  34062. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34063. import { Scene } from "babylonjs/scene";
  34064. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34065. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34066. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34067. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34068. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34069. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34070. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34071. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34072. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34073. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34074. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34076. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34077. import "babylonjs/Engines/Extensions/engine.alpha";
  34078. import { Material } from "babylonjs/Materials/material";
  34079. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34080. /**
  34081. * Defines the interface used by display changed events
  34082. */
  34083. export interface IDisplayChangedEventArgs {
  34084. /** Gets the vrDisplay object (if any) */
  34085. vrDisplay: Nullable<any>;
  34086. /** Gets a boolean indicating if webVR is supported */
  34087. vrSupported: boolean;
  34088. }
  34089. /**
  34090. * Defines the interface used by objects containing a viewport (like a camera)
  34091. */
  34092. interface IViewportOwnerLike {
  34093. /**
  34094. * Gets or sets the viewport
  34095. */
  34096. viewport: IViewportLike;
  34097. }
  34098. /**
  34099. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34100. */
  34101. export class Engine extends ThinEngine {
  34102. /** Defines that alpha blending is disabled */
  34103. static readonly ALPHA_DISABLE: number;
  34104. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34105. static readonly ALPHA_ADD: number;
  34106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34107. static readonly ALPHA_COMBINE: number;
  34108. /** Defines that alpha blending to DEST - SRC * DEST */
  34109. static readonly ALPHA_SUBTRACT: number;
  34110. /** Defines that alpha blending to SRC * DEST */
  34111. static readonly ALPHA_MULTIPLY: number;
  34112. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34113. static readonly ALPHA_MAXIMIZED: number;
  34114. /** Defines that alpha blending to SRC + DEST */
  34115. static readonly ALPHA_ONEONE: number;
  34116. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34117. static readonly ALPHA_PREMULTIPLIED: number;
  34118. /**
  34119. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34120. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34121. */
  34122. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34123. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34124. static readonly ALPHA_INTERPOLATE: number;
  34125. /**
  34126. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34127. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34128. */
  34129. static readonly ALPHA_SCREENMODE: number;
  34130. /** Defines that the ressource is not delayed*/
  34131. static readonly DELAYLOADSTATE_NONE: number;
  34132. /** Defines that the ressource was successfully delay loaded */
  34133. static readonly DELAYLOADSTATE_LOADED: number;
  34134. /** Defines that the ressource is currently delay loading */
  34135. static readonly DELAYLOADSTATE_LOADING: number;
  34136. /** Defines that the ressource is delayed and has not started loading */
  34137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34139. static readonly NEVER: number;
  34140. /** 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 */
  34141. static readonly ALWAYS: number;
  34142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34143. static readonly LESS: number;
  34144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34145. static readonly EQUAL: number;
  34146. /** 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 */
  34147. static readonly LEQUAL: number;
  34148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34149. static readonly GREATER: number;
  34150. /** 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 */
  34151. static readonly GEQUAL: number;
  34152. /** 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 */
  34153. static readonly NOTEQUAL: number;
  34154. /** Passed to stencilOperation to specify that stencil value must be kept */
  34155. static readonly KEEP: number;
  34156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34157. static readonly REPLACE: number;
  34158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34159. static readonly INCR: number;
  34160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34161. static readonly DECR: number;
  34162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34163. static readonly INVERT: number;
  34164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34165. static readonly INCR_WRAP: number;
  34166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34167. static readonly DECR_WRAP: number;
  34168. /** Texture is not repeating outside of 0..1 UVs */
  34169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34170. /** Texture is repeating outside of 0..1 UVs */
  34171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34172. /** Texture is repeating and mirrored */
  34173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34174. /** ALPHA */
  34175. static readonly TEXTUREFORMAT_ALPHA: number;
  34176. /** LUMINANCE */
  34177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34178. /** LUMINANCE_ALPHA */
  34179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34180. /** RGB */
  34181. static readonly TEXTUREFORMAT_RGB: number;
  34182. /** RGBA */
  34183. static readonly TEXTUREFORMAT_RGBA: number;
  34184. /** RED */
  34185. static readonly TEXTUREFORMAT_RED: number;
  34186. /** RED (2nd reference) */
  34187. static readonly TEXTUREFORMAT_R: number;
  34188. /** RG */
  34189. static readonly TEXTUREFORMAT_RG: number;
  34190. /** RED_INTEGER */
  34191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34192. /** RED_INTEGER (2nd reference) */
  34193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34194. /** RG_INTEGER */
  34195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34196. /** RGB_INTEGER */
  34197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34198. /** RGBA_INTEGER */
  34199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34200. /** UNSIGNED_BYTE */
  34201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34202. /** UNSIGNED_BYTE (2nd reference) */
  34203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34204. /** FLOAT */
  34205. static readonly TEXTURETYPE_FLOAT: number;
  34206. /** HALF_FLOAT */
  34207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34208. /** BYTE */
  34209. static readonly TEXTURETYPE_BYTE: number;
  34210. /** SHORT */
  34211. static readonly TEXTURETYPE_SHORT: number;
  34212. /** UNSIGNED_SHORT */
  34213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34214. /** INT */
  34215. static readonly TEXTURETYPE_INT: number;
  34216. /** UNSIGNED_INT */
  34217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34218. /** UNSIGNED_SHORT_4_4_4_4 */
  34219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34220. /** UNSIGNED_SHORT_5_5_5_1 */
  34221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34222. /** UNSIGNED_SHORT_5_6_5 */
  34223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34224. /** UNSIGNED_INT_2_10_10_10_REV */
  34225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34226. /** UNSIGNED_INT_24_8 */
  34227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34228. /** UNSIGNED_INT_10F_11F_11F_REV */
  34229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34230. /** UNSIGNED_INT_5_9_9_9_REV */
  34231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34234. /** nearest is mag = nearest and min = nearest and mip = linear */
  34235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34238. /** Trilinear is mag = linear and min = linear and mip = linear */
  34239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34240. /** nearest is mag = nearest and min = nearest and mip = linear */
  34241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34244. /** Trilinear is mag = linear and min = linear and mip = linear */
  34245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34246. /** mag = nearest and min = nearest and mip = nearest */
  34247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34248. /** mag = nearest and min = linear and mip = nearest */
  34249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34250. /** mag = nearest and min = linear and mip = linear */
  34251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34252. /** mag = nearest and min = linear and mip = none */
  34253. static readonly TEXTURE_NEAREST_LINEAR: number;
  34254. /** mag = nearest and min = nearest and mip = none */
  34255. static readonly TEXTURE_NEAREST_NEAREST: number;
  34256. /** mag = linear and min = nearest and mip = nearest */
  34257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34258. /** mag = linear and min = nearest and mip = linear */
  34259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34260. /** mag = linear and min = linear and mip = none */
  34261. static readonly TEXTURE_LINEAR_LINEAR: number;
  34262. /** mag = linear and min = nearest and mip = none */
  34263. static readonly TEXTURE_LINEAR_NEAREST: number;
  34264. /** Explicit coordinates mode */
  34265. static readonly TEXTURE_EXPLICIT_MODE: number;
  34266. /** Spherical coordinates mode */
  34267. static readonly TEXTURE_SPHERICAL_MODE: number;
  34268. /** Planar coordinates mode */
  34269. static readonly TEXTURE_PLANAR_MODE: number;
  34270. /** Cubic coordinates mode */
  34271. static readonly TEXTURE_CUBIC_MODE: number;
  34272. /** Projection coordinates mode */
  34273. static readonly TEXTURE_PROJECTION_MODE: number;
  34274. /** Skybox coordinates mode */
  34275. static readonly TEXTURE_SKYBOX_MODE: number;
  34276. /** Inverse Cubic coordinates mode */
  34277. static readonly TEXTURE_INVCUBIC_MODE: number;
  34278. /** Equirectangular coordinates mode */
  34279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34280. /** Equirectangular Fixed coordinates mode */
  34281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34282. /** Equirectangular Fixed Mirrored coordinates mode */
  34283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34285. static readonly SCALEMODE_FLOOR: number;
  34286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34287. static readonly SCALEMODE_NEAREST: number;
  34288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34289. static readonly SCALEMODE_CEILING: number;
  34290. /**
  34291. * Returns the current npm package of the sdk
  34292. */
  34293. static get NpmPackage(): string;
  34294. /**
  34295. * Returns the current version of the framework
  34296. */
  34297. static get Version(): string;
  34298. /** Gets the list of created engines */
  34299. static get Instances(): Engine[];
  34300. /**
  34301. * Gets the latest created engine
  34302. */
  34303. static get LastCreatedEngine(): Nullable<Engine>;
  34304. /**
  34305. * Gets the latest created scene
  34306. */
  34307. static get LastCreatedScene(): Nullable<Scene>;
  34308. /**
  34309. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34310. * @param flag defines which part of the materials must be marked as dirty
  34311. * @param predicate defines a predicate used to filter which materials should be affected
  34312. */
  34313. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34314. /**
  34315. * Method called to create the default loading screen.
  34316. * This can be overriden in your own app.
  34317. * @param canvas The rendering canvas element
  34318. * @returns The loading screen
  34319. */
  34320. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34321. /**
  34322. * Method called to create the default rescale post process on each engine.
  34323. */
  34324. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34325. /**
  34326. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34327. **/
  34328. enableOfflineSupport: boolean;
  34329. /**
  34330. * 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)
  34331. **/
  34332. disableManifestCheck: boolean;
  34333. /**
  34334. * Gets the list of created scenes
  34335. */
  34336. scenes: Scene[];
  34337. /**
  34338. * Event raised when a new scene is created
  34339. */
  34340. onNewSceneAddedObservable: Observable<Scene>;
  34341. /**
  34342. * Gets the list of created postprocesses
  34343. */
  34344. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34345. /**
  34346. * Gets a boolean indicating if the pointer is currently locked
  34347. */
  34348. isPointerLock: boolean;
  34349. /**
  34350. * Observable event triggered each time the rendering canvas is resized
  34351. */
  34352. onResizeObservable: Observable<Engine>;
  34353. /**
  34354. * Observable event triggered each time the canvas loses focus
  34355. */
  34356. onCanvasBlurObservable: Observable<Engine>;
  34357. /**
  34358. * Observable event triggered each time the canvas gains focus
  34359. */
  34360. onCanvasFocusObservable: Observable<Engine>;
  34361. /**
  34362. * Observable event triggered each time the canvas receives pointerout event
  34363. */
  34364. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34365. /**
  34366. * Observable raised when the engine begins a new frame
  34367. */
  34368. onBeginFrameObservable: Observable<Engine>;
  34369. /**
  34370. * If set, will be used to request the next animation frame for the render loop
  34371. */
  34372. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34373. /**
  34374. * Observable raised when the engine ends the current frame
  34375. */
  34376. onEndFrameObservable: Observable<Engine>;
  34377. /**
  34378. * Observable raised when the engine is about to compile a shader
  34379. */
  34380. onBeforeShaderCompilationObservable: Observable<Engine>;
  34381. /**
  34382. * Observable raised when the engine has jsut compiled a shader
  34383. */
  34384. onAfterShaderCompilationObservable: Observable<Engine>;
  34385. /**
  34386. * Gets the audio engine
  34387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34388. * @ignorenaming
  34389. */
  34390. static audioEngine: IAudioEngine;
  34391. /**
  34392. * Default AudioEngine factory responsible of creating the Audio Engine.
  34393. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34394. */
  34395. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34396. /**
  34397. * Default offline support factory responsible of creating a tool used to store data locally.
  34398. * By default, this will create a Database object if the workload has been embedded.
  34399. */
  34400. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34401. private _loadingScreen;
  34402. private _pointerLockRequested;
  34403. private _dummyFramebuffer;
  34404. private _rescalePostProcess;
  34405. private _deterministicLockstep;
  34406. private _lockstepMaxSteps;
  34407. private _timeStep;
  34408. protected get _supportsHardwareTextureRescaling(): boolean;
  34409. private _fps;
  34410. private _deltaTime;
  34411. /** @hidden */
  34412. _drawCalls: PerfCounter;
  34413. /** 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 */
  34414. canvasTabIndex: number;
  34415. /**
  34416. * Turn this value on if you want to pause FPS computation when in background
  34417. */
  34418. disablePerformanceMonitorInBackground: boolean;
  34419. private _performanceMonitor;
  34420. /**
  34421. * Gets the performance monitor attached to this engine
  34422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34423. */
  34424. get performanceMonitor(): PerformanceMonitor;
  34425. private _onFocus;
  34426. private _onBlur;
  34427. private _onCanvasPointerOut;
  34428. private _onCanvasBlur;
  34429. private _onCanvasFocus;
  34430. private _onFullscreenChange;
  34431. private _onPointerLockChange;
  34432. /**
  34433. * Gets the HTML element used to attach event listeners
  34434. * @returns a HTML element
  34435. */
  34436. getInputElement(): Nullable<HTMLElement>;
  34437. /**
  34438. * Creates a new engine
  34439. * @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
  34440. * @param antialias defines enable antialiasing (default: false)
  34441. * @param options defines further options to be sent to the getContext() function
  34442. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34443. */
  34444. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34445. /**
  34446. * Gets current aspect ratio
  34447. * @param viewportOwner defines the camera to use to get the aspect ratio
  34448. * @param useScreen defines if screen size must be used (or the current render target if any)
  34449. * @returns a number defining the aspect ratio
  34450. */
  34451. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34452. /**
  34453. * Gets current screen aspect ratio
  34454. * @returns a number defining the aspect ratio
  34455. */
  34456. getScreenAspectRatio(): number;
  34457. /**
  34458. * Gets the client rect of the HTML canvas attached with the current webGL context
  34459. * @returns a client rectanglee
  34460. */
  34461. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34462. /**
  34463. * Gets the client rect of the HTML element used for events
  34464. * @returns a client rectanglee
  34465. */
  34466. getInputElementClientRect(): Nullable<ClientRect>;
  34467. /**
  34468. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34469. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34470. * @returns true if engine is in deterministic lock step mode
  34471. */
  34472. isDeterministicLockStep(): boolean;
  34473. /**
  34474. * Gets the max steps when engine is running in deterministic lock step
  34475. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34476. * @returns the max steps
  34477. */
  34478. getLockstepMaxSteps(): number;
  34479. /**
  34480. * Returns the time in ms between steps when using deterministic lock step.
  34481. * @returns time step in (ms)
  34482. */
  34483. getTimeStep(): number;
  34484. /**
  34485. * Force the mipmap generation for the given render target texture
  34486. * @param texture defines the render target texture to use
  34487. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34488. */
  34489. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34490. /** States */
  34491. /**
  34492. * Set various states to the webGL context
  34493. * @param culling defines backface culling state
  34494. * @param zOffset defines the value to apply to zOffset (0 by default)
  34495. * @param force defines if states must be applied even if cache is up to date
  34496. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34497. */
  34498. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34499. /**
  34500. * Set the z offset to apply to current rendering
  34501. * @param value defines the offset to apply
  34502. */
  34503. setZOffset(value: number): void;
  34504. /**
  34505. * Gets the current value of the zOffset
  34506. * @returns the current zOffset state
  34507. */
  34508. getZOffset(): number;
  34509. /**
  34510. * Enable or disable depth buffering
  34511. * @param enable defines the state to set
  34512. */
  34513. setDepthBuffer(enable: boolean): void;
  34514. /**
  34515. * Gets a boolean indicating if depth writing is enabled
  34516. * @returns the current depth writing state
  34517. */
  34518. getDepthWrite(): boolean;
  34519. /**
  34520. * Enable or disable depth writing
  34521. * @param enable defines the state to set
  34522. */
  34523. setDepthWrite(enable: boolean): void;
  34524. /**
  34525. * Gets a boolean indicating if stencil buffer is enabled
  34526. * @returns the current stencil buffer state
  34527. */
  34528. getStencilBuffer(): boolean;
  34529. /**
  34530. * Enable or disable the stencil buffer
  34531. * @param enable defines if the stencil buffer must be enabled or disabled
  34532. */
  34533. setStencilBuffer(enable: boolean): void;
  34534. /**
  34535. * Gets the current stencil mask
  34536. * @returns a number defining the new stencil mask to use
  34537. */
  34538. getStencilMask(): number;
  34539. /**
  34540. * Sets the current stencil mask
  34541. * @param mask defines the new stencil mask to use
  34542. */
  34543. setStencilMask(mask: number): void;
  34544. /**
  34545. * Gets the current stencil function
  34546. * @returns a number defining the stencil function to use
  34547. */
  34548. getStencilFunction(): number;
  34549. /**
  34550. * Gets the current stencil reference value
  34551. * @returns a number defining the stencil reference value to use
  34552. */
  34553. getStencilFunctionReference(): number;
  34554. /**
  34555. * Gets the current stencil mask
  34556. * @returns a number defining the stencil mask to use
  34557. */
  34558. getStencilFunctionMask(): number;
  34559. /**
  34560. * Sets the current stencil function
  34561. * @param stencilFunc defines the new stencil function to use
  34562. */
  34563. setStencilFunction(stencilFunc: number): void;
  34564. /**
  34565. * Sets the current stencil reference
  34566. * @param reference defines the new stencil reference to use
  34567. */
  34568. setStencilFunctionReference(reference: number): void;
  34569. /**
  34570. * Sets the current stencil mask
  34571. * @param mask defines the new stencil mask to use
  34572. */
  34573. setStencilFunctionMask(mask: number): void;
  34574. /**
  34575. * Gets the current stencil operation when stencil fails
  34576. * @returns a number defining stencil operation to use when stencil fails
  34577. */
  34578. getStencilOperationFail(): number;
  34579. /**
  34580. * Gets the current stencil operation when depth fails
  34581. * @returns a number defining stencil operation to use when depth fails
  34582. */
  34583. getStencilOperationDepthFail(): number;
  34584. /**
  34585. * Gets the current stencil operation when stencil passes
  34586. * @returns a number defining stencil operation to use when stencil passes
  34587. */
  34588. getStencilOperationPass(): number;
  34589. /**
  34590. * Sets the stencil operation to use when stencil fails
  34591. * @param operation defines the stencil operation to use when stencil fails
  34592. */
  34593. setStencilOperationFail(operation: number): void;
  34594. /**
  34595. * Sets the stencil operation to use when depth fails
  34596. * @param operation defines the stencil operation to use when depth fails
  34597. */
  34598. setStencilOperationDepthFail(operation: number): void;
  34599. /**
  34600. * Sets the stencil operation to use when stencil passes
  34601. * @param operation defines the stencil operation to use when stencil passes
  34602. */
  34603. setStencilOperationPass(operation: number): void;
  34604. /**
  34605. * Sets a boolean indicating if the dithering state is enabled or disabled
  34606. * @param value defines the dithering state
  34607. */
  34608. setDitheringState(value: boolean): void;
  34609. /**
  34610. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34611. * @param value defines the rasterizer state
  34612. */
  34613. setRasterizerState(value: boolean): void;
  34614. /**
  34615. * Gets the current depth function
  34616. * @returns a number defining the depth function
  34617. */
  34618. getDepthFunction(): Nullable<number>;
  34619. /**
  34620. * Sets the current depth function
  34621. * @param depthFunc defines the function to use
  34622. */
  34623. setDepthFunction(depthFunc: number): void;
  34624. /**
  34625. * Sets the current depth function to GREATER
  34626. */
  34627. setDepthFunctionToGreater(): void;
  34628. /**
  34629. * Sets the current depth function to GEQUAL
  34630. */
  34631. setDepthFunctionToGreaterOrEqual(): void;
  34632. /**
  34633. * Sets the current depth function to LESS
  34634. */
  34635. setDepthFunctionToLess(): void;
  34636. /**
  34637. * Sets the current depth function to LEQUAL
  34638. */
  34639. setDepthFunctionToLessOrEqual(): void;
  34640. private _cachedStencilBuffer;
  34641. private _cachedStencilFunction;
  34642. private _cachedStencilMask;
  34643. private _cachedStencilOperationPass;
  34644. private _cachedStencilOperationFail;
  34645. private _cachedStencilOperationDepthFail;
  34646. private _cachedStencilReference;
  34647. /**
  34648. * Caches the the state of the stencil buffer
  34649. */
  34650. cacheStencilState(): void;
  34651. /**
  34652. * Restores the state of the stencil buffer
  34653. */
  34654. restoreStencilState(): void;
  34655. /**
  34656. * Directly set the WebGL Viewport
  34657. * @param x defines the x coordinate of the viewport (in screen space)
  34658. * @param y defines the y coordinate of the viewport (in screen space)
  34659. * @param width defines the width of the viewport (in screen space)
  34660. * @param height defines the height of the viewport (in screen space)
  34661. * @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
  34662. */
  34663. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34664. /**
  34665. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34666. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34667. * @param y defines the y-coordinate of the corner of the clear rectangle
  34668. * @param width defines the width of the clear rectangle
  34669. * @param height defines the height of the clear rectangle
  34670. * @param clearColor defines the clear color
  34671. */
  34672. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34673. /**
  34674. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34675. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34676. * @param y defines the y-coordinate of the corner of the clear rectangle
  34677. * @param width defines the width of the clear rectangle
  34678. * @param height defines the height of the clear rectangle
  34679. */
  34680. enableScissor(x: number, y: number, width: number, height: number): void;
  34681. /**
  34682. * Disable previously set scissor test rectangle
  34683. */
  34684. disableScissor(): void;
  34685. protected _reportDrawCall(): void;
  34686. /**
  34687. * Initializes a webVR display and starts listening to display change events
  34688. * The onVRDisplayChangedObservable will be notified upon these changes
  34689. * @returns The onVRDisplayChangedObservable
  34690. */
  34691. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34692. /** @hidden */
  34693. _prepareVRComponent(): void;
  34694. /** @hidden */
  34695. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34696. /** @hidden */
  34697. _submitVRFrame(): void;
  34698. /**
  34699. * Call this function to leave webVR mode
  34700. * Will do nothing if webVR is not supported or if there is no webVR device
  34701. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34702. */
  34703. disableVR(): void;
  34704. /**
  34705. * Gets a boolean indicating that the system is in VR mode and is presenting
  34706. * @returns true if VR mode is engaged
  34707. */
  34708. isVRPresenting(): boolean;
  34709. /** @hidden */
  34710. _requestVRFrame(): void;
  34711. /** @hidden */
  34712. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34713. /**
  34714. * Gets the source code of the vertex shader associated with a specific webGL program
  34715. * @param program defines the program to use
  34716. * @returns a string containing the source code of the vertex shader associated with the program
  34717. */
  34718. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34719. /**
  34720. * Gets the source code of the fragment shader associated with a specific webGL program
  34721. * @param program defines the program to use
  34722. * @returns a string containing the source code of the fragment shader associated with the program
  34723. */
  34724. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34725. /**
  34726. * Sets a depth stencil texture from a render target to the according uniform.
  34727. * @param channel The texture channel
  34728. * @param uniform The uniform to set
  34729. * @param texture The render target texture containing the depth stencil texture to apply
  34730. */
  34731. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34732. /**
  34733. * Sets a texture to the webGL context from a postprocess
  34734. * @param channel defines the channel to use
  34735. * @param postProcess defines the source postprocess
  34736. */
  34737. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34738. /**
  34739. * Binds the output of the passed in post process to the texture channel specified
  34740. * @param channel The channel the texture should be bound to
  34741. * @param postProcess The post process which's output should be bound
  34742. */
  34743. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34744. /** @hidden */
  34745. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34746. protected _rebuildBuffers(): void;
  34747. /** @hidden */
  34748. _renderFrame(): void;
  34749. _renderLoop(): void;
  34750. /** @hidden */
  34751. _renderViews(): boolean;
  34752. /**
  34753. * Toggle full screen mode
  34754. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34755. */
  34756. switchFullscreen(requestPointerLock: boolean): void;
  34757. /**
  34758. * Enters full screen mode
  34759. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34760. */
  34761. enterFullscreen(requestPointerLock: boolean): void;
  34762. /**
  34763. * Exits full screen mode
  34764. */
  34765. exitFullscreen(): void;
  34766. /**
  34767. * Enters Pointerlock mode
  34768. */
  34769. enterPointerlock(): void;
  34770. /**
  34771. * Exits Pointerlock mode
  34772. */
  34773. exitPointerlock(): void;
  34774. /**
  34775. * Begin a new frame
  34776. */
  34777. beginFrame(): void;
  34778. /**
  34779. * Enf the current frame
  34780. */
  34781. endFrame(): void;
  34782. resize(): void;
  34783. /**
  34784. * Force a specific size of the canvas
  34785. * @param width defines the new canvas' width
  34786. * @param height defines the new canvas' height
  34787. */
  34788. setSize(width: number, height: number): void;
  34789. /**
  34790. * Updates a dynamic vertex buffer.
  34791. * @param vertexBuffer the vertex buffer to update
  34792. * @param data the data used to update the vertex buffer
  34793. * @param byteOffset the byte offset of the data
  34794. * @param byteLength the byte length of the data
  34795. */
  34796. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34797. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34798. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34799. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34800. _releaseTexture(texture: InternalTexture): void;
  34801. /**
  34802. * @hidden
  34803. * Rescales a texture
  34804. * @param source input texutre
  34805. * @param destination destination texture
  34806. * @param scene scene to use to render the resize
  34807. * @param internalFormat format to use when resizing
  34808. * @param onComplete callback to be called when resize has completed
  34809. */
  34810. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34811. /**
  34812. * Gets the current framerate
  34813. * @returns a number representing the framerate
  34814. */
  34815. getFps(): number;
  34816. /**
  34817. * Gets the time spent between current and previous frame
  34818. * @returns a number representing the delta time in ms
  34819. */
  34820. getDeltaTime(): number;
  34821. private _measureFps;
  34822. /** @hidden */
  34823. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34824. /**
  34825. * Update a dynamic index buffer
  34826. * @param indexBuffer defines the target index buffer
  34827. * @param indices defines the data to update
  34828. * @param offset defines the offset in the target index buffer where update should start
  34829. */
  34830. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34831. /**
  34832. * Updates the sample count of a render target texture
  34833. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34834. * @param texture defines the texture to update
  34835. * @param samples defines the sample count to set
  34836. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34837. */
  34838. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34839. /**
  34840. * Updates a depth texture Comparison Mode and Function.
  34841. * If the comparison Function is equal to 0, the mode will be set to none.
  34842. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34843. * @param texture The texture to set the comparison function for
  34844. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34845. */
  34846. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34847. /**
  34848. * Creates a webGL buffer to use with instanciation
  34849. * @param capacity defines the size of the buffer
  34850. * @returns the webGL buffer
  34851. */
  34852. createInstancesBuffer(capacity: number): DataBuffer;
  34853. /**
  34854. * Delete a webGL buffer used with instanciation
  34855. * @param buffer defines the webGL buffer to delete
  34856. */
  34857. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34858. private _clientWaitAsync;
  34859. /** @hidden */
  34860. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34861. /** @hidden */
  34862. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34863. dispose(): void;
  34864. private _disableTouchAction;
  34865. /**
  34866. * Display the loading screen
  34867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34868. */
  34869. displayLoadingUI(): void;
  34870. /**
  34871. * Hide the loading screen
  34872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34873. */
  34874. hideLoadingUI(): void;
  34875. /**
  34876. * Gets the current loading screen object
  34877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34878. */
  34879. get loadingScreen(): ILoadingScreen;
  34880. /**
  34881. * Sets the current loading screen object
  34882. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34883. */
  34884. set loadingScreen(loadingScreen: ILoadingScreen);
  34885. /**
  34886. * Sets the current loading screen text
  34887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34888. */
  34889. set loadingUIText(text: string);
  34890. /**
  34891. * Sets the current loading screen background color
  34892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34893. */
  34894. set loadingUIBackgroundColor(color: string);
  34895. /** Pointerlock and fullscreen */
  34896. /**
  34897. * Ask the browser to promote the current element to pointerlock mode
  34898. * @param element defines the DOM element to promote
  34899. */
  34900. static _RequestPointerlock(element: HTMLElement): void;
  34901. /**
  34902. * Asks the browser to exit pointerlock mode
  34903. */
  34904. static _ExitPointerlock(): void;
  34905. /**
  34906. * Ask the browser to promote the current element to fullscreen rendering mode
  34907. * @param element defines the DOM element to promote
  34908. */
  34909. static _RequestFullscreen(element: HTMLElement): void;
  34910. /**
  34911. * Asks the browser to exit fullscreen mode
  34912. */
  34913. static _ExitFullscreen(): void;
  34914. }
  34915. }
  34916. declare module "babylonjs/Engines/engineStore" {
  34917. import { Nullable } from "babylonjs/types";
  34918. import { Engine } from "babylonjs/Engines/engine";
  34919. import { Scene } from "babylonjs/scene";
  34920. /**
  34921. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34922. * during the life time of the application.
  34923. */
  34924. export class EngineStore {
  34925. /** Gets the list of created engines */
  34926. static Instances: import("babylonjs/Engines/engine").Engine[];
  34927. /** @hidden */
  34928. static _LastCreatedScene: Nullable<Scene>;
  34929. /**
  34930. * Gets the latest created engine
  34931. */
  34932. static get LastCreatedEngine(): Nullable<Engine>;
  34933. /**
  34934. * Gets the latest created scene
  34935. */
  34936. static get LastCreatedScene(): Nullable<Scene>;
  34937. /**
  34938. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34939. * @ignorenaming
  34940. */
  34941. static UseFallbackTexture: boolean;
  34942. /**
  34943. * Texture content used if a texture cannot loaded
  34944. * @ignorenaming
  34945. */
  34946. static FallbackTexture: string;
  34947. }
  34948. }
  34949. declare module "babylonjs/Misc/promise" {
  34950. /**
  34951. * Helper class that provides a small promise polyfill
  34952. */
  34953. export class PromisePolyfill {
  34954. /**
  34955. * Static function used to check if the polyfill is required
  34956. * If this is the case then the function will inject the polyfill to window.Promise
  34957. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34958. */
  34959. static Apply(force?: boolean): void;
  34960. }
  34961. }
  34962. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34963. /**
  34964. * Interface for screenshot methods with describe argument called `size` as object with options
  34965. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34966. */
  34967. export interface IScreenshotSize {
  34968. /**
  34969. * number in pixels for canvas height
  34970. */
  34971. height?: number;
  34972. /**
  34973. * multiplier allowing render at a higher or lower resolution
  34974. * If value is defined then height and width will be ignored and taken from camera
  34975. */
  34976. precision?: number;
  34977. /**
  34978. * number in pixels for canvas width
  34979. */
  34980. width?: number;
  34981. }
  34982. }
  34983. declare module "babylonjs/Misc/tools" {
  34984. import { Nullable, float } from "babylonjs/types";
  34985. import { DomManagement } from "babylonjs/Misc/domManagement";
  34986. import { WebRequest } from "babylonjs/Misc/webRequest";
  34987. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34988. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34989. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34990. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34991. import { Camera } from "babylonjs/Cameras/camera";
  34992. import { Engine } from "babylonjs/Engines/engine";
  34993. interface IColor4Like {
  34994. r: float;
  34995. g: float;
  34996. b: float;
  34997. a: float;
  34998. }
  34999. /**
  35000. * Class containing a set of static utilities functions
  35001. */
  35002. export class Tools {
  35003. /**
  35004. * Gets or sets the base URL to use to load assets
  35005. */
  35006. static get BaseUrl(): string;
  35007. static set BaseUrl(value: string);
  35008. /**
  35009. * Enable/Disable Custom HTTP Request Headers globally.
  35010. * default = false
  35011. * @see CustomRequestHeaders
  35012. */
  35013. static UseCustomRequestHeaders: boolean;
  35014. /**
  35015. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35016. * i.e. when loading files, where the server/service expects an Authorization header
  35017. */
  35018. static CustomRequestHeaders: {
  35019. [key: string]: string;
  35020. };
  35021. /**
  35022. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35023. */
  35024. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35025. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35026. /**
  35027. * Default behaviour for cors in the application.
  35028. * It can be a string if the expected behavior is identical in the entire app.
  35029. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35030. */
  35031. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35032. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35033. /**
  35034. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35035. * @ignorenaming
  35036. */
  35037. static get UseFallbackTexture(): boolean;
  35038. static set UseFallbackTexture(value: boolean);
  35039. /**
  35040. * Use this object to register external classes like custom textures or material
  35041. * to allow the laoders to instantiate them
  35042. */
  35043. static get RegisteredExternalClasses(): {
  35044. [key: string]: Object;
  35045. };
  35046. static set RegisteredExternalClasses(classes: {
  35047. [key: string]: Object;
  35048. });
  35049. /**
  35050. * Texture content used if a texture cannot loaded
  35051. * @ignorenaming
  35052. */
  35053. static get fallbackTexture(): string;
  35054. static set fallbackTexture(value: string);
  35055. /**
  35056. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35057. * @param u defines the coordinate on X axis
  35058. * @param v defines the coordinate on Y axis
  35059. * @param width defines the width of the source data
  35060. * @param height defines the height of the source data
  35061. * @param pixels defines the source byte array
  35062. * @param color defines the output color
  35063. */
  35064. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35065. /**
  35066. * Interpolates between a and b via alpha
  35067. * @param a The lower value (returned when alpha = 0)
  35068. * @param b The upper value (returned when alpha = 1)
  35069. * @param alpha The interpolation-factor
  35070. * @return The mixed value
  35071. */
  35072. static Mix(a: number, b: number, alpha: number): number;
  35073. /**
  35074. * Tries to instantiate a new object from a given class name
  35075. * @param className defines the class name to instantiate
  35076. * @returns the new object or null if the system was not able to do the instantiation
  35077. */
  35078. static Instantiate(className: string): any;
  35079. /**
  35080. * Provides a slice function that will work even on IE
  35081. * @param data defines the array to slice
  35082. * @param start defines the start of the data (optional)
  35083. * @param end defines the end of the data (optional)
  35084. * @returns the new sliced array
  35085. */
  35086. static Slice<T>(data: T, start?: number, end?: number): T;
  35087. /**
  35088. * Polyfill for setImmediate
  35089. * @param action defines the action to execute after the current execution block
  35090. */
  35091. static SetImmediate(action: () => void): void;
  35092. /**
  35093. * Function indicating if a number is an exponent of 2
  35094. * @param value defines the value to test
  35095. * @returns true if the value is an exponent of 2
  35096. */
  35097. static IsExponentOfTwo(value: number): boolean;
  35098. private static _tmpFloatArray;
  35099. /**
  35100. * Returns the nearest 32-bit single precision float representation of a Number
  35101. * @param value A Number. If the parameter is of a different type, it will get converted
  35102. * to a number or to NaN if it cannot be converted
  35103. * @returns number
  35104. */
  35105. static FloatRound(value: number): number;
  35106. /**
  35107. * Extracts the filename from a path
  35108. * @param path defines the path to use
  35109. * @returns the filename
  35110. */
  35111. static GetFilename(path: string): string;
  35112. /**
  35113. * Extracts the "folder" part of a path (everything before the filename).
  35114. * @param uri The URI to extract the info from
  35115. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35116. * @returns The "folder" part of the path
  35117. */
  35118. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35119. /**
  35120. * Extracts text content from a DOM element hierarchy
  35121. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35122. */
  35123. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35124. /**
  35125. * Convert an angle in radians to degrees
  35126. * @param angle defines the angle to convert
  35127. * @returns the angle in degrees
  35128. */
  35129. static ToDegrees(angle: number): number;
  35130. /**
  35131. * Convert an angle in degrees to radians
  35132. * @param angle defines the angle to convert
  35133. * @returns the angle in radians
  35134. */
  35135. static ToRadians(angle: number): number;
  35136. /**
  35137. * Returns an array if obj is not an array
  35138. * @param obj defines the object to evaluate as an array
  35139. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35140. * @returns either obj directly if obj is an array or a new array containing obj
  35141. */
  35142. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35143. /**
  35144. * Gets the pointer prefix to use
  35145. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35146. */
  35147. static GetPointerPrefix(): string;
  35148. /**
  35149. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35150. * @param url define the url we are trying
  35151. * @param element define the dom element where to configure the cors policy
  35152. */
  35153. static SetCorsBehavior(url: string | string[], element: {
  35154. crossOrigin: string | null;
  35155. }): void;
  35156. /**
  35157. * Removes unwanted characters from an url
  35158. * @param url defines the url to clean
  35159. * @returns the cleaned url
  35160. */
  35161. static CleanUrl(url: string): string;
  35162. /**
  35163. * Gets or sets a function used to pre-process url before using them to load assets
  35164. */
  35165. static get PreprocessUrl(): (url: string) => string;
  35166. static set PreprocessUrl(processor: (url: string) => string);
  35167. /**
  35168. * Loads an image as an HTMLImageElement.
  35169. * @param input url string, ArrayBuffer, or Blob to load
  35170. * @param onLoad callback called when the image successfully loads
  35171. * @param onError callback called when the image fails to load
  35172. * @param offlineProvider offline provider for caching
  35173. * @param mimeType optional mime type
  35174. * @returns the HTMLImageElement of the loaded image
  35175. */
  35176. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35177. /**
  35178. * Loads a file from a url
  35179. * @param url url string, ArrayBuffer, or Blob to load
  35180. * @param onSuccess callback called when the file successfully loads
  35181. * @param onProgress callback called while file is loading (if the server supports this mode)
  35182. * @param offlineProvider defines the offline provider for caching
  35183. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35184. * @param onError callback called when the file fails to load
  35185. * @returns a file request object
  35186. */
  35187. 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;
  35188. /**
  35189. * Loads a file from a url
  35190. * @param url the file url to load
  35191. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35192. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35193. */
  35194. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35195. /**
  35196. * Load a script (identified by an url). When the url returns, the
  35197. * content of this file is added into a new script element, attached to the DOM (body element)
  35198. * @param scriptUrl defines the url of the script to laod
  35199. * @param onSuccess defines the callback called when the script is loaded
  35200. * @param onError defines the callback to call if an error occurs
  35201. * @param scriptId defines the id of the script element
  35202. */
  35203. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35204. /**
  35205. * Load an asynchronous script (identified by an url). When the url returns, the
  35206. * content of this file is added into a new script element, attached to the DOM (body element)
  35207. * @param scriptUrl defines the url of the script to laod
  35208. * @param scriptId defines the id of the script element
  35209. * @returns a promise request object
  35210. */
  35211. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35212. /**
  35213. * Loads a file from a blob
  35214. * @param fileToLoad defines the blob to use
  35215. * @param callback defines the callback to call when data is loaded
  35216. * @param progressCallback defines the callback to call during loading process
  35217. * @returns a file request object
  35218. */
  35219. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35220. /**
  35221. * Reads a file from a File object
  35222. * @param file defines the file to load
  35223. * @param onSuccess defines the callback to call when data is loaded
  35224. * @param onProgress defines the callback to call during loading process
  35225. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35226. * @param onError defines the callback to call when an error occurs
  35227. * @returns a file request object
  35228. */
  35229. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35230. /**
  35231. * Creates a data url from a given string content
  35232. * @param content defines the content to convert
  35233. * @returns the new data url link
  35234. */
  35235. static FileAsURL(content: string): string;
  35236. /**
  35237. * Format the given number to a specific decimal format
  35238. * @param value defines the number to format
  35239. * @param decimals defines the number of decimals to use
  35240. * @returns the formatted string
  35241. */
  35242. static Format(value: number, decimals?: number): string;
  35243. /**
  35244. * Tries to copy an object by duplicating every property
  35245. * @param source defines the source object
  35246. * @param destination defines the target object
  35247. * @param doNotCopyList defines a list of properties to avoid
  35248. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35249. */
  35250. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35251. /**
  35252. * Gets a boolean indicating if the given object has no own property
  35253. * @param obj defines the object to test
  35254. * @returns true if object has no own property
  35255. */
  35256. static IsEmpty(obj: any): boolean;
  35257. /**
  35258. * Function used to register events at window level
  35259. * @param windowElement defines the Window object to use
  35260. * @param events defines the events to register
  35261. */
  35262. static RegisterTopRootEvents(windowElement: Window, events: {
  35263. name: string;
  35264. handler: Nullable<(e: FocusEvent) => any>;
  35265. }[]): void;
  35266. /**
  35267. * Function used to unregister events from window level
  35268. * @param windowElement defines the Window object to use
  35269. * @param events defines the events to unregister
  35270. */
  35271. static UnregisterTopRootEvents(windowElement: Window, events: {
  35272. name: string;
  35273. handler: Nullable<(e: FocusEvent) => any>;
  35274. }[]): void;
  35275. /**
  35276. * @ignore
  35277. */
  35278. static _ScreenshotCanvas: HTMLCanvasElement;
  35279. /**
  35280. * Dumps the current bound framebuffer
  35281. * @param width defines the rendering width
  35282. * @param height defines the rendering height
  35283. * @param engine defines the hosting engine
  35284. * @param successCallback defines the callback triggered once the data are available
  35285. * @param mimeType defines the mime type of the result
  35286. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35287. */
  35288. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35289. /**
  35290. * Converts the canvas data to blob.
  35291. * This acts as a polyfill for browsers not supporting the to blob function.
  35292. * @param canvas Defines the canvas to extract the data from
  35293. * @param successCallback Defines the callback triggered once the data are available
  35294. * @param mimeType Defines the mime type of the result
  35295. */
  35296. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35297. /**
  35298. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35299. * @param successCallback defines the callback triggered once the data are available
  35300. * @param mimeType defines the mime type of the result
  35301. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35302. */
  35303. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35304. /**
  35305. * Downloads a blob in the browser
  35306. * @param blob defines the blob to download
  35307. * @param fileName defines the name of the downloaded file
  35308. */
  35309. static Download(blob: Blob, fileName: string): void;
  35310. /**
  35311. * Captures a screenshot of the current rendering
  35312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35313. * @param engine defines the rendering engine
  35314. * @param camera defines the source camera
  35315. * @param size This parameter can be set to a single number or to an object with the
  35316. * following (optional) properties: precision, width, height. If a single number is passed,
  35317. * it will be used for both width and height. If an object is passed, the screenshot size
  35318. * will be derived from the parameters. The precision property is a multiplier allowing
  35319. * rendering at a higher or lower resolution
  35320. * @param successCallback defines the callback receives a single parameter which contains the
  35321. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35322. * src parameter of an <img> to display it
  35323. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35324. * Check your browser for supported MIME types
  35325. */
  35326. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35327. /**
  35328. * Captures a screenshot of the current rendering
  35329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35330. * @param engine defines the rendering engine
  35331. * @param camera defines the source camera
  35332. * @param size This parameter can be set to a single number or to an object with the
  35333. * following (optional) properties: precision, width, height. If a single number is passed,
  35334. * it will be used for both width and height. If an object is passed, the screenshot size
  35335. * will be derived from the parameters. The precision property is a multiplier allowing
  35336. * rendering at a higher or lower resolution
  35337. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35338. * Check your browser for supported MIME types
  35339. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35340. * to the src parameter of an <img> to display it
  35341. */
  35342. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35343. /**
  35344. * Generates an image screenshot from the specified camera.
  35345. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35346. * @param engine The engine to use for rendering
  35347. * @param camera The camera to use for rendering
  35348. * @param size This parameter can be set to a single number or to an object with the
  35349. * following (optional) properties: precision, width, height. If a single number is passed,
  35350. * it will be used for both width and height. If an object is passed, the screenshot size
  35351. * will be derived from the parameters. The precision property is a multiplier allowing
  35352. * rendering at a higher or lower resolution
  35353. * @param successCallback The callback receives a single parameter which contains the
  35354. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35355. * src parameter of an <img> to display it
  35356. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35357. * Check your browser for supported MIME types
  35358. * @param samples Texture samples (default: 1)
  35359. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35360. * @param fileName A name for for the downloaded file.
  35361. */
  35362. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35363. /**
  35364. * Generates an image screenshot from the specified camera.
  35365. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35366. * @param engine The engine to use for rendering
  35367. * @param camera The camera to use for rendering
  35368. * @param size This parameter can be set to a single number or to an object with the
  35369. * following (optional) properties: precision, width, height. If a single number is passed,
  35370. * it will be used for both width and height. If an object is passed, the screenshot size
  35371. * will be derived from the parameters. The precision property is a multiplier allowing
  35372. * rendering at a higher or lower resolution
  35373. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35374. * Check your browser for supported MIME types
  35375. * @param samples Texture samples (default: 1)
  35376. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35377. * @param fileName A name for for the downloaded file.
  35378. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35379. * to the src parameter of an <img> to display it
  35380. */
  35381. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35382. /**
  35383. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35384. * Be aware Math.random() could cause collisions, but:
  35385. * "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"
  35386. * @returns a pseudo random id
  35387. */
  35388. static RandomId(): string;
  35389. /**
  35390. * Test if the given uri is a base64 string
  35391. * @param uri The uri to test
  35392. * @return True if the uri is a base64 string or false otherwise
  35393. */
  35394. static IsBase64(uri: string): boolean;
  35395. /**
  35396. * Decode the given base64 uri.
  35397. * @param uri The uri to decode
  35398. * @return The decoded base64 data.
  35399. */
  35400. static DecodeBase64(uri: string): ArrayBuffer;
  35401. /**
  35402. * Gets the absolute url.
  35403. * @param url the input url
  35404. * @return the absolute url
  35405. */
  35406. static GetAbsoluteUrl(url: string): string;
  35407. /**
  35408. * No log
  35409. */
  35410. static readonly NoneLogLevel: number;
  35411. /**
  35412. * Only message logs
  35413. */
  35414. static readonly MessageLogLevel: number;
  35415. /**
  35416. * Only warning logs
  35417. */
  35418. static readonly WarningLogLevel: number;
  35419. /**
  35420. * Only error logs
  35421. */
  35422. static readonly ErrorLogLevel: number;
  35423. /**
  35424. * All logs
  35425. */
  35426. static readonly AllLogLevel: number;
  35427. /**
  35428. * Gets a value indicating the number of loading errors
  35429. * @ignorenaming
  35430. */
  35431. static get errorsCount(): number;
  35432. /**
  35433. * Callback called when a new log is added
  35434. */
  35435. static OnNewCacheEntry: (entry: string) => void;
  35436. /**
  35437. * Log a message to the console
  35438. * @param message defines the message to log
  35439. */
  35440. static Log(message: string): void;
  35441. /**
  35442. * Write a warning message to the console
  35443. * @param message defines the message to log
  35444. */
  35445. static Warn(message: string): void;
  35446. /**
  35447. * Write an error message to the console
  35448. * @param message defines the message to log
  35449. */
  35450. static Error(message: string): void;
  35451. /**
  35452. * Gets current log cache (list of logs)
  35453. */
  35454. static get LogCache(): string;
  35455. /**
  35456. * Clears the log cache
  35457. */
  35458. static ClearLogCache(): void;
  35459. /**
  35460. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35461. */
  35462. static set LogLevels(level: number);
  35463. /**
  35464. * Checks if the window object exists
  35465. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35466. */
  35467. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35468. /**
  35469. * No performance log
  35470. */
  35471. static readonly PerformanceNoneLogLevel: number;
  35472. /**
  35473. * Use user marks to log performance
  35474. */
  35475. static readonly PerformanceUserMarkLogLevel: number;
  35476. /**
  35477. * Log performance to the console
  35478. */
  35479. static readonly PerformanceConsoleLogLevel: number;
  35480. private static _performance;
  35481. /**
  35482. * Sets the current performance log level
  35483. */
  35484. static set PerformanceLogLevel(level: number);
  35485. private static _StartPerformanceCounterDisabled;
  35486. private static _EndPerformanceCounterDisabled;
  35487. private static _StartUserMark;
  35488. private static _EndUserMark;
  35489. private static _StartPerformanceConsole;
  35490. private static _EndPerformanceConsole;
  35491. /**
  35492. * Starts a performance counter
  35493. */
  35494. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35495. /**
  35496. * Ends a specific performance coutner
  35497. */
  35498. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35499. /**
  35500. * Gets either window.performance.now() if supported or Date.now() else
  35501. */
  35502. static get Now(): number;
  35503. /**
  35504. * This method will return the name of the class used to create the instance of the given object.
  35505. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35506. * @param object the object to get the class name from
  35507. * @param isType defines if the object is actually a type
  35508. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35509. */
  35510. static GetClassName(object: any, isType?: boolean): string;
  35511. /**
  35512. * Gets the first element of an array satisfying a given predicate
  35513. * @param array defines the array to browse
  35514. * @param predicate defines the predicate to use
  35515. * @returns null if not found or the element
  35516. */
  35517. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35518. /**
  35519. * This method will return the name of the full name of the class, including its owning module (if any).
  35520. * 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).
  35521. * @param object the object to get the class name from
  35522. * @param isType defines if the object is actually a type
  35523. * @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.
  35524. * @ignorenaming
  35525. */
  35526. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35527. /**
  35528. * Returns a promise that resolves after the given amount of time.
  35529. * @param delay Number of milliseconds to delay
  35530. * @returns Promise that resolves after the given amount of time
  35531. */
  35532. static DelayAsync(delay: number): Promise<void>;
  35533. /**
  35534. * Utility function to detect if the current user agent is Safari
  35535. * @returns whether or not the current user agent is safari
  35536. */
  35537. static IsSafari(): boolean;
  35538. }
  35539. /**
  35540. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35541. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35542. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35543. * @param name The name of the class, case should be preserved
  35544. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35545. */
  35546. export function className(name: string, module?: string): (target: Object) => void;
  35547. /**
  35548. * An implementation of a loop for asynchronous functions.
  35549. */
  35550. export class AsyncLoop {
  35551. /**
  35552. * Defines the number of iterations for the loop
  35553. */
  35554. iterations: number;
  35555. /**
  35556. * Defines the current index of the loop.
  35557. */
  35558. index: number;
  35559. private _done;
  35560. private _fn;
  35561. private _successCallback;
  35562. /**
  35563. * Constructor.
  35564. * @param iterations the number of iterations.
  35565. * @param func the function to run each iteration
  35566. * @param successCallback the callback that will be called upon succesful execution
  35567. * @param offset starting offset.
  35568. */
  35569. constructor(
  35570. /**
  35571. * Defines the number of iterations for the loop
  35572. */
  35573. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35574. /**
  35575. * Execute the next iteration. Must be called after the last iteration was finished.
  35576. */
  35577. executeNext(): void;
  35578. /**
  35579. * Break the loop and run the success callback.
  35580. */
  35581. breakLoop(): void;
  35582. /**
  35583. * Create and run an async loop.
  35584. * @param iterations the number of iterations.
  35585. * @param fn the function to run each iteration
  35586. * @param successCallback the callback that will be called upon succesful execution
  35587. * @param offset starting offset.
  35588. * @returns the created async loop object
  35589. */
  35590. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35591. /**
  35592. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35593. * @param iterations total number of iterations
  35594. * @param syncedIterations number of synchronous iterations in each async iteration.
  35595. * @param fn the function to call each iteration.
  35596. * @param callback a success call back that will be called when iterating stops.
  35597. * @param breakFunction a break condition (optional)
  35598. * @param timeout timeout settings for the setTimeout function. default - 0.
  35599. * @returns the created async loop object
  35600. */
  35601. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35602. }
  35603. }
  35604. declare module "babylonjs/Misc/stringDictionary" {
  35605. import { Nullable } from "babylonjs/types";
  35606. /**
  35607. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35608. * The underlying implementation relies on an associative array to ensure the best performances.
  35609. * The value can be anything including 'null' but except 'undefined'
  35610. */
  35611. export class StringDictionary<T> {
  35612. /**
  35613. * This will clear this dictionary and copy the content from the 'source' one.
  35614. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35615. * @param source the dictionary to take the content from and copy to this dictionary
  35616. */
  35617. copyFrom(source: StringDictionary<T>): void;
  35618. /**
  35619. * Get a value based from its key
  35620. * @param key the given key to get the matching value from
  35621. * @return the value if found, otherwise undefined is returned
  35622. */
  35623. get(key: string): T | undefined;
  35624. /**
  35625. * Get a value from its key or add it if it doesn't exist.
  35626. * This method will ensure you that a given key/data will be present in the dictionary.
  35627. * @param key the given key to get the matching value from
  35628. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35629. * The factory will only be invoked if there's no data for the given key.
  35630. * @return the value corresponding to the key.
  35631. */
  35632. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35633. /**
  35634. * Get a value from its key if present in the dictionary otherwise add it
  35635. * @param key the key to get the value from
  35636. * @param val if there's no such key/value pair in the dictionary add it with this value
  35637. * @return the value corresponding to the key
  35638. */
  35639. getOrAdd(key: string, val: T): T;
  35640. /**
  35641. * Check if there's a given key in the dictionary
  35642. * @param key the key to check for
  35643. * @return true if the key is present, false otherwise
  35644. */
  35645. contains(key: string): boolean;
  35646. /**
  35647. * Add a new key and its corresponding value
  35648. * @param key the key to add
  35649. * @param value the value corresponding to the key
  35650. * @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
  35651. */
  35652. add(key: string, value: T): boolean;
  35653. /**
  35654. * Update a specific value associated to a key
  35655. * @param key defines the key to use
  35656. * @param value defines the value to store
  35657. * @returns true if the value was updated (or false if the key was not found)
  35658. */
  35659. set(key: string, value: T): boolean;
  35660. /**
  35661. * Get the element of the given key and remove it from the dictionary
  35662. * @param key defines the key to search
  35663. * @returns the value associated with the key or null if not found
  35664. */
  35665. getAndRemove(key: string): Nullable<T>;
  35666. /**
  35667. * Remove a key/value from the dictionary.
  35668. * @param key the key to remove
  35669. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35670. */
  35671. remove(key: string): boolean;
  35672. /**
  35673. * Clear the whole content of the dictionary
  35674. */
  35675. clear(): void;
  35676. /**
  35677. * Gets the current count
  35678. */
  35679. get count(): number;
  35680. /**
  35681. * Execute a callback on each key/val of the dictionary.
  35682. * Note that you can remove any element in this dictionary in the callback implementation
  35683. * @param callback the callback to execute on a given key/value pair
  35684. */
  35685. forEach(callback: (key: string, val: T) => void): void;
  35686. /**
  35687. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35688. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35689. * Note that you can remove any element in this dictionary in the callback implementation
  35690. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35691. * @returns the first item
  35692. */
  35693. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35694. private _count;
  35695. private _data;
  35696. }
  35697. }
  35698. declare module "babylonjs/Collisions/collisionCoordinator" {
  35699. import { Nullable } from "babylonjs/types";
  35700. import { Scene } from "babylonjs/scene";
  35701. import { Vector3 } from "babylonjs/Maths/math.vector";
  35702. import { Collider } from "babylonjs/Collisions/collider";
  35703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35704. /** @hidden */
  35705. export interface ICollisionCoordinator {
  35706. createCollider(): Collider;
  35707. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35708. init(scene: Scene): void;
  35709. }
  35710. /** @hidden */
  35711. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35712. private _scene;
  35713. private _scaledPosition;
  35714. private _scaledVelocity;
  35715. private _finalPosition;
  35716. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35717. createCollider(): Collider;
  35718. init(scene: Scene): void;
  35719. private _collideWithWorld;
  35720. }
  35721. }
  35722. declare module "babylonjs/Inputs/scene.inputManager" {
  35723. import { Nullable } from "babylonjs/types";
  35724. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35725. import { Vector2 } from "babylonjs/Maths/math.vector";
  35726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35727. import { Scene } from "babylonjs/scene";
  35728. /**
  35729. * Class used to manage all inputs for the scene.
  35730. */
  35731. export class InputManager {
  35732. /** The distance in pixel that you have to move to prevent some events */
  35733. static DragMovementThreshold: number;
  35734. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35735. static LongPressDelay: number;
  35736. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35737. static DoubleClickDelay: number;
  35738. /** If you need to check double click without raising a single click at first click, enable this flag */
  35739. static ExclusiveDoubleClickMode: boolean;
  35740. private _wheelEventName;
  35741. private _onPointerMove;
  35742. private _onPointerDown;
  35743. private _onPointerUp;
  35744. private _initClickEvent;
  35745. private _initActionManager;
  35746. private _delayedSimpleClick;
  35747. private _delayedSimpleClickTimeout;
  35748. private _previousDelayedSimpleClickTimeout;
  35749. private _meshPickProceed;
  35750. private _previousButtonPressed;
  35751. private _currentPickResult;
  35752. private _previousPickResult;
  35753. private _totalPointersPressed;
  35754. private _doubleClickOccured;
  35755. private _pointerOverMesh;
  35756. private _pickedDownMesh;
  35757. private _pickedUpMesh;
  35758. private _pointerX;
  35759. private _pointerY;
  35760. private _unTranslatedPointerX;
  35761. private _unTranslatedPointerY;
  35762. private _startingPointerPosition;
  35763. private _previousStartingPointerPosition;
  35764. private _startingPointerTime;
  35765. private _previousStartingPointerTime;
  35766. private _pointerCaptures;
  35767. private _onKeyDown;
  35768. private _onKeyUp;
  35769. private _onCanvasFocusObserver;
  35770. private _onCanvasBlurObserver;
  35771. private _scene;
  35772. /**
  35773. * Creates a new InputManager
  35774. * @param scene defines the hosting scene
  35775. */
  35776. constructor(scene: Scene);
  35777. /**
  35778. * Gets the mesh that is currently under the pointer
  35779. */
  35780. get meshUnderPointer(): Nullable<AbstractMesh>;
  35781. /**
  35782. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35783. */
  35784. get unTranslatedPointer(): Vector2;
  35785. /**
  35786. * Gets or sets the current on-screen X position of the pointer
  35787. */
  35788. get pointerX(): number;
  35789. set pointerX(value: number);
  35790. /**
  35791. * Gets or sets the current on-screen Y position of the pointer
  35792. */
  35793. get pointerY(): number;
  35794. set pointerY(value: number);
  35795. private _updatePointerPosition;
  35796. private _processPointerMove;
  35797. private _setRayOnPointerInfo;
  35798. private _checkPrePointerObservable;
  35799. /**
  35800. * Use this method to simulate a pointer move on a mesh
  35801. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35802. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35803. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35804. */
  35805. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35806. /**
  35807. * Use this method to simulate a pointer down on a mesh
  35808. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35809. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35810. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35811. */
  35812. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35813. private _processPointerDown;
  35814. /** @hidden */
  35815. _isPointerSwiping(): boolean;
  35816. /**
  35817. * Use this method to simulate a pointer up on a mesh
  35818. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35819. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35820. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35821. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35822. */
  35823. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35824. private _processPointerUp;
  35825. /**
  35826. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35827. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35828. * @returns true if the pointer was captured
  35829. */
  35830. isPointerCaptured(pointerId?: number): boolean;
  35831. /**
  35832. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35833. * @param attachUp defines if you want to attach events to pointerup
  35834. * @param attachDown defines if you want to attach events to pointerdown
  35835. * @param attachMove defines if you want to attach events to pointermove
  35836. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35837. */
  35838. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35839. /**
  35840. * Detaches all event handlers
  35841. */
  35842. detachControl(): void;
  35843. /**
  35844. * Force the value of meshUnderPointer
  35845. * @param mesh defines the mesh to use
  35846. */
  35847. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35848. /**
  35849. * Gets the mesh under the pointer
  35850. * @returns a Mesh or null if no mesh is under the pointer
  35851. */
  35852. getPointerOverMesh(): Nullable<AbstractMesh>;
  35853. }
  35854. }
  35855. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35856. /**
  35857. * Helper class used to generate session unique ID
  35858. */
  35859. export class UniqueIdGenerator {
  35860. private static _UniqueIdCounter;
  35861. /**
  35862. * Gets an unique (relatively to the current scene) Id
  35863. */
  35864. static get UniqueId(): number;
  35865. }
  35866. }
  35867. declare module "babylonjs/Animations/animationGroup" {
  35868. import { Animatable } from "babylonjs/Animations/animatable";
  35869. import { Animation } from "babylonjs/Animations/animation";
  35870. import { Scene, IDisposable } from "babylonjs/scene";
  35871. import { Observable } from "babylonjs/Misc/observable";
  35872. import { Nullable } from "babylonjs/types";
  35873. import "babylonjs/Animations/animatable";
  35874. /**
  35875. * This class defines the direct association between an animation and a target
  35876. */
  35877. export class TargetedAnimation {
  35878. /**
  35879. * Animation to perform
  35880. */
  35881. animation: Animation;
  35882. /**
  35883. * Target to animate
  35884. */
  35885. target: any;
  35886. /**
  35887. * Serialize the object
  35888. * @returns the JSON object representing the current entity
  35889. */
  35890. serialize(): any;
  35891. }
  35892. /**
  35893. * Use this class to create coordinated animations on multiple targets
  35894. */
  35895. export class AnimationGroup implements IDisposable {
  35896. /** The name of the animation group */
  35897. name: string;
  35898. private _scene;
  35899. private _targetedAnimations;
  35900. private _animatables;
  35901. private _from;
  35902. private _to;
  35903. private _isStarted;
  35904. private _isPaused;
  35905. private _speedRatio;
  35906. private _loopAnimation;
  35907. /**
  35908. * Gets or sets the unique id of the node
  35909. */
  35910. uniqueId: number;
  35911. /**
  35912. * This observable will notify when one animation have ended
  35913. */
  35914. onAnimationEndObservable: Observable<TargetedAnimation>;
  35915. /**
  35916. * Observer raised when one animation loops
  35917. */
  35918. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35919. /**
  35920. * Observer raised when all animations have looped
  35921. */
  35922. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35923. /**
  35924. * This observable will notify when all animations have ended.
  35925. */
  35926. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35927. /**
  35928. * This observable will notify when all animations have paused.
  35929. */
  35930. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35931. /**
  35932. * This observable will notify when all animations are playing.
  35933. */
  35934. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35935. /**
  35936. * Gets the first frame
  35937. */
  35938. get from(): number;
  35939. /**
  35940. * Gets the last frame
  35941. */
  35942. get to(): number;
  35943. /**
  35944. * Define if the animations are started
  35945. */
  35946. get isStarted(): boolean;
  35947. /**
  35948. * Gets a value indicating that the current group is playing
  35949. */
  35950. get isPlaying(): boolean;
  35951. /**
  35952. * Gets or sets the speed ratio to use for all animations
  35953. */
  35954. get speedRatio(): number;
  35955. /**
  35956. * Gets or sets the speed ratio to use for all animations
  35957. */
  35958. set speedRatio(value: number);
  35959. /**
  35960. * Gets or sets if all animations should loop or not
  35961. */
  35962. get loopAnimation(): boolean;
  35963. set loopAnimation(value: boolean);
  35964. /**
  35965. * Gets the targeted animations for this animation group
  35966. */
  35967. get targetedAnimations(): Array<TargetedAnimation>;
  35968. /**
  35969. * returning the list of animatables controlled by this animation group.
  35970. */
  35971. get animatables(): Array<Animatable>;
  35972. /**
  35973. * Instantiates a new Animation Group.
  35974. * This helps managing several animations at once.
  35975. * @see http://doc.babylonjs.com/how_to/group
  35976. * @param name Defines the name of the group
  35977. * @param scene Defines the scene the group belongs to
  35978. */
  35979. constructor(
  35980. /** The name of the animation group */
  35981. name: string, scene?: Nullable<Scene>);
  35982. /**
  35983. * Add an animation (with its target) in the group
  35984. * @param animation defines the animation we want to add
  35985. * @param target defines the target of the animation
  35986. * @returns the TargetedAnimation object
  35987. */
  35988. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35989. /**
  35990. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35991. * It can add constant keys at begin or end
  35992. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35993. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35994. * @returns the animation group
  35995. */
  35996. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35997. private _animationLoopCount;
  35998. private _animationLoopFlags;
  35999. private _processLoop;
  36000. /**
  36001. * Start all animations on given targets
  36002. * @param loop defines if animations must loop
  36003. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36004. * @param from defines the from key (optional)
  36005. * @param to defines the to key (optional)
  36006. * @returns the current animation group
  36007. */
  36008. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  36009. /**
  36010. * Pause all animations
  36011. * @returns the animation group
  36012. */
  36013. pause(): AnimationGroup;
  36014. /**
  36015. * Play all animations to initial state
  36016. * This function will start() the animations if they were not started or will restart() them if they were paused
  36017. * @param loop defines if animations must loop
  36018. * @returns the animation group
  36019. */
  36020. play(loop?: boolean): AnimationGroup;
  36021. /**
  36022. * Reset all animations to initial state
  36023. * @returns the animation group
  36024. */
  36025. reset(): AnimationGroup;
  36026. /**
  36027. * Restart animations from key 0
  36028. * @returns the animation group
  36029. */
  36030. restart(): AnimationGroup;
  36031. /**
  36032. * Stop all animations
  36033. * @returns the animation group
  36034. */
  36035. stop(): AnimationGroup;
  36036. /**
  36037. * Set animation weight for all animatables
  36038. * @param weight defines the weight to use
  36039. * @return the animationGroup
  36040. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36041. */
  36042. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36043. /**
  36044. * Synchronize and normalize all animatables with a source animatable
  36045. * @param root defines the root animatable to synchronize with
  36046. * @return the animationGroup
  36047. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36048. */
  36049. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36050. /**
  36051. * Goes to a specific frame in this animation group
  36052. * @param frame the frame number to go to
  36053. * @return the animationGroup
  36054. */
  36055. goToFrame(frame: number): AnimationGroup;
  36056. /**
  36057. * Dispose all associated resources
  36058. */
  36059. dispose(): void;
  36060. private _checkAnimationGroupEnded;
  36061. /**
  36062. * Clone the current animation group and returns a copy
  36063. * @param newName defines the name of the new group
  36064. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36065. * @returns the new aniamtion group
  36066. */
  36067. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36068. /**
  36069. * Serializes the animationGroup to an object
  36070. * @returns Serialized object
  36071. */
  36072. serialize(): any;
  36073. /**
  36074. * Returns a new AnimationGroup object parsed from the source provided.
  36075. * @param parsedAnimationGroup defines the source
  36076. * @param scene defines the scene that will receive the animationGroup
  36077. * @returns a new AnimationGroup
  36078. */
  36079. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36080. /**
  36081. * Returns the string "AnimationGroup"
  36082. * @returns "AnimationGroup"
  36083. */
  36084. getClassName(): string;
  36085. /**
  36086. * Creates a detailled string about the object
  36087. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36088. * @returns a string representing the object
  36089. */
  36090. toString(fullDetails?: boolean): string;
  36091. }
  36092. }
  36093. declare module "babylonjs/scene" {
  36094. import { Nullable } from "babylonjs/types";
  36095. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36096. import { Observable } from "babylonjs/Misc/observable";
  36097. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36098. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36099. import { Geometry } from "babylonjs/Meshes/geometry";
  36100. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36101. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36103. import { Mesh } from "babylonjs/Meshes/mesh";
  36104. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36105. import { Bone } from "babylonjs/Bones/bone";
  36106. import { Skeleton } from "babylonjs/Bones/skeleton";
  36107. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36108. import { Camera } from "babylonjs/Cameras/camera";
  36109. import { AbstractScene } from "babylonjs/abstractScene";
  36110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36111. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36112. import { Material } from "babylonjs/Materials/material";
  36113. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36114. import { Effect } from "babylonjs/Materials/effect";
  36115. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36116. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36117. import { Light } from "babylonjs/Lights/light";
  36118. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36119. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36120. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36121. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36122. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36123. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36124. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36125. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36126. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36127. import { Engine } from "babylonjs/Engines/engine";
  36128. import { Node } from "babylonjs/node";
  36129. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36130. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36131. import { WebRequest } from "babylonjs/Misc/webRequest";
  36132. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36133. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36134. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36135. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36136. import { Plane } from "babylonjs/Maths/math.plane";
  36137. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36138. import { Ray } from "babylonjs/Culling/ray";
  36139. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36140. import { Animation } from "babylonjs/Animations/animation";
  36141. import { Animatable } from "babylonjs/Animations/animatable";
  36142. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36143. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36144. import { Collider } from "babylonjs/Collisions/collider";
  36145. /**
  36146. * Define an interface for all classes that will hold resources
  36147. */
  36148. export interface IDisposable {
  36149. /**
  36150. * Releases all held resources
  36151. */
  36152. dispose(): void;
  36153. }
  36154. /** Interface defining initialization parameters for Scene class */
  36155. export interface SceneOptions {
  36156. /**
  36157. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36158. * It will improve performance when the number of geometries becomes important.
  36159. */
  36160. useGeometryUniqueIdsMap?: boolean;
  36161. /**
  36162. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36163. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36164. */
  36165. useMaterialMeshMap?: boolean;
  36166. /**
  36167. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36168. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36169. */
  36170. useClonedMeshMap?: boolean;
  36171. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36172. virtual?: boolean;
  36173. }
  36174. /**
  36175. * Represents a scene to be rendered by the engine.
  36176. * @see http://doc.babylonjs.com/features/scene
  36177. */
  36178. export class Scene extends AbstractScene implements IAnimatable {
  36179. /** The fog is deactivated */
  36180. static readonly FOGMODE_NONE: number;
  36181. /** The fog density is following an exponential function */
  36182. static readonly FOGMODE_EXP: number;
  36183. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36184. static readonly FOGMODE_EXP2: number;
  36185. /** The fog density is following a linear function. */
  36186. static readonly FOGMODE_LINEAR: number;
  36187. /**
  36188. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36189. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36190. */
  36191. static MinDeltaTime: number;
  36192. /**
  36193. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36195. */
  36196. static MaxDeltaTime: number;
  36197. /**
  36198. * Factory used to create the default material.
  36199. * @param name The name of the material to create
  36200. * @param scene The scene to create the material for
  36201. * @returns The default material
  36202. */
  36203. static DefaultMaterialFactory(scene: Scene): Material;
  36204. /**
  36205. * Factory used to create the a collision coordinator.
  36206. * @returns The collision coordinator
  36207. */
  36208. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36209. /** @hidden */
  36210. _inputManager: InputManager;
  36211. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36212. cameraToUseForPointers: Nullable<Camera>;
  36213. /** @hidden */
  36214. readonly _isScene: boolean;
  36215. /** @hidden */
  36216. _blockEntityCollection: boolean;
  36217. /**
  36218. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36219. */
  36220. autoClear: boolean;
  36221. /**
  36222. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36223. */
  36224. autoClearDepthAndStencil: boolean;
  36225. /**
  36226. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36227. */
  36228. clearColor: Color4;
  36229. /**
  36230. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36231. */
  36232. ambientColor: Color3;
  36233. /**
  36234. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36235. * It should only be one of the following (if not the default embedded one):
  36236. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36237. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36238. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36239. * The material properties need to be setup according to the type of texture in use.
  36240. */
  36241. environmentBRDFTexture: BaseTexture;
  36242. /** @hidden */
  36243. protected _environmentTexture: Nullable<BaseTexture>;
  36244. /**
  36245. * Texture used in all pbr material as the reflection texture.
  36246. * As in the majority of the scene they are the same (exception for multi room and so on),
  36247. * this is easier to reference from here than from all the materials.
  36248. */
  36249. get environmentTexture(): Nullable<BaseTexture>;
  36250. /**
  36251. * Texture used in all pbr material as the reflection texture.
  36252. * As in the majority of the scene they are the same (exception for multi room and so on),
  36253. * this is easier to set here than in all the materials.
  36254. */
  36255. set environmentTexture(value: Nullable<BaseTexture>);
  36256. /** @hidden */
  36257. protected _environmentIntensity: number;
  36258. /**
  36259. * Intensity of the environment in all pbr material.
  36260. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36261. * As in the majority of the scene they are the same (exception for multi room and so on),
  36262. * this is easier to reference from here than from all the materials.
  36263. */
  36264. get environmentIntensity(): number;
  36265. /**
  36266. * Intensity of the environment in all pbr material.
  36267. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36268. * As in the majority of the scene they are the same (exception for multi room and so on),
  36269. * this is easier to set here than in all the materials.
  36270. */
  36271. set environmentIntensity(value: number);
  36272. /** @hidden */
  36273. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36274. /**
  36275. * Default image processing configuration used either in the rendering
  36276. * Forward main pass or through the imageProcessingPostProcess if present.
  36277. * As in the majority of the scene they are the same (exception for multi camera),
  36278. * this is easier to reference from here than from all the materials and post process.
  36279. *
  36280. * No setter as we it is a shared configuration, you can set the values instead.
  36281. */
  36282. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36283. private _forceWireframe;
  36284. /**
  36285. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36286. */
  36287. set forceWireframe(value: boolean);
  36288. get forceWireframe(): boolean;
  36289. private _skipFrustumClipping;
  36290. /**
  36291. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36292. */
  36293. set skipFrustumClipping(value: boolean);
  36294. get skipFrustumClipping(): boolean;
  36295. private _forcePointsCloud;
  36296. /**
  36297. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36298. */
  36299. set forcePointsCloud(value: boolean);
  36300. get forcePointsCloud(): boolean;
  36301. /**
  36302. * Gets or sets the active clipplane 1
  36303. */
  36304. clipPlane: Nullable<Plane>;
  36305. /**
  36306. * Gets or sets the active clipplane 2
  36307. */
  36308. clipPlane2: Nullable<Plane>;
  36309. /**
  36310. * Gets or sets the active clipplane 3
  36311. */
  36312. clipPlane3: Nullable<Plane>;
  36313. /**
  36314. * Gets or sets the active clipplane 4
  36315. */
  36316. clipPlane4: Nullable<Plane>;
  36317. /**
  36318. * Gets or sets the active clipplane 5
  36319. */
  36320. clipPlane5: Nullable<Plane>;
  36321. /**
  36322. * Gets or sets the active clipplane 6
  36323. */
  36324. clipPlane6: Nullable<Plane>;
  36325. /**
  36326. * Gets or sets a boolean indicating if animations are enabled
  36327. */
  36328. animationsEnabled: boolean;
  36329. private _animationPropertiesOverride;
  36330. /**
  36331. * Gets or sets the animation properties override
  36332. */
  36333. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36334. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36335. /**
  36336. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36337. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36338. */
  36339. useConstantAnimationDeltaTime: boolean;
  36340. /**
  36341. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36342. * Please note that it requires to run a ray cast through the scene on every frame
  36343. */
  36344. constantlyUpdateMeshUnderPointer: boolean;
  36345. /**
  36346. * Defines the HTML cursor to use when hovering over interactive elements
  36347. */
  36348. hoverCursor: string;
  36349. /**
  36350. * Defines the HTML default cursor to use (empty by default)
  36351. */
  36352. defaultCursor: string;
  36353. /**
  36354. * Defines whether cursors are handled by the scene.
  36355. */
  36356. doNotHandleCursors: boolean;
  36357. /**
  36358. * This is used to call preventDefault() on pointer down
  36359. * in order to block unwanted artifacts like system double clicks
  36360. */
  36361. preventDefaultOnPointerDown: boolean;
  36362. /**
  36363. * This is used to call preventDefault() on pointer up
  36364. * in order to block unwanted artifacts like system double clicks
  36365. */
  36366. preventDefaultOnPointerUp: boolean;
  36367. /**
  36368. * Gets or sets user defined metadata
  36369. */
  36370. metadata: any;
  36371. /**
  36372. * For internal use only. Please do not use.
  36373. */
  36374. reservedDataStore: any;
  36375. /**
  36376. * Gets the name of the plugin used to load this scene (null by default)
  36377. */
  36378. loadingPluginName: string;
  36379. /**
  36380. * Use this array to add regular expressions used to disable offline support for specific urls
  36381. */
  36382. disableOfflineSupportExceptionRules: RegExp[];
  36383. /**
  36384. * An event triggered when the scene is disposed.
  36385. */
  36386. onDisposeObservable: Observable<Scene>;
  36387. private _onDisposeObserver;
  36388. /** Sets a function to be executed when this scene is disposed. */
  36389. set onDispose(callback: () => void);
  36390. /**
  36391. * An event triggered before rendering the scene (right after animations and physics)
  36392. */
  36393. onBeforeRenderObservable: Observable<Scene>;
  36394. private _onBeforeRenderObserver;
  36395. /** Sets a function to be executed before rendering this scene */
  36396. set beforeRender(callback: Nullable<() => void>);
  36397. /**
  36398. * An event triggered after rendering the scene
  36399. */
  36400. onAfterRenderObservable: Observable<Scene>;
  36401. /**
  36402. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36403. */
  36404. onAfterRenderCameraObservable: Observable<Camera>;
  36405. private _onAfterRenderObserver;
  36406. /** Sets a function to be executed after rendering this scene */
  36407. set afterRender(callback: Nullable<() => void>);
  36408. /**
  36409. * An event triggered before animating the scene
  36410. */
  36411. onBeforeAnimationsObservable: Observable<Scene>;
  36412. /**
  36413. * An event triggered after animations processing
  36414. */
  36415. onAfterAnimationsObservable: Observable<Scene>;
  36416. /**
  36417. * An event triggered before draw calls are ready to be sent
  36418. */
  36419. onBeforeDrawPhaseObservable: Observable<Scene>;
  36420. /**
  36421. * An event triggered after draw calls have been sent
  36422. */
  36423. onAfterDrawPhaseObservable: Observable<Scene>;
  36424. /**
  36425. * An event triggered when the scene is ready
  36426. */
  36427. onReadyObservable: Observable<Scene>;
  36428. /**
  36429. * An event triggered before rendering a camera
  36430. */
  36431. onBeforeCameraRenderObservable: Observable<Camera>;
  36432. private _onBeforeCameraRenderObserver;
  36433. /** Sets a function to be executed before rendering a camera*/
  36434. set beforeCameraRender(callback: () => void);
  36435. /**
  36436. * An event triggered after rendering a camera
  36437. */
  36438. onAfterCameraRenderObservable: Observable<Camera>;
  36439. private _onAfterCameraRenderObserver;
  36440. /** Sets a function to be executed after rendering a camera*/
  36441. set afterCameraRender(callback: () => void);
  36442. /**
  36443. * An event triggered when active meshes evaluation is about to start
  36444. */
  36445. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36446. /**
  36447. * An event triggered when active meshes evaluation is done
  36448. */
  36449. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36450. /**
  36451. * An event triggered when particles rendering is about to start
  36452. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36453. */
  36454. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36455. /**
  36456. * An event triggered when particles rendering is done
  36457. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36458. */
  36459. onAfterParticlesRenderingObservable: Observable<Scene>;
  36460. /**
  36461. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36462. */
  36463. onDataLoadedObservable: Observable<Scene>;
  36464. /**
  36465. * An event triggered when a camera is created
  36466. */
  36467. onNewCameraAddedObservable: Observable<Camera>;
  36468. /**
  36469. * An event triggered when a camera is removed
  36470. */
  36471. onCameraRemovedObservable: Observable<Camera>;
  36472. /**
  36473. * An event triggered when a light is created
  36474. */
  36475. onNewLightAddedObservable: Observable<Light>;
  36476. /**
  36477. * An event triggered when a light is removed
  36478. */
  36479. onLightRemovedObservable: Observable<Light>;
  36480. /**
  36481. * An event triggered when a geometry is created
  36482. */
  36483. onNewGeometryAddedObservable: Observable<Geometry>;
  36484. /**
  36485. * An event triggered when a geometry is removed
  36486. */
  36487. onGeometryRemovedObservable: Observable<Geometry>;
  36488. /**
  36489. * An event triggered when a transform node is created
  36490. */
  36491. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36492. /**
  36493. * An event triggered when a transform node is removed
  36494. */
  36495. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36496. /**
  36497. * An event triggered when a mesh is created
  36498. */
  36499. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36500. /**
  36501. * An event triggered when a mesh is removed
  36502. */
  36503. onMeshRemovedObservable: Observable<AbstractMesh>;
  36504. /**
  36505. * An event triggered when a skeleton is created
  36506. */
  36507. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36508. /**
  36509. * An event triggered when a skeleton is removed
  36510. */
  36511. onSkeletonRemovedObservable: Observable<Skeleton>;
  36512. /**
  36513. * An event triggered when a material is created
  36514. */
  36515. onNewMaterialAddedObservable: Observable<Material>;
  36516. /**
  36517. * An event triggered when a material is removed
  36518. */
  36519. onMaterialRemovedObservable: Observable<Material>;
  36520. /**
  36521. * An event triggered when a texture is created
  36522. */
  36523. onNewTextureAddedObservable: Observable<BaseTexture>;
  36524. /**
  36525. * An event triggered when a texture is removed
  36526. */
  36527. onTextureRemovedObservable: Observable<BaseTexture>;
  36528. /**
  36529. * An event triggered when render targets are about to be rendered
  36530. * Can happen multiple times per frame.
  36531. */
  36532. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36533. /**
  36534. * An event triggered when render targets were rendered.
  36535. * Can happen multiple times per frame.
  36536. */
  36537. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36538. /**
  36539. * An event triggered before calculating deterministic simulation step
  36540. */
  36541. onBeforeStepObservable: Observable<Scene>;
  36542. /**
  36543. * An event triggered after calculating deterministic simulation step
  36544. */
  36545. onAfterStepObservable: Observable<Scene>;
  36546. /**
  36547. * An event triggered when the activeCamera property is updated
  36548. */
  36549. onActiveCameraChanged: Observable<Scene>;
  36550. /**
  36551. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36552. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36553. * 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)
  36554. */
  36555. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36556. /**
  36557. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36558. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36559. * 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)
  36560. */
  36561. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36562. /**
  36563. * This Observable will when a mesh has been imported into the scene.
  36564. */
  36565. onMeshImportedObservable: Observable<AbstractMesh>;
  36566. /**
  36567. * This Observable will when an animation file has been imported into the scene.
  36568. */
  36569. onAnimationFileImportedObservable: Observable<Scene>;
  36570. /**
  36571. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36572. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36573. */
  36574. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36575. /** @hidden */
  36576. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36577. /**
  36578. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36579. */
  36580. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36581. /**
  36582. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36583. */
  36584. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36585. /**
  36586. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36587. */
  36588. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36589. /** Callback called when a pointer move is detected */
  36590. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36591. /** Callback called when a pointer down is detected */
  36592. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36593. /** Callback called when a pointer up is detected */
  36594. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36595. /** Callback called when a pointer pick is detected */
  36596. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36597. /**
  36598. * 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).
  36599. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36600. */
  36601. onPrePointerObservable: Observable<PointerInfoPre>;
  36602. /**
  36603. * Observable event triggered each time an input event is received from the rendering canvas
  36604. */
  36605. onPointerObservable: Observable<PointerInfo>;
  36606. /**
  36607. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36608. */
  36609. get unTranslatedPointer(): Vector2;
  36610. /**
  36611. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36612. */
  36613. static get DragMovementThreshold(): number;
  36614. static set DragMovementThreshold(value: number);
  36615. /**
  36616. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36617. */
  36618. static get LongPressDelay(): number;
  36619. static set LongPressDelay(value: number);
  36620. /**
  36621. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36622. */
  36623. static get DoubleClickDelay(): number;
  36624. static set DoubleClickDelay(value: number);
  36625. /** If you need to check double click without raising a single click at first click, enable this flag */
  36626. static get ExclusiveDoubleClickMode(): boolean;
  36627. static set ExclusiveDoubleClickMode(value: boolean);
  36628. /** @hidden */
  36629. _mirroredCameraPosition: Nullable<Vector3>;
  36630. /**
  36631. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36632. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36633. */
  36634. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36635. /**
  36636. * Observable event triggered each time an keyboard event is received from the hosting window
  36637. */
  36638. onKeyboardObservable: Observable<KeyboardInfo>;
  36639. private _useRightHandedSystem;
  36640. /**
  36641. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36642. */
  36643. set useRightHandedSystem(value: boolean);
  36644. get useRightHandedSystem(): boolean;
  36645. private _timeAccumulator;
  36646. private _currentStepId;
  36647. private _currentInternalStep;
  36648. /**
  36649. * Sets the step Id used by deterministic lock step
  36650. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36651. * @param newStepId defines the step Id
  36652. */
  36653. setStepId(newStepId: number): void;
  36654. /**
  36655. * Gets the step Id used by deterministic lock step
  36656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36657. * @returns the step Id
  36658. */
  36659. getStepId(): number;
  36660. /**
  36661. * Gets the internal step used by deterministic lock step
  36662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36663. * @returns the internal step
  36664. */
  36665. getInternalStep(): number;
  36666. private _fogEnabled;
  36667. /**
  36668. * Gets or sets a boolean indicating if fog is enabled on this scene
  36669. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36670. * (Default is true)
  36671. */
  36672. set fogEnabled(value: boolean);
  36673. get fogEnabled(): boolean;
  36674. private _fogMode;
  36675. /**
  36676. * Gets or sets the fog mode to use
  36677. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36678. * | mode | value |
  36679. * | --- | --- |
  36680. * | FOGMODE_NONE | 0 |
  36681. * | FOGMODE_EXP | 1 |
  36682. * | FOGMODE_EXP2 | 2 |
  36683. * | FOGMODE_LINEAR | 3 |
  36684. */
  36685. set fogMode(value: number);
  36686. get fogMode(): number;
  36687. /**
  36688. * Gets or sets the fog color to use
  36689. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36690. * (Default is Color3(0.2, 0.2, 0.3))
  36691. */
  36692. fogColor: Color3;
  36693. /**
  36694. * Gets or sets the fog density to use
  36695. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36696. * (Default is 0.1)
  36697. */
  36698. fogDensity: number;
  36699. /**
  36700. * Gets or sets the fog start distance to use
  36701. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36702. * (Default is 0)
  36703. */
  36704. fogStart: number;
  36705. /**
  36706. * Gets or sets the fog end distance to use
  36707. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36708. * (Default is 1000)
  36709. */
  36710. fogEnd: number;
  36711. private _shadowsEnabled;
  36712. /**
  36713. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36714. */
  36715. set shadowsEnabled(value: boolean);
  36716. get shadowsEnabled(): boolean;
  36717. private _lightsEnabled;
  36718. /**
  36719. * Gets or sets a boolean indicating if lights are enabled on this scene
  36720. */
  36721. set lightsEnabled(value: boolean);
  36722. get lightsEnabled(): boolean;
  36723. /** All of the active cameras added to this scene. */
  36724. activeCameras: Camera[];
  36725. /** @hidden */
  36726. _activeCamera: Nullable<Camera>;
  36727. /** Gets or sets the current active camera */
  36728. get activeCamera(): Nullable<Camera>;
  36729. set activeCamera(value: Nullable<Camera>);
  36730. private _defaultMaterial;
  36731. /** The default material used on meshes when no material is affected */
  36732. get defaultMaterial(): Material;
  36733. /** The default material used on meshes when no material is affected */
  36734. set defaultMaterial(value: Material);
  36735. private _texturesEnabled;
  36736. /**
  36737. * Gets or sets a boolean indicating if textures are enabled on this scene
  36738. */
  36739. set texturesEnabled(value: boolean);
  36740. get texturesEnabled(): boolean;
  36741. /**
  36742. * Gets or sets a boolean indicating if particles are enabled on this scene
  36743. */
  36744. particlesEnabled: boolean;
  36745. /**
  36746. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36747. */
  36748. spritesEnabled: boolean;
  36749. private _skeletonsEnabled;
  36750. /**
  36751. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36752. */
  36753. set skeletonsEnabled(value: boolean);
  36754. get skeletonsEnabled(): boolean;
  36755. /**
  36756. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36757. */
  36758. lensFlaresEnabled: boolean;
  36759. /**
  36760. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36761. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36762. */
  36763. collisionsEnabled: boolean;
  36764. private _collisionCoordinator;
  36765. /** @hidden */
  36766. get collisionCoordinator(): ICollisionCoordinator;
  36767. /**
  36768. * Defines the gravity applied to this scene (used only for collisions)
  36769. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36770. */
  36771. gravity: Vector3;
  36772. /**
  36773. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36774. */
  36775. postProcessesEnabled: boolean;
  36776. /**
  36777. * The list of postprocesses added to the scene
  36778. */
  36779. postProcesses: PostProcess[];
  36780. /**
  36781. * Gets the current postprocess manager
  36782. */
  36783. postProcessManager: PostProcessManager;
  36784. /**
  36785. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36786. */
  36787. renderTargetsEnabled: boolean;
  36788. /**
  36789. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36790. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36791. */
  36792. dumpNextRenderTargets: boolean;
  36793. /**
  36794. * The list of user defined render targets added to the scene
  36795. */
  36796. customRenderTargets: RenderTargetTexture[];
  36797. /**
  36798. * Defines if texture loading must be delayed
  36799. * If true, textures will only be loaded when they need to be rendered
  36800. */
  36801. useDelayedTextureLoading: boolean;
  36802. /**
  36803. * Gets the list of meshes imported to the scene through SceneLoader
  36804. */
  36805. importedMeshesFiles: String[];
  36806. /**
  36807. * Gets or sets a boolean indicating if probes are enabled on this scene
  36808. */
  36809. probesEnabled: boolean;
  36810. /**
  36811. * Gets or sets the current offline provider to use to store scene data
  36812. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36813. */
  36814. offlineProvider: IOfflineProvider;
  36815. /**
  36816. * Gets or sets the action manager associated with the scene
  36817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36818. */
  36819. actionManager: AbstractActionManager;
  36820. private _meshesForIntersections;
  36821. /**
  36822. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36823. */
  36824. proceduralTexturesEnabled: boolean;
  36825. private _engine;
  36826. private _totalVertices;
  36827. /** @hidden */
  36828. _activeIndices: PerfCounter;
  36829. /** @hidden */
  36830. _activeParticles: PerfCounter;
  36831. /** @hidden */
  36832. _activeBones: PerfCounter;
  36833. private _animationRatio;
  36834. /** @hidden */
  36835. _animationTimeLast: number;
  36836. /** @hidden */
  36837. _animationTime: number;
  36838. /**
  36839. * Gets or sets a general scale for animation speed
  36840. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36841. */
  36842. animationTimeScale: number;
  36843. /** @hidden */
  36844. _cachedMaterial: Nullable<Material>;
  36845. /** @hidden */
  36846. _cachedEffect: Nullable<Effect>;
  36847. /** @hidden */
  36848. _cachedVisibility: Nullable<number>;
  36849. private _renderId;
  36850. private _frameId;
  36851. private _executeWhenReadyTimeoutId;
  36852. private _intermediateRendering;
  36853. private _viewUpdateFlag;
  36854. private _projectionUpdateFlag;
  36855. /** @hidden */
  36856. _toBeDisposed: Nullable<IDisposable>[];
  36857. private _activeRequests;
  36858. /** @hidden */
  36859. _pendingData: any[];
  36860. private _isDisposed;
  36861. /**
  36862. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36863. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36864. */
  36865. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36866. private _activeMeshes;
  36867. private _processedMaterials;
  36868. private _renderTargets;
  36869. /** @hidden */
  36870. _activeParticleSystems: SmartArray<IParticleSystem>;
  36871. private _activeSkeletons;
  36872. private _softwareSkinnedMeshes;
  36873. private _renderingManager;
  36874. /** @hidden */
  36875. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36876. private _transformMatrix;
  36877. private _sceneUbo;
  36878. /** @hidden */
  36879. _viewMatrix: Matrix;
  36880. private _projectionMatrix;
  36881. /** @hidden */
  36882. _forcedViewPosition: Nullable<Vector3>;
  36883. /** @hidden */
  36884. _frustumPlanes: Plane[];
  36885. /**
  36886. * Gets the list of frustum planes (built from the active camera)
  36887. */
  36888. get frustumPlanes(): Plane[];
  36889. /**
  36890. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36891. * This is useful if there are more lights that the maximum simulteanous authorized
  36892. */
  36893. requireLightSorting: boolean;
  36894. /** @hidden */
  36895. readonly useMaterialMeshMap: boolean;
  36896. /** @hidden */
  36897. readonly useClonedMeshMap: boolean;
  36898. private _externalData;
  36899. private _uid;
  36900. /**
  36901. * @hidden
  36902. * Backing store of defined scene components.
  36903. */
  36904. _components: ISceneComponent[];
  36905. /**
  36906. * @hidden
  36907. * Backing store of defined scene components.
  36908. */
  36909. _serializableComponents: ISceneSerializableComponent[];
  36910. /**
  36911. * List of components to register on the next registration step.
  36912. */
  36913. private _transientComponents;
  36914. /**
  36915. * Registers the transient components if needed.
  36916. */
  36917. private _registerTransientComponents;
  36918. /**
  36919. * @hidden
  36920. * Add a component to the scene.
  36921. * Note that the ccomponent could be registered on th next frame if this is called after
  36922. * the register component stage.
  36923. * @param component Defines the component to add to the scene
  36924. */
  36925. _addComponent(component: ISceneComponent): void;
  36926. /**
  36927. * @hidden
  36928. * Gets a component from the scene.
  36929. * @param name defines the name of the component to retrieve
  36930. * @returns the component or null if not present
  36931. */
  36932. _getComponent(name: string): Nullable<ISceneComponent>;
  36933. /**
  36934. * @hidden
  36935. * Defines the actions happening before camera updates.
  36936. */
  36937. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36938. /**
  36939. * @hidden
  36940. * Defines the actions happening before clear the canvas.
  36941. */
  36942. _beforeClearStage: Stage<SimpleStageAction>;
  36943. /**
  36944. * @hidden
  36945. * Defines the actions when collecting render targets for the frame.
  36946. */
  36947. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36948. /**
  36949. * @hidden
  36950. * Defines the actions happening for one camera in the frame.
  36951. */
  36952. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36953. /**
  36954. * @hidden
  36955. * Defines the actions happening during the per mesh ready checks.
  36956. */
  36957. _isReadyForMeshStage: Stage<MeshStageAction>;
  36958. /**
  36959. * @hidden
  36960. * Defines the actions happening before evaluate active mesh checks.
  36961. */
  36962. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36963. /**
  36964. * @hidden
  36965. * Defines the actions happening during the evaluate sub mesh checks.
  36966. */
  36967. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36968. /**
  36969. * @hidden
  36970. * Defines the actions happening during the active mesh stage.
  36971. */
  36972. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36973. /**
  36974. * @hidden
  36975. * Defines the actions happening during the per camera render target step.
  36976. */
  36977. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36978. /**
  36979. * @hidden
  36980. * Defines the actions happening just before the active camera is drawing.
  36981. */
  36982. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36983. /**
  36984. * @hidden
  36985. * Defines the actions happening just before a render target is drawing.
  36986. */
  36987. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36988. /**
  36989. * @hidden
  36990. * Defines the actions happening just before a rendering group is drawing.
  36991. */
  36992. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36993. /**
  36994. * @hidden
  36995. * Defines the actions happening just before a mesh is drawing.
  36996. */
  36997. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36998. /**
  36999. * @hidden
  37000. * Defines the actions happening just after a mesh has been drawn.
  37001. */
  37002. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37003. /**
  37004. * @hidden
  37005. * Defines the actions happening just after a rendering group has been drawn.
  37006. */
  37007. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37008. /**
  37009. * @hidden
  37010. * Defines the actions happening just after the active camera has been drawn.
  37011. */
  37012. _afterCameraDrawStage: Stage<CameraStageAction>;
  37013. /**
  37014. * @hidden
  37015. * Defines the actions happening just after a render target has been drawn.
  37016. */
  37017. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37018. /**
  37019. * @hidden
  37020. * Defines the actions happening just after rendering all cameras and computing intersections.
  37021. */
  37022. _afterRenderStage: Stage<SimpleStageAction>;
  37023. /**
  37024. * @hidden
  37025. * Defines the actions happening when a pointer move event happens.
  37026. */
  37027. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37028. /**
  37029. * @hidden
  37030. * Defines the actions happening when a pointer down event happens.
  37031. */
  37032. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37033. /**
  37034. * @hidden
  37035. * Defines the actions happening when a pointer up event happens.
  37036. */
  37037. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37038. /**
  37039. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37040. */
  37041. private geometriesByUniqueId;
  37042. /**
  37043. * Creates a new Scene
  37044. * @param engine defines the engine to use to render this scene
  37045. * @param options defines the scene options
  37046. */
  37047. constructor(engine: Engine, options?: SceneOptions);
  37048. /**
  37049. * Gets a string idenfifying the name of the class
  37050. * @returns "Scene" string
  37051. */
  37052. getClassName(): string;
  37053. private _defaultMeshCandidates;
  37054. /**
  37055. * @hidden
  37056. */
  37057. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37058. private _defaultSubMeshCandidates;
  37059. /**
  37060. * @hidden
  37061. */
  37062. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37063. /**
  37064. * Sets the default candidate providers for the scene.
  37065. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37066. * and getCollidingSubMeshCandidates to their default function
  37067. */
  37068. setDefaultCandidateProviders(): void;
  37069. /**
  37070. * Gets the mesh that is currently under the pointer
  37071. */
  37072. get meshUnderPointer(): Nullable<AbstractMesh>;
  37073. /**
  37074. * Gets or sets the current on-screen X position of the pointer
  37075. */
  37076. get pointerX(): number;
  37077. set pointerX(value: number);
  37078. /**
  37079. * Gets or sets the current on-screen Y position of the pointer
  37080. */
  37081. get pointerY(): number;
  37082. set pointerY(value: number);
  37083. /**
  37084. * Gets the cached material (ie. the latest rendered one)
  37085. * @returns the cached material
  37086. */
  37087. getCachedMaterial(): Nullable<Material>;
  37088. /**
  37089. * Gets the cached effect (ie. the latest rendered one)
  37090. * @returns the cached effect
  37091. */
  37092. getCachedEffect(): Nullable<Effect>;
  37093. /**
  37094. * Gets the cached visibility state (ie. the latest rendered one)
  37095. * @returns the cached visibility state
  37096. */
  37097. getCachedVisibility(): Nullable<number>;
  37098. /**
  37099. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37100. * @param material defines the current material
  37101. * @param effect defines the current effect
  37102. * @param visibility defines the current visibility state
  37103. * @returns true if one parameter is not cached
  37104. */
  37105. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37106. /**
  37107. * Gets the engine associated with the scene
  37108. * @returns an Engine
  37109. */
  37110. getEngine(): Engine;
  37111. /**
  37112. * Gets the total number of vertices rendered per frame
  37113. * @returns the total number of vertices rendered per frame
  37114. */
  37115. getTotalVertices(): number;
  37116. /**
  37117. * Gets the performance counter for total vertices
  37118. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37119. */
  37120. get totalVerticesPerfCounter(): PerfCounter;
  37121. /**
  37122. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37123. * @returns the total number of active indices rendered per frame
  37124. */
  37125. getActiveIndices(): number;
  37126. /**
  37127. * Gets the performance counter for active indices
  37128. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37129. */
  37130. get totalActiveIndicesPerfCounter(): PerfCounter;
  37131. /**
  37132. * Gets the total number of active particles rendered per frame
  37133. * @returns the total number of active particles rendered per frame
  37134. */
  37135. getActiveParticles(): number;
  37136. /**
  37137. * Gets the performance counter for active particles
  37138. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37139. */
  37140. get activeParticlesPerfCounter(): PerfCounter;
  37141. /**
  37142. * Gets the total number of active bones rendered per frame
  37143. * @returns the total number of active bones rendered per frame
  37144. */
  37145. getActiveBones(): number;
  37146. /**
  37147. * Gets the performance counter for active bones
  37148. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37149. */
  37150. get activeBonesPerfCounter(): PerfCounter;
  37151. /**
  37152. * Gets the array of active meshes
  37153. * @returns an array of AbstractMesh
  37154. */
  37155. getActiveMeshes(): SmartArray<AbstractMesh>;
  37156. /**
  37157. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37158. * @returns a number
  37159. */
  37160. getAnimationRatio(): number;
  37161. /**
  37162. * Gets an unique Id for the current render phase
  37163. * @returns a number
  37164. */
  37165. getRenderId(): number;
  37166. /**
  37167. * Gets an unique Id for the current frame
  37168. * @returns a number
  37169. */
  37170. getFrameId(): number;
  37171. /** Call this function if you want to manually increment the render Id*/
  37172. incrementRenderId(): void;
  37173. private _createUbo;
  37174. /**
  37175. * Use this method to simulate a pointer move on a mesh
  37176. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37177. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37178. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37179. * @returns the current scene
  37180. */
  37181. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37182. /**
  37183. * Use this method to simulate a pointer down on a mesh
  37184. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37185. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37186. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37187. * @returns the current scene
  37188. */
  37189. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37190. /**
  37191. * Use this method to simulate a pointer up on a mesh
  37192. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37193. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37194. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37195. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37196. * @returns the current scene
  37197. */
  37198. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37199. /**
  37200. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37201. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37202. * @returns true if the pointer was captured
  37203. */
  37204. isPointerCaptured(pointerId?: number): boolean;
  37205. /**
  37206. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37207. * @param attachUp defines if you want to attach events to pointerup
  37208. * @param attachDown defines if you want to attach events to pointerdown
  37209. * @param attachMove defines if you want to attach events to pointermove
  37210. */
  37211. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37212. /** Detaches all event handlers*/
  37213. detachControl(): void;
  37214. /**
  37215. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37216. * Delay loaded resources are not taking in account
  37217. * @return true if all required resources are ready
  37218. */
  37219. isReady(): boolean;
  37220. /** Resets all cached information relative to material (including effect and visibility) */
  37221. resetCachedMaterial(): void;
  37222. /**
  37223. * Registers a function to be called before every frame render
  37224. * @param func defines the function to register
  37225. */
  37226. registerBeforeRender(func: () => void): void;
  37227. /**
  37228. * Unregisters a function called before every frame render
  37229. * @param func defines the function to unregister
  37230. */
  37231. unregisterBeforeRender(func: () => void): void;
  37232. /**
  37233. * Registers a function to be called after every frame render
  37234. * @param func defines the function to register
  37235. */
  37236. registerAfterRender(func: () => void): void;
  37237. /**
  37238. * Unregisters a function called after every frame render
  37239. * @param func defines the function to unregister
  37240. */
  37241. unregisterAfterRender(func: () => void): void;
  37242. private _executeOnceBeforeRender;
  37243. /**
  37244. * The provided function will run before render once and will be disposed afterwards.
  37245. * A timeout delay can be provided so that the function will be executed in N ms.
  37246. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37247. * @param func The function to be executed.
  37248. * @param timeout optional delay in ms
  37249. */
  37250. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37251. /** @hidden */
  37252. _addPendingData(data: any): void;
  37253. /** @hidden */
  37254. _removePendingData(data: any): void;
  37255. /**
  37256. * Returns the number of items waiting to be loaded
  37257. * @returns the number of items waiting to be loaded
  37258. */
  37259. getWaitingItemsCount(): number;
  37260. /**
  37261. * Returns a boolean indicating if the scene is still loading data
  37262. */
  37263. get isLoading(): boolean;
  37264. /**
  37265. * Registers a function to be executed when the scene is ready
  37266. * @param {Function} func - the function to be executed
  37267. */
  37268. executeWhenReady(func: () => void): void;
  37269. /**
  37270. * Returns a promise that resolves when the scene is ready
  37271. * @returns A promise that resolves when the scene is ready
  37272. */
  37273. whenReadyAsync(): Promise<void>;
  37274. /** @hidden */
  37275. _checkIsReady(): void;
  37276. /**
  37277. * Gets all animatable attached to the scene
  37278. */
  37279. get animatables(): Animatable[];
  37280. /**
  37281. * Resets the last animation time frame.
  37282. * Useful to override when animations start running when loading a scene for the first time.
  37283. */
  37284. resetLastAnimationTimeFrame(): void;
  37285. /**
  37286. * Gets the current view matrix
  37287. * @returns a Matrix
  37288. */
  37289. getViewMatrix(): Matrix;
  37290. /**
  37291. * Gets the current projection matrix
  37292. * @returns a Matrix
  37293. */
  37294. getProjectionMatrix(): Matrix;
  37295. /**
  37296. * Gets the current transform matrix
  37297. * @returns a Matrix made of View * Projection
  37298. */
  37299. getTransformMatrix(): Matrix;
  37300. /**
  37301. * Sets the current transform matrix
  37302. * @param viewL defines the View matrix to use
  37303. * @param projectionL defines the Projection matrix to use
  37304. * @param viewR defines the right View matrix to use (if provided)
  37305. * @param projectionR defines the right Projection matrix to use (if provided)
  37306. */
  37307. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37308. /**
  37309. * Gets the uniform buffer used to store scene data
  37310. * @returns a UniformBuffer
  37311. */
  37312. getSceneUniformBuffer(): UniformBuffer;
  37313. /**
  37314. * Gets an unique (relatively to the current scene) Id
  37315. * @returns an unique number for the scene
  37316. */
  37317. getUniqueId(): number;
  37318. /**
  37319. * Add a mesh to the list of scene's meshes
  37320. * @param newMesh defines the mesh to add
  37321. * @param recursive if all child meshes should also be added to the scene
  37322. */
  37323. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37324. /**
  37325. * Remove a mesh for the list of scene's meshes
  37326. * @param toRemove defines the mesh to remove
  37327. * @param recursive if all child meshes should also be removed from the scene
  37328. * @returns the index where the mesh was in the mesh list
  37329. */
  37330. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37331. /**
  37332. * Add a transform node to the list of scene's transform nodes
  37333. * @param newTransformNode defines the transform node to add
  37334. */
  37335. addTransformNode(newTransformNode: TransformNode): void;
  37336. /**
  37337. * Remove a transform node for the list of scene's transform nodes
  37338. * @param toRemove defines the transform node to remove
  37339. * @returns the index where the transform node was in the transform node list
  37340. */
  37341. removeTransformNode(toRemove: TransformNode): number;
  37342. /**
  37343. * Remove a skeleton for the list of scene's skeletons
  37344. * @param toRemove defines the skeleton to remove
  37345. * @returns the index where the skeleton was in the skeleton list
  37346. */
  37347. removeSkeleton(toRemove: Skeleton): number;
  37348. /**
  37349. * Remove a morph target for the list of scene's morph targets
  37350. * @param toRemove defines the morph target to remove
  37351. * @returns the index where the morph target was in the morph target list
  37352. */
  37353. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37354. /**
  37355. * Remove a light for the list of scene's lights
  37356. * @param toRemove defines the light to remove
  37357. * @returns the index where the light was in the light list
  37358. */
  37359. removeLight(toRemove: Light): number;
  37360. /**
  37361. * Remove a camera for the list of scene's cameras
  37362. * @param toRemove defines the camera to remove
  37363. * @returns the index where the camera was in the camera list
  37364. */
  37365. removeCamera(toRemove: Camera): number;
  37366. /**
  37367. * Remove a particle system for the list of scene's particle systems
  37368. * @param toRemove defines the particle system to remove
  37369. * @returns the index where the particle system was in the particle system list
  37370. */
  37371. removeParticleSystem(toRemove: IParticleSystem): number;
  37372. /**
  37373. * Remove a animation for the list of scene's animations
  37374. * @param toRemove defines the animation to remove
  37375. * @returns the index where the animation was in the animation list
  37376. */
  37377. removeAnimation(toRemove: Animation): number;
  37378. /**
  37379. * Will stop the animation of the given target
  37380. * @param target - the target
  37381. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37382. * @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)
  37383. */
  37384. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37385. /**
  37386. * Removes the given animation group from this scene.
  37387. * @param toRemove The animation group to remove
  37388. * @returns The index of the removed animation group
  37389. */
  37390. removeAnimationGroup(toRemove: AnimationGroup): number;
  37391. /**
  37392. * Removes the given multi-material from this scene.
  37393. * @param toRemove The multi-material to remove
  37394. * @returns The index of the removed multi-material
  37395. */
  37396. removeMultiMaterial(toRemove: MultiMaterial): number;
  37397. /**
  37398. * Removes the given material from this scene.
  37399. * @param toRemove The material to remove
  37400. * @returns The index of the removed material
  37401. */
  37402. removeMaterial(toRemove: Material): number;
  37403. /**
  37404. * Removes the given action manager from this scene.
  37405. * @param toRemove The action manager to remove
  37406. * @returns The index of the removed action manager
  37407. */
  37408. removeActionManager(toRemove: AbstractActionManager): number;
  37409. /**
  37410. * Removes the given texture from this scene.
  37411. * @param toRemove The texture to remove
  37412. * @returns The index of the removed texture
  37413. */
  37414. removeTexture(toRemove: BaseTexture): number;
  37415. /**
  37416. * Adds the given light to this scene
  37417. * @param newLight The light to add
  37418. */
  37419. addLight(newLight: Light): void;
  37420. /**
  37421. * Sorts the list list based on light priorities
  37422. */
  37423. sortLightsByPriority(): void;
  37424. /**
  37425. * Adds the given camera to this scene
  37426. * @param newCamera The camera to add
  37427. */
  37428. addCamera(newCamera: Camera): void;
  37429. /**
  37430. * Adds the given skeleton to this scene
  37431. * @param newSkeleton The skeleton to add
  37432. */
  37433. addSkeleton(newSkeleton: Skeleton): void;
  37434. /**
  37435. * Adds the given particle system to this scene
  37436. * @param newParticleSystem The particle system to add
  37437. */
  37438. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37439. /**
  37440. * Adds the given animation to this scene
  37441. * @param newAnimation The animation to add
  37442. */
  37443. addAnimation(newAnimation: Animation): void;
  37444. /**
  37445. * Adds the given animation group to this scene.
  37446. * @param newAnimationGroup The animation group to add
  37447. */
  37448. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37449. /**
  37450. * Adds the given multi-material to this scene
  37451. * @param newMultiMaterial The multi-material to add
  37452. */
  37453. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37454. /**
  37455. * Adds the given material to this scene
  37456. * @param newMaterial The material to add
  37457. */
  37458. addMaterial(newMaterial: Material): void;
  37459. /**
  37460. * Adds the given morph target to this scene
  37461. * @param newMorphTargetManager The morph target to add
  37462. */
  37463. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37464. /**
  37465. * Adds the given geometry to this scene
  37466. * @param newGeometry The geometry to add
  37467. */
  37468. addGeometry(newGeometry: Geometry): void;
  37469. /**
  37470. * Adds the given action manager to this scene
  37471. * @param newActionManager The action manager to add
  37472. */
  37473. addActionManager(newActionManager: AbstractActionManager): void;
  37474. /**
  37475. * Adds the given texture to this scene.
  37476. * @param newTexture The texture to add
  37477. */
  37478. addTexture(newTexture: BaseTexture): void;
  37479. /**
  37480. * Switch active camera
  37481. * @param newCamera defines the new active camera
  37482. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37483. */
  37484. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37485. /**
  37486. * sets the active camera of the scene using its ID
  37487. * @param id defines the camera's ID
  37488. * @return the new active camera or null if none found.
  37489. */
  37490. setActiveCameraByID(id: string): Nullable<Camera>;
  37491. /**
  37492. * sets the active camera of the scene using its name
  37493. * @param name defines the camera's name
  37494. * @returns the new active camera or null if none found.
  37495. */
  37496. setActiveCameraByName(name: string): Nullable<Camera>;
  37497. /**
  37498. * get an animation group using its name
  37499. * @param name defines the material's name
  37500. * @return the animation group or null if none found.
  37501. */
  37502. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37503. /**
  37504. * Get a material using its unique id
  37505. * @param uniqueId defines the material's unique id
  37506. * @return the material or null if none found.
  37507. */
  37508. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37509. /**
  37510. * get a material using its id
  37511. * @param id defines the material's ID
  37512. * @return the material or null if none found.
  37513. */
  37514. getMaterialByID(id: string): Nullable<Material>;
  37515. /**
  37516. * Gets a the last added material using a given id
  37517. * @param id defines the material's ID
  37518. * @return the last material with the given id or null if none found.
  37519. */
  37520. getLastMaterialByID(id: string): Nullable<Material>;
  37521. /**
  37522. * Gets a material using its name
  37523. * @param name defines the material's name
  37524. * @return the material or null if none found.
  37525. */
  37526. getMaterialByName(name: string): Nullable<Material>;
  37527. /**
  37528. * Get a texture using its unique id
  37529. * @param uniqueId defines the texture's unique id
  37530. * @return the texture or null if none found.
  37531. */
  37532. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37533. /**
  37534. * Gets a camera using its id
  37535. * @param id defines the id to look for
  37536. * @returns the camera or null if not found
  37537. */
  37538. getCameraByID(id: string): Nullable<Camera>;
  37539. /**
  37540. * Gets a camera using its unique id
  37541. * @param uniqueId defines the unique id to look for
  37542. * @returns the camera or null if not found
  37543. */
  37544. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37545. /**
  37546. * Gets a camera using its name
  37547. * @param name defines the camera's name
  37548. * @return the camera or null if none found.
  37549. */
  37550. getCameraByName(name: string): Nullable<Camera>;
  37551. /**
  37552. * Gets a bone using its id
  37553. * @param id defines the bone's id
  37554. * @return the bone or null if not found
  37555. */
  37556. getBoneByID(id: string): Nullable<Bone>;
  37557. /**
  37558. * Gets a bone using its id
  37559. * @param name defines the bone's name
  37560. * @return the bone or null if not found
  37561. */
  37562. getBoneByName(name: string): Nullable<Bone>;
  37563. /**
  37564. * Gets a light node using its name
  37565. * @param name defines the the light's name
  37566. * @return the light or null if none found.
  37567. */
  37568. getLightByName(name: string): Nullable<Light>;
  37569. /**
  37570. * Gets a light node using its id
  37571. * @param id defines the light's id
  37572. * @return the light or null if none found.
  37573. */
  37574. getLightByID(id: string): Nullable<Light>;
  37575. /**
  37576. * Gets a light node using its scene-generated unique ID
  37577. * @param uniqueId defines the light's unique id
  37578. * @return the light or null if none found.
  37579. */
  37580. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37581. /**
  37582. * Gets a particle system by id
  37583. * @param id defines the particle system id
  37584. * @return the corresponding system or null if none found
  37585. */
  37586. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37587. /**
  37588. * Gets a geometry using its ID
  37589. * @param id defines the geometry's id
  37590. * @return the geometry or null if none found.
  37591. */
  37592. getGeometryByID(id: string): Nullable<Geometry>;
  37593. private _getGeometryByUniqueID;
  37594. /**
  37595. * Add a new geometry to this scene
  37596. * @param geometry defines the geometry to be added to the scene.
  37597. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37598. * @return a boolean defining if the geometry was added or not
  37599. */
  37600. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37601. /**
  37602. * Removes an existing geometry
  37603. * @param geometry defines the geometry to be removed from the scene
  37604. * @return a boolean defining if the geometry was removed or not
  37605. */
  37606. removeGeometry(geometry: Geometry): boolean;
  37607. /**
  37608. * Gets the list of geometries attached to the scene
  37609. * @returns an array of Geometry
  37610. */
  37611. getGeometries(): Geometry[];
  37612. /**
  37613. * Gets the first added mesh found of a given ID
  37614. * @param id defines the id to search for
  37615. * @return the mesh found or null if not found at all
  37616. */
  37617. getMeshByID(id: string): Nullable<AbstractMesh>;
  37618. /**
  37619. * Gets a list of meshes using their id
  37620. * @param id defines the id to search for
  37621. * @returns a list of meshes
  37622. */
  37623. getMeshesByID(id: string): Array<AbstractMesh>;
  37624. /**
  37625. * Gets the first added transform node found of a given ID
  37626. * @param id defines the id to search for
  37627. * @return the found transform node or null if not found at all.
  37628. */
  37629. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37630. /**
  37631. * Gets a transform node with its auto-generated unique id
  37632. * @param uniqueId efines the unique id to search for
  37633. * @return the found transform node or null if not found at all.
  37634. */
  37635. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37636. /**
  37637. * Gets a list of transform nodes using their id
  37638. * @param id defines the id to search for
  37639. * @returns a list of transform nodes
  37640. */
  37641. getTransformNodesByID(id: string): Array<TransformNode>;
  37642. /**
  37643. * Gets a mesh with its auto-generated unique id
  37644. * @param uniqueId defines the unique id to search for
  37645. * @return the found mesh or null if not found at all.
  37646. */
  37647. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37648. /**
  37649. * Gets a the last added mesh using a given id
  37650. * @param id defines the id to search for
  37651. * @return the found mesh or null if not found at all.
  37652. */
  37653. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37654. /**
  37655. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37656. * @param id defines the id to search for
  37657. * @return the found node or null if not found at all
  37658. */
  37659. getLastEntryByID(id: string): Nullable<Node>;
  37660. /**
  37661. * Gets a node (Mesh, Camera, Light) using a given id
  37662. * @param id defines the id to search for
  37663. * @return the found node or null if not found at all
  37664. */
  37665. getNodeByID(id: string): Nullable<Node>;
  37666. /**
  37667. * Gets a node (Mesh, Camera, Light) using a given name
  37668. * @param name defines the name to search for
  37669. * @return the found node or null if not found at all.
  37670. */
  37671. getNodeByName(name: string): Nullable<Node>;
  37672. /**
  37673. * Gets a mesh using a given name
  37674. * @param name defines the name to search for
  37675. * @return the found mesh or null if not found at all.
  37676. */
  37677. getMeshByName(name: string): Nullable<AbstractMesh>;
  37678. /**
  37679. * Gets a transform node using a given name
  37680. * @param name defines the name to search for
  37681. * @return the found transform node or null if not found at all.
  37682. */
  37683. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37684. /**
  37685. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37686. * @param id defines the id to search for
  37687. * @return the found skeleton or null if not found at all.
  37688. */
  37689. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37690. /**
  37691. * Gets a skeleton using a given auto generated unique id
  37692. * @param uniqueId defines the unique id to search for
  37693. * @return the found skeleton or null if not found at all.
  37694. */
  37695. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37696. /**
  37697. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37698. * @param id defines the id to search for
  37699. * @return the found skeleton or null if not found at all.
  37700. */
  37701. getSkeletonById(id: string): Nullable<Skeleton>;
  37702. /**
  37703. * Gets a skeleton using a given name
  37704. * @param name defines the name to search for
  37705. * @return the found skeleton or null if not found at all.
  37706. */
  37707. getSkeletonByName(name: string): Nullable<Skeleton>;
  37708. /**
  37709. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37710. * @param id defines the id to search for
  37711. * @return the found morph target manager or null if not found at all.
  37712. */
  37713. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37714. /**
  37715. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37716. * @param id defines the id to search for
  37717. * @return the found morph target or null if not found at all.
  37718. */
  37719. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37720. /**
  37721. * Gets a boolean indicating if the given mesh is active
  37722. * @param mesh defines the mesh to look for
  37723. * @returns true if the mesh is in the active list
  37724. */
  37725. isActiveMesh(mesh: AbstractMesh): boolean;
  37726. /**
  37727. * Return a unique id as a string which can serve as an identifier for the scene
  37728. */
  37729. get uid(): string;
  37730. /**
  37731. * Add an externaly attached data from its key.
  37732. * This method call will fail and return false, if such key already exists.
  37733. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37734. * @param key the unique key that identifies the data
  37735. * @param data the data object to associate to the key for this Engine instance
  37736. * @return true if no such key were already present and the data was added successfully, false otherwise
  37737. */
  37738. addExternalData<T>(key: string, data: T): boolean;
  37739. /**
  37740. * Get an externaly attached data from its key
  37741. * @param key the unique key that identifies the data
  37742. * @return the associated data, if present (can be null), or undefined if not present
  37743. */
  37744. getExternalData<T>(key: string): Nullable<T>;
  37745. /**
  37746. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37747. * @param key the unique key that identifies the data
  37748. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37749. * @return the associated data, can be null if the factory returned null.
  37750. */
  37751. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37752. /**
  37753. * Remove an externaly attached data from the Engine instance
  37754. * @param key the unique key that identifies the data
  37755. * @return true if the data was successfully removed, false if it doesn't exist
  37756. */
  37757. removeExternalData(key: string): boolean;
  37758. private _evaluateSubMesh;
  37759. /**
  37760. * Clear the processed materials smart array preventing retention point in material dispose.
  37761. */
  37762. freeProcessedMaterials(): void;
  37763. private _preventFreeActiveMeshesAndRenderingGroups;
  37764. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37765. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37766. * when disposing several meshes in a row or a hierarchy of meshes.
  37767. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37768. */
  37769. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37770. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37771. /**
  37772. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37773. */
  37774. freeActiveMeshes(): void;
  37775. /**
  37776. * Clear the info related to rendering groups preventing retention points during dispose.
  37777. */
  37778. freeRenderingGroups(): void;
  37779. /** @hidden */
  37780. _isInIntermediateRendering(): boolean;
  37781. /**
  37782. * Lambda returning the list of potentially active meshes.
  37783. */
  37784. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37785. /**
  37786. * Lambda returning the list of potentially active sub meshes.
  37787. */
  37788. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37789. /**
  37790. * Lambda returning the list of potentially intersecting sub meshes.
  37791. */
  37792. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37793. /**
  37794. * Lambda returning the list of potentially colliding sub meshes.
  37795. */
  37796. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37797. private _activeMeshesFrozen;
  37798. private _skipEvaluateActiveMeshesCompletely;
  37799. /**
  37800. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37801. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37802. * @returns the current scene
  37803. */
  37804. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37805. /**
  37806. * Use this function to restart evaluating active meshes on every frame
  37807. * @returns the current scene
  37808. */
  37809. unfreezeActiveMeshes(): Scene;
  37810. private _evaluateActiveMeshes;
  37811. private _activeMesh;
  37812. /**
  37813. * Update the transform matrix to update from the current active camera
  37814. * @param force defines a boolean used to force the update even if cache is up to date
  37815. */
  37816. updateTransformMatrix(force?: boolean): void;
  37817. private _bindFrameBuffer;
  37818. /** @hidden */
  37819. _allowPostProcessClearColor: boolean;
  37820. /** @hidden */
  37821. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37822. private _processSubCameras;
  37823. private _checkIntersections;
  37824. /** @hidden */
  37825. _advancePhysicsEngineStep(step: number): void;
  37826. /**
  37827. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37828. */
  37829. getDeterministicFrameTime: () => number;
  37830. /** @hidden */
  37831. _animate(): void;
  37832. /** Execute all animations (for a frame) */
  37833. animate(): void;
  37834. /**
  37835. * Render the scene
  37836. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37837. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37838. */
  37839. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37840. /**
  37841. * Freeze all materials
  37842. * A frozen material will not be updatable but should be faster to render
  37843. */
  37844. freezeMaterials(): void;
  37845. /**
  37846. * Unfreeze all materials
  37847. * A frozen material will not be updatable but should be faster to render
  37848. */
  37849. unfreezeMaterials(): void;
  37850. /**
  37851. * Releases all held ressources
  37852. */
  37853. dispose(): void;
  37854. /**
  37855. * Gets if the scene is already disposed
  37856. */
  37857. get isDisposed(): boolean;
  37858. /**
  37859. * Call this function to reduce memory footprint of the scene.
  37860. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37861. */
  37862. clearCachedVertexData(): void;
  37863. /**
  37864. * This function will remove the local cached buffer data from texture.
  37865. * It will save memory but will prevent the texture from being rebuilt
  37866. */
  37867. cleanCachedTextureBuffer(): void;
  37868. /**
  37869. * Get the world extend vectors with an optional filter
  37870. *
  37871. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37872. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37873. */
  37874. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37875. min: Vector3;
  37876. max: Vector3;
  37877. };
  37878. /**
  37879. * Creates a ray that can be used to pick in the scene
  37880. * @param x defines the x coordinate of the origin (on-screen)
  37881. * @param y defines the y coordinate of the origin (on-screen)
  37882. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37883. * @param camera defines the camera to use for the picking
  37884. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37885. * @returns a Ray
  37886. */
  37887. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37888. /**
  37889. * Creates a ray that can be used to pick in the scene
  37890. * @param x defines the x coordinate of the origin (on-screen)
  37891. * @param y defines the y coordinate of the origin (on-screen)
  37892. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37893. * @param result defines the ray where to store the picking ray
  37894. * @param camera defines the camera to use for the picking
  37895. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37896. * @returns the current scene
  37897. */
  37898. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37899. /**
  37900. * Creates a ray that can be used to pick in the scene
  37901. * @param x defines the x coordinate of the origin (on-screen)
  37902. * @param y defines the y coordinate of the origin (on-screen)
  37903. * @param camera defines the camera to use for the picking
  37904. * @returns a Ray
  37905. */
  37906. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37907. /**
  37908. * Creates a ray that can be used to pick in the scene
  37909. * @param x defines the x coordinate of the origin (on-screen)
  37910. * @param y defines the y coordinate of the origin (on-screen)
  37911. * @param result defines the ray where to store the picking ray
  37912. * @param camera defines the camera to use for the picking
  37913. * @returns the current scene
  37914. */
  37915. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37916. /** Launch a ray to try to pick a mesh in the scene
  37917. * @param x position on screen
  37918. * @param y position on screen
  37919. * @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
  37920. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37921. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37922. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37923. * @returns a PickingInfo
  37924. */
  37925. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37926. /** Use the given ray to pick a mesh in the scene
  37927. * @param ray The ray to use to pick meshes
  37928. * @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
  37929. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37930. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37931. * @returns a PickingInfo
  37932. */
  37933. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37934. /**
  37935. * Launch a ray to try to pick a mesh in the scene
  37936. * @param x X position on screen
  37937. * @param y Y position on screen
  37938. * @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
  37939. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37940. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37941. * @returns an array of PickingInfo
  37942. */
  37943. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37944. /**
  37945. * Launch a ray to try to pick a mesh in the scene
  37946. * @param ray Ray to use
  37947. * @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
  37948. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37949. * @returns an array of PickingInfo
  37950. */
  37951. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37952. /**
  37953. * Force the value of meshUnderPointer
  37954. * @param mesh defines the mesh to use
  37955. */
  37956. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37957. /**
  37958. * Gets the mesh under the pointer
  37959. * @returns a Mesh or null if no mesh is under the pointer
  37960. */
  37961. getPointerOverMesh(): Nullable<AbstractMesh>;
  37962. /** @hidden */
  37963. _rebuildGeometries(): void;
  37964. /** @hidden */
  37965. _rebuildTextures(): void;
  37966. private _getByTags;
  37967. /**
  37968. * Get a list of meshes by tags
  37969. * @param tagsQuery defines the tags query to use
  37970. * @param forEach defines a predicate used to filter results
  37971. * @returns an array of Mesh
  37972. */
  37973. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37974. /**
  37975. * Get a list of cameras by tags
  37976. * @param tagsQuery defines the tags query to use
  37977. * @param forEach defines a predicate used to filter results
  37978. * @returns an array of Camera
  37979. */
  37980. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37981. /**
  37982. * Get a list of lights by tags
  37983. * @param tagsQuery defines the tags query to use
  37984. * @param forEach defines a predicate used to filter results
  37985. * @returns an array of Light
  37986. */
  37987. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37988. /**
  37989. * Get a list of materials by tags
  37990. * @param tagsQuery defines the tags query to use
  37991. * @param forEach defines a predicate used to filter results
  37992. * @returns an array of Material
  37993. */
  37994. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37995. /**
  37996. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37997. * This allowed control for front to back rendering or reversly depending of the special needs.
  37998. *
  37999. * @param renderingGroupId The rendering group id corresponding to its index
  38000. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38001. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38002. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38003. */
  38004. 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;
  38005. /**
  38006. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38007. *
  38008. * @param renderingGroupId The rendering group id corresponding to its index
  38009. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38010. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38011. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38012. */
  38013. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38014. /**
  38015. * Gets the current auto clear configuration for one rendering group of the rendering
  38016. * manager.
  38017. * @param index the rendering group index to get the information for
  38018. * @returns The auto clear setup for the requested rendering group
  38019. */
  38020. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38021. private _blockMaterialDirtyMechanism;
  38022. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38023. get blockMaterialDirtyMechanism(): boolean;
  38024. set blockMaterialDirtyMechanism(value: boolean);
  38025. /**
  38026. * Will flag all materials as dirty to trigger new shader compilation
  38027. * @param flag defines the flag used to specify which material part must be marked as dirty
  38028. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38029. */
  38030. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38031. /** @hidden */
  38032. _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;
  38033. /** @hidden */
  38034. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38035. /** @hidden */
  38036. _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;
  38037. /** @hidden */
  38038. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38039. /** @hidden */
  38040. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38041. /** @hidden */
  38042. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38043. }
  38044. }
  38045. declare module "babylonjs/assetContainer" {
  38046. import { AbstractScene } from "babylonjs/abstractScene";
  38047. import { Scene } from "babylonjs/scene";
  38048. import { Mesh } from "babylonjs/Meshes/mesh";
  38049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38050. import { Skeleton } from "babylonjs/Bones/skeleton";
  38051. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38052. import { Animatable } from "babylonjs/Animations/animatable";
  38053. import { Nullable } from "babylonjs/types";
  38054. import { Node } from "babylonjs/node";
  38055. /**
  38056. * Set of assets to keep when moving a scene into an asset container.
  38057. */
  38058. export class KeepAssets extends AbstractScene {
  38059. }
  38060. /**
  38061. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38062. */
  38063. export class InstantiatedEntries {
  38064. /**
  38065. * List of new root nodes (eg. nodes with no parent)
  38066. */
  38067. rootNodes: TransformNode[];
  38068. /**
  38069. * List of new skeletons
  38070. */
  38071. skeletons: Skeleton[];
  38072. /**
  38073. * List of new animation groups
  38074. */
  38075. animationGroups: AnimationGroup[];
  38076. }
  38077. /**
  38078. * Container with a set of assets that can be added or removed from a scene.
  38079. */
  38080. export class AssetContainer extends AbstractScene {
  38081. private _wasAddedToScene;
  38082. /**
  38083. * The scene the AssetContainer belongs to.
  38084. */
  38085. scene: Scene;
  38086. /**
  38087. * Instantiates an AssetContainer.
  38088. * @param scene The scene the AssetContainer belongs to.
  38089. */
  38090. constructor(scene: Scene);
  38091. /**
  38092. * Instantiate or clone all meshes and add the new ones to the scene.
  38093. * Skeletons and animation groups will all be cloned
  38094. * @param nameFunction defines an optional function used to get new names for clones
  38095. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38096. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38097. */
  38098. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38099. /**
  38100. * Adds all the assets from the container to the scene.
  38101. */
  38102. addAllToScene(): void;
  38103. /**
  38104. * Removes all the assets in the container from the scene
  38105. */
  38106. removeAllFromScene(): void;
  38107. /**
  38108. * Disposes all the assets in the container
  38109. */
  38110. dispose(): void;
  38111. private _moveAssets;
  38112. /**
  38113. * Removes all the assets contained in the scene and adds them to the container.
  38114. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38115. */
  38116. moveAllFromScene(keepAssets?: KeepAssets): void;
  38117. /**
  38118. * 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.
  38119. * @returns the root mesh
  38120. */
  38121. createRootMesh(): Mesh;
  38122. /**
  38123. * Merge animations from this asset container into a scene
  38124. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38125. * @param animatables set of animatables to retarget to a node from the scene
  38126. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38127. */
  38128. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38129. }
  38130. }
  38131. declare module "babylonjs/abstractScene" {
  38132. import { Scene } from "babylonjs/scene";
  38133. import { Nullable } from "babylonjs/types";
  38134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38135. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38136. import { Geometry } from "babylonjs/Meshes/geometry";
  38137. import { Skeleton } from "babylonjs/Bones/skeleton";
  38138. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38139. import { AssetContainer } from "babylonjs/assetContainer";
  38140. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38141. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38142. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38143. import { Material } from "babylonjs/Materials/material";
  38144. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38145. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38146. import { Camera } from "babylonjs/Cameras/camera";
  38147. import { Light } from "babylonjs/Lights/light";
  38148. import { Node } from "babylonjs/node";
  38149. import { Animation } from "babylonjs/Animations/animation";
  38150. /**
  38151. * Defines how the parser contract is defined.
  38152. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38153. */
  38154. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38155. /**
  38156. * Defines how the individual parser contract is defined.
  38157. * These parser can parse an individual asset
  38158. */
  38159. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38160. /**
  38161. * Base class of the scene acting as a container for the different elements composing a scene.
  38162. * This class is dynamically extended by the different components of the scene increasing
  38163. * flexibility and reducing coupling
  38164. */
  38165. export abstract class AbstractScene {
  38166. /**
  38167. * Stores the list of available parsers in the application.
  38168. */
  38169. private static _BabylonFileParsers;
  38170. /**
  38171. * Stores the list of available individual parsers in the application.
  38172. */
  38173. private static _IndividualBabylonFileParsers;
  38174. /**
  38175. * Adds a parser in the list of available ones
  38176. * @param name Defines the name of the parser
  38177. * @param parser Defines the parser to add
  38178. */
  38179. static AddParser(name: string, parser: BabylonFileParser): void;
  38180. /**
  38181. * Gets a general parser from the list of avaialble ones
  38182. * @param name Defines the name of the parser
  38183. * @returns the requested parser or null
  38184. */
  38185. static GetParser(name: string): Nullable<BabylonFileParser>;
  38186. /**
  38187. * Adds n individual parser in the list of available ones
  38188. * @param name Defines the name of the parser
  38189. * @param parser Defines the parser to add
  38190. */
  38191. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38192. /**
  38193. * Gets an individual parser from the list of avaialble ones
  38194. * @param name Defines the name of the parser
  38195. * @returns the requested parser or null
  38196. */
  38197. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38198. /**
  38199. * Parser json data and populate both a scene and its associated container object
  38200. * @param jsonData Defines the data to parse
  38201. * @param scene Defines the scene to parse the data for
  38202. * @param container Defines the container attached to the parsing sequence
  38203. * @param rootUrl Defines the root url of the data
  38204. */
  38205. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38206. /**
  38207. * Gets the list of root nodes (ie. nodes with no parent)
  38208. */
  38209. rootNodes: Node[];
  38210. /** All of the cameras added to this scene
  38211. * @see http://doc.babylonjs.com/babylon101/cameras
  38212. */
  38213. cameras: Camera[];
  38214. /**
  38215. * All of the lights added to this scene
  38216. * @see http://doc.babylonjs.com/babylon101/lights
  38217. */
  38218. lights: Light[];
  38219. /**
  38220. * All of the (abstract) meshes added to this scene
  38221. */
  38222. meshes: AbstractMesh[];
  38223. /**
  38224. * The list of skeletons added to the scene
  38225. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38226. */
  38227. skeletons: Skeleton[];
  38228. /**
  38229. * All of the particle systems added to this scene
  38230. * @see http://doc.babylonjs.com/babylon101/particles
  38231. */
  38232. particleSystems: IParticleSystem[];
  38233. /**
  38234. * Gets a list of Animations associated with the scene
  38235. */
  38236. animations: Animation[];
  38237. /**
  38238. * All of the animation groups added to this scene
  38239. * @see http://doc.babylonjs.com/how_to/group
  38240. */
  38241. animationGroups: AnimationGroup[];
  38242. /**
  38243. * All of the multi-materials added to this scene
  38244. * @see http://doc.babylonjs.com/how_to/multi_materials
  38245. */
  38246. multiMaterials: MultiMaterial[];
  38247. /**
  38248. * All of the materials added to this scene
  38249. * In the context of a Scene, it is not supposed to be modified manually.
  38250. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38251. * Note also that the order of the Material within the array is not significant and might change.
  38252. * @see http://doc.babylonjs.com/babylon101/materials
  38253. */
  38254. materials: Material[];
  38255. /**
  38256. * The list of morph target managers added to the scene
  38257. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38258. */
  38259. morphTargetManagers: MorphTargetManager[];
  38260. /**
  38261. * The list of geometries used in the scene.
  38262. */
  38263. geometries: Geometry[];
  38264. /**
  38265. * All of the tranform nodes added to this scene
  38266. * In the context of a Scene, it is not supposed to be modified manually.
  38267. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38268. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38269. * @see http://doc.babylonjs.com/how_to/transformnode
  38270. */
  38271. transformNodes: TransformNode[];
  38272. /**
  38273. * ActionManagers available on the scene.
  38274. */
  38275. actionManagers: AbstractActionManager[];
  38276. /**
  38277. * Textures to keep.
  38278. */
  38279. textures: BaseTexture[];
  38280. /**
  38281. * Environment texture for the scene
  38282. */
  38283. environmentTexture: Nullable<BaseTexture>;
  38284. /**
  38285. * @returns all meshes, lights, cameras, transformNodes and bones
  38286. */
  38287. getNodes(): Array<Node>;
  38288. }
  38289. }
  38290. declare module "babylonjs/Audio/sound" {
  38291. import { Observable } from "babylonjs/Misc/observable";
  38292. import { Vector3 } from "babylonjs/Maths/math.vector";
  38293. import { Nullable } from "babylonjs/types";
  38294. import { Scene } from "babylonjs/scene";
  38295. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38296. /**
  38297. * Interface used to define options for Sound class
  38298. */
  38299. export interface ISoundOptions {
  38300. /**
  38301. * Does the sound autoplay once loaded.
  38302. */
  38303. autoplay?: boolean;
  38304. /**
  38305. * Does the sound loop after it finishes playing once.
  38306. */
  38307. loop?: boolean;
  38308. /**
  38309. * Sound's volume
  38310. */
  38311. volume?: number;
  38312. /**
  38313. * Is it a spatial sound?
  38314. */
  38315. spatialSound?: boolean;
  38316. /**
  38317. * Maximum distance to hear that sound
  38318. */
  38319. maxDistance?: number;
  38320. /**
  38321. * Uses user defined attenuation function
  38322. */
  38323. useCustomAttenuation?: boolean;
  38324. /**
  38325. * Define the roll off factor of spatial sounds.
  38326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38327. */
  38328. rolloffFactor?: number;
  38329. /**
  38330. * Define the reference distance the sound should be heard perfectly.
  38331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38332. */
  38333. refDistance?: number;
  38334. /**
  38335. * Define the distance attenuation model the sound will follow.
  38336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38337. */
  38338. distanceModel?: string;
  38339. /**
  38340. * Defines the playback speed (1 by default)
  38341. */
  38342. playbackRate?: number;
  38343. /**
  38344. * Defines if the sound is from a streaming source
  38345. */
  38346. streaming?: boolean;
  38347. /**
  38348. * Defines an optional length (in seconds) inside the sound file
  38349. */
  38350. length?: number;
  38351. /**
  38352. * Defines an optional offset (in seconds) inside the sound file
  38353. */
  38354. offset?: number;
  38355. /**
  38356. * If true, URLs will not be required to state the audio file codec to use.
  38357. */
  38358. skipCodecCheck?: boolean;
  38359. }
  38360. /**
  38361. * Defines a sound that can be played in the application.
  38362. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38364. */
  38365. export class Sound {
  38366. /**
  38367. * The name of the sound in the scene.
  38368. */
  38369. name: string;
  38370. /**
  38371. * Does the sound autoplay once loaded.
  38372. */
  38373. autoplay: boolean;
  38374. /**
  38375. * Does the sound loop after it finishes playing once.
  38376. */
  38377. loop: boolean;
  38378. /**
  38379. * Does the sound use a custom attenuation curve to simulate the falloff
  38380. * happening when the source gets further away from the camera.
  38381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38382. */
  38383. useCustomAttenuation: boolean;
  38384. /**
  38385. * The sound track id this sound belongs to.
  38386. */
  38387. soundTrackId: number;
  38388. /**
  38389. * Is this sound currently played.
  38390. */
  38391. isPlaying: boolean;
  38392. /**
  38393. * Is this sound currently paused.
  38394. */
  38395. isPaused: boolean;
  38396. /**
  38397. * Does this sound enables spatial sound.
  38398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38399. */
  38400. spatialSound: boolean;
  38401. /**
  38402. * Define the reference distance the sound should be heard perfectly.
  38403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38404. */
  38405. refDistance: number;
  38406. /**
  38407. * Define the roll off factor of spatial sounds.
  38408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38409. */
  38410. rolloffFactor: number;
  38411. /**
  38412. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38414. */
  38415. maxDistance: number;
  38416. /**
  38417. * Define the distance attenuation model the sound will follow.
  38418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38419. */
  38420. distanceModel: string;
  38421. /**
  38422. * @hidden
  38423. * Back Compat
  38424. **/
  38425. onended: () => any;
  38426. /**
  38427. * Observable event when the current playing sound finishes.
  38428. */
  38429. onEndedObservable: Observable<Sound>;
  38430. private _panningModel;
  38431. private _playbackRate;
  38432. private _streaming;
  38433. private _startTime;
  38434. private _startOffset;
  38435. private _position;
  38436. /** @hidden */
  38437. _positionInEmitterSpace: boolean;
  38438. private _localDirection;
  38439. private _volume;
  38440. private _isReadyToPlay;
  38441. private _isDirectional;
  38442. private _readyToPlayCallback;
  38443. private _audioBuffer;
  38444. private _soundSource;
  38445. private _streamingSource;
  38446. private _soundPanner;
  38447. private _soundGain;
  38448. private _inputAudioNode;
  38449. private _outputAudioNode;
  38450. private _coneInnerAngle;
  38451. private _coneOuterAngle;
  38452. private _coneOuterGain;
  38453. private _scene;
  38454. private _connectedTransformNode;
  38455. private _customAttenuationFunction;
  38456. private _registerFunc;
  38457. private _isOutputConnected;
  38458. private _htmlAudioElement;
  38459. private _urlType;
  38460. private _length?;
  38461. private _offset?;
  38462. /** @hidden */
  38463. static _SceneComponentInitialization: (scene: Scene) => void;
  38464. /**
  38465. * Create a sound and attach it to a scene
  38466. * @param name Name of your sound
  38467. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38468. * @param scene defines the scene the sound belongs to
  38469. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38470. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38471. */
  38472. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38473. /**
  38474. * Release the sound and its associated resources
  38475. */
  38476. dispose(): void;
  38477. /**
  38478. * Gets if the sounds is ready to be played or not.
  38479. * @returns true if ready, otherwise false
  38480. */
  38481. isReady(): boolean;
  38482. private _soundLoaded;
  38483. /**
  38484. * Sets the data of the sound from an audiobuffer
  38485. * @param audioBuffer The audioBuffer containing the data
  38486. */
  38487. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38488. /**
  38489. * Updates the current sounds options such as maxdistance, loop...
  38490. * @param options A JSON object containing values named as the object properties
  38491. */
  38492. updateOptions(options: ISoundOptions): void;
  38493. private _createSpatialParameters;
  38494. private _updateSpatialParameters;
  38495. /**
  38496. * Switch the panning model to HRTF:
  38497. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38499. */
  38500. switchPanningModelToHRTF(): void;
  38501. /**
  38502. * Switch the panning model to Equal Power:
  38503. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38505. */
  38506. switchPanningModelToEqualPower(): void;
  38507. private _switchPanningModel;
  38508. /**
  38509. * Connect this sound to a sound track audio node like gain...
  38510. * @param soundTrackAudioNode the sound track audio node to connect to
  38511. */
  38512. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38513. /**
  38514. * Transform this sound into a directional source
  38515. * @param coneInnerAngle Size of the inner cone in degree
  38516. * @param coneOuterAngle Size of the outer cone in degree
  38517. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38518. */
  38519. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38520. /**
  38521. * Gets or sets the inner angle for the directional cone.
  38522. */
  38523. get directionalConeInnerAngle(): number;
  38524. /**
  38525. * Gets or sets the inner angle for the directional cone.
  38526. */
  38527. set directionalConeInnerAngle(value: number);
  38528. /**
  38529. * Gets or sets the outer angle for the directional cone.
  38530. */
  38531. get directionalConeOuterAngle(): number;
  38532. /**
  38533. * Gets or sets the outer angle for the directional cone.
  38534. */
  38535. set directionalConeOuterAngle(value: number);
  38536. /**
  38537. * Sets the position of the emitter if spatial sound is enabled
  38538. * @param newPosition Defines the new posisiton
  38539. */
  38540. setPosition(newPosition: Vector3): void;
  38541. /**
  38542. * Sets the local direction of the emitter if spatial sound is enabled
  38543. * @param newLocalDirection Defines the new local direction
  38544. */
  38545. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38546. private _updateDirection;
  38547. /** @hidden */
  38548. updateDistanceFromListener(): void;
  38549. /**
  38550. * Sets a new custom attenuation function for the sound.
  38551. * @param callback Defines the function used for the attenuation
  38552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38553. */
  38554. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38555. /**
  38556. * Play the sound
  38557. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38558. * @param offset (optional) Start the sound at a specific time in seconds
  38559. * @param length (optional) Sound duration (in seconds)
  38560. */
  38561. play(time?: number, offset?: number, length?: number): void;
  38562. private _onended;
  38563. /**
  38564. * Stop the sound
  38565. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38566. */
  38567. stop(time?: number): void;
  38568. /**
  38569. * Put the sound in pause
  38570. */
  38571. pause(): void;
  38572. /**
  38573. * Sets a dedicated volume for this sounds
  38574. * @param newVolume Define the new volume of the sound
  38575. * @param time Define time for gradual change to new volume
  38576. */
  38577. setVolume(newVolume: number, time?: number): void;
  38578. /**
  38579. * Set the sound play back rate
  38580. * @param newPlaybackRate Define the playback rate the sound should be played at
  38581. */
  38582. setPlaybackRate(newPlaybackRate: number): void;
  38583. /**
  38584. * Gets the volume of the sound.
  38585. * @returns the volume of the sound
  38586. */
  38587. getVolume(): number;
  38588. /**
  38589. * Attach the sound to a dedicated mesh
  38590. * @param transformNode The transform node to connect the sound with
  38591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38592. */
  38593. attachToMesh(transformNode: TransformNode): void;
  38594. /**
  38595. * Detach the sound from the previously attached mesh
  38596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38597. */
  38598. detachFromMesh(): void;
  38599. private _onRegisterAfterWorldMatrixUpdate;
  38600. /**
  38601. * Clone the current sound in the scene.
  38602. * @returns the new sound clone
  38603. */
  38604. clone(): Nullable<Sound>;
  38605. /**
  38606. * Gets the current underlying audio buffer containing the data
  38607. * @returns the audio buffer
  38608. */
  38609. getAudioBuffer(): Nullable<AudioBuffer>;
  38610. /**
  38611. * Serializes the Sound in a JSON representation
  38612. * @returns the JSON representation of the sound
  38613. */
  38614. serialize(): any;
  38615. /**
  38616. * Parse a JSON representation of a sound to innstantiate in a given scene
  38617. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38618. * @param scene Define the scene the new parsed sound should be created in
  38619. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38620. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38621. * @returns the newly parsed sound
  38622. */
  38623. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38624. }
  38625. }
  38626. declare module "babylonjs/Actions/directAudioActions" {
  38627. import { Action } from "babylonjs/Actions/action";
  38628. import { Condition } from "babylonjs/Actions/condition";
  38629. import { Sound } from "babylonjs/Audio/sound";
  38630. /**
  38631. * This defines an action helpful to play a defined sound on a triggered action.
  38632. */
  38633. export class PlaySoundAction extends Action {
  38634. private _sound;
  38635. /**
  38636. * Instantiate the action
  38637. * @param triggerOptions defines the trigger options
  38638. * @param sound defines the sound to play
  38639. * @param condition defines the trigger related conditions
  38640. */
  38641. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38642. /** @hidden */
  38643. _prepare(): void;
  38644. /**
  38645. * Execute the action and play the sound.
  38646. */
  38647. execute(): void;
  38648. /**
  38649. * Serializes the actions and its related information.
  38650. * @param parent defines the object to serialize in
  38651. * @returns the serialized object
  38652. */
  38653. serialize(parent: any): any;
  38654. }
  38655. /**
  38656. * This defines an action helpful to stop a defined sound on a triggered action.
  38657. */
  38658. export class StopSoundAction extends Action {
  38659. private _sound;
  38660. /**
  38661. * Instantiate the action
  38662. * @param triggerOptions defines the trigger options
  38663. * @param sound defines the sound to stop
  38664. * @param condition defines the trigger related conditions
  38665. */
  38666. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38667. /** @hidden */
  38668. _prepare(): void;
  38669. /**
  38670. * Execute the action and stop the sound.
  38671. */
  38672. execute(): void;
  38673. /**
  38674. * Serializes the actions and its related information.
  38675. * @param parent defines the object to serialize in
  38676. * @returns the serialized object
  38677. */
  38678. serialize(parent: any): any;
  38679. }
  38680. }
  38681. declare module "babylonjs/Actions/interpolateValueAction" {
  38682. import { Action } from "babylonjs/Actions/action";
  38683. import { Condition } from "babylonjs/Actions/condition";
  38684. import { Observable } from "babylonjs/Misc/observable";
  38685. /**
  38686. * This defines an action responsible to change the value of a property
  38687. * by interpolating between its current value and the newly set one once triggered.
  38688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38689. */
  38690. export class InterpolateValueAction extends Action {
  38691. /**
  38692. * Defines the path of the property where the value should be interpolated
  38693. */
  38694. propertyPath: string;
  38695. /**
  38696. * Defines the target value at the end of the interpolation.
  38697. */
  38698. value: any;
  38699. /**
  38700. * Defines the time it will take for the property to interpolate to the value.
  38701. */
  38702. duration: number;
  38703. /**
  38704. * Defines if the other scene animations should be stopped when the action has been triggered
  38705. */
  38706. stopOtherAnimations?: boolean;
  38707. /**
  38708. * Defines a callback raised once the interpolation animation has been done.
  38709. */
  38710. onInterpolationDone?: () => void;
  38711. /**
  38712. * Observable triggered once the interpolation animation has been done.
  38713. */
  38714. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38715. private _target;
  38716. private _effectiveTarget;
  38717. private _property;
  38718. /**
  38719. * Instantiate the action
  38720. * @param triggerOptions defines the trigger options
  38721. * @param target defines the object containing the value to interpolate
  38722. * @param propertyPath defines the path to the property in the target object
  38723. * @param value defines the target value at the end of the interpolation
  38724. * @param duration deines the time it will take for the property to interpolate to the value.
  38725. * @param condition defines the trigger related conditions
  38726. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38727. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38728. */
  38729. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38730. /** @hidden */
  38731. _prepare(): void;
  38732. /**
  38733. * Execute the action starts the value interpolation.
  38734. */
  38735. execute(): void;
  38736. /**
  38737. * Serializes the actions and its related information.
  38738. * @param parent defines the object to serialize in
  38739. * @returns the serialized object
  38740. */
  38741. serialize(parent: any): any;
  38742. }
  38743. }
  38744. declare module "babylonjs/Actions/index" {
  38745. export * from "babylonjs/Actions/abstractActionManager";
  38746. export * from "babylonjs/Actions/action";
  38747. export * from "babylonjs/Actions/actionEvent";
  38748. export * from "babylonjs/Actions/actionManager";
  38749. export * from "babylonjs/Actions/condition";
  38750. export * from "babylonjs/Actions/directActions";
  38751. export * from "babylonjs/Actions/directAudioActions";
  38752. export * from "babylonjs/Actions/interpolateValueAction";
  38753. }
  38754. declare module "babylonjs/Animations/index" {
  38755. export * from "babylonjs/Animations/animatable";
  38756. export * from "babylonjs/Animations/animation";
  38757. export * from "babylonjs/Animations/animationGroup";
  38758. export * from "babylonjs/Animations/animationPropertiesOverride";
  38759. export * from "babylonjs/Animations/easing";
  38760. export * from "babylonjs/Animations/runtimeAnimation";
  38761. export * from "babylonjs/Animations/animationEvent";
  38762. export * from "babylonjs/Animations/animationGroup";
  38763. export * from "babylonjs/Animations/animationKey";
  38764. export * from "babylonjs/Animations/animationRange";
  38765. export * from "babylonjs/Animations/animatable.interface";
  38766. }
  38767. declare module "babylonjs/Audio/soundTrack" {
  38768. import { Sound } from "babylonjs/Audio/sound";
  38769. import { Analyser } from "babylonjs/Audio/analyser";
  38770. import { Scene } from "babylonjs/scene";
  38771. /**
  38772. * Options allowed during the creation of a sound track.
  38773. */
  38774. export interface ISoundTrackOptions {
  38775. /**
  38776. * The volume the sound track should take during creation
  38777. */
  38778. volume?: number;
  38779. /**
  38780. * Define if the sound track is the main sound track of the scene
  38781. */
  38782. mainTrack?: boolean;
  38783. }
  38784. /**
  38785. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38786. * It will be also used in a future release to apply effects on a specific track.
  38787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38788. */
  38789. export class SoundTrack {
  38790. /**
  38791. * The unique identifier of the sound track in the scene.
  38792. */
  38793. id: number;
  38794. /**
  38795. * The list of sounds included in the sound track.
  38796. */
  38797. soundCollection: Array<Sound>;
  38798. private _outputAudioNode;
  38799. private _scene;
  38800. private _connectedAnalyser;
  38801. private _options;
  38802. private _isInitialized;
  38803. /**
  38804. * Creates a new sound track.
  38805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38806. * @param scene Define the scene the sound track belongs to
  38807. * @param options
  38808. */
  38809. constructor(scene: Scene, options?: ISoundTrackOptions);
  38810. private _initializeSoundTrackAudioGraph;
  38811. /**
  38812. * Release the sound track and its associated resources
  38813. */
  38814. dispose(): void;
  38815. /**
  38816. * Adds a sound to this sound track
  38817. * @param sound define the cound to add
  38818. * @ignoreNaming
  38819. */
  38820. AddSound(sound: Sound): void;
  38821. /**
  38822. * Removes a sound to this sound track
  38823. * @param sound define the cound to remove
  38824. * @ignoreNaming
  38825. */
  38826. RemoveSound(sound: Sound): void;
  38827. /**
  38828. * Set a global volume for the full sound track.
  38829. * @param newVolume Define the new volume of the sound track
  38830. */
  38831. setVolume(newVolume: number): void;
  38832. /**
  38833. * Switch the panning model to HRTF:
  38834. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38836. */
  38837. switchPanningModelToHRTF(): void;
  38838. /**
  38839. * Switch the panning model to Equal Power:
  38840. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38842. */
  38843. switchPanningModelToEqualPower(): void;
  38844. /**
  38845. * Connect the sound track to an audio analyser allowing some amazing
  38846. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38848. * @param analyser The analyser to connect to the engine
  38849. */
  38850. connectToAnalyser(analyser: Analyser): void;
  38851. }
  38852. }
  38853. declare module "babylonjs/Audio/audioSceneComponent" {
  38854. import { Sound } from "babylonjs/Audio/sound";
  38855. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38856. import { Nullable } from "babylonjs/types";
  38857. import { Vector3 } from "babylonjs/Maths/math.vector";
  38858. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38859. import { Scene } from "babylonjs/scene";
  38860. import { AbstractScene } from "babylonjs/abstractScene";
  38861. import "babylonjs/Audio/audioEngine";
  38862. module "babylonjs/abstractScene" {
  38863. interface AbstractScene {
  38864. /**
  38865. * The list of sounds used in the scene.
  38866. */
  38867. sounds: Nullable<Array<Sound>>;
  38868. }
  38869. }
  38870. module "babylonjs/scene" {
  38871. interface Scene {
  38872. /**
  38873. * @hidden
  38874. * Backing field
  38875. */
  38876. _mainSoundTrack: SoundTrack;
  38877. /**
  38878. * The main sound track played by the scene.
  38879. * It cotains your primary collection of sounds.
  38880. */
  38881. mainSoundTrack: SoundTrack;
  38882. /**
  38883. * The list of sound tracks added to the scene
  38884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38885. */
  38886. soundTracks: Nullable<Array<SoundTrack>>;
  38887. /**
  38888. * Gets a sound using a given name
  38889. * @param name defines the name to search for
  38890. * @return the found sound or null if not found at all.
  38891. */
  38892. getSoundByName(name: string): Nullable<Sound>;
  38893. /**
  38894. * Gets or sets if audio support is enabled
  38895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38896. */
  38897. audioEnabled: boolean;
  38898. /**
  38899. * Gets or sets if audio will be output to headphones
  38900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38901. */
  38902. headphone: boolean;
  38903. /**
  38904. * Gets or sets custom audio listener position provider
  38905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38906. */
  38907. audioListenerPositionProvider: Nullable<() => Vector3>;
  38908. /**
  38909. * Gets or sets a refresh rate when using 3D audio positioning
  38910. */
  38911. audioPositioningRefreshRate: number;
  38912. }
  38913. }
  38914. /**
  38915. * Defines the sound scene component responsible to manage any sounds
  38916. * in a given scene.
  38917. */
  38918. export class AudioSceneComponent implements ISceneSerializableComponent {
  38919. /**
  38920. * The component name helpfull to identify the component in the list of scene components.
  38921. */
  38922. readonly name: string;
  38923. /**
  38924. * The scene the component belongs to.
  38925. */
  38926. scene: Scene;
  38927. private _audioEnabled;
  38928. /**
  38929. * Gets whether audio is enabled or not.
  38930. * Please use related enable/disable method to switch state.
  38931. */
  38932. get audioEnabled(): boolean;
  38933. private _headphone;
  38934. /**
  38935. * Gets whether audio is outputing to headphone or not.
  38936. * Please use the according Switch methods to change output.
  38937. */
  38938. get headphone(): boolean;
  38939. /**
  38940. * Gets or sets a refresh rate when using 3D audio positioning
  38941. */
  38942. audioPositioningRefreshRate: number;
  38943. private _audioListenerPositionProvider;
  38944. /**
  38945. * Gets the current audio listener position provider
  38946. */
  38947. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38948. /**
  38949. * Sets a custom listener position for all sounds in the scene
  38950. * By default, this is the position of the first active camera
  38951. */
  38952. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38953. /**
  38954. * Creates a new instance of the component for the given scene
  38955. * @param scene Defines the scene to register the component in
  38956. */
  38957. constructor(scene: Scene);
  38958. /**
  38959. * Registers the component in a given scene
  38960. */
  38961. register(): void;
  38962. /**
  38963. * Rebuilds the elements related to this component in case of
  38964. * context lost for instance.
  38965. */
  38966. rebuild(): void;
  38967. /**
  38968. * Serializes the component data to the specified json object
  38969. * @param serializationObject The object to serialize to
  38970. */
  38971. serialize(serializationObject: any): void;
  38972. /**
  38973. * Adds all the elements from the container to the scene
  38974. * @param container the container holding the elements
  38975. */
  38976. addFromContainer(container: AbstractScene): void;
  38977. /**
  38978. * Removes all the elements in the container from the scene
  38979. * @param container contains the elements to remove
  38980. * @param dispose if the removed element should be disposed (default: false)
  38981. */
  38982. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38983. /**
  38984. * Disposes the component and the associated ressources.
  38985. */
  38986. dispose(): void;
  38987. /**
  38988. * Disables audio in the associated scene.
  38989. */
  38990. disableAudio(): void;
  38991. /**
  38992. * Enables audio in the associated scene.
  38993. */
  38994. enableAudio(): void;
  38995. /**
  38996. * Switch audio to headphone output.
  38997. */
  38998. switchAudioModeForHeadphones(): void;
  38999. /**
  39000. * Switch audio to normal speakers.
  39001. */
  39002. switchAudioModeForNormalSpeakers(): void;
  39003. private _cachedCameraDirection;
  39004. private _cachedCameraPosition;
  39005. private _lastCheck;
  39006. private _afterRender;
  39007. }
  39008. }
  39009. declare module "babylonjs/Audio/weightedsound" {
  39010. import { Sound } from "babylonjs/Audio/sound";
  39011. /**
  39012. * Wraps one or more Sound objects and selects one with random weight for playback.
  39013. */
  39014. export class WeightedSound {
  39015. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39016. loop: boolean;
  39017. private _coneInnerAngle;
  39018. private _coneOuterAngle;
  39019. private _volume;
  39020. /** A Sound is currently playing. */
  39021. isPlaying: boolean;
  39022. /** A Sound is currently paused. */
  39023. isPaused: boolean;
  39024. private _sounds;
  39025. private _weights;
  39026. private _currentIndex?;
  39027. /**
  39028. * Creates a new WeightedSound from the list of sounds given.
  39029. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39030. * @param sounds Array of Sounds that will be selected from.
  39031. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39032. */
  39033. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39034. /**
  39035. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39036. */
  39037. get directionalConeInnerAngle(): number;
  39038. /**
  39039. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39040. */
  39041. set directionalConeInnerAngle(value: number);
  39042. /**
  39043. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39044. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39045. */
  39046. get directionalConeOuterAngle(): number;
  39047. /**
  39048. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39049. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39050. */
  39051. set directionalConeOuterAngle(value: number);
  39052. /**
  39053. * Playback volume.
  39054. */
  39055. get volume(): number;
  39056. /**
  39057. * Playback volume.
  39058. */
  39059. set volume(value: number);
  39060. private _onended;
  39061. /**
  39062. * Suspend playback
  39063. */
  39064. pause(): void;
  39065. /**
  39066. * Stop playback
  39067. */
  39068. stop(): void;
  39069. /**
  39070. * Start playback.
  39071. * @param startOffset Position the clip head at a specific time in seconds.
  39072. */
  39073. play(startOffset?: number): void;
  39074. }
  39075. }
  39076. declare module "babylonjs/Audio/index" {
  39077. export * from "babylonjs/Audio/analyser";
  39078. export * from "babylonjs/Audio/audioEngine";
  39079. export * from "babylonjs/Audio/audioSceneComponent";
  39080. export * from "babylonjs/Audio/sound";
  39081. export * from "babylonjs/Audio/soundTrack";
  39082. export * from "babylonjs/Audio/weightedsound";
  39083. }
  39084. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39085. import { Behavior } from "babylonjs/Behaviors/behavior";
  39086. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39087. import { BackEase } from "babylonjs/Animations/easing";
  39088. /**
  39089. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39091. */
  39092. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39093. /**
  39094. * Gets the name of the behavior.
  39095. */
  39096. get name(): string;
  39097. /**
  39098. * The easing function used by animations
  39099. */
  39100. static EasingFunction: BackEase;
  39101. /**
  39102. * The easing mode used by animations
  39103. */
  39104. static EasingMode: number;
  39105. /**
  39106. * The duration of the animation, in milliseconds
  39107. */
  39108. transitionDuration: number;
  39109. /**
  39110. * Length of the distance animated by the transition when lower radius is reached
  39111. */
  39112. lowerRadiusTransitionRange: number;
  39113. /**
  39114. * Length of the distance animated by the transition when upper radius is reached
  39115. */
  39116. upperRadiusTransitionRange: number;
  39117. private _autoTransitionRange;
  39118. /**
  39119. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39120. */
  39121. get autoTransitionRange(): boolean;
  39122. /**
  39123. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39124. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39125. */
  39126. set autoTransitionRange(value: boolean);
  39127. private _attachedCamera;
  39128. private _onAfterCheckInputsObserver;
  39129. private _onMeshTargetChangedObserver;
  39130. /**
  39131. * Initializes the behavior.
  39132. */
  39133. init(): void;
  39134. /**
  39135. * Attaches the behavior to its arc rotate camera.
  39136. * @param camera Defines the camera to attach the behavior to
  39137. */
  39138. attach(camera: ArcRotateCamera): void;
  39139. /**
  39140. * Detaches the behavior from its current arc rotate camera.
  39141. */
  39142. detach(): void;
  39143. private _radiusIsAnimating;
  39144. private _radiusBounceTransition;
  39145. private _animatables;
  39146. private _cachedWheelPrecision;
  39147. /**
  39148. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39149. * @param radiusLimit The limit to check against.
  39150. * @return Bool to indicate if at limit.
  39151. */
  39152. private _isRadiusAtLimit;
  39153. /**
  39154. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39155. * @param radiusDelta The delta by which to animate to. Can be negative.
  39156. */
  39157. private _applyBoundRadiusAnimation;
  39158. /**
  39159. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39160. */
  39161. protected _clearAnimationLocks(): void;
  39162. /**
  39163. * Stops and removes all animations that have been applied to the camera
  39164. */
  39165. stopAllAnimations(): void;
  39166. }
  39167. }
  39168. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39169. import { Behavior } from "babylonjs/Behaviors/behavior";
  39170. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39171. import { ExponentialEase } from "babylonjs/Animations/easing";
  39172. import { Nullable } from "babylonjs/types";
  39173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39174. import { Vector3 } from "babylonjs/Maths/math.vector";
  39175. /**
  39176. * 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.
  39177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39178. */
  39179. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39180. /**
  39181. * Gets the name of the behavior.
  39182. */
  39183. get name(): string;
  39184. private _mode;
  39185. private _radiusScale;
  39186. private _positionScale;
  39187. private _defaultElevation;
  39188. private _elevationReturnTime;
  39189. private _elevationReturnWaitTime;
  39190. private _zoomStopsAnimation;
  39191. private _framingTime;
  39192. /**
  39193. * The easing function used by animations
  39194. */
  39195. static EasingFunction: ExponentialEase;
  39196. /**
  39197. * The easing mode used by animations
  39198. */
  39199. static EasingMode: number;
  39200. /**
  39201. * Sets the current mode used by the behavior
  39202. */
  39203. set mode(mode: number);
  39204. /**
  39205. * Gets current mode used by the behavior.
  39206. */
  39207. get mode(): number;
  39208. /**
  39209. * Sets the scale applied to the radius (1 by default)
  39210. */
  39211. set radiusScale(radius: number);
  39212. /**
  39213. * Gets the scale applied to the radius
  39214. */
  39215. get radiusScale(): number;
  39216. /**
  39217. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39218. */
  39219. set positionScale(scale: number);
  39220. /**
  39221. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39222. */
  39223. get positionScale(): number;
  39224. /**
  39225. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39226. * behaviour is triggered, in radians.
  39227. */
  39228. set defaultElevation(elevation: number);
  39229. /**
  39230. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39231. * behaviour is triggered, in radians.
  39232. */
  39233. get defaultElevation(): number;
  39234. /**
  39235. * Sets the time (in milliseconds) taken to return to the default beta position.
  39236. * Negative value indicates camera should not return to default.
  39237. */
  39238. set elevationReturnTime(speed: number);
  39239. /**
  39240. * Gets the time (in milliseconds) taken to return to the default beta position.
  39241. * Negative value indicates camera should not return to default.
  39242. */
  39243. get elevationReturnTime(): number;
  39244. /**
  39245. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39246. */
  39247. set elevationReturnWaitTime(time: number);
  39248. /**
  39249. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39250. */
  39251. get elevationReturnWaitTime(): number;
  39252. /**
  39253. * Sets the flag that indicates if user zooming should stop animation.
  39254. */
  39255. set zoomStopsAnimation(flag: boolean);
  39256. /**
  39257. * Gets the flag that indicates if user zooming should stop animation.
  39258. */
  39259. get zoomStopsAnimation(): boolean;
  39260. /**
  39261. * Sets the transition time when framing the mesh, in milliseconds
  39262. */
  39263. set framingTime(time: number);
  39264. /**
  39265. * Gets the transition time when framing the mesh, in milliseconds
  39266. */
  39267. get framingTime(): number;
  39268. /**
  39269. * Define if the behavior should automatically change the configured
  39270. * camera limits and sensibilities.
  39271. */
  39272. autoCorrectCameraLimitsAndSensibility: boolean;
  39273. private _onPrePointerObservableObserver;
  39274. private _onAfterCheckInputsObserver;
  39275. private _onMeshTargetChangedObserver;
  39276. private _attachedCamera;
  39277. private _isPointerDown;
  39278. private _lastInteractionTime;
  39279. /**
  39280. * Initializes the behavior.
  39281. */
  39282. init(): void;
  39283. /**
  39284. * Attaches the behavior to its arc rotate camera.
  39285. * @param camera Defines the camera to attach the behavior to
  39286. */
  39287. attach(camera: ArcRotateCamera): void;
  39288. /**
  39289. * Detaches the behavior from its current arc rotate camera.
  39290. */
  39291. detach(): void;
  39292. private _animatables;
  39293. private _betaIsAnimating;
  39294. private _betaTransition;
  39295. private _radiusTransition;
  39296. private _vectorTransition;
  39297. /**
  39298. * Targets the given mesh and updates zoom level accordingly.
  39299. * @param mesh The mesh to target.
  39300. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39301. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39302. */
  39303. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39304. /**
  39305. * Targets the given mesh with its children and updates zoom level accordingly.
  39306. * @param mesh The mesh to target.
  39307. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39308. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39309. */
  39310. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39311. /**
  39312. * Targets the given meshes with their children and updates zoom level accordingly.
  39313. * @param meshes The mesh to target.
  39314. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39315. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39316. */
  39317. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39318. /**
  39319. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39320. * @param minimumWorld Determines the smaller position of the bounding box extend
  39321. * @param maximumWorld Determines the bigger position of the bounding box extend
  39322. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39323. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39324. */
  39325. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39326. /**
  39327. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39328. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39329. * frustum width.
  39330. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39331. * to fully enclose the mesh in the viewing frustum.
  39332. */
  39333. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39334. /**
  39335. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39336. * is automatically returned to its default position (expected to be above ground plane).
  39337. */
  39338. private _maintainCameraAboveGround;
  39339. /**
  39340. * Returns the frustum slope based on the canvas ratio and camera FOV
  39341. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39342. */
  39343. private _getFrustumSlope;
  39344. /**
  39345. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39346. */
  39347. private _clearAnimationLocks;
  39348. /**
  39349. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39350. */
  39351. private _applyUserInteraction;
  39352. /**
  39353. * Stops and removes all animations that have been applied to the camera
  39354. */
  39355. stopAllAnimations(): void;
  39356. /**
  39357. * Gets a value indicating if the user is moving the camera
  39358. */
  39359. get isUserIsMoving(): boolean;
  39360. /**
  39361. * The camera can move all the way towards the mesh.
  39362. */
  39363. static IgnoreBoundsSizeMode: number;
  39364. /**
  39365. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39366. */
  39367. static FitFrustumSidesMode: number;
  39368. }
  39369. }
  39370. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39371. import { Nullable } from "babylonjs/types";
  39372. import { Camera } from "babylonjs/Cameras/camera";
  39373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39374. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39375. /**
  39376. * Base class for Camera Pointer Inputs.
  39377. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39378. * for example usage.
  39379. */
  39380. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39381. /**
  39382. * Defines the camera the input is attached to.
  39383. */
  39384. abstract camera: Camera;
  39385. /**
  39386. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39387. */
  39388. protected _altKey: boolean;
  39389. protected _ctrlKey: boolean;
  39390. protected _metaKey: boolean;
  39391. protected _shiftKey: boolean;
  39392. /**
  39393. * Which mouse buttons were pressed at time of last mouse event.
  39394. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39395. */
  39396. protected _buttonsPressed: number;
  39397. /**
  39398. * Defines the buttons associated with the input to handle camera move.
  39399. */
  39400. buttons: number[];
  39401. /**
  39402. * Attach the input controls to a specific dom element to get the input from.
  39403. * @param element Defines the element the controls should be listened from
  39404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39405. */
  39406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39407. /**
  39408. * Detach the current controls from the specified dom element.
  39409. * @param element Defines the element to stop listening the inputs from
  39410. */
  39411. detachControl(element: Nullable<HTMLElement>): void;
  39412. /**
  39413. * Gets the class name of the current input.
  39414. * @returns the class name
  39415. */
  39416. getClassName(): string;
  39417. /**
  39418. * Get the friendly name associated with the input class.
  39419. * @returns the input friendly name
  39420. */
  39421. getSimpleName(): string;
  39422. /**
  39423. * Called on pointer POINTERDOUBLETAP event.
  39424. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39425. */
  39426. protected onDoubleTap(type: string): void;
  39427. /**
  39428. * Called on pointer POINTERMOVE event if only a single touch is active.
  39429. * Override this method to provide functionality.
  39430. */
  39431. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39432. /**
  39433. * Called on pointer POINTERMOVE event if multiple touches are active.
  39434. * Override this method to provide functionality.
  39435. */
  39436. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39437. /**
  39438. * Called on JS contextmenu event.
  39439. * Override this method to provide functionality.
  39440. */
  39441. protected onContextMenu(evt: PointerEvent): void;
  39442. /**
  39443. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39444. * press.
  39445. * Override this method to provide functionality.
  39446. */
  39447. protected onButtonDown(evt: PointerEvent): void;
  39448. /**
  39449. * Called each time a new POINTERUP event occurs. Ie, for each button
  39450. * release.
  39451. * Override this method to provide functionality.
  39452. */
  39453. protected onButtonUp(evt: PointerEvent): void;
  39454. /**
  39455. * Called when window becomes inactive.
  39456. * Override this method to provide functionality.
  39457. */
  39458. protected onLostFocus(): void;
  39459. private _pointerInput;
  39460. private _observer;
  39461. private _onLostFocus;
  39462. private pointA;
  39463. private pointB;
  39464. }
  39465. }
  39466. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39467. import { Nullable } from "babylonjs/types";
  39468. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39469. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39470. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39471. /**
  39472. * Manage the pointers inputs to control an arc rotate camera.
  39473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39474. */
  39475. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39476. /**
  39477. * Defines the camera the input is attached to.
  39478. */
  39479. camera: ArcRotateCamera;
  39480. /**
  39481. * Gets the class name of the current input.
  39482. * @returns the class name
  39483. */
  39484. getClassName(): string;
  39485. /**
  39486. * Defines the buttons associated with the input to handle camera move.
  39487. */
  39488. buttons: number[];
  39489. /**
  39490. * Defines the pointer angular sensibility along the X axis or how fast is
  39491. * the camera rotating.
  39492. */
  39493. angularSensibilityX: number;
  39494. /**
  39495. * Defines the pointer angular sensibility along the Y axis or how fast is
  39496. * the camera rotating.
  39497. */
  39498. angularSensibilityY: number;
  39499. /**
  39500. * Defines the pointer pinch precision or how fast is the camera zooming.
  39501. */
  39502. pinchPrecision: number;
  39503. /**
  39504. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39505. * from 0.
  39506. * It defines the percentage of current camera.radius to use as delta when
  39507. * pinch zoom is used.
  39508. */
  39509. pinchDeltaPercentage: number;
  39510. /**
  39511. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39512. * that any object in the plane at the camera's target point will scale
  39513. * perfectly with finger motion.
  39514. * Overrides pinchDeltaPercentage and pinchPrecision.
  39515. */
  39516. useNaturalPinchZoom: boolean;
  39517. /**
  39518. * Defines the pointer panning sensibility or how fast is the camera moving.
  39519. */
  39520. panningSensibility: number;
  39521. /**
  39522. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39523. */
  39524. multiTouchPanning: boolean;
  39525. /**
  39526. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39527. * zoom (pinch) through multitouch.
  39528. */
  39529. multiTouchPanAndZoom: boolean;
  39530. /**
  39531. * Revers pinch action direction.
  39532. */
  39533. pinchInwards: boolean;
  39534. private _isPanClick;
  39535. private _twoFingerActivityCount;
  39536. private _isPinching;
  39537. /**
  39538. * Called on pointer POINTERMOVE event if only a single touch is active.
  39539. */
  39540. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39541. /**
  39542. * Called on pointer POINTERDOUBLETAP event.
  39543. */
  39544. protected onDoubleTap(type: string): void;
  39545. /**
  39546. * Called on pointer POINTERMOVE event if multiple touches are active.
  39547. */
  39548. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39549. /**
  39550. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39551. * press.
  39552. */
  39553. protected onButtonDown(evt: PointerEvent): void;
  39554. /**
  39555. * Called each time a new POINTERUP event occurs. Ie, for each button
  39556. * release.
  39557. */
  39558. protected onButtonUp(evt: PointerEvent): void;
  39559. /**
  39560. * Called when window becomes inactive.
  39561. */
  39562. protected onLostFocus(): void;
  39563. }
  39564. }
  39565. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39566. import { Nullable } from "babylonjs/types";
  39567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39568. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39569. /**
  39570. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39572. */
  39573. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39574. /**
  39575. * Defines the camera the input is attached to.
  39576. */
  39577. camera: ArcRotateCamera;
  39578. /**
  39579. * Defines the list of key codes associated with the up action (increase alpha)
  39580. */
  39581. keysUp: number[];
  39582. /**
  39583. * Defines the list of key codes associated with the down action (decrease alpha)
  39584. */
  39585. keysDown: number[];
  39586. /**
  39587. * Defines the list of key codes associated with the left action (increase beta)
  39588. */
  39589. keysLeft: number[];
  39590. /**
  39591. * Defines the list of key codes associated with the right action (decrease beta)
  39592. */
  39593. keysRight: number[];
  39594. /**
  39595. * Defines the list of key codes associated with the reset action.
  39596. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39597. */
  39598. keysReset: number[];
  39599. /**
  39600. * Defines the panning sensibility of the inputs.
  39601. * (How fast is the camera panning)
  39602. */
  39603. panningSensibility: number;
  39604. /**
  39605. * Defines the zooming sensibility of the inputs.
  39606. * (How fast is the camera zooming)
  39607. */
  39608. zoomingSensibility: number;
  39609. /**
  39610. * Defines whether maintaining the alt key down switch the movement mode from
  39611. * orientation to zoom.
  39612. */
  39613. useAltToZoom: boolean;
  39614. /**
  39615. * Rotation speed of the camera
  39616. */
  39617. angularSpeed: number;
  39618. private _keys;
  39619. private _ctrlPressed;
  39620. private _altPressed;
  39621. private _onCanvasBlurObserver;
  39622. private _onKeyboardObserver;
  39623. private _engine;
  39624. private _scene;
  39625. /**
  39626. * Attach the input controls to a specific dom element to get the input from.
  39627. * @param element Defines the element the controls should be listened from
  39628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39629. */
  39630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39631. /**
  39632. * Detach the current controls from the specified dom element.
  39633. * @param element Defines the element to stop listening the inputs from
  39634. */
  39635. detachControl(element: Nullable<HTMLElement>): void;
  39636. /**
  39637. * Update the current camera state depending on the inputs that have been used this frame.
  39638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39639. */
  39640. checkInputs(): void;
  39641. /**
  39642. * Gets the class name of the current intput.
  39643. * @returns the class name
  39644. */
  39645. getClassName(): string;
  39646. /**
  39647. * Get the friendly name associated with the input class.
  39648. * @returns the input friendly name
  39649. */
  39650. getSimpleName(): string;
  39651. }
  39652. }
  39653. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39654. import { Nullable } from "babylonjs/types";
  39655. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39656. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39657. /**
  39658. * Manage the mouse wheel inputs to control an arc rotate camera.
  39659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39660. */
  39661. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39662. /**
  39663. * Defines the camera the input is attached to.
  39664. */
  39665. camera: ArcRotateCamera;
  39666. /**
  39667. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39668. */
  39669. wheelPrecision: number;
  39670. /**
  39671. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39672. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39673. */
  39674. wheelDeltaPercentage: number;
  39675. private _wheel;
  39676. private _observer;
  39677. private computeDeltaFromMouseWheelLegacyEvent;
  39678. /**
  39679. * Attach the input controls to a specific dom element to get the input from.
  39680. * @param element Defines the element the controls should be listened from
  39681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39682. */
  39683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39684. /**
  39685. * Detach the current controls from the specified dom element.
  39686. * @param element Defines the element to stop listening the inputs from
  39687. */
  39688. detachControl(element: Nullable<HTMLElement>): void;
  39689. /**
  39690. * Gets the class name of the current intput.
  39691. * @returns the class name
  39692. */
  39693. getClassName(): string;
  39694. /**
  39695. * Get the friendly name associated with the input class.
  39696. * @returns the input friendly name
  39697. */
  39698. getSimpleName(): string;
  39699. }
  39700. }
  39701. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39702. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39703. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39704. /**
  39705. * Default Inputs manager for the ArcRotateCamera.
  39706. * It groups all the default supported inputs for ease of use.
  39707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39708. */
  39709. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39710. /**
  39711. * Instantiates a new ArcRotateCameraInputsManager.
  39712. * @param camera Defines the camera the inputs belong to
  39713. */
  39714. constructor(camera: ArcRotateCamera);
  39715. /**
  39716. * Add mouse wheel input support to the input manager.
  39717. * @returns the current input manager
  39718. */
  39719. addMouseWheel(): ArcRotateCameraInputsManager;
  39720. /**
  39721. * Add pointers input support to the input manager.
  39722. * @returns the current input manager
  39723. */
  39724. addPointers(): ArcRotateCameraInputsManager;
  39725. /**
  39726. * Add keyboard input support to the input manager.
  39727. * @returns the current input manager
  39728. */
  39729. addKeyboard(): ArcRotateCameraInputsManager;
  39730. }
  39731. }
  39732. declare module "babylonjs/Cameras/arcRotateCamera" {
  39733. import { Observable } from "babylonjs/Misc/observable";
  39734. import { Nullable } from "babylonjs/types";
  39735. import { Scene } from "babylonjs/scene";
  39736. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39738. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39739. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39740. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39741. import { Camera } from "babylonjs/Cameras/camera";
  39742. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39743. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39744. import { Collider } from "babylonjs/Collisions/collider";
  39745. /**
  39746. * This represents an orbital type of camera.
  39747. *
  39748. * 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.
  39749. * 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.
  39750. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39751. */
  39752. export class ArcRotateCamera extends TargetCamera {
  39753. /**
  39754. * Defines the rotation angle of the camera along the longitudinal axis.
  39755. */
  39756. alpha: number;
  39757. /**
  39758. * Defines the rotation angle of the camera along the latitudinal axis.
  39759. */
  39760. beta: number;
  39761. /**
  39762. * Defines the radius of the camera from it s target point.
  39763. */
  39764. radius: number;
  39765. protected _target: Vector3;
  39766. protected _targetHost: Nullable<AbstractMesh>;
  39767. /**
  39768. * Defines the target point of the camera.
  39769. * The camera looks towards it form the radius distance.
  39770. */
  39771. get target(): Vector3;
  39772. set target(value: Vector3);
  39773. /**
  39774. * Define the current local position of the camera in the scene
  39775. */
  39776. get position(): Vector3;
  39777. set position(newPosition: Vector3);
  39778. protected _upVector: Vector3;
  39779. protected _upToYMatrix: Matrix;
  39780. protected _YToUpMatrix: Matrix;
  39781. /**
  39782. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39783. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39784. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39785. */
  39786. set upVector(vec: Vector3);
  39787. get upVector(): Vector3;
  39788. /**
  39789. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39790. */
  39791. setMatUp(): void;
  39792. /**
  39793. * Current inertia value on the longitudinal axis.
  39794. * The bigger this number the longer it will take for the camera to stop.
  39795. */
  39796. inertialAlphaOffset: number;
  39797. /**
  39798. * Current inertia value on the latitudinal axis.
  39799. * The bigger this number the longer it will take for the camera to stop.
  39800. */
  39801. inertialBetaOffset: number;
  39802. /**
  39803. * Current inertia value on the radius axis.
  39804. * The bigger this number the longer it will take for the camera to stop.
  39805. */
  39806. inertialRadiusOffset: number;
  39807. /**
  39808. * Minimum allowed angle on the longitudinal axis.
  39809. * This can help limiting how the Camera is able to move in the scene.
  39810. */
  39811. lowerAlphaLimit: Nullable<number>;
  39812. /**
  39813. * Maximum allowed angle on the longitudinal axis.
  39814. * This can help limiting how the Camera is able to move in the scene.
  39815. */
  39816. upperAlphaLimit: Nullable<number>;
  39817. /**
  39818. * Minimum allowed angle on the latitudinal axis.
  39819. * This can help limiting how the Camera is able to move in the scene.
  39820. */
  39821. lowerBetaLimit: number;
  39822. /**
  39823. * Maximum allowed angle on the latitudinal axis.
  39824. * This can help limiting how the Camera is able to move in the scene.
  39825. */
  39826. upperBetaLimit: number;
  39827. /**
  39828. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39829. * This can help limiting how the Camera is able to move in the scene.
  39830. */
  39831. lowerRadiusLimit: Nullable<number>;
  39832. /**
  39833. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39834. * This can help limiting how the Camera is able to move in the scene.
  39835. */
  39836. upperRadiusLimit: Nullable<number>;
  39837. /**
  39838. * Defines the current inertia value used during panning of the camera along the X axis.
  39839. */
  39840. inertialPanningX: number;
  39841. /**
  39842. * Defines the current inertia value used during panning of the camera along the Y axis.
  39843. */
  39844. inertialPanningY: number;
  39845. /**
  39846. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39847. * Basically if your fingers moves away from more than this distance you will be considered
  39848. * in pinch mode.
  39849. */
  39850. pinchToPanMaxDistance: number;
  39851. /**
  39852. * Defines the maximum distance the camera can pan.
  39853. * This could help keeping the cammera always in your scene.
  39854. */
  39855. panningDistanceLimit: Nullable<number>;
  39856. /**
  39857. * Defines the target of the camera before paning.
  39858. */
  39859. panningOriginTarget: Vector3;
  39860. /**
  39861. * Defines the value of the inertia used during panning.
  39862. * 0 would mean stop inertia and one would mean no decelleration at all.
  39863. */
  39864. panningInertia: number;
  39865. /**
  39866. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39867. */
  39868. get angularSensibilityX(): number;
  39869. set angularSensibilityX(value: number);
  39870. /**
  39871. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39872. */
  39873. get angularSensibilityY(): number;
  39874. set angularSensibilityY(value: number);
  39875. /**
  39876. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39877. */
  39878. get pinchPrecision(): number;
  39879. set pinchPrecision(value: number);
  39880. /**
  39881. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39882. * It will be used instead of pinchDeltaPrecision if different from 0.
  39883. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39884. */
  39885. get pinchDeltaPercentage(): number;
  39886. set pinchDeltaPercentage(value: number);
  39887. /**
  39888. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39889. * and pinch delta percentage.
  39890. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39891. * that any object in the plane at the camera's target point will scale
  39892. * perfectly with finger motion.
  39893. */
  39894. get useNaturalPinchZoom(): boolean;
  39895. set useNaturalPinchZoom(value: boolean);
  39896. /**
  39897. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39898. */
  39899. get panningSensibility(): number;
  39900. set panningSensibility(value: number);
  39901. /**
  39902. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39903. */
  39904. get keysUp(): number[];
  39905. set keysUp(value: number[]);
  39906. /**
  39907. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39908. */
  39909. get keysDown(): number[];
  39910. set keysDown(value: number[]);
  39911. /**
  39912. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39913. */
  39914. get keysLeft(): number[];
  39915. set keysLeft(value: number[]);
  39916. /**
  39917. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39918. */
  39919. get keysRight(): number[];
  39920. set keysRight(value: number[]);
  39921. /**
  39922. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39923. */
  39924. get wheelPrecision(): number;
  39925. set wheelPrecision(value: number);
  39926. /**
  39927. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39928. * It will be used instead of pinchDeltaPrecision if different from 0.
  39929. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39930. */
  39931. get wheelDeltaPercentage(): number;
  39932. set wheelDeltaPercentage(value: number);
  39933. /**
  39934. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39935. */
  39936. zoomOnFactor: number;
  39937. /**
  39938. * Defines a screen offset for the camera position.
  39939. */
  39940. targetScreenOffset: Vector2;
  39941. /**
  39942. * Allows the camera to be completely reversed.
  39943. * If false the camera can not arrive upside down.
  39944. */
  39945. allowUpsideDown: boolean;
  39946. /**
  39947. * Define if double tap/click is used to restore the previously saved state of the camera.
  39948. */
  39949. useInputToRestoreState: boolean;
  39950. /** @hidden */
  39951. _viewMatrix: Matrix;
  39952. /** @hidden */
  39953. _useCtrlForPanning: boolean;
  39954. /** @hidden */
  39955. _panningMouseButton: number;
  39956. /**
  39957. * Defines the input associated to the camera.
  39958. */
  39959. inputs: ArcRotateCameraInputsManager;
  39960. /** @hidden */
  39961. _reset: () => void;
  39962. /**
  39963. * Defines the allowed panning axis.
  39964. */
  39965. panningAxis: Vector3;
  39966. protected _localDirection: Vector3;
  39967. protected _transformedDirection: Vector3;
  39968. private _bouncingBehavior;
  39969. /**
  39970. * Gets the bouncing behavior of the camera if it has been enabled.
  39971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39972. */
  39973. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39974. /**
  39975. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39977. */
  39978. get useBouncingBehavior(): boolean;
  39979. set useBouncingBehavior(value: boolean);
  39980. private _framingBehavior;
  39981. /**
  39982. * Gets the framing behavior of the camera if it has been enabled.
  39983. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39984. */
  39985. get framingBehavior(): Nullable<FramingBehavior>;
  39986. /**
  39987. * Defines if the framing behavior of the camera is enabled on the camera.
  39988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39989. */
  39990. get useFramingBehavior(): boolean;
  39991. set useFramingBehavior(value: boolean);
  39992. private _autoRotationBehavior;
  39993. /**
  39994. * Gets the auto rotation behavior of the camera if it has been enabled.
  39995. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39996. */
  39997. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39998. /**
  39999. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40001. */
  40002. get useAutoRotationBehavior(): boolean;
  40003. set useAutoRotationBehavior(value: boolean);
  40004. /**
  40005. * Observable triggered when the mesh target has been changed on the camera.
  40006. */
  40007. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40008. /**
  40009. * Event raised when the camera is colliding with a mesh.
  40010. */
  40011. onCollide: (collidedMesh: AbstractMesh) => void;
  40012. /**
  40013. * Defines whether the camera should check collision with the objects oh the scene.
  40014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40015. */
  40016. checkCollisions: boolean;
  40017. /**
  40018. * Defines the collision radius of the camera.
  40019. * This simulates a sphere around the camera.
  40020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40021. */
  40022. collisionRadius: Vector3;
  40023. protected _collider: Collider;
  40024. protected _previousPosition: Vector3;
  40025. protected _collisionVelocity: Vector3;
  40026. protected _newPosition: Vector3;
  40027. protected _previousAlpha: number;
  40028. protected _previousBeta: number;
  40029. protected _previousRadius: number;
  40030. protected _collisionTriggered: boolean;
  40031. protected _targetBoundingCenter: Nullable<Vector3>;
  40032. private _computationVector;
  40033. /**
  40034. * Instantiates a new ArcRotateCamera in a given scene
  40035. * @param name Defines the name of the camera
  40036. * @param alpha Defines the camera rotation along the logitudinal axis
  40037. * @param beta Defines the camera rotation along the latitudinal axis
  40038. * @param radius Defines the camera distance from its target
  40039. * @param target Defines the camera target
  40040. * @param scene Defines the scene the camera belongs to
  40041. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40042. */
  40043. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40044. /** @hidden */
  40045. _initCache(): void;
  40046. /** @hidden */
  40047. _updateCache(ignoreParentClass?: boolean): void;
  40048. protected _getTargetPosition(): Vector3;
  40049. private _storedAlpha;
  40050. private _storedBeta;
  40051. private _storedRadius;
  40052. private _storedTarget;
  40053. private _storedTargetScreenOffset;
  40054. /**
  40055. * Stores the current state of the camera (alpha, beta, radius and target)
  40056. * @returns the camera itself
  40057. */
  40058. storeState(): Camera;
  40059. /**
  40060. * @hidden
  40061. * Restored camera state. You must call storeState() first
  40062. */
  40063. _restoreStateValues(): boolean;
  40064. /** @hidden */
  40065. _isSynchronizedViewMatrix(): boolean;
  40066. /**
  40067. * Attached controls to the current camera.
  40068. * @param element Defines the element the controls should be listened from
  40069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40070. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40071. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40072. */
  40073. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40074. /**
  40075. * Detach the current controls from the camera.
  40076. * The camera will stop reacting to inputs.
  40077. * @param element Defines the element to stop listening the inputs from
  40078. */
  40079. detachControl(element: HTMLElement): void;
  40080. /** @hidden */
  40081. _checkInputs(): void;
  40082. protected _checkLimits(): void;
  40083. /**
  40084. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40085. */
  40086. rebuildAnglesAndRadius(): void;
  40087. /**
  40088. * Use a position to define the current camera related information like alpha, beta and radius
  40089. * @param position Defines the position to set the camera at
  40090. */
  40091. setPosition(position: Vector3): void;
  40092. /**
  40093. * Defines the target the camera should look at.
  40094. * This will automatically adapt alpha beta and radius to fit within the new target.
  40095. * @param target Defines the new target as a Vector or a mesh
  40096. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40097. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40098. */
  40099. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40100. /** @hidden */
  40101. _getViewMatrix(): Matrix;
  40102. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40103. /**
  40104. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40105. * @param meshes Defines the mesh to zoom on
  40106. * @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)
  40107. */
  40108. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40109. /**
  40110. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40111. * The target will be changed but the radius
  40112. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40113. * @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)
  40114. */
  40115. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40116. min: Vector3;
  40117. max: Vector3;
  40118. distance: number;
  40119. }, doNotUpdateMaxZ?: boolean): void;
  40120. /**
  40121. * @override
  40122. * Override Camera.createRigCamera
  40123. */
  40124. createRigCamera(name: string, cameraIndex: number): Camera;
  40125. /**
  40126. * @hidden
  40127. * @override
  40128. * Override Camera._updateRigCameras
  40129. */
  40130. _updateRigCameras(): void;
  40131. /**
  40132. * Destroy the camera and release the current resources hold by it.
  40133. */
  40134. dispose(): void;
  40135. /**
  40136. * Gets the current object class name.
  40137. * @return the class name
  40138. */
  40139. getClassName(): string;
  40140. }
  40141. }
  40142. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40143. import { Behavior } from "babylonjs/Behaviors/behavior";
  40144. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40145. /**
  40146. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40148. */
  40149. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40150. /**
  40151. * Gets the name of the behavior.
  40152. */
  40153. get name(): string;
  40154. private _zoomStopsAnimation;
  40155. private _idleRotationSpeed;
  40156. private _idleRotationWaitTime;
  40157. private _idleRotationSpinupTime;
  40158. /**
  40159. * Sets the flag that indicates if user zooming should stop animation.
  40160. */
  40161. set zoomStopsAnimation(flag: boolean);
  40162. /**
  40163. * Gets the flag that indicates if user zooming should stop animation.
  40164. */
  40165. get zoomStopsAnimation(): boolean;
  40166. /**
  40167. * Sets the default speed at which the camera rotates around the model.
  40168. */
  40169. set idleRotationSpeed(speed: number);
  40170. /**
  40171. * Gets the default speed at which the camera rotates around the model.
  40172. */
  40173. get idleRotationSpeed(): number;
  40174. /**
  40175. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40176. */
  40177. set idleRotationWaitTime(time: number);
  40178. /**
  40179. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40180. */
  40181. get idleRotationWaitTime(): number;
  40182. /**
  40183. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40184. */
  40185. set idleRotationSpinupTime(time: number);
  40186. /**
  40187. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40188. */
  40189. get idleRotationSpinupTime(): number;
  40190. /**
  40191. * Gets a value indicating if the camera is currently rotating because of this behavior
  40192. */
  40193. get rotationInProgress(): boolean;
  40194. private _onPrePointerObservableObserver;
  40195. private _onAfterCheckInputsObserver;
  40196. private _attachedCamera;
  40197. private _isPointerDown;
  40198. private _lastFrameTime;
  40199. private _lastInteractionTime;
  40200. private _cameraRotationSpeed;
  40201. /**
  40202. * Initializes the behavior.
  40203. */
  40204. init(): void;
  40205. /**
  40206. * Attaches the behavior to its arc rotate camera.
  40207. * @param camera Defines the camera to attach the behavior to
  40208. */
  40209. attach(camera: ArcRotateCamera): void;
  40210. /**
  40211. * Detaches the behavior from its current arc rotate camera.
  40212. */
  40213. detach(): void;
  40214. /**
  40215. * Returns true if user is scrolling.
  40216. * @return true if user is scrolling.
  40217. */
  40218. private _userIsZooming;
  40219. private _lastFrameRadius;
  40220. private _shouldAnimationStopForInteraction;
  40221. /**
  40222. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40223. */
  40224. private _applyUserInteraction;
  40225. private _userIsMoving;
  40226. }
  40227. }
  40228. declare module "babylonjs/Behaviors/Cameras/index" {
  40229. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40230. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40231. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40232. }
  40233. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40234. import { Mesh } from "babylonjs/Meshes/mesh";
  40235. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40236. import { Behavior } from "babylonjs/Behaviors/behavior";
  40237. /**
  40238. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40239. */
  40240. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40241. private ui;
  40242. /**
  40243. * The name of the behavior
  40244. */
  40245. name: string;
  40246. /**
  40247. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40248. */
  40249. distanceAwayFromFace: number;
  40250. /**
  40251. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40252. */
  40253. distanceAwayFromBottomOfFace: number;
  40254. private _faceVectors;
  40255. private _target;
  40256. private _scene;
  40257. private _onRenderObserver;
  40258. private _tmpMatrix;
  40259. private _tmpVector;
  40260. /**
  40261. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40262. * @param ui The transform node that should be attched to the mesh
  40263. */
  40264. constructor(ui: TransformNode);
  40265. /**
  40266. * Initializes the behavior
  40267. */
  40268. init(): void;
  40269. private _closestFace;
  40270. private _zeroVector;
  40271. private _lookAtTmpMatrix;
  40272. private _lookAtToRef;
  40273. /**
  40274. * Attaches the AttachToBoxBehavior to the passed in mesh
  40275. * @param target The mesh that the specified node will be attached to
  40276. */
  40277. attach(target: Mesh): void;
  40278. /**
  40279. * Detaches the behavior from the mesh
  40280. */
  40281. detach(): void;
  40282. }
  40283. }
  40284. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40285. import { Behavior } from "babylonjs/Behaviors/behavior";
  40286. import { Mesh } from "babylonjs/Meshes/mesh";
  40287. /**
  40288. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40289. */
  40290. export class FadeInOutBehavior implements Behavior<Mesh> {
  40291. /**
  40292. * Time in milliseconds to delay before fading in (Default: 0)
  40293. */
  40294. delay: number;
  40295. /**
  40296. * Time in milliseconds for the mesh to fade in (Default: 300)
  40297. */
  40298. fadeInTime: number;
  40299. private _millisecondsPerFrame;
  40300. private _hovered;
  40301. private _hoverValue;
  40302. private _ownerNode;
  40303. /**
  40304. * Instatiates the FadeInOutBehavior
  40305. */
  40306. constructor();
  40307. /**
  40308. * The name of the behavior
  40309. */
  40310. get name(): string;
  40311. /**
  40312. * Initializes the behavior
  40313. */
  40314. init(): void;
  40315. /**
  40316. * Attaches the fade behavior on the passed in mesh
  40317. * @param ownerNode The mesh that will be faded in/out once attached
  40318. */
  40319. attach(ownerNode: Mesh): void;
  40320. /**
  40321. * Detaches the behavior from the mesh
  40322. */
  40323. detach(): void;
  40324. /**
  40325. * Triggers the mesh to begin fading in or out
  40326. * @param value if the object should fade in or out (true to fade in)
  40327. */
  40328. fadeIn(value: boolean): void;
  40329. private _update;
  40330. private _setAllVisibility;
  40331. }
  40332. }
  40333. declare module "babylonjs/Misc/pivotTools" {
  40334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40335. /**
  40336. * Class containing a set of static utilities functions for managing Pivots
  40337. * @hidden
  40338. */
  40339. export class PivotTools {
  40340. private static _PivotCached;
  40341. private static _OldPivotPoint;
  40342. private static _PivotTranslation;
  40343. private static _PivotTmpVector;
  40344. /** @hidden */
  40345. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40346. /** @hidden */
  40347. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40348. }
  40349. }
  40350. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40351. import { Scene } from "babylonjs/scene";
  40352. import { Vector4 } from "babylonjs/Maths/math.vector";
  40353. import { Mesh } from "babylonjs/Meshes/mesh";
  40354. import { Nullable } from "babylonjs/types";
  40355. import { Plane } from "babylonjs/Maths/math.plane";
  40356. /**
  40357. * Class containing static functions to help procedurally build meshes
  40358. */
  40359. export class PlaneBuilder {
  40360. /**
  40361. * Creates a plane mesh
  40362. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40363. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40364. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40368. * @param name defines the name of the mesh
  40369. * @param options defines the options used to create the mesh
  40370. * @param scene defines the hosting scene
  40371. * @returns the plane mesh
  40372. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40373. */
  40374. static CreatePlane(name: string, options: {
  40375. size?: number;
  40376. width?: number;
  40377. height?: number;
  40378. sideOrientation?: number;
  40379. frontUVs?: Vector4;
  40380. backUVs?: Vector4;
  40381. updatable?: boolean;
  40382. sourcePlane?: Plane;
  40383. }, scene?: Nullable<Scene>): Mesh;
  40384. }
  40385. }
  40386. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40387. import { Behavior } from "babylonjs/Behaviors/behavior";
  40388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40389. import { Observable } from "babylonjs/Misc/observable";
  40390. import { Vector3 } from "babylonjs/Maths/math.vector";
  40391. import { Ray } from "babylonjs/Culling/ray";
  40392. import "babylonjs/Meshes/Builders/planeBuilder";
  40393. /**
  40394. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40395. */
  40396. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40397. private static _AnyMouseID;
  40398. /**
  40399. * Abstract mesh the behavior is set on
  40400. */
  40401. attachedNode: AbstractMesh;
  40402. private _dragPlane;
  40403. private _scene;
  40404. private _pointerObserver;
  40405. private _beforeRenderObserver;
  40406. private static _planeScene;
  40407. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40408. /**
  40409. * 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)
  40410. */
  40411. maxDragAngle: number;
  40412. /**
  40413. * @hidden
  40414. */
  40415. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40416. /**
  40417. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40418. */
  40419. currentDraggingPointerID: number;
  40420. /**
  40421. * The last position where the pointer hit the drag plane in world space
  40422. */
  40423. lastDragPosition: Vector3;
  40424. /**
  40425. * If the behavior is currently in a dragging state
  40426. */
  40427. dragging: boolean;
  40428. /**
  40429. * 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)
  40430. */
  40431. dragDeltaRatio: number;
  40432. /**
  40433. * If the drag plane orientation should be updated during the dragging (Default: true)
  40434. */
  40435. updateDragPlane: boolean;
  40436. private _debugMode;
  40437. private _moving;
  40438. /**
  40439. * Fires each time the attached mesh is dragged with the pointer
  40440. * * delta between last drag position and current drag position in world space
  40441. * * dragDistance along the drag axis
  40442. * * dragPlaneNormal normal of the current drag plane used during the drag
  40443. * * dragPlanePoint in world space where the drag intersects the drag plane
  40444. */
  40445. onDragObservable: Observable<{
  40446. delta: Vector3;
  40447. dragPlanePoint: Vector3;
  40448. dragPlaneNormal: Vector3;
  40449. dragDistance: number;
  40450. pointerId: number;
  40451. }>;
  40452. /**
  40453. * Fires each time a drag begins (eg. mouse down on mesh)
  40454. */
  40455. onDragStartObservable: Observable<{
  40456. dragPlanePoint: Vector3;
  40457. pointerId: number;
  40458. }>;
  40459. /**
  40460. * Fires each time a drag ends (eg. mouse release after drag)
  40461. */
  40462. onDragEndObservable: Observable<{
  40463. dragPlanePoint: Vector3;
  40464. pointerId: number;
  40465. }>;
  40466. /**
  40467. * If the attached mesh should be moved when dragged
  40468. */
  40469. moveAttached: boolean;
  40470. /**
  40471. * If the drag behavior will react to drag events (Default: true)
  40472. */
  40473. enabled: boolean;
  40474. /**
  40475. * If pointer events should start and release the drag (Default: true)
  40476. */
  40477. startAndReleaseDragOnPointerEvents: boolean;
  40478. /**
  40479. * If camera controls should be detached during the drag
  40480. */
  40481. detachCameraControls: boolean;
  40482. /**
  40483. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40484. */
  40485. useObjectOrientationForDragging: boolean;
  40486. private _options;
  40487. /**
  40488. * Gets the options used by the behavior
  40489. */
  40490. get options(): {
  40491. dragAxis?: Vector3;
  40492. dragPlaneNormal?: Vector3;
  40493. };
  40494. /**
  40495. * Sets the options used by the behavior
  40496. */
  40497. set options(options: {
  40498. dragAxis?: Vector3;
  40499. dragPlaneNormal?: Vector3;
  40500. });
  40501. /**
  40502. * Creates a pointer drag behavior that can be attached to a mesh
  40503. * @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)
  40504. */
  40505. constructor(options?: {
  40506. dragAxis?: Vector3;
  40507. dragPlaneNormal?: Vector3;
  40508. });
  40509. /**
  40510. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40511. */
  40512. validateDrag: (targetPosition: Vector3) => boolean;
  40513. /**
  40514. * The name of the behavior
  40515. */
  40516. get name(): string;
  40517. /**
  40518. * Initializes the behavior
  40519. */
  40520. init(): void;
  40521. private _tmpVector;
  40522. private _alternatePickedPoint;
  40523. private _worldDragAxis;
  40524. private _targetPosition;
  40525. private _attachedElement;
  40526. /**
  40527. * Attaches the drag behavior the passed in mesh
  40528. * @param ownerNode The mesh that will be dragged around once attached
  40529. * @param predicate Predicate to use for pick filtering
  40530. */
  40531. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40532. /**
  40533. * Force relase the drag action by code.
  40534. */
  40535. releaseDrag(): void;
  40536. private _startDragRay;
  40537. private _lastPointerRay;
  40538. /**
  40539. * Simulates the start of a pointer drag event on the behavior
  40540. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40541. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40542. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40543. */
  40544. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40545. private _startDrag;
  40546. private _dragDelta;
  40547. private _moveDrag;
  40548. private _pickWithRayOnDragPlane;
  40549. private _pointA;
  40550. private _pointB;
  40551. private _pointC;
  40552. private _lineA;
  40553. private _lineB;
  40554. private _localAxis;
  40555. private _lookAt;
  40556. private _updateDragPlanePosition;
  40557. /**
  40558. * Detaches the behavior from the mesh
  40559. */
  40560. detach(): void;
  40561. }
  40562. }
  40563. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40564. import { Mesh } from "babylonjs/Meshes/mesh";
  40565. import { Behavior } from "babylonjs/Behaviors/behavior";
  40566. /**
  40567. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40568. */
  40569. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40570. private _dragBehaviorA;
  40571. private _dragBehaviorB;
  40572. private _startDistance;
  40573. private _initialScale;
  40574. private _targetScale;
  40575. private _ownerNode;
  40576. private _sceneRenderObserver;
  40577. /**
  40578. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40579. */
  40580. constructor();
  40581. /**
  40582. * The name of the behavior
  40583. */
  40584. get name(): string;
  40585. /**
  40586. * Initializes the behavior
  40587. */
  40588. init(): void;
  40589. private _getCurrentDistance;
  40590. /**
  40591. * Attaches the scale behavior the passed in mesh
  40592. * @param ownerNode The mesh that will be scaled around once attached
  40593. */
  40594. attach(ownerNode: Mesh): void;
  40595. /**
  40596. * Detaches the behavior from the mesh
  40597. */
  40598. detach(): void;
  40599. }
  40600. }
  40601. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40602. import { Behavior } from "babylonjs/Behaviors/behavior";
  40603. import { Mesh } from "babylonjs/Meshes/mesh";
  40604. import { Observable } from "babylonjs/Misc/observable";
  40605. /**
  40606. * 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
  40607. */
  40608. export class SixDofDragBehavior implements Behavior<Mesh> {
  40609. private static _virtualScene;
  40610. private _ownerNode;
  40611. private _sceneRenderObserver;
  40612. private _scene;
  40613. private _targetPosition;
  40614. private _virtualOriginMesh;
  40615. private _virtualDragMesh;
  40616. private _pointerObserver;
  40617. private _moving;
  40618. private _startingOrientation;
  40619. /**
  40620. * 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)
  40621. */
  40622. private zDragFactor;
  40623. /**
  40624. * If the object should rotate to face the drag origin
  40625. */
  40626. rotateDraggedObject: boolean;
  40627. /**
  40628. * If the behavior is currently in a dragging state
  40629. */
  40630. dragging: boolean;
  40631. /**
  40632. * 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)
  40633. */
  40634. dragDeltaRatio: number;
  40635. /**
  40636. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40637. */
  40638. currentDraggingPointerID: number;
  40639. /**
  40640. * If camera controls should be detached during the drag
  40641. */
  40642. detachCameraControls: boolean;
  40643. /**
  40644. * Fires each time a drag starts
  40645. */
  40646. onDragStartObservable: Observable<{}>;
  40647. /**
  40648. * Fires each time a drag ends (eg. mouse release after drag)
  40649. */
  40650. onDragEndObservable: Observable<{}>;
  40651. /**
  40652. * 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
  40653. */
  40654. constructor();
  40655. /**
  40656. * The name of the behavior
  40657. */
  40658. get name(): string;
  40659. /**
  40660. * Initializes the behavior
  40661. */
  40662. init(): void;
  40663. /**
  40664. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40665. */
  40666. private get _pointerCamera();
  40667. /**
  40668. * Attaches the scale behavior the passed in mesh
  40669. * @param ownerNode The mesh that will be scaled around once attached
  40670. */
  40671. attach(ownerNode: Mesh): void;
  40672. /**
  40673. * Detaches the behavior from the mesh
  40674. */
  40675. detach(): void;
  40676. }
  40677. }
  40678. declare module "babylonjs/Behaviors/Meshes/index" {
  40679. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40680. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40681. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40682. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40683. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40684. }
  40685. declare module "babylonjs/Behaviors/index" {
  40686. export * from "babylonjs/Behaviors/behavior";
  40687. export * from "babylonjs/Behaviors/Cameras/index";
  40688. export * from "babylonjs/Behaviors/Meshes/index";
  40689. }
  40690. declare module "babylonjs/Bones/boneIKController" {
  40691. import { Bone } from "babylonjs/Bones/bone";
  40692. import { Vector3 } from "babylonjs/Maths/math.vector";
  40693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40694. import { Nullable } from "babylonjs/types";
  40695. /**
  40696. * Class used to apply inverse kinematics to bones
  40697. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40698. */
  40699. export class BoneIKController {
  40700. private static _tmpVecs;
  40701. private static _tmpQuat;
  40702. private static _tmpMats;
  40703. /**
  40704. * Gets or sets the target mesh
  40705. */
  40706. targetMesh: AbstractMesh;
  40707. /** Gets or sets the mesh used as pole */
  40708. poleTargetMesh: AbstractMesh;
  40709. /**
  40710. * Gets or sets the bone used as pole
  40711. */
  40712. poleTargetBone: Nullable<Bone>;
  40713. /**
  40714. * Gets or sets the target position
  40715. */
  40716. targetPosition: Vector3;
  40717. /**
  40718. * Gets or sets the pole target position
  40719. */
  40720. poleTargetPosition: Vector3;
  40721. /**
  40722. * Gets or sets the pole target local offset
  40723. */
  40724. poleTargetLocalOffset: Vector3;
  40725. /**
  40726. * Gets or sets the pole angle
  40727. */
  40728. poleAngle: number;
  40729. /**
  40730. * Gets or sets the mesh associated with the controller
  40731. */
  40732. mesh: AbstractMesh;
  40733. /**
  40734. * 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)
  40735. */
  40736. slerpAmount: number;
  40737. private _bone1Quat;
  40738. private _bone1Mat;
  40739. private _bone2Ang;
  40740. private _bone1;
  40741. private _bone2;
  40742. private _bone1Length;
  40743. private _bone2Length;
  40744. private _maxAngle;
  40745. private _maxReach;
  40746. private _rightHandedSystem;
  40747. private _bendAxis;
  40748. private _slerping;
  40749. private _adjustRoll;
  40750. /**
  40751. * Gets or sets maximum allowed angle
  40752. */
  40753. get maxAngle(): number;
  40754. set maxAngle(value: number);
  40755. /**
  40756. * Creates a new BoneIKController
  40757. * @param mesh defines the mesh to control
  40758. * @param bone defines the bone to control
  40759. * @param options defines options to set up the controller
  40760. */
  40761. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40762. targetMesh?: AbstractMesh;
  40763. poleTargetMesh?: AbstractMesh;
  40764. poleTargetBone?: Bone;
  40765. poleTargetLocalOffset?: Vector3;
  40766. poleAngle?: number;
  40767. bendAxis?: Vector3;
  40768. maxAngle?: number;
  40769. slerpAmount?: number;
  40770. });
  40771. private _setMaxAngle;
  40772. /**
  40773. * Force the controller to update the bones
  40774. */
  40775. update(): void;
  40776. }
  40777. }
  40778. declare module "babylonjs/Bones/boneLookController" {
  40779. import { Vector3 } from "babylonjs/Maths/math.vector";
  40780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40781. import { Bone } from "babylonjs/Bones/bone";
  40782. import { Space } from "babylonjs/Maths/math.axis";
  40783. /**
  40784. * Class used to make a bone look toward a point in space
  40785. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40786. */
  40787. export class BoneLookController {
  40788. private static _tmpVecs;
  40789. private static _tmpQuat;
  40790. private static _tmpMats;
  40791. /**
  40792. * The target Vector3 that the bone will look at
  40793. */
  40794. target: Vector3;
  40795. /**
  40796. * The mesh that the bone is attached to
  40797. */
  40798. mesh: AbstractMesh;
  40799. /**
  40800. * The bone that will be looking to the target
  40801. */
  40802. bone: Bone;
  40803. /**
  40804. * The up axis of the coordinate system that is used when the bone is rotated
  40805. */
  40806. upAxis: Vector3;
  40807. /**
  40808. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40809. */
  40810. upAxisSpace: Space;
  40811. /**
  40812. * Used to make an adjustment to the yaw of the bone
  40813. */
  40814. adjustYaw: number;
  40815. /**
  40816. * Used to make an adjustment to the pitch of the bone
  40817. */
  40818. adjustPitch: number;
  40819. /**
  40820. * Used to make an adjustment to the roll of the bone
  40821. */
  40822. adjustRoll: number;
  40823. /**
  40824. * 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)
  40825. */
  40826. slerpAmount: number;
  40827. private _minYaw;
  40828. private _maxYaw;
  40829. private _minPitch;
  40830. private _maxPitch;
  40831. private _minYawSin;
  40832. private _minYawCos;
  40833. private _maxYawSin;
  40834. private _maxYawCos;
  40835. private _midYawConstraint;
  40836. private _minPitchTan;
  40837. private _maxPitchTan;
  40838. private _boneQuat;
  40839. private _slerping;
  40840. private _transformYawPitch;
  40841. private _transformYawPitchInv;
  40842. private _firstFrameSkipped;
  40843. private _yawRange;
  40844. private _fowardAxis;
  40845. /**
  40846. * Gets or sets the minimum yaw angle that the bone can look to
  40847. */
  40848. get minYaw(): number;
  40849. set minYaw(value: number);
  40850. /**
  40851. * Gets or sets the maximum yaw angle that the bone can look to
  40852. */
  40853. get maxYaw(): number;
  40854. set maxYaw(value: number);
  40855. /**
  40856. * Gets or sets the minimum pitch angle that the bone can look to
  40857. */
  40858. get minPitch(): number;
  40859. set minPitch(value: number);
  40860. /**
  40861. * Gets or sets the maximum pitch angle that the bone can look to
  40862. */
  40863. get maxPitch(): number;
  40864. set maxPitch(value: number);
  40865. /**
  40866. * Create a BoneLookController
  40867. * @param mesh the mesh that the bone belongs to
  40868. * @param bone the bone that will be looking to the target
  40869. * @param target the target Vector3 to look at
  40870. * @param options optional settings:
  40871. * * maxYaw: the maximum angle the bone will yaw to
  40872. * * minYaw: the minimum angle the bone will yaw to
  40873. * * maxPitch: the maximum angle the bone will pitch to
  40874. * * minPitch: the minimum angle the bone will yaw to
  40875. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40876. * * upAxis: the up axis of the coordinate system
  40877. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40878. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40879. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40880. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40881. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40882. * * adjustRoll: used to make an adjustment to the roll of the bone
  40883. **/
  40884. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40885. maxYaw?: number;
  40886. minYaw?: number;
  40887. maxPitch?: number;
  40888. minPitch?: number;
  40889. slerpAmount?: number;
  40890. upAxis?: Vector3;
  40891. upAxisSpace?: Space;
  40892. yawAxis?: Vector3;
  40893. pitchAxis?: Vector3;
  40894. adjustYaw?: number;
  40895. adjustPitch?: number;
  40896. adjustRoll?: number;
  40897. });
  40898. /**
  40899. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40900. */
  40901. update(): void;
  40902. private _getAngleDiff;
  40903. private _getAngleBetween;
  40904. private _isAngleBetween;
  40905. }
  40906. }
  40907. declare module "babylonjs/Bones/index" {
  40908. export * from "babylonjs/Bones/bone";
  40909. export * from "babylonjs/Bones/boneIKController";
  40910. export * from "babylonjs/Bones/boneLookController";
  40911. export * from "babylonjs/Bones/skeleton";
  40912. }
  40913. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40914. import { Nullable } from "babylonjs/types";
  40915. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40916. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40917. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40918. /**
  40919. * Manage the gamepad inputs to control an arc rotate camera.
  40920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40921. */
  40922. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40923. /**
  40924. * Defines the camera the input is attached to.
  40925. */
  40926. camera: ArcRotateCamera;
  40927. /**
  40928. * Defines the gamepad the input is gathering event from.
  40929. */
  40930. gamepad: Nullable<Gamepad>;
  40931. /**
  40932. * Defines the gamepad rotation sensiblity.
  40933. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40934. */
  40935. gamepadRotationSensibility: number;
  40936. /**
  40937. * Defines the gamepad move sensiblity.
  40938. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40939. */
  40940. gamepadMoveSensibility: number;
  40941. private _yAxisScale;
  40942. /**
  40943. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40944. */
  40945. get invertYAxis(): boolean;
  40946. set invertYAxis(value: boolean);
  40947. private _onGamepadConnectedObserver;
  40948. private _onGamepadDisconnectedObserver;
  40949. /**
  40950. * Attach the input controls to a specific dom element to get the input from.
  40951. * @param element Defines the element the controls should be listened from
  40952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40953. */
  40954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40955. /**
  40956. * Detach the current controls from the specified dom element.
  40957. * @param element Defines the element to stop listening the inputs from
  40958. */
  40959. detachControl(element: Nullable<HTMLElement>): void;
  40960. /**
  40961. * Update the current camera state depending on the inputs that have been used this frame.
  40962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40963. */
  40964. checkInputs(): void;
  40965. /**
  40966. * Gets the class name of the current intput.
  40967. * @returns the class name
  40968. */
  40969. getClassName(): string;
  40970. /**
  40971. * Get the friendly name associated with the input class.
  40972. * @returns the input friendly name
  40973. */
  40974. getSimpleName(): string;
  40975. }
  40976. }
  40977. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40978. import { Nullable } from "babylonjs/types";
  40979. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40980. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40981. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40982. interface ArcRotateCameraInputsManager {
  40983. /**
  40984. * Add orientation input support to the input manager.
  40985. * @returns the current input manager
  40986. */
  40987. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40988. }
  40989. }
  40990. /**
  40991. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40993. */
  40994. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40995. /**
  40996. * Defines the camera the input is attached to.
  40997. */
  40998. camera: ArcRotateCamera;
  40999. /**
  41000. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41001. */
  41002. alphaCorrection: number;
  41003. /**
  41004. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41005. */
  41006. gammaCorrection: number;
  41007. private _alpha;
  41008. private _gamma;
  41009. private _dirty;
  41010. private _deviceOrientationHandler;
  41011. /**
  41012. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41013. */
  41014. constructor();
  41015. /**
  41016. * Attach the input controls to a specific dom element to get the input from.
  41017. * @param element Defines the element the controls should be listened from
  41018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41019. */
  41020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41021. /** @hidden */
  41022. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41023. /**
  41024. * Update the current camera state depending on the inputs that have been used this frame.
  41025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41026. */
  41027. checkInputs(): void;
  41028. /**
  41029. * Detach the current controls from the specified dom element.
  41030. * @param element Defines the element to stop listening the inputs from
  41031. */
  41032. detachControl(element: Nullable<HTMLElement>): void;
  41033. /**
  41034. * Gets the class name of the current intput.
  41035. * @returns the class name
  41036. */
  41037. getClassName(): string;
  41038. /**
  41039. * Get the friendly name associated with the input class.
  41040. * @returns the input friendly name
  41041. */
  41042. getSimpleName(): string;
  41043. }
  41044. }
  41045. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41046. import { Nullable } from "babylonjs/types";
  41047. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41048. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41049. /**
  41050. * Listen to mouse events to control the camera.
  41051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41052. */
  41053. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41054. /**
  41055. * Defines the camera the input is attached to.
  41056. */
  41057. camera: FlyCamera;
  41058. /**
  41059. * Defines if touch is enabled. (Default is true.)
  41060. */
  41061. touchEnabled: boolean;
  41062. /**
  41063. * Defines the buttons associated with the input to handle camera rotation.
  41064. */
  41065. buttons: number[];
  41066. /**
  41067. * Assign buttons for Yaw control.
  41068. */
  41069. buttonsYaw: number[];
  41070. /**
  41071. * Assign buttons for Pitch control.
  41072. */
  41073. buttonsPitch: number[];
  41074. /**
  41075. * Assign buttons for Roll control.
  41076. */
  41077. buttonsRoll: number[];
  41078. /**
  41079. * Detect if any button is being pressed while mouse is moved.
  41080. * -1 = Mouse locked.
  41081. * 0 = Left button.
  41082. * 1 = Middle Button.
  41083. * 2 = Right Button.
  41084. */
  41085. activeButton: number;
  41086. /**
  41087. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41088. * Higher values reduce its sensitivity.
  41089. */
  41090. angularSensibility: number;
  41091. private _mousemoveCallback;
  41092. private _observer;
  41093. private _rollObserver;
  41094. private previousPosition;
  41095. private noPreventDefault;
  41096. private element;
  41097. /**
  41098. * Listen to mouse events to control the camera.
  41099. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41101. */
  41102. constructor(touchEnabled?: boolean);
  41103. /**
  41104. * Attach the mouse control to the HTML DOM element.
  41105. * @param element Defines the element that listens to the input events.
  41106. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41107. */
  41108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41109. /**
  41110. * Detach the current controls from the specified dom element.
  41111. * @param element Defines the element to stop listening the inputs from
  41112. */
  41113. detachControl(element: Nullable<HTMLElement>): void;
  41114. /**
  41115. * Gets the class name of the current input.
  41116. * @returns the class name.
  41117. */
  41118. getClassName(): string;
  41119. /**
  41120. * Get the friendly name associated with the input class.
  41121. * @returns the input's friendly name.
  41122. */
  41123. getSimpleName(): string;
  41124. private _pointerInput;
  41125. private _onMouseMove;
  41126. /**
  41127. * Rotate camera by mouse offset.
  41128. */
  41129. private rotateCamera;
  41130. }
  41131. }
  41132. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41133. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41134. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41135. /**
  41136. * Default Inputs manager for the FlyCamera.
  41137. * It groups all the default supported inputs for ease of use.
  41138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41139. */
  41140. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41141. /**
  41142. * Instantiates a new FlyCameraInputsManager.
  41143. * @param camera Defines the camera the inputs belong to.
  41144. */
  41145. constructor(camera: FlyCamera);
  41146. /**
  41147. * Add keyboard input support to the input manager.
  41148. * @returns the new FlyCameraKeyboardMoveInput().
  41149. */
  41150. addKeyboard(): FlyCameraInputsManager;
  41151. /**
  41152. * Add mouse input support to the input manager.
  41153. * @param touchEnabled Enable touch screen support.
  41154. * @returns the new FlyCameraMouseInput().
  41155. */
  41156. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41157. }
  41158. }
  41159. declare module "babylonjs/Cameras/flyCamera" {
  41160. import { Scene } from "babylonjs/scene";
  41161. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41163. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41164. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41165. /**
  41166. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41167. * such as in a 3D Space Shooter or a Flight Simulator.
  41168. */
  41169. export class FlyCamera extends TargetCamera {
  41170. /**
  41171. * Define the collision ellipsoid of the camera.
  41172. * This is helpful for simulating a camera body, like a player's body.
  41173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41174. */
  41175. ellipsoid: Vector3;
  41176. /**
  41177. * Define an offset for the position of the ellipsoid around the camera.
  41178. * This can be helpful if the camera is attached away from the player's body center,
  41179. * such as at its head.
  41180. */
  41181. ellipsoidOffset: Vector3;
  41182. /**
  41183. * Enable or disable collisions of the camera with the rest of the scene objects.
  41184. */
  41185. checkCollisions: boolean;
  41186. /**
  41187. * Enable or disable gravity on the camera.
  41188. */
  41189. applyGravity: boolean;
  41190. /**
  41191. * Define the current direction the camera is moving to.
  41192. */
  41193. cameraDirection: Vector3;
  41194. /**
  41195. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41196. * This overrides and empties cameraRotation.
  41197. */
  41198. rotationQuaternion: Quaternion;
  41199. /**
  41200. * Track Roll to maintain the wanted Rolling when looking around.
  41201. */
  41202. _trackRoll: number;
  41203. /**
  41204. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41205. */
  41206. rollCorrect: number;
  41207. /**
  41208. * Mimic a banked turn, Rolling the camera when Yawing.
  41209. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41210. */
  41211. bankedTurn: boolean;
  41212. /**
  41213. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41214. */
  41215. bankedTurnLimit: number;
  41216. /**
  41217. * Value of 0 disables the banked Roll.
  41218. * Value of 1 is equal to the Yaw angle in radians.
  41219. */
  41220. bankedTurnMultiplier: number;
  41221. /**
  41222. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41223. */
  41224. inputs: FlyCameraInputsManager;
  41225. /**
  41226. * Gets the input sensibility for mouse input.
  41227. * Higher values reduce sensitivity.
  41228. */
  41229. get angularSensibility(): number;
  41230. /**
  41231. * Sets the input sensibility for a mouse input.
  41232. * Higher values reduce sensitivity.
  41233. */
  41234. set angularSensibility(value: number);
  41235. /**
  41236. * Get the keys for camera movement forward.
  41237. */
  41238. get keysForward(): number[];
  41239. /**
  41240. * Set the keys for camera movement forward.
  41241. */
  41242. set keysForward(value: number[]);
  41243. /**
  41244. * Get the keys for camera movement backward.
  41245. */
  41246. get keysBackward(): number[];
  41247. set keysBackward(value: number[]);
  41248. /**
  41249. * Get the keys for camera movement up.
  41250. */
  41251. get keysUp(): number[];
  41252. /**
  41253. * Set the keys for camera movement up.
  41254. */
  41255. set keysUp(value: number[]);
  41256. /**
  41257. * Get the keys for camera movement down.
  41258. */
  41259. get keysDown(): number[];
  41260. /**
  41261. * Set the keys for camera movement down.
  41262. */
  41263. set keysDown(value: number[]);
  41264. /**
  41265. * Get the keys for camera movement left.
  41266. */
  41267. get keysLeft(): number[];
  41268. /**
  41269. * Set the keys for camera movement left.
  41270. */
  41271. set keysLeft(value: number[]);
  41272. /**
  41273. * Set the keys for camera movement right.
  41274. */
  41275. get keysRight(): number[];
  41276. /**
  41277. * Set the keys for camera movement right.
  41278. */
  41279. set keysRight(value: number[]);
  41280. /**
  41281. * Event raised when the camera collides with a mesh in the scene.
  41282. */
  41283. onCollide: (collidedMesh: AbstractMesh) => void;
  41284. private _collider;
  41285. private _needMoveForGravity;
  41286. private _oldPosition;
  41287. private _diffPosition;
  41288. private _newPosition;
  41289. /** @hidden */
  41290. _localDirection: Vector3;
  41291. /** @hidden */
  41292. _transformedDirection: Vector3;
  41293. /**
  41294. * Instantiates a FlyCamera.
  41295. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41296. * such as in a 3D Space Shooter or a Flight Simulator.
  41297. * @param name Define the name of the camera in the scene.
  41298. * @param position Define the starting position of the camera in the scene.
  41299. * @param scene Define the scene the camera belongs to.
  41300. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41301. */
  41302. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41303. /**
  41304. * Attach a control to the HTML DOM element.
  41305. * @param element Defines the element that listens to the input events.
  41306. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41307. */
  41308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41309. /**
  41310. * Detach a control from the HTML DOM element.
  41311. * The camera will stop reacting to that input.
  41312. * @param element Defines the element that listens to the input events.
  41313. */
  41314. detachControl(element: HTMLElement): void;
  41315. private _collisionMask;
  41316. /**
  41317. * Get the mask that the camera ignores in collision events.
  41318. */
  41319. get collisionMask(): number;
  41320. /**
  41321. * Set the mask that the camera ignores in collision events.
  41322. */
  41323. set collisionMask(mask: number);
  41324. /** @hidden */
  41325. _collideWithWorld(displacement: Vector3): void;
  41326. /** @hidden */
  41327. private _onCollisionPositionChange;
  41328. /** @hidden */
  41329. _checkInputs(): void;
  41330. /** @hidden */
  41331. _decideIfNeedsToMove(): boolean;
  41332. /** @hidden */
  41333. _updatePosition(): void;
  41334. /**
  41335. * Restore the Roll to its target value at the rate specified.
  41336. * @param rate - Higher means slower restoring.
  41337. * @hidden
  41338. */
  41339. restoreRoll(rate: number): void;
  41340. /**
  41341. * Destroy the camera and release the current resources held by it.
  41342. */
  41343. dispose(): void;
  41344. /**
  41345. * Get the current object class name.
  41346. * @returns the class name.
  41347. */
  41348. getClassName(): string;
  41349. }
  41350. }
  41351. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41352. import { Nullable } from "babylonjs/types";
  41353. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41354. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41355. /**
  41356. * Listen to keyboard events to control the camera.
  41357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41358. */
  41359. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41360. /**
  41361. * Defines the camera the input is attached to.
  41362. */
  41363. camera: FlyCamera;
  41364. /**
  41365. * The list of keyboard keys used to control the forward move of the camera.
  41366. */
  41367. keysForward: number[];
  41368. /**
  41369. * The list of keyboard keys used to control the backward move of the camera.
  41370. */
  41371. keysBackward: number[];
  41372. /**
  41373. * The list of keyboard keys used to control the forward move of the camera.
  41374. */
  41375. keysUp: number[];
  41376. /**
  41377. * The list of keyboard keys used to control the backward move of the camera.
  41378. */
  41379. keysDown: number[];
  41380. /**
  41381. * The list of keyboard keys used to control the right strafe move of the camera.
  41382. */
  41383. keysRight: number[];
  41384. /**
  41385. * The list of keyboard keys used to control the left strafe move of the camera.
  41386. */
  41387. keysLeft: number[];
  41388. private _keys;
  41389. private _onCanvasBlurObserver;
  41390. private _onKeyboardObserver;
  41391. private _engine;
  41392. private _scene;
  41393. /**
  41394. * Attach the input controls to a specific dom element to get the input from.
  41395. * @param element Defines the element the controls should be listened from
  41396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41397. */
  41398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41399. /**
  41400. * Detach the current controls from the specified dom element.
  41401. * @param element Defines the element to stop listening the inputs from
  41402. */
  41403. detachControl(element: Nullable<HTMLElement>): void;
  41404. /**
  41405. * Gets the class name of the current intput.
  41406. * @returns the class name
  41407. */
  41408. getClassName(): string;
  41409. /** @hidden */
  41410. _onLostFocus(e: FocusEvent): void;
  41411. /**
  41412. * Get the friendly name associated with the input class.
  41413. * @returns the input friendly name
  41414. */
  41415. getSimpleName(): string;
  41416. /**
  41417. * Update the current camera state depending on the inputs that have been used this frame.
  41418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41419. */
  41420. checkInputs(): void;
  41421. }
  41422. }
  41423. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41424. import { Nullable } from "babylonjs/types";
  41425. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41426. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41427. /**
  41428. * Manage the mouse wheel inputs to control a follow camera.
  41429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41430. */
  41431. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41432. /**
  41433. * Defines the camera the input is attached to.
  41434. */
  41435. camera: FollowCamera;
  41436. /**
  41437. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41438. */
  41439. axisControlRadius: boolean;
  41440. /**
  41441. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41442. */
  41443. axisControlHeight: boolean;
  41444. /**
  41445. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41446. */
  41447. axisControlRotation: boolean;
  41448. /**
  41449. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41450. * relation to mouseWheel events.
  41451. */
  41452. wheelPrecision: number;
  41453. /**
  41454. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41455. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41456. */
  41457. wheelDeltaPercentage: number;
  41458. private _wheel;
  41459. private _observer;
  41460. /**
  41461. * Attach the input controls to a specific dom element to get the input from.
  41462. * @param element Defines the element the controls should be listened from
  41463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41464. */
  41465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41466. /**
  41467. * Detach the current controls from the specified dom element.
  41468. * @param element Defines the element to stop listening the inputs from
  41469. */
  41470. detachControl(element: Nullable<HTMLElement>): void;
  41471. /**
  41472. * Gets the class name of the current intput.
  41473. * @returns the class name
  41474. */
  41475. getClassName(): string;
  41476. /**
  41477. * Get the friendly name associated with the input class.
  41478. * @returns the input friendly name
  41479. */
  41480. getSimpleName(): string;
  41481. }
  41482. }
  41483. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41484. import { Nullable } from "babylonjs/types";
  41485. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41486. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41487. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41488. /**
  41489. * Manage the pointers inputs to control an follow camera.
  41490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41491. */
  41492. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41493. /**
  41494. * Defines the camera the input is attached to.
  41495. */
  41496. camera: FollowCamera;
  41497. /**
  41498. * Gets the class name of the current input.
  41499. * @returns the class name
  41500. */
  41501. getClassName(): string;
  41502. /**
  41503. * Defines the pointer angular sensibility along the X axis or how fast is
  41504. * the camera rotating.
  41505. * A negative number will reverse the axis direction.
  41506. */
  41507. angularSensibilityX: number;
  41508. /**
  41509. * Defines the pointer angular sensibility along the Y axis or how fast is
  41510. * the camera rotating.
  41511. * A negative number will reverse the axis direction.
  41512. */
  41513. angularSensibilityY: number;
  41514. /**
  41515. * Defines the pointer pinch precision or how fast is the camera zooming.
  41516. * A negative number will reverse the axis direction.
  41517. */
  41518. pinchPrecision: number;
  41519. /**
  41520. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41521. * from 0.
  41522. * It defines the percentage of current camera.radius to use as delta when
  41523. * pinch zoom is used.
  41524. */
  41525. pinchDeltaPercentage: number;
  41526. /**
  41527. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41528. */
  41529. axisXControlRadius: boolean;
  41530. /**
  41531. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41532. */
  41533. axisXControlHeight: boolean;
  41534. /**
  41535. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41536. */
  41537. axisXControlRotation: boolean;
  41538. /**
  41539. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41540. */
  41541. axisYControlRadius: boolean;
  41542. /**
  41543. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41544. */
  41545. axisYControlHeight: boolean;
  41546. /**
  41547. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41548. */
  41549. axisYControlRotation: boolean;
  41550. /**
  41551. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41552. */
  41553. axisPinchControlRadius: boolean;
  41554. /**
  41555. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41556. */
  41557. axisPinchControlHeight: boolean;
  41558. /**
  41559. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41560. */
  41561. axisPinchControlRotation: boolean;
  41562. /**
  41563. * Log error messages if basic misconfiguration has occurred.
  41564. */
  41565. warningEnable: boolean;
  41566. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41567. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41568. private _warningCounter;
  41569. private _warning;
  41570. }
  41571. }
  41572. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41573. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41574. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41575. /**
  41576. * Default Inputs manager for the FollowCamera.
  41577. * It groups all the default supported inputs for ease of use.
  41578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41579. */
  41580. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41581. /**
  41582. * Instantiates a new FollowCameraInputsManager.
  41583. * @param camera Defines the camera the inputs belong to
  41584. */
  41585. constructor(camera: FollowCamera);
  41586. /**
  41587. * Add keyboard input support to the input manager.
  41588. * @returns the current input manager
  41589. */
  41590. addKeyboard(): FollowCameraInputsManager;
  41591. /**
  41592. * Add mouse wheel input support to the input manager.
  41593. * @returns the current input manager
  41594. */
  41595. addMouseWheel(): FollowCameraInputsManager;
  41596. /**
  41597. * Add pointers input support to the input manager.
  41598. * @returns the current input manager
  41599. */
  41600. addPointers(): FollowCameraInputsManager;
  41601. /**
  41602. * Add orientation input support to the input manager.
  41603. * @returns the current input manager
  41604. */
  41605. addVRDeviceOrientation(): FollowCameraInputsManager;
  41606. }
  41607. }
  41608. declare module "babylonjs/Cameras/followCamera" {
  41609. import { Nullable } from "babylonjs/types";
  41610. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41611. import { Scene } from "babylonjs/scene";
  41612. import { Vector3 } from "babylonjs/Maths/math.vector";
  41613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41614. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41615. /**
  41616. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41617. * an arc rotate version arcFollowCamera are available.
  41618. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41619. */
  41620. export class FollowCamera extends TargetCamera {
  41621. /**
  41622. * Distance the follow camera should follow an object at
  41623. */
  41624. radius: number;
  41625. /**
  41626. * Minimum allowed distance of the camera to the axis of rotation
  41627. * (The camera can not get closer).
  41628. * This can help limiting how the Camera is able to move in the scene.
  41629. */
  41630. lowerRadiusLimit: Nullable<number>;
  41631. /**
  41632. * Maximum allowed distance of the camera to the axis of rotation
  41633. * (The camera can not get further).
  41634. * This can help limiting how the Camera is able to move in the scene.
  41635. */
  41636. upperRadiusLimit: Nullable<number>;
  41637. /**
  41638. * Define a rotation offset between the camera and the object it follows
  41639. */
  41640. rotationOffset: number;
  41641. /**
  41642. * Minimum allowed angle to camera position relative to target object.
  41643. * This can help limiting how the Camera is able to move in the scene.
  41644. */
  41645. lowerRotationOffsetLimit: Nullable<number>;
  41646. /**
  41647. * Maximum allowed angle to camera position relative to target object.
  41648. * This can help limiting how the Camera is able to move in the scene.
  41649. */
  41650. upperRotationOffsetLimit: Nullable<number>;
  41651. /**
  41652. * Define a height offset between the camera and the object it follows.
  41653. * It can help following an object from the top (like a car chaing a plane)
  41654. */
  41655. heightOffset: number;
  41656. /**
  41657. * Minimum allowed height of camera position relative to target object.
  41658. * This can help limiting how the Camera is able to move in the scene.
  41659. */
  41660. lowerHeightOffsetLimit: Nullable<number>;
  41661. /**
  41662. * Maximum allowed height of camera position relative to target object.
  41663. * This can help limiting how the Camera is able to move in the scene.
  41664. */
  41665. upperHeightOffsetLimit: Nullable<number>;
  41666. /**
  41667. * Define how fast the camera can accelerate to follow it s target.
  41668. */
  41669. cameraAcceleration: number;
  41670. /**
  41671. * Define the speed limit of the camera following an object.
  41672. */
  41673. maxCameraSpeed: number;
  41674. /**
  41675. * Define the target of the camera.
  41676. */
  41677. lockedTarget: Nullable<AbstractMesh>;
  41678. /**
  41679. * Defines the input associated with the camera.
  41680. */
  41681. inputs: FollowCameraInputsManager;
  41682. /**
  41683. * Instantiates the follow camera.
  41684. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41685. * @param name Define the name of the camera in the scene
  41686. * @param position Define the position of the camera
  41687. * @param scene Define the scene the camera belong to
  41688. * @param lockedTarget Define the target of the camera
  41689. */
  41690. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41691. private _follow;
  41692. /**
  41693. * Attached controls to the current camera.
  41694. * @param element Defines the element the controls should be listened from
  41695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41696. */
  41697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41698. /**
  41699. * Detach the current controls from the camera.
  41700. * The camera will stop reacting to inputs.
  41701. * @param element Defines the element to stop listening the inputs from
  41702. */
  41703. detachControl(element: HTMLElement): void;
  41704. /** @hidden */
  41705. _checkInputs(): void;
  41706. private _checkLimits;
  41707. /**
  41708. * Gets the camera class name.
  41709. * @returns the class name
  41710. */
  41711. getClassName(): string;
  41712. }
  41713. /**
  41714. * Arc Rotate version of the follow camera.
  41715. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41716. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41717. */
  41718. export class ArcFollowCamera extends TargetCamera {
  41719. /** The longitudinal angle of the camera */
  41720. alpha: number;
  41721. /** The latitudinal angle of the camera */
  41722. beta: number;
  41723. /** The radius of the camera from its target */
  41724. radius: number;
  41725. /** Define the camera target (the messh it should follow) */
  41726. target: Nullable<AbstractMesh>;
  41727. private _cartesianCoordinates;
  41728. /**
  41729. * Instantiates a new ArcFollowCamera
  41730. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41731. * @param name Define the name of the camera
  41732. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41733. * @param beta Define the rotation angle of the camera around the elevation axis
  41734. * @param radius Define the radius of the camera from its target point
  41735. * @param target Define the target of the camera
  41736. * @param scene Define the scene the camera belongs to
  41737. */
  41738. constructor(name: string,
  41739. /** The longitudinal angle of the camera */
  41740. alpha: number,
  41741. /** The latitudinal angle of the camera */
  41742. beta: number,
  41743. /** The radius of the camera from its target */
  41744. radius: number,
  41745. /** Define the camera target (the messh it should follow) */
  41746. target: Nullable<AbstractMesh>, scene: Scene);
  41747. private _follow;
  41748. /** @hidden */
  41749. _checkInputs(): void;
  41750. /**
  41751. * Returns the class name of the object.
  41752. * It is mostly used internally for serialization purposes.
  41753. */
  41754. getClassName(): string;
  41755. }
  41756. }
  41757. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41758. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41759. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41760. import { Nullable } from "babylonjs/types";
  41761. /**
  41762. * Manage the keyboard inputs to control the movement of a follow camera.
  41763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41764. */
  41765. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41766. /**
  41767. * Defines the camera the input is attached to.
  41768. */
  41769. camera: FollowCamera;
  41770. /**
  41771. * Defines the list of key codes associated with the up action (increase heightOffset)
  41772. */
  41773. keysHeightOffsetIncr: number[];
  41774. /**
  41775. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41776. */
  41777. keysHeightOffsetDecr: number[];
  41778. /**
  41779. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41780. */
  41781. keysHeightOffsetModifierAlt: boolean;
  41782. /**
  41783. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41784. */
  41785. keysHeightOffsetModifierCtrl: boolean;
  41786. /**
  41787. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41788. */
  41789. keysHeightOffsetModifierShift: boolean;
  41790. /**
  41791. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41792. */
  41793. keysRotationOffsetIncr: number[];
  41794. /**
  41795. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41796. */
  41797. keysRotationOffsetDecr: number[];
  41798. /**
  41799. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41800. */
  41801. keysRotationOffsetModifierAlt: boolean;
  41802. /**
  41803. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41804. */
  41805. keysRotationOffsetModifierCtrl: boolean;
  41806. /**
  41807. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41808. */
  41809. keysRotationOffsetModifierShift: boolean;
  41810. /**
  41811. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41812. */
  41813. keysRadiusIncr: number[];
  41814. /**
  41815. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41816. */
  41817. keysRadiusDecr: number[];
  41818. /**
  41819. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41820. */
  41821. keysRadiusModifierAlt: boolean;
  41822. /**
  41823. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41824. */
  41825. keysRadiusModifierCtrl: boolean;
  41826. /**
  41827. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41828. */
  41829. keysRadiusModifierShift: boolean;
  41830. /**
  41831. * Defines the rate of change of heightOffset.
  41832. */
  41833. heightSensibility: number;
  41834. /**
  41835. * Defines the rate of change of rotationOffset.
  41836. */
  41837. rotationSensibility: number;
  41838. /**
  41839. * Defines the rate of change of radius.
  41840. */
  41841. radiusSensibility: number;
  41842. private _keys;
  41843. private _ctrlPressed;
  41844. private _altPressed;
  41845. private _shiftPressed;
  41846. private _onCanvasBlurObserver;
  41847. private _onKeyboardObserver;
  41848. private _engine;
  41849. private _scene;
  41850. /**
  41851. * Attach the input controls to a specific dom element to get the input from.
  41852. * @param element Defines the element the controls should be listened from
  41853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41854. */
  41855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41856. /**
  41857. * Detach the current controls from the specified dom element.
  41858. * @param element Defines the element to stop listening the inputs from
  41859. */
  41860. detachControl(element: Nullable<HTMLElement>): void;
  41861. /**
  41862. * Update the current camera state depending on the inputs that have been used this frame.
  41863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41864. */
  41865. checkInputs(): void;
  41866. /**
  41867. * Gets the class name of the current input.
  41868. * @returns the class name
  41869. */
  41870. getClassName(): string;
  41871. /**
  41872. * Get the friendly name associated with the input class.
  41873. * @returns the input friendly name
  41874. */
  41875. getSimpleName(): string;
  41876. /**
  41877. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41878. * allow modification of the heightOffset value.
  41879. */
  41880. private _modifierHeightOffset;
  41881. /**
  41882. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41883. * allow modification of the rotationOffset value.
  41884. */
  41885. private _modifierRotationOffset;
  41886. /**
  41887. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41888. * allow modification of the radius value.
  41889. */
  41890. private _modifierRadius;
  41891. }
  41892. }
  41893. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41894. import { Nullable } from "babylonjs/types";
  41895. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41896. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41897. import { Observable } from "babylonjs/Misc/observable";
  41898. module "babylonjs/Cameras/freeCameraInputsManager" {
  41899. interface FreeCameraInputsManager {
  41900. /**
  41901. * @hidden
  41902. */
  41903. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41904. /**
  41905. * Add orientation input support to the input manager.
  41906. * @returns the current input manager
  41907. */
  41908. addDeviceOrientation(): FreeCameraInputsManager;
  41909. }
  41910. }
  41911. /**
  41912. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41913. * Screen rotation is taken into account.
  41914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41915. */
  41916. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41917. private _camera;
  41918. private _screenOrientationAngle;
  41919. private _constantTranform;
  41920. private _screenQuaternion;
  41921. private _alpha;
  41922. private _beta;
  41923. private _gamma;
  41924. /**
  41925. * Can be used to detect if a device orientation sensor is available on a device
  41926. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41927. * @returns a promise that will resolve on orientation change
  41928. */
  41929. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41930. /**
  41931. * @hidden
  41932. */
  41933. _onDeviceOrientationChangedObservable: Observable<void>;
  41934. /**
  41935. * Instantiates a new input
  41936. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41937. */
  41938. constructor();
  41939. /**
  41940. * Define the camera controlled by the input.
  41941. */
  41942. get camera(): FreeCamera;
  41943. set camera(camera: FreeCamera);
  41944. /**
  41945. * Attach the input controls to a specific dom element to get the input from.
  41946. * @param element Defines the element the controls should be listened from
  41947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41948. */
  41949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41950. private _orientationChanged;
  41951. private _deviceOrientation;
  41952. /**
  41953. * Detach the current controls from the specified dom element.
  41954. * @param element Defines the element to stop listening the inputs from
  41955. */
  41956. detachControl(element: Nullable<HTMLElement>): void;
  41957. /**
  41958. * Update the current camera state depending on the inputs that have been used this frame.
  41959. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41960. */
  41961. checkInputs(): void;
  41962. /**
  41963. * Gets the class name of the current intput.
  41964. * @returns the class name
  41965. */
  41966. getClassName(): string;
  41967. /**
  41968. * Get the friendly name associated with the input class.
  41969. * @returns the input friendly name
  41970. */
  41971. getSimpleName(): string;
  41972. }
  41973. }
  41974. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41975. import { Nullable } from "babylonjs/types";
  41976. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41978. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41979. /**
  41980. * Manage the gamepad inputs to control a free camera.
  41981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41982. */
  41983. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41984. /**
  41985. * Define the camera the input is attached to.
  41986. */
  41987. camera: FreeCamera;
  41988. /**
  41989. * Define the Gamepad controlling the input
  41990. */
  41991. gamepad: Nullable<Gamepad>;
  41992. /**
  41993. * Defines the gamepad rotation sensiblity.
  41994. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41995. */
  41996. gamepadAngularSensibility: number;
  41997. /**
  41998. * Defines the gamepad move sensiblity.
  41999. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42000. */
  42001. gamepadMoveSensibility: number;
  42002. private _yAxisScale;
  42003. /**
  42004. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42005. */
  42006. get invertYAxis(): boolean;
  42007. set invertYAxis(value: boolean);
  42008. private _onGamepadConnectedObserver;
  42009. private _onGamepadDisconnectedObserver;
  42010. private _cameraTransform;
  42011. private _deltaTransform;
  42012. private _vector3;
  42013. private _vector2;
  42014. /**
  42015. * Attach the input controls to a specific dom element to get the input from.
  42016. * @param element Defines the element the controls should be listened from
  42017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42018. */
  42019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42020. /**
  42021. * Detach the current controls from the specified dom element.
  42022. * @param element Defines the element to stop listening the inputs from
  42023. */
  42024. detachControl(element: Nullable<HTMLElement>): void;
  42025. /**
  42026. * Update the current camera state depending on the inputs that have been used this frame.
  42027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42028. */
  42029. checkInputs(): void;
  42030. /**
  42031. * Gets the class name of the current intput.
  42032. * @returns the class name
  42033. */
  42034. getClassName(): string;
  42035. /**
  42036. * Get the friendly name associated with the input class.
  42037. * @returns the input friendly name
  42038. */
  42039. getSimpleName(): string;
  42040. }
  42041. }
  42042. declare module "babylonjs/Misc/virtualJoystick" {
  42043. import { Nullable } from "babylonjs/types";
  42044. import { Vector3 } from "babylonjs/Maths/math.vector";
  42045. /**
  42046. * Defines the potential axis of a Joystick
  42047. */
  42048. export enum JoystickAxis {
  42049. /** X axis */
  42050. X = 0,
  42051. /** Y axis */
  42052. Y = 1,
  42053. /** Z axis */
  42054. Z = 2
  42055. }
  42056. /**
  42057. * Class used to define virtual joystick (used in touch mode)
  42058. */
  42059. export class VirtualJoystick {
  42060. /**
  42061. * Gets or sets a boolean indicating that left and right values must be inverted
  42062. */
  42063. reverseLeftRight: boolean;
  42064. /**
  42065. * Gets or sets a boolean indicating that up and down values must be inverted
  42066. */
  42067. reverseUpDown: boolean;
  42068. /**
  42069. * Gets the offset value for the position (ie. the change of the position value)
  42070. */
  42071. deltaPosition: Vector3;
  42072. /**
  42073. * Gets a boolean indicating if the virtual joystick was pressed
  42074. */
  42075. pressed: boolean;
  42076. /**
  42077. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42078. */
  42079. static Canvas: Nullable<HTMLCanvasElement>;
  42080. private static _globalJoystickIndex;
  42081. private static vjCanvasContext;
  42082. private static vjCanvasWidth;
  42083. private static vjCanvasHeight;
  42084. private static halfWidth;
  42085. private _action;
  42086. private _axisTargetedByLeftAndRight;
  42087. private _axisTargetedByUpAndDown;
  42088. private _joystickSensibility;
  42089. private _inversedSensibility;
  42090. private _joystickPointerID;
  42091. private _joystickColor;
  42092. private _joystickPointerPos;
  42093. private _joystickPreviousPointerPos;
  42094. private _joystickPointerStartPos;
  42095. private _deltaJoystickVector;
  42096. private _leftJoystick;
  42097. private _touches;
  42098. private _onPointerDownHandlerRef;
  42099. private _onPointerMoveHandlerRef;
  42100. private _onPointerUpHandlerRef;
  42101. private _onResize;
  42102. /**
  42103. * Creates a new virtual joystick
  42104. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42105. */
  42106. constructor(leftJoystick?: boolean);
  42107. /**
  42108. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42109. * @param newJoystickSensibility defines the new sensibility
  42110. */
  42111. setJoystickSensibility(newJoystickSensibility: number): void;
  42112. private _onPointerDown;
  42113. private _onPointerMove;
  42114. private _onPointerUp;
  42115. /**
  42116. * Change the color of the virtual joystick
  42117. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42118. */
  42119. setJoystickColor(newColor: string): void;
  42120. /**
  42121. * Defines a callback to call when the joystick is touched
  42122. * @param action defines the callback
  42123. */
  42124. setActionOnTouch(action: () => any): void;
  42125. /**
  42126. * Defines which axis you'd like to control for left & right
  42127. * @param axis defines the axis to use
  42128. */
  42129. setAxisForLeftRight(axis: JoystickAxis): void;
  42130. /**
  42131. * Defines which axis you'd like to control for up & down
  42132. * @param axis defines the axis to use
  42133. */
  42134. setAxisForUpDown(axis: JoystickAxis): void;
  42135. private _drawVirtualJoystick;
  42136. /**
  42137. * Release internal HTML canvas
  42138. */
  42139. releaseCanvas(): void;
  42140. }
  42141. }
  42142. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42143. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42144. import { Nullable } from "babylonjs/types";
  42145. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42146. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42147. module "babylonjs/Cameras/freeCameraInputsManager" {
  42148. interface FreeCameraInputsManager {
  42149. /**
  42150. * Add virtual joystick input support to the input manager.
  42151. * @returns the current input manager
  42152. */
  42153. addVirtualJoystick(): FreeCameraInputsManager;
  42154. }
  42155. }
  42156. /**
  42157. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42159. */
  42160. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42161. /**
  42162. * Defines the camera the input is attached to.
  42163. */
  42164. camera: FreeCamera;
  42165. private _leftjoystick;
  42166. private _rightjoystick;
  42167. /**
  42168. * Gets the left stick of the virtual joystick.
  42169. * @returns The virtual Joystick
  42170. */
  42171. getLeftJoystick(): VirtualJoystick;
  42172. /**
  42173. * Gets the right stick of the virtual joystick.
  42174. * @returns The virtual Joystick
  42175. */
  42176. getRightJoystick(): VirtualJoystick;
  42177. /**
  42178. * Update the current camera state depending on the inputs that have been used this frame.
  42179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42180. */
  42181. checkInputs(): void;
  42182. /**
  42183. * Attach the input controls to a specific dom element to get the input from.
  42184. * @param element Defines the element the controls should be listened from
  42185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42186. */
  42187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42188. /**
  42189. * Detach the current controls from the specified dom element.
  42190. * @param element Defines the element to stop listening the inputs from
  42191. */
  42192. detachControl(element: Nullable<HTMLElement>): void;
  42193. /**
  42194. * Gets the class name of the current intput.
  42195. * @returns the class name
  42196. */
  42197. getClassName(): string;
  42198. /**
  42199. * Get the friendly name associated with the input class.
  42200. * @returns the input friendly name
  42201. */
  42202. getSimpleName(): string;
  42203. }
  42204. }
  42205. declare module "babylonjs/Cameras/Inputs/index" {
  42206. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42207. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42208. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42209. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42210. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42211. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42212. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42213. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42214. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42215. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42216. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42217. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42218. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42219. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42220. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42221. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42222. }
  42223. declare module "babylonjs/Cameras/touchCamera" {
  42224. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42225. import { Scene } from "babylonjs/scene";
  42226. import { Vector3 } from "babylonjs/Maths/math.vector";
  42227. /**
  42228. * This represents a FPS type of camera controlled by touch.
  42229. * This is like a universal camera minus the Gamepad controls.
  42230. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42231. */
  42232. export class TouchCamera extends FreeCamera {
  42233. /**
  42234. * Defines the touch sensibility for rotation.
  42235. * The higher the faster.
  42236. */
  42237. get touchAngularSensibility(): number;
  42238. set touchAngularSensibility(value: number);
  42239. /**
  42240. * Defines the touch sensibility for move.
  42241. * The higher the faster.
  42242. */
  42243. get touchMoveSensibility(): number;
  42244. set touchMoveSensibility(value: number);
  42245. /**
  42246. * Instantiates a new touch camera.
  42247. * This represents a FPS type of camera controlled by touch.
  42248. * This is like a universal camera minus the Gamepad controls.
  42249. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42250. * @param name Define the name of the camera in the scene
  42251. * @param position Define the start position of the camera in the scene
  42252. * @param scene Define the scene the camera belongs to
  42253. */
  42254. constructor(name: string, position: Vector3, scene: Scene);
  42255. /**
  42256. * Gets the current object class name.
  42257. * @return the class name
  42258. */
  42259. getClassName(): string;
  42260. /** @hidden */
  42261. _setupInputs(): void;
  42262. }
  42263. }
  42264. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42265. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42266. import { Scene } from "babylonjs/scene";
  42267. import { Vector3 } from "babylonjs/Maths/math.vector";
  42268. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42269. import { Axis } from "babylonjs/Maths/math.axis";
  42270. /**
  42271. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42272. * being tilted forward or back and left or right.
  42273. */
  42274. export class DeviceOrientationCamera extends FreeCamera {
  42275. private _initialQuaternion;
  42276. private _quaternionCache;
  42277. private _tmpDragQuaternion;
  42278. private _disablePointerInputWhenUsingDeviceOrientation;
  42279. /**
  42280. * Creates a new device orientation camera
  42281. * @param name The name of the camera
  42282. * @param position The start position camera
  42283. * @param scene The scene the camera belongs to
  42284. */
  42285. constructor(name: string, position: Vector3, scene: Scene);
  42286. /**
  42287. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42288. */
  42289. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42290. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42291. private _dragFactor;
  42292. /**
  42293. * Enabled turning on the y axis when the orientation sensor is active
  42294. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42295. */
  42296. enableHorizontalDragging(dragFactor?: number): void;
  42297. /**
  42298. * Gets the current instance class name ("DeviceOrientationCamera").
  42299. * This helps avoiding instanceof at run time.
  42300. * @returns the class name
  42301. */
  42302. getClassName(): string;
  42303. /**
  42304. * @hidden
  42305. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42306. */
  42307. _checkInputs(): void;
  42308. /**
  42309. * Reset the camera to its default orientation on the specified axis only.
  42310. * @param axis The axis to reset
  42311. */
  42312. resetToCurrentRotation(axis?: Axis): void;
  42313. }
  42314. }
  42315. declare module "babylonjs/Gamepads/xboxGamepad" {
  42316. import { Observable } from "babylonjs/Misc/observable";
  42317. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42318. /**
  42319. * Defines supported buttons for XBox360 compatible gamepads
  42320. */
  42321. export enum Xbox360Button {
  42322. /** A */
  42323. A = 0,
  42324. /** B */
  42325. B = 1,
  42326. /** X */
  42327. X = 2,
  42328. /** Y */
  42329. Y = 3,
  42330. /** Left button */
  42331. LB = 4,
  42332. /** Right button */
  42333. RB = 5,
  42334. /** Back */
  42335. Back = 8,
  42336. /** Start */
  42337. Start = 9,
  42338. /** Left stick */
  42339. LeftStick = 10,
  42340. /** Right stick */
  42341. RightStick = 11
  42342. }
  42343. /** Defines values for XBox360 DPad */
  42344. export enum Xbox360Dpad {
  42345. /** Up */
  42346. Up = 12,
  42347. /** Down */
  42348. Down = 13,
  42349. /** Left */
  42350. Left = 14,
  42351. /** Right */
  42352. Right = 15
  42353. }
  42354. /**
  42355. * Defines a XBox360 gamepad
  42356. */
  42357. export class Xbox360Pad extends Gamepad {
  42358. private _leftTrigger;
  42359. private _rightTrigger;
  42360. private _onlefttriggerchanged;
  42361. private _onrighttriggerchanged;
  42362. private _onbuttondown;
  42363. private _onbuttonup;
  42364. private _ondpaddown;
  42365. private _ondpadup;
  42366. /** Observable raised when a button is pressed */
  42367. onButtonDownObservable: Observable<Xbox360Button>;
  42368. /** Observable raised when a button is released */
  42369. onButtonUpObservable: Observable<Xbox360Button>;
  42370. /** Observable raised when a pad is pressed */
  42371. onPadDownObservable: Observable<Xbox360Dpad>;
  42372. /** Observable raised when a pad is released */
  42373. onPadUpObservable: Observable<Xbox360Dpad>;
  42374. private _buttonA;
  42375. private _buttonB;
  42376. private _buttonX;
  42377. private _buttonY;
  42378. private _buttonBack;
  42379. private _buttonStart;
  42380. private _buttonLB;
  42381. private _buttonRB;
  42382. private _buttonLeftStick;
  42383. private _buttonRightStick;
  42384. private _dPadUp;
  42385. private _dPadDown;
  42386. private _dPadLeft;
  42387. private _dPadRight;
  42388. private _isXboxOnePad;
  42389. /**
  42390. * Creates a new XBox360 gamepad object
  42391. * @param id defines the id of this gamepad
  42392. * @param index defines its index
  42393. * @param gamepad defines the internal HTML gamepad object
  42394. * @param xboxOne defines if it is a XBox One gamepad
  42395. */
  42396. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42397. /**
  42398. * Defines the callback to call when left trigger is pressed
  42399. * @param callback defines the callback to use
  42400. */
  42401. onlefttriggerchanged(callback: (value: number) => void): void;
  42402. /**
  42403. * Defines the callback to call when right trigger is pressed
  42404. * @param callback defines the callback to use
  42405. */
  42406. onrighttriggerchanged(callback: (value: number) => void): void;
  42407. /**
  42408. * Gets the left trigger value
  42409. */
  42410. get leftTrigger(): number;
  42411. /**
  42412. * Sets the left trigger value
  42413. */
  42414. set leftTrigger(newValue: number);
  42415. /**
  42416. * Gets the right trigger value
  42417. */
  42418. get rightTrigger(): number;
  42419. /**
  42420. * Sets the right trigger value
  42421. */
  42422. set rightTrigger(newValue: number);
  42423. /**
  42424. * Defines the callback to call when a button is pressed
  42425. * @param callback defines the callback to use
  42426. */
  42427. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42428. /**
  42429. * Defines the callback to call when a button is released
  42430. * @param callback defines the callback to use
  42431. */
  42432. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42433. /**
  42434. * Defines the callback to call when a pad is pressed
  42435. * @param callback defines the callback to use
  42436. */
  42437. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42438. /**
  42439. * Defines the callback to call when a pad is released
  42440. * @param callback defines the callback to use
  42441. */
  42442. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42443. private _setButtonValue;
  42444. private _setDPadValue;
  42445. /**
  42446. * Gets the value of the `A` button
  42447. */
  42448. get buttonA(): number;
  42449. /**
  42450. * Sets the value of the `A` button
  42451. */
  42452. set buttonA(value: number);
  42453. /**
  42454. * Gets the value of the `B` button
  42455. */
  42456. get buttonB(): number;
  42457. /**
  42458. * Sets the value of the `B` button
  42459. */
  42460. set buttonB(value: number);
  42461. /**
  42462. * Gets the value of the `X` button
  42463. */
  42464. get buttonX(): number;
  42465. /**
  42466. * Sets the value of the `X` button
  42467. */
  42468. set buttonX(value: number);
  42469. /**
  42470. * Gets the value of the `Y` button
  42471. */
  42472. get buttonY(): number;
  42473. /**
  42474. * Sets the value of the `Y` button
  42475. */
  42476. set buttonY(value: number);
  42477. /**
  42478. * Gets the value of the `Start` button
  42479. */
  42480. get buttonStart(): number;
  42481. /**
  42482. * Sets the value of the `Start` button
  42483. */
  42484. set buttonStart(value: number);
  42485. /**
  42486. * Gets the value of the `Back` button
  42487. */
  42488. get buttonBack(): number;
  42489. /**
  42490. * Sets the value of the `Back` button
  42491. */
  42492. set buttonBack(value: number);
  42493. /**
  42494. * Gets the value of the `Left` button
  42495. */
  42496. get buttonLB(): number;
  42497. /**
  42498. * Sets the value of the `Left` button
  42499. */
  42500. set buttonLB(value: number);
  42501. /**
  42502. * Gets the value of the `Right` button
  42503. */
  42504. get buttonRB(): number;
  42505. /**
  42506. * Sets the value of the `Right` button
  42507. */
  42508. set buttonRB(value: number);
  42509. /**
  42510. * Gets the value of the Left joystick
  42511. */
  42512. get buttonLeftStick(): number;
  42513. /**
  42514. * Sets the value of the Left joystick
  42515. */
  42516. set buttonLeftStick(value: number);
  42517. /**
  42518. * Gets the value of the Right joystick
  42519. */
  42520. get buttonRightStick(): number;
  42521. /**
  42522. * Sets the value of the Right joystick
  42523. */
  42524. set buttonRightStick(value: number);
  42525. /**
  42526. * Gets the value of D-pad up
  42527. */
  42528. get dPadUp(): number;
  42529. /**
  42530. * Sets the value of D-pad up
  42531. */
  42532. set dPadUp(value: number);
  42533. /**
  42534. * Gets the value of D-pad down
  42535. */
  42536. get dPadDown(): number;
  42537. /**
  42538. * Sets the value of D-pad down
  42539. */
  42540. set dPadDown(value: number);
  42541. /**
  42542. * Gets the value of D-pad left
  42543. */
  42544. get dPadLeft(): number;
  42545. /**
  42546. * Sets the value of D-pad left
  42547. */
  42548. set dPadLeft(value: number);
  42549. /**
  42550. * Gets the value of D-pad right
  42551. */
  42552. get dPadRight(): number;
  42553. /**
  42554. * Sets the value of D-pad right
  42555. */
  42556. set dPadRight(value: number);
  42557. /**
  42558. * Force the gamepad to synchronize with device values
  42559. */
  42560. update(): void;
  42561. /**
  42562. * Disposes the gamepad
  42563. */
  42564. dispose(): void;
  42565. }
  42566. }
  42567. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42568. import { Observable } from "babylonjs/Misc/observable";
  42569. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42570. /**
  42571. * Defines supported buttons for DualShock compatible gamepads
  42572. */
  42573. export enum DualShockButton {
  42574. /** Cross */
  42575. Cross = 0,
  42576. /** Circle */
  42577. Circle = 1,
  42578. /** Square */
  42579. Square = 2,
  42580. /** Triangle */
  42581. Triangle = 3,
  42582. /** L1 */
  42583. L1 = 4,
  42584. /** R1 */
  42585. R1 = 5,
  42586. /** Share */
  42587. Share = 8,
  42588. /** Options */
  42589. Options = 9,
  42590. /** Left stick */
  42591. LeftStick = 10,
  42592. /** Right stick */
  42593. RightStick = 11
  42594. }
  42595. /** Defines values for DualShock DPad */
  42596. export enum DualShockDpad {
  42597. /** Up */
  42598. Up = 12,
  42599. /** Down */
  42600. Down = 13,
  42601. /** Left */
  42602. Left = 14,
  42603. /** Right */
  42604. Right = 15
  42605. }
  42606. /**
  42607. * Defines a DualShock gamepad
  42608. */
  42609. export class DualShockPad extends Gamepad {
  42610. private _leftTrigger;
  42611. private _rightTrigger;
  42612. private _onlefttriggerchanged;
  42613. private _onrighttriggerchanged;
  42614. private _onbuttondown;
  42615. private _onbuttonup;
  42616. private _ondpaddown;
  42617. private _ondpadup;
  42618. /** Observable raised when a button is pressed */
  42619. onButtonDownObservable: Observable<DualShockButton>;
  42620. /** Observable raised when a button is released */
  42621. onButtonUpObservable: Observable<DualShockButton>;
  42622. /** Observable raised when a pad is pressed */
  42623. onPadDownObservable: Observable<DualShockDpad>;
  42624. /** Observable raised when a pad is released */
  42625. onPadUpObservable: Observable<DualShockDpad>;
  42626. private _buttonCross;
  42627. private _buttonCircle;
  42628. private _buttonSquare;
  42629. private _buttonTriangle;
  42630. private _buttonShare;
  42631. private _buttonOptions;
  42632. private _buttonL1;
  42633. private _buttonR1;
  42634. private _buttonLeftStick;
  42635. private _buttonRightStick;
  42636. private _dPadUp;
  42637. private _dPadDown;
  42638. private _dPadLeft;
  42639. private _dPadRight;
  42640. /**
  42641. * Creates a new DualShock gamepad object
  42642. * @param id defines the id of this gamepad
  42643. * @param index defines its index
  42644. * @param gamepad defines the internal HTML gamepad object
  42645. */
  42646. constructor(id: string, index: number, gamepad: any);
  42647. /**
  42648. * Defines the callback to call when left trigger is pressed
  42649. * @param callback defines the callback to use
  42650. */
  42651. onlefttriggerchanged(callback: (value: number) => void): void;
  42652. /**
  42653. * Defines the callback to call when right trigger is pressed
  42654. * @param callback defines the callback to use
  42655. */
  42656. onrighttriggerchanged(callback: (value: number) => void): void;
  42657. /**
  42658. * Gets the left trigger value
  42659. */
  42660. get leftTrigger(): number;
  42661. /**
  42662. * Sets the left trigger value
  42663. */
  42664. set leftTrigger(newValue: number);
  42665. /**
  42666. * Gets the right trigger value
  42667. */
  42668. get rightTrigger(): number;
  42669. /**
  42670. * Sets the right trigger value
  42671. */
  42672. set rightTrigger(newValue: number);
  42673. /**
  42674. * Defines the callback to call when a button is pressed
  42675. * @param callback defines the callback to use
  42676. */
  42677. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42678. /**
  42679. * Defines the callback to call when a button is released
  42680. * @param callback defines the callback to use
  42681. */
  42682. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42683. /**
  42684. * Defines the callback to call when a pad is pressed
  42685. * @param callback defines the callback to use
  42686. */
  42687. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42688. /**
  42689. * Defines the callback to call when a pad is released
  42690. * @param callback defines the callback to use
  42691. */
  42692. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42693. private _setButtonValue;
  42694. private _setDPadValue;
  42695. /**
  42696. * Gets the value of the `Cross` button
  42697. */
  42698. get buttonCross(): number;
  42699. /**
  42700. * Sets the value of the `Cross` button
  42701. */
  42702. set buttonCross(value: number);
  42703. /**
  42704. * Gets the value of the `Circle` button
  42705. */
  42706. get buttonCircle(): number;
  42707. /**
  42708. * Sets the value of the `Circle` button
  42709. */
  42710. set buttonCircle(value: number);
  42711. /**
  42712. * Gets the value of the `Square` button
  42713. */
  42714. get buttonSquare(): number;
  42715. /**
  42716. * Sets the value of the `Square` button
  42717. */
  42718. set buttonSquare(value: number);
  42719. /**
  42720. * Gets the value of the `Triangle` button
  42721. */
  42722. get buttonTriangle(): number;
  42723. /**
  42724. * Sets the value of the `Triangle` button
  42725. */
  42726. set buttonTriangle(value: number);
  42727. /**
  42728. * Gets the value of the `Options` button
  42729. */
  42730. get buttonOptions(): number;
  42731. /**
  42732. * Sets the value of the `Options` button
  42733. */
  42734. set buttonOptions(value: number);
  42735. /**
  42736. * Gets the value of the `Share` button
  42737. */
  42738. get buttonShare(): number;
  42739. /**
  42740. * Sets the value of the `Share` button
  42741. */
  42742. set buttonShare(value: number);
  42743. /**
  42744. * Gets the value of the `L1` button
  42745. */
  42746. get buttonL1(): number;
  42747. /**
  42748. * Sets the value of the `L1` button
  42749. */
  42750. set buttonL1(value: number);
  42751. /**
  42752. * Gets the value of the `R1` button
  42753. */
  42754. get buttonR1(): number;
  42755. /**
  42756. * Sets the value of the `R1` button
  42757. */
  42758. set buttonR1(value: number);
  42759. /**
  42760. * Gets the value of the Left joystick
  42761. */
  42762. get buttonLeftStick(): number;
  42763. /**
  42764. * Sets the value of the Left joystick
  42765. */
  42766. set buttonLeftStick(value: number);
  42767. /**
  42768. * Gets the value of the Right joystick
  42769. */
  42770. get buttonRightStick(): number;
  42771. /**
  42772. * Sets the value of the Right joystick
  42773. */
  42774. set buttonRightStick(value: number);
  42775. /**
  42776. * Gets the value of D-pad up
  42777. */
  42778. get dPadUp(): number;
  42779. /**
  42780. * Sets the value of D-pad up
  42781. */
  42782. set dPadUp(value: number);
  42783. /**
  42784. * Gets the value of D-pad down
  42785. */
  42786. get dPadDown(): number;
  42787. /**
  42788. * Sets the value of D-pad down
  42789. */
  42790. set dPadDown(value: number);
  42791. /**
  42792. * Gets the value of D-pad left
  42793. */
  42794. get dPadLeft(): number;
  42795. /**
  42796. * Sets the value of D-pad left
  42797. */
  42798. set dPadLeft(value: number);
  42799. /**
  42800. * Gets the value of D-pad right
  42801. */
  42802. get dPadRight(): number;
  42803. /**
  42804. * Sets the value of D-pad right
  42805. */
  42806. set dPadRight(value: number);
  42807. /**
  42808. * Force the gamepad to synchronize with device values
  42809. */
  42810. update(): void;
  42811. /**
  42812. * Disposes the gamepad
  42813. */
  42814. dispose(): void;
  42815. }
  42816. }
  42817. declare module "babylonjs/Gamepads/gamepadManager" {
  42818. import { Observable } from "babylonjs/Misc/observable";
  42819. import { Nullable } from "babylonjs/types";
  42820. import { Scene } from "babylonjs/scene";
  42821. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42822. /**
  42823. * Manager for handling gamepads
  42824. */
  42825. export class GamepadManager {
  42826. private _scene?;
  42827. private _babylonGamepads;
  42828. private _oneGamepadConnected;
  42829. /** @hidden */
  42830. _isMonitoring: boolean;
  42831. private _gamepadEventSupported;
  42832. private _gamepadSupport?;
  42833. /**
  42834. * observable to be triggered when the gamepad controller has been connected
  42835. */
  42836. onGamepadConnectedObservable: Observable<Gamepad>;
  42837. /**
  42838. * observable to be triggered when the gamepad controller has been disconnected
  42839. */
  42840. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42841. private _onGamepadConnectedEvent;
  42842. private _onGamepadDisconnectedEvent;
  42843. /**
  42844. * Initializes the gamepad manager
  42845. * @param _scene BabylonJS scene
  42846. */
  42847. constructor(_scene?: Scene | undefined);
  42848. /**
  42849. * The gamepads in the game pad manager
  42850. */
  42851. get gamepads(): Gamepad[];
  42852. /**
  42853. * Get the gamepad controllers based on type
  42854. * @param type The type of gamepad controller
  42855. * @returns Nullable gamepad
  42856. */
  42857. getGamepadByType(type?: number): Nullable<Gamepad>;
  42858. /**
  42859. * Disposes the gamepad manager
  42860. */
  42861. dispose(): void;
  42862. private _addNewGamepad;
  42863. private _startMonitoringGamepads;
  42864. private _stopMonitoringGamepads;
  42865. /** @hidden */
  42866. _checkGamepadsStatus(): void;
  42867. private _updateGamepadObjects;
  42868. }
  42869. }
  42870. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42871. import { Nullable } from "babylonjs/types";
  42872. import { Scene } from "babylonjs/scene";
  42873. import { ISceneComponent } from "babylonjs/sceneComponent";
  42874. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42875. module "babylonjs/scene" {
  42876. interface Scene {
  42877. /** @hidden */
  42878. _gamepadManager: Nullable<GamepadManager>;
  42879. /**
  42880. * Gets the gamepad manager associated with the scene
  42881. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42882. */
  42883. gamepadManager: GamepadManager;
  42884. }
  42885. }
  42886. module "babylonjs/Cameras/freeCameraInputsManager" {
  42887. /**
  42888. * Interface representing a free camera inputs manager
  42889. */
  42890. interface FreeCameraInputsManager {
  42891. /**
  42892. * Adds gamepad input support to the FreeCameraInputsManager.
  42893. * @returns the FreeCameraInputsManager
  42894. */
  42895. addGamepad(): FreeCameraInputsManager;
  42896. }
  42897. }
  42898. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42899. /**
  42900. * Interface representing an arc rotate camera inputs manager
  42901. */
  42902. interface ArcRotateCameraInputsManager {
  42903. /**
  42904. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42905. * @returns the camera inputs manager
  42906. */
  42907. addGamepad(): ArcRotateCameraInputsManager;
  42908. }
  42909. }
  42910. /**
  42911. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42912. */
  42913. export class GamepadSystemSceneComponent implements ISceneComponent {
  42914. /**
  42915. * The component name helpfull to identify the component in the list of scene components.
  42916. */
  42917. readonly name: string;
  42918. /**
  42919. * The scene the component belongs to.
  42920. */
  42921. scene: Scene;
  42922. /**
  42923. * Creates a new instance of the component for the given scene
  42924. * @param scene Defines the scene to register the component in
  42925. */
  42926. constructor(scene: Scene);
  42927. /**
  42928. * Registers the component in a given scene
  42929. */
  42930. register(): void;
  42931. /**
  42932. * Rebuilds the elements related to this component in case of
  42933. * context lost for instance.
  42934. */
  42935. rebuild(): void;
  42936. /**
  42937. * Disposes the component and the associated ressources
  42938. */
  42939. dispose(): void;
  42940. private _beforeCameraUpdate;
  42941. }
  42942. }
  42943. declare module "babylonjs/Cameras/universalCamera" {
  42944. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42945. import { Scene } from "babylonjs/scene";
  42946. import { Vector3 } from "babylonjs/Maths/math.vector";
  42947. import "babylonjs/Gamepads/gamepadSceneComponent";
  42948. /**
  42949. * 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,
  42950. * which still works and will still be found in many Playgrounds.
  42951. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42952. */
  42953. export class UniversalCamera extends TouchCamera {
  42954. /**
  42955. * Defines the gamepad rotation sensiblity.
  42956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42957. */
  42958. get gamepadAngularSensibility(): number;
  42959. set gamepadAngularSensibility(value: number);
  42960. /**
  42961. * Defines the gamepad move sensiblity.
  42962. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42963. */
  42964. get gamepadMoveSensibility(): number;
  42965. set gamepadMoveSensibility(value: number);
  42966. /**
  42967. * 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,
  42968. * which still works and will still be found in many Playgrounds.
  42969. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42970. * @param name Define the name of the camera in the scene
  42971. * @param position Define the start position of the camera in the scene
  42972. * @param scene Define the scene the camera belongs to
  42973. */
  42974. constructor(name: string, position: Vector3, scene: Scene);
  42975. /**
  42976. * Gets the current object class name.
  42977. * @return the class name
  42978. */
  42979. getClassName(): string;
  42980. }
  42981. }
  42982. declare module "babylonjs/Cameras/gamepadCamera" {
  42983. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42984. import { Scene } from "babylonjs/scene";
  42985. import { Vector3 } from "babylonjs/Maths/math.vector";
  42986. /**
  42987. * This represents a FPS type of camera. This is only here for back compat purpose.
  42988. * Please use the UniversalCamera instead as both are identical.
  42989. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42990. */
  42991. export class GamepadCamera extends UniversalCamera {
  42992. /**
  42993. * Instantiates a new Gamepad Camera
  42994. * This represents a FPS type of camera. This is only here for back compat purpose.
  42995. * Please use the UniversalCamera instead as both are identical.
  42996. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42997. * @param name Define the name of the camera in the scene
  42998. * @param position Define the start position of the camera in the scene
  42999. * @param scene Define the scene the camera belongs to
  43000. */
  43001. constructor(name: string, position: Vector3, scene: Scene);
  43002. /**
  43003. * Gets the current object class name.
  43004. * @return the class name
  43005. */
  43006. getClassName(): string;
  43007. }
  43008. }
  43009. declare module "babylonjs/Shaders/pass.fragment" {
  43010. /** @hidden */
  43011. export var passPixelShader: {
  43012. name: string;
  43013. shader: string;
  43014. };
  43015. }
  43016. declare module "babylonjs/Shaders/passCube.fragment" {
  43017. /** @hidden */
  43018. export var passCubePixelShader: {
  43019. name: string;
  43020. shader: string;
  43021. };
  43022. }
  43023. declare module "babylonjs/PostProcesses/passPostProcess" {
  43024. import { Nullable } from "babylonjs/types";
  43025. import { Camera } from "babylonjs/Cameras/camera";
  43026. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43027. import { Engine } from "babylonjs/Engines/engine";
  43028. import "babylonjs/Shaders/pass.fragment";
  43029. import "babylonjs/Shaders/passCube.fragment";
  43030. /**
  43031. * PassPostProcess which produces an output the same as it's input
  43032. */
  43033. export class PassPostProcess extends PostProcess {
  43034. /**
  43035. * Creates the PassPostProcess
  43036. * @param name The name of the effect.
  43037. * @param options The required width/height ratio to downsize to before computing the render pass.
  43038. * @param camera The camera to apply the render pass to.
  43039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43040. * @param engine The engine which the post process will be applied. (default: current engine)
  43041. * @param reusable If the post process can be reused on the same frame. (default: false)
  43042. * @param textureType The type of texture to be used when performing the post processing.
  43043. * @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)
  43044. */
  43045. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43046. }
  43047. /**
  43048. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43049. */
  43050. export class PassCubePostProcess extends PostProcess {
  43051. private _face;
  43052. /**
  43053. * Gets or sets the cube face to display.
  43054. * * 0 is +X
  43055. * * 1 is -X
  43056. * * 2 is +Y
  43057. * * 3 is -Y
  43058. * * 4 is +Z
  43059. * * 5 is -Z
  43060. */
  43061. get face(): number;
  43062. set face(value: number);
  43063. /**
  43064. * Creates the PassCubePostProcess
  43065. * @param name The name of the effect.
  43066. * @param options The required width/height ratio to downsize to before computing the render pass.
  43067. * @param camera The camera to apply the render pass to.
  43068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43069. * @param engine The engine which the post process will be applied. (default: current engine)
  43070. * @param reusable If the post process can be reused on the same frame. (default: false)
  43071. * @param textureType The type of texture to be used when performing the post processing.
  43072. * @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)
  43073. */
  43074. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43075. }
  43076. }
  43077. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43078. /** @hidden */
  43079. export var anaglyphPixelShader: {
  43080. name: string;
  43081. shader: string;
  43082. };
  43083. }
  43084. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43085. import { Engine } from "babylonjs/Engines/engine";
  43086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43087. import { Camera } from "babylonjs/Cameras/camera";
  43088. import "babylonjs/Shaders/anaglyph.fragment";
  43089. /**
  43090. * Postprocess used to generate anaglyphic rendering
  43091. */
  43092. export class AnaglyphPostProcess extends PostProcess {
  43093. private _passedProcess;
  43094. /**
  43095. * Creates a new AnaglyphPostProcess
  43096. * @param name defines postprocess name
  43097. * @param options defines creation options or target ratio scale
  43098. * @param rigCameras defines cameras using this postprocess
  43099. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43100. * @param engine defines hosting engine
  43101. * @param reusable defines if the postprocess will be reused multiple times per frame
  43102. */
  43103. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43104. }
  43105. }
  43106. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43107. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43108. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43109. import { Scene } from "babylonjs/scene";
  43110. import { Vector3 } from "babylonjs/Maths/math.vector";
  43111. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43112. /**
  43113. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43114. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43115. */
  43116. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43117. /**
  43118. * Creates a new AnaglyphArcRotateCamera
  43119. * @param name defines camera name
  43120. * @param alpha defines alpha angle (in radians)
  43121. * @param beta defines beta angle (in radians)
  43122. * @param radius defines radius
  43123. * @param target defines camera target
  43124. * @param interaxialDistance defines distance between each color axis
  43125. * @param scene defines the hosting scene
  43126. */
  43127. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43128. /**
  43129. * Gets camera class name
  43130. * @returns AnaglyphArcRotateCamera
  43131. */
  43132. getClassName(): string;
  43133. }
  43134. }
  43135. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43136. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43137. import { Scene } from "babylonjs/scene";
  43138. import { Vector3 } from "babylonjs/Maths/math.vector";
  43139. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43140. /**
  43141. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43142. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43143. */
  43144. export class AnaglyphFreeCamera extends FreeCamera {
  43145. /**
  43146. * Creates a new AnaglyphFreeCamera
  43147. * @param name defines camera name
  43148. * @param position defines initial position
  43149. * @param interaxialDistance defines distance between each color axis
  43150. * @param scene defines the hosting scene
  43151. */
  43152. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43153. /**
  43154. * Gets camera class name
  43155. * @returns AnaglyphFreeCamera
  43156. */
  43157. getClassName(): string;
  43158. }
  43159. }
  43160. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43161. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43162. import { Scene } from "babylonjs/scene";
  43163. import { Vector3 } from "babylonjs/Maths/math.vector";
  43164. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43165. /**
  43166. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43167. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43168. */
  43169. export class AnaglyphGamepadCamera extends GamepadCamera {
  43170. /**
  43171. * Creates a new AnaglyphGamepadCamera
  43172. * @param name defines camera name
  43173. * @param position defines initial position
  43174. * @param interaxialDistance defines distance between each color axis
  43175. * @param scene defines the hosting scene
  43176. */
  43177. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43178. /**
  43179. * Gets camera class name
  43180. * @returns AnaglyphGamepadCamera
  43181. */
  43182. getClassName(): string;
  43183. }
  43184. }
  43185. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43186. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43187. import { Scene } from "babylonjs/scene";
  43188. import { Vector3 } from "babylonjs/Maths/math.vector";
  43189. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43190. /**
  43191. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43192. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43193. */
  43194. export class AnaglyphUniversalCamera extends UniversalCamera {
  43195. /**
  43196. * Creates a new AnaglyphUniversalCamera
  43197. * @param name defines camera name
  43198. * @param position defines initial position
  43199. * @param interaxialDistance defines distance between each color axis
  43200. * @param scene defines the hosting scene
  43201. */
  43202. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43203. /**
  43204. * Gets camera class name
  43205. * @returns AnaglyphUniversalCamera
  43206. */
  43207. getClassName(): string;
  43208. }
  43209. }
  43210. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43211. /** @hidden */
  43212. export var stereoscopicInterlacePixelShader: {
  43213. name: string;
  43214. shader: string;
  43215. };
  43216. }
  43217. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43218. import { Camera } from "babylonjs/Cameras/camera";
  43219. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43220. import { Engine } from "babylonjs/Engines/engine";
  43221. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43222. /**
  43223. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43224. */
  43225. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43226. private _stepSize;
  43227. private _passedProcess;
  43228. /**
  43229. * Initializes a StereoscopicInterlacePostProcessI
  43230. * @param name The name of the effect.
  43231. * @param rigCameras The rig cameras to be appled to the post process
  43232. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43233. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43235. * @param engine The engine which the post process will be applied. (default: current engine)
  43236. * @param reusable If the post process can be reused on the same frame. (default: false)
  43237. */
  43238. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43239. }
  43240. /**
  43241. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43242. */
  43243. export class StereoscopicInterlacePostProcess extends PostProcess {
  43244. private _stepSize;
  43245. private _passedProcess;
  43246. /**
  43247. * Initializes a StereoscopicInterlacePostProcess
  43248. * @param name The name of the effect.
  43249. * @param rigCameras The rig cameras to be appled to the post process
  43250. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43252. * @param engine The engine which the post process will be applied. (default: current engine)
  43253. * @param reusable If the post process can be reused on the same frame. (default: false)
  43254. */
  43255. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43256. }
  43257. }
  43258. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43259. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43260. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43261. import { Scene } from "babylonjs/scene";
  43262. import { Vector3 } from "babylonjs/Maths/math.vector";
  43263. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43264. /**
  43265. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43266. * @see http://doc.babylonjs.com/features/cameras
  43267. */
  43268. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43269. /**
  43270. * Creates a new StereoscopicArcRotateCamera
  43271. * @param name defines camera name
  43272. * @param alpha defines alpha angle (in radians)
  43273. * @param beta defines beta angle (in radians)
  43274. * @param radius defines radius
  43275. * @param target defines camera target
  43276. * @param interaxialDistance defines distance between each color axis
  43277. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43278. * @param scene defines the hosting scene
  43279. */
  43280. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43281. /**
  43282. * Gets camera class name
  43283. * @returns StereoscopicArcRotateCamera
  43284. */
  43285. getClassName(): string;
  43286. }
  43287. }
  43288. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43289. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43290. import { Scene } from "babylonjs/scene";
  43291. import { Vector3 } from "babylonjs/Maths/math.vector";
  43292. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43293. /**
  43294. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43295. * @see http://doc.babylonjs.com/features/cameras
  43296. */
  43297. export class StereoscopicFreeCamera extends FreeCamera {
  43298. /**
  43299. * Creates a new StereoscopicFreeCamera
  43300. * @param name defines camera name
  43301. * @param position defines initial position
  43302. * @param interaxialDistance defines distance between each color axis
  43303. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43304. * @param scene defines the hosting scene
  43305. */
  43306. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43307. /**
  43308. * Gets camera class name
  43309. * @returns StereoscopicFreeCamera
  43310. */
  43311. getClassName(): string;
  43312. }
  43313. }
  43314. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43315. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43316. import { Scene } from "babylonjs/scene";
  43317. import { Vector3 } from "babylonjs/Maths/math.vector";
  43318. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43319. /**
  43320. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43321. * @see http://doc.babylonjs.com/features/cameras
  43322. */
  43323. export class StereoscopicGamepadCamera extends GamepadCamera {
  43324. /**
  43325. * Creates a new StereoscopicGamepadCamera
  43326. * @param name defines camera name
  43327. * @param position defines initial position
  43328. * @param interaxialDistance defines distance between each color axis
  43329. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43330. * @param scene defines the hosting scene
  43331. */
  43332. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43333. /**
  43334. * Gets camera class name
  43335. * @returns StereoscopicGamepadCamera
  43336. */
  43337. getClassName(): string;
  43338. }
  43339. }
  43340. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43341. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43342. import { Scene } from "babylonjs/scene";
  43343. import { Vector3 } from "babylonjs/Maths/math.vector";
  43344. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43345. /**
  43346. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43347. * @see http://doc.babylonjs.com/features/cameras
  43348. */
  43349. export class StereoscopicUniversalCamera extends UniversalCamera {
  43350. /**
  43351. * Creates a new StereoscopicUniversalCamera
  43352. * @param name defines camera name
  43353. * @param position defines initial position
  43354. * @param interaxialDistance defines distance between each color axis
  43355. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43356. * @param scene defines the hosting scene
  43357. */
  43358. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43359. /**
  43360. * Gets camera class name
  43361. * @returns StereoscopicUniversalCamera
  43362. */
  43363. getClassName(): string;
  43364. }
  43365. }
  43366. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43367. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43368. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43369. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43370. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43371. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43372. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43373. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43374. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43375. }
  43376. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43377. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43378. import { Scene } from "babylonjs/scene";
  43379. import { Vector3 } from "babylonjs/Maths/math.vector";
  43380. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43381. /**
  43382. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43383. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43384. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43385. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43386. */
  43387. export class VirtualJoysticksCamera extends FreeCamera {
  43388. /**
  43389. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43390. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43391. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43392. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43393. * @param name Define the name of the camera in the scene
  43394. * @param position Define the start position of the camera in the scene
  43395. * @param scene Define the scene the camera belongs to
  43396. */
  43397. constructor(name: string, position: Vector3, scene: Scene);
  43398. /**
  43399. * Gets the current object class name.
  43400. * @return the class name
  43401. */
  43402. getClassName(): string;
  43403. }
  43404. }
  43405. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43406. import { Matrix } from "babylonjs/Maths/math.vector";
  43407. /**
  43408. * This represents all the required metrics to create a VR camera.
  43409. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43410. */
  43411. export class VRCameraMetrics {
  43412. /**
  43413. * Define the horizontal resolution off the screen.
  43414. */
  43415. hResolution: number;
  43416. /**
  43417. * Define the vertical resolution off the screen.
  43418. */
  43419. vResolution: number;
  43420. /**
  43421. * Define the horizontal screen size.
  43422. */
  43423. hScreenSize: number;
  43424. /**
  43425. * Define the vertical screen size.
  43426. */
  43427. vScreenSize: number;
  43428. /**
  43429. * Define the vertical screen center position.
  43430. */
  43431. vScreenCenter: number;
  43432. /**
  43433. * Define the distance of the eyes to the screen.
  43434. */
  43435. eyeToScreenDistance: number;
  43436. /**
  43437. * Define the distance between both lenses
  43438. */
  43439. lensSeparationDistance: number;
  43440. /**
  43441. * Define the distance between both viewer's eyes.
  43442. */
  43443. interpupillaryDistance: number;
  43444. /**
  43445. * Define the distortion factor of the VR postprocess.
  43446. * Please, touch with care.
  43447. */
  43448. distortionK: number[];
  43449. /**
  43450. * Define the chromatic aberration correction factors for the VR post process.
  43451. */
  43452. chromaAbCorrection: number[];
  43453. /**
  43454. * Define the scale factor of the post process.
  43455. * The smaller the better but the slower.
  43456. */
  43457. postProcessScaleFactor: number;
  43458. /**
  43459. * Define an offset for the lens center.
  43460. */
  43461. lensCenterOffset: number;
  43462. /**
  43463. * Define if the current vr camera should compensate the distortion of the lense or not.
  43464. */
  43465. compensateDistortion: boolean;
  43466. /**
  43467. * Defines if multiview should be enabled when rendering (Default: false)
  43468. */
  43469. multiviewEnabled: boolean;
  43470. /**
  43471. * Gets the rendering aspect ratio based on the provided resolutions.
  43472. */
  43473. get aspectRatio(): number;
  43474. /**
  43475. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43476. */
  43477. get aspectRatioFov(): number;
  43478. /**
  43479. * @hidden
  43480. */
  43481. get leftHMatrix(): Matrix;
  43482. /**
  43483. * @hidden
  43484. */
  43485. get rightHMatrix(): Matrix;
  43486. /**
  43487. * @hidden
  43488. */
  43489. get leftPreViewMatrix(): Matrix;
  43490. /**
  43491. * @hidden
  43492. */
  43493. get rightPreViewMatrix(): Matrix;
  43494. /**
  43495. * Get the default VRMetrics based on the most generic setup.
  43496. * @returns the default vr metrics
  43497. */
  43498. static GetDefault(): VRCameraMetrics;
  43499. }
  43500. }
  43501. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43502. /** @hidden */
  43503. export var vrDistortionCorrectionPixelShader: {
  43504. name: string;
  43505. shader: string;
  43506. };
  43507. }
  43508. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43509. import { Camera } from "babylonjs/Cameras/camera";
  43510. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43511. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43512. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43513. /**
  43514. * VRDistortionCorrectionPostProcess used for mobile VR
  43515. */
  43516. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43517. private _isRightEye;
  43518. private _distortionFactors;
  43519. private _postProcessScaleFactor;
  43520. private _lensCenterOffset;
  43521. private _scaleIn;
  43522. private _scaleFactor;
  43523. private _lensCenter;
  43524. /**
  43525. * Initializes the VRDistortionCorrectionPostProcess
  43526. * @param name The name of the effect.
  43527. * @param camera The camera to apply the render pass to.
  43528. * @param isRightEye If this is for the right eye distortion
  43529. * @param vrMetrics All the required metrics for the VR camera
  43530. */
  43531. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43532. }
  43533. }
  43534. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43535. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43536. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43537. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43538. import { Scene } from "babylonjs/scene";
  43539. import { Vector3 } from "babylonjs/Maths/math.vector";
  43540. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43541. import "babylonjs/Cameras/RigModes/vrRigMode";
  43542. /**
  43543. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43544. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43545. */
  43546. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43547. /**
  43548. * Creates a new VRDeviceOrientationArcRotateCamera
  43549. * @param name defines camera name
  43550. * @param alpha defines the camera rotation along the logitudinal axis
  43551. * @param beta defines the camera rotation along the latitudinal axis
  43552. * @param radius defines the camera distance from its target
  43553. * @param target defines the camera target
  43554. * @param scene defines the scene the camera belongs to
  43555. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43556. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43557. */
  43558. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43559. /**
  43560. * Gets camera class name
  43561. * @returns VRDeviceOrientationArcRotateCamera
  43562. */
  43563. getClassName(): string;
  43564. }
  43565. }
  43566. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43567. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43568. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43569. import { Scene } from "babylonjs/scene";
  43570. import { Vector3 } from "babylonjs/Maths/math.vector";
  43571. import "babylonjs/Cameras/RigModes/vrRigMode";
  43572. /**
  43573. * Camera used to simulate VR rendering (based on FreeCamera)
  43574. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43575. */
  43576. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43577. /**
  43578. * Creates a new VRDeviceOrientationFreeCamera
  43579. * @param name defines camera name
  43580. * @param position defines the start position of the camera
  43581. * @param scene defines the scene the camera belongs to
  43582. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43583. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43584. */
  43585. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43586. /**
  43587. * Gets camera class name
  43588. * @returns VRDeviceOrientationFreeCamera
  43589. */
  43590. getClassName(): string;
  43591. }
  43592. }
  43593. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43594. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43595. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43596. import { Scene } from "babylonjs/scene";
  43597. import { Vector3 } from "babylonjs/Maths/math.vector";
  43598. import "babylonjs/Gamepads/gamepadSceneComponent";
  43599. /**
  43600. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43601. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43602. */
  43603. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43604. /**
  43605. * Creates a new VRDeviceOrientationGamepadCamera
  43606. * @param name defines camera name
  43607. * @param position defines the start position of the camera
  43608. * @param scene defines the scene the camera belongs to
  43609. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43610. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43611. */
  43612. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43613. /**
  43614. * Gets camera class name
  43615. * @returns VRDeviceOrientationGamepadCamera
  43616. */
  43617. getClassName(): string;
  43618. }
  43619. }
  43620. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43621. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43622. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43623. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43624. /** @hidden */
  43625. export var imageProcessingPixelShader: {
  43626. name: string;
  43627. shader: string;
  43628. };
  43629. }
  43630. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43631. import { Nullable } from "babylonjs/types";
  43632. import { Color4 } from "babylonjs/Maths/math.color";
  43633. import { Camera } from "babylonjs/Cameras/camera";
  43634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43635. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43636. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43637. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43638. import { Engine } from "babylonjs/Engines/engine";
  43639. import "babylonjs/Shaders/imageProcessing.fragment";
  43640. import "babylonjs/Shaders/postprocess.vertex";
  43641. /**
  43642. * ImageProcessingPostProcess
  43643. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43644. */
  43645. export class ImageProcessingPostProcess extends PostProcess {
  43646. /**
  43647. * Default configuration related to image processing available in the PBR Material.
  43648. */
  43649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43650. /**
  43651. * Gets the image processing configuration used either in this material.
  43652. */
  43653. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43654. /**
  43655. * Sets the Default image processing configuration used either in the this material.
  43656. *
  43657. * If sets to null, the scene one is in use.
  43658. */
  43659. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43660. /**
  43661. * Keep track of the image processing observer to allow dispose and replace.
  43662. */
  43663. private _imageProcessingObserver;
  43664. /**
  43665. * Attaches a new image processing configuration to the PBR Material.
  43666. * @param configuration
  43667. */
  43668. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43669. /**
  43670. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43671. */
  43672. get colorCurves(): Nullable<ColorCurves>;
  43673. /**
  43674. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43675. */
  43676. set colorCurves(value: Nullable<ColorCurves>);
  43677. /**
  43678. * Gets wether the color curves effect is enabled.
  43679. */
  43680. get colorCurvesEnabled(): boolean;
  43681. /**
  43682. * Sets wether the color curves effect is enabled.
  43683. */
  43684. set colorCurvesEnabled(value: boolean);
  43685. /**
  43686. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43687. */
  43688. get colorGradingTexture(): Nullable<BaseTexture>;
  43689. /**
  43690. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43691. */
  43692. set colorGradingTexture(value: Nullable<BaseTexture>);
  43693. /**
  43694. * Gets wether the color grading effect is enabled.
  43695. */
  43696. get colorGradingEnabled(): boolean;
  43697. /**
  43698. * Gets wether the color grading effect is enabled.
  43699. */
  43700. set colorGradingEnabled(value: boolean);
  43701. /**
  43702. * Gets exposure used in the effect.
  43703. */
  43704. get exposure(): number;
  43705. /**
  43706. * Sets exposure used in the effect.
  43707. */
  43708. set exposure(value: number);
  43709. /**
  43710. * Gets wether tonemapping is enabled or not.
  43711. */
  43712. get toneMappingEnabled(): boolean;
  43713. /**
  43714. * Sets wether tonemapping is enabled or not
  43715. */
  43716. set toneMappingEnabled(value: boolean);
  43717. /**
  43718. * Gets the type of tone mapping effect.
  43719. */
  43720. get toneMappingType(): number;
  43721. /**
  43722. * Sets the type of tone mapping effect.
  43723. */
  43724. set toneMappingType(value: number);
  43725. /**
  43726. * Gets contrast used in the effect.
  43727. */
  43728. get contrast(): number;
  43729. /**
  43730. * Sets contrast used in the effect.
  43731. */
  43732. set contrast(value: number);
  43733. /**
  43734. * Gets Vignette stretch size.
  43735. */
  43736. get vignetteStretch(): number;
  43737. /**
  43738. * Sets Vignette stretch size.
  43739. */
  43740. set vignetteStretch(value: number);
  43741. /**
  43742. * Gets Vignette centre X Offset.
  43743. */
  43744. get vignetteCentreX(): number;
  43745. /**
  43746. * Sets Vignette centre X Offset.
  43747. */
  43748. set vignetteCentreX(value: number);
  43749. /**
  43750. * Gets Vignette centre Y Offset.
  43751. */
  43752. get vignetteCentreY(): number;
  43753. /**
  43754. * Sets Vignette centre Y Offset.
  43755. */
  43756. set vignetteCentreY(value: number);
  43757. /**
  43758. * Gets Vignette weight or intensity of the vignette effect.
  43759. */
  43760. get vignetteWeight(): number;
  43761. /**
  43762. * Sets Vignette weight or intensity of the vignette effect.
  43763. */
  43764. set vignetteWeight(value: number);
  43765. /**
  43766. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43767. * if vignetteEnabled is set to true.
  43768. */
  43769. get vignetteColor(): Color4;
  43770. /**
  43771. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43772. * if vignetteEnabled is set to true.
  43773. */
  43774. set vignetteColor(value: Color4);
  43775. /**
  43776. * Gets Camera field of view used by the Vignette effect.
  43777. */
  43778. get vignetteCameraFov(): number;
  43779. /**
  43780. * Sets Camera field of view used by the Vignette effect.
  43781. */
  43782. set vignetteCameraFov(value: number);
  43783. /**
  43784. * Gets the vignette blend mode allowing different kind of effect.
  43785. */
  43786. get vignetteBlendMode(): number;
  43787. /**
  43788. * Sets the vignette blend mode allowing different kind of effect.
  43789. */
  43790. set vignetteBlendMode(value: number);
  43791. /**
  43792. * Gets wether the vignette effect is enabled.
  43793. */
  43794. get vignetteEnabled(): boolean;
  43795. /**
  43796. * Sets wether the vignette effect is enabled.
  43797. */
  43798. set vignetteEnabled(value: boolean);
  43799. private _fromLinearSpace;
  43800. /**
  43801. * Gets wether the input of the processing is in Gamma or Linear Space.
  43802. */
  43803. get fromLinearSpace(): boolean;
  43804. /**
  43805. * Sets wether the input of the processing is in Gamma or Linear Space.
  43806. */
  43807. set fromLinearSpace(value: boolean);
  43808. /**
  43809. * Defines cache preventing GC.
  43810. */
  43811. private _defines;
  43812. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43813. /**
  43814. * "ImageProcessingPostProcess"
  43815. * @returns "ImageProcessingPostProcess"
  43816. */
  43817. getClassName(): string;
  43818. protected _updateParameters(): void;
  43819. dispose(camera?: Camera): void;
  43820. }
  43821. }
  43822. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43823. import { Scene } from "babylonjs/scene";
  43824. import { Color3 } from "babylonjs/Maths/math.color";
  43825. import { Mesh } from "babylonjs/Meshes/mesh";
  43826. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43827. import { Nullable } from "babylonjs/types";
  43828. /**
  43829. * Class containing static functions to help procedurally build meshes
  43830. */
  43831. export class GroundBuilder {
  43832. /**
  43833. * Creates a ground mesh
  43834. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43835. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43837. * @param name defines the name of the mesh
  43838. * @param options defines the options used to create the mesh
  43839. * @param scene defines the hosting scene
  43840. * @returns the ground mesh
  43841. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43842. */
  43843. static CreateGround(name: string, options: {
  43844. width?: number;
  43845. height?: number;
  43846. subdivisions?: number;
  43847. subdivisionsX?: number;
  43848. subdivisionsY?: number;
  43849. updatable?: boolean;
  43850. }, scene: any): Mesh;
  43851. /**
  43852. * Creates a tiled ground mesh
  43853. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43854. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43855. * * 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
  43856. * * 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
  43857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43858. * @param name defines the name of the mesh
  43859. * @param options defines the options used to create the mesh
  43860. * @param scene defines the hosting scene
  43861. * @returns the tiled ground mesh
  43862. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43863. */
  43864. static CreateTiledGround(name: string, options: {
  43865. xmin: number;
  43866. zmin: number;
  43867. xmax: number;
  43868. zmax: number;
  43869. subdivisions?: {
  43870. w: number;
  43871. h: number;
  43872. };
  43873. precision?: {
  43874. w: number;
  43875. h: number;
  43876. };
  43877. updatable?: boolean;
  43878. }, scene?: Nullable<Scene>): Mesh;
  43879. /**
  43880. * Creates a ground mesh from a height map
  43881. * * The parameter `url` sets the URL of the height map image resource.
  43882. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43883. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43884. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43885. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43886. * * 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.
  43887. * * 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).
  43888. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43890. * @param name defines the name of the mesh
  43891. * @param url defines the url to the height map
  43892. * @param options defines the options used to create the mesh
  43893. * @param scene defines the hosting scene
  43894. * @returns the ground mesh
  43895. * @see https://doc.babylonjs.com/babylon101/height_map
  43896. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43897. */
  43898. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43899. width?: number;
  43900. height?: number;
  43901. subdivisions?: number;
  43902. minHeight?: number;
  43903. maxHeight?: number;
  43904. colorFilter?: Color3;
  43905. alphaFilter?: number;
  43906. updatable?: boolean;
  43907. onReady?: (mesh: GroundMesh) => void;
  43908. }, scene?: Nullable<Scene>): GroundMesh;
  43909. }
  43910. }
  43911. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43912. import { Vector4 } from "babylonjs/Maths/math.vector";
  43913. import { Mesh } from "babylonjs/Meshes/mesh";
  43914. /**
  43915. * Class containing static functions to help procedurally build meshes
  43916. */
  43917. export class TorusBuilder {
  43918. /**
  43919. * Creates a torus mesh
  43920. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43921. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43922. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43926. * @param name defines the name of the mesh
  43927. * @param options defines the options used to create the mesh
  43928. * @param scene defines the hosting scene
  43929. * @returns the torus mesh
  43930. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43931. */
  43932. static CreateTorus(name: string, options: {
  43933. diameter?: number;
  43934. thickness?: number;
  43935. tessellation?: number;
  43936. updatable?: boolean;
  43937. sideOrientation?: number;
  43938. frontUVs?: Vector4;
  43939. backUVs?: Vector4;
  43940. }, scene: any): Mesh;
  43941. }
  43942. }
  43943. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43944. import { Vector4 } from "babylonjs/Maths/math.vector";
  43945. import { Color4 } from "babylonjs/Maths/math.color";
  43946. import { Mesh } from "babylonjs/Meshes/mesh";
  43947. /**
  43948. * Class containing static functions to help procedurally build meshes
  43949. */
  43950. export class CylinderBuilder {
  43951. /**
  43952. * Creates a cylinder or a cone mesh
  43953. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43954. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43955. * * 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.
  43956. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43957. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43958. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43959. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43960. * * 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).
  43961. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43962. * * 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).
  43963. * * 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
  43964. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43965. * * 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
  43966. * * 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.
  43967. * * If `enclose` is false, a ring surface is one element.
  43968. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43969. * * 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
  43970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43973. * @param name defines the name of the mesh
  43974. * @param options defines the options used to create the mesh
  43975. * @param scene defines the hosting scene
  43976. * @returns the cylinder mesh
  43977. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43978. */
  43979. static CreateCylinder(name: string, options: {
  43980. height?: number;
  43981. diameterTop?: number;
  43982. diameterBottom?: number;
  43983. diameter?: number;
  43984. tessellation?: number;
  43985. subdivisions?: number;
  43986. arc?: number;
  43987. faceColors?: Color4[];
  43988. faceUV?: Vector4[];
  43989. updatable?: boolean;
  43990. hasRings?: boolean;
  43991. enclose?: boolean;
  43992. cap?: number;
  43993. sideOrientation?: number;
  43994. frontUVs?: Vector4;
  43995. backUVs?: Vector4;
  43996. }, scene: any): Mesh;
  43997. }
  43998. }
  43999. declare module "babylonjs/XR/webXRTypes" {
  44000. import { Nullable } from "babylonjs/types";
  44001. import { IDisposable } from "babylonjs/scene";
  44002. /**
  44003. * States of the webXR experience
  44004. */
  44005. export enum WebXRState {
  44006. /**
  44007. * Transitioning to being in XR mode
  44008. */
  44009. ENTERING_XR = 0,
  44010. /**
  44011. * Transitioning to non XR mode
  44012. */
  44013. EXITING_XR = 1,
  44014. /**
  44015. * In XR mode and presenting
  44016. */
  44017. IN_XR = 2,
  44018. /**
  44019. * Not entered XR mode
  44020. */
  44021. NOT_IN_XR = 3
  44022. }
  44023. /**
  44024. * Abstraction of the XR render target
  44025. */
  44026. export interface WebXRRenderTarget extends IDisposable {
  44027. /**
  44028. * xrpresent context of the canvas which can be used to display/mirror xr content
  44029. */
  44030. canvasContext: WebGLRenderingContext;
  44031. /**
  44032. * xr layer for the canvas
  44033. */
  44034. xrLayer: Nullable<XRWebGLLayer>;
  44035. /**
  44036. * Initializes the xr layer for the session
  44037. * @param xrSession xr session
  44038. * @returns a promise that will resolve once the XR Layer has been created
  44039. */
  44040. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44041. }
  44042. }
  44043. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44044. import { Nullable } from "babylonjs/types";
  44045. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44046. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44047. /**
  44048. * COnfiguration object for WebXR output canvas
  44049. */
  44050. export class WebXRManagedOutputCanvasOptions {
  44051. /**
  44052. * An optional canvas in case you wish to create it yourself and provide it here.
  44053. * If not provided, a new canvas will be created
  44054. */
  44055. canvasElement?: HTMLCanvasElement;
  44056. /**
  44057. * Options for this XR Layer output
  44058. */
  44059. canvasOptions?: XRWebGLLayerOptions;
  44060. /**
  44061. * CSS styling for a newly created canvas (if not provided)
  44062. */
  44063. newCanvasCssStyle?: string;
  44064. /**
  44065. * Get the default values of the configuration object
  44066. * @returns default values of this configuration object
  44067. */
  44068. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44069. }
  44070. /**
  44071. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44072. */
  44073. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44074. private _options;
  44075. private _canvas;
  44076. private _engine;
  44077. /**
  44078. * Rendering context of the canvas which can be used to display/mirror xr content
  44079. */
  44080. canvasContext: WebGLRenderingContext;
  44081. /**
  44082. * xr layer for the canvas
  44083. */
  44084. xrLayer: Nullable<XRWebGLLayer>;
  44085. /**
  44086. * Initializes the canvas to be added/removed upon entering/exiting xr
  44087. * @param _xrSessionManager The XR Session manager
  44088. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44089. */
  44090. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44091. /**
  44092. * Disposes of the object
  44093. */
  44094. dispose(): void;
  44095. /**
  44096. * Initializes the xr layer for the session
  44097. * @param xrSession xr session
  44098. * @returns a promise that will resolve once the XR Layer has been created
  44099. */
  44100. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44101. private _addCanvas;
  44102. private _removeCanvas;
  44103. private _setManagedOutputCanvas;
  44104. }
  44105. }
  44106. declare module "babylonjs/XR/webXRSessionManager" {
  44107. import { Observable } from "babylonjs/Misc/observable";
  44108. import { Nullable } from "babylonjs/types";
  44109. import { IDisposable, Scene } from "babylonjs/scene";
  44110. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44111. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44112. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44113. /**
  44114. * Manages an XRSession to work with Babylon's engine
  44115. * @see https://doc.babylonjs.com/how_to/webxr
  44116. */
  44117. export class WebXRSessionManager implements IDisposable {
  44118. /** The scene which the session should be created for */
  44119. scene: Scene;
  44120. private _referenceSpace;
  44121. private _rttProvider;
  44122. private _sessionEnded;
  44123. private _xrNavigator;
  44124. private baseLayer;
  44125. /**
  44126. * The base reference space from which the session started. good if you want to reset your
  44127. * reference space
  44128. */
  44129. baseReferenceSpace: XRReferenceSpace;
  44130. /**
  44131. * Current XR frame
  44132. */
  44133. currentFrame: Nullable<XRFrame>;
  44134. /** WebXR timestamp updated every frame */
  44135. currentTimestamp: number;
  44136. /**
  44137. * Used just in case of a failure to initialize an immersive session.
  44138. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44139. */
  44140. defaultHeightCompensation: number;
  44141. /**
  44142. * Fires every time a new xrFrame arrives which can be used to update the camera
  44143. */
  44144. onXRFrameObservable: Observable<XRFrame>;
  44145. /**
  44146. * Fires when the reference space changed
  44147. */
  44148. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44149. /**
  44150. * Fires when the xr session is ended either by the device or manually done
  44151. */
  44152. onXRSessionEnded: Observable<any>;
  44153. /**
  44154. * Fires when the xr session is ended either by the device or manually done
  44155. */
  44156. onXRSessionInit: Observable<XRSession>;
  44157. /**
  44158. * Underlying xr session
  44159. */
  44160. session: XRSession;
  44161. /**
  44162. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44163. * or get the offset the player is currently at.
  44164. */
  44165. viewerReferenceSpace: XRReferenceSpace;
  44166. /**
  44167. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44168. * @param scene The scene which the session should be created for
  44169. */
  44170. constructor(
  44171. /** The scene which the session should be created for */
  44172. scene: Scene);
  44173. /**
  44174. * The current reference space used in this session. This reference space can constantly change!
  44175. * It is mainly used to offset the camera's position.
  44176. */
  44177. get referenceSpace(): XRReferenceSpace;
  44178. /**
  44179. * Set a new reference space and triggers the observable
  44180. */
  44181. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44182. /**
  44183. * Disposes of the session manager
  44184. */
  44185. dispose(): void;
  44186. /**
  44187. * Stops the xrSession and restores the render loop
  44188. * @returns Promise which resolves after it exits XR
  44189. */
  44190. exitXRAsync(): Promise<void>;
  44191. /**
  44192. * Gets the correct render target texture to be rendered this frame for this eye
  44193. * @param eye the eye for which to get the render target
  44194. * @returns the render target for the specified eye
  44195. */
  44196. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44197. /**
  44198. * Creates a WebXRRenderTarget object for the XR session
  44199. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44200. * @param options optional options to provide when creating a new render target
  44201. * @returns a WebXR render target to which the session can render
  44202. */
  44203. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44204. /**
  44205. * Initializes the manager
  44206. * After initialization enterXR can be called to start an XR session
  44207. * @returns Promise which resolves after it is initialized
  44208. */
  44209. initializeAsync(): Promise<void>;
  44210. /**
  44211. * Initializes an xr session
  44212. * @param xrSessionMode mode to initialize
  44213. * @param xrSessionInit defines optional and required values to pass to the session builder
  44214. * @returns a promise which will resolve once the session has been initialized
  44215. */
  44216. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44217. /**
  44218. * Checks if a session would be supported for the creation options specified
  44219. * @param sessionMode session mode to check if supported eg. immersive-vr
  44220. * @returns A Promise that resolves to true if supported and false if not
  44221. */
  44222. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44223. /**
  44224. * Resets the reference space to the one started the session
  44225. */
  44226. resetReferenceSpace(): void;
  44227. /**
  44228. * Starts rendering to the xr layer
  44229. */
  44230. runXRRenderLoop(): void;
  44231. /**
  44232. * Sets the reference space on the xr session
  44233. * @param referenceSpaceType space to set
  44234. * @returns a promise that will resolve once the reference space has been set
  44235. */
  44236. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44237. /**
  44238. * Updates the render state of the session
  44239. * @param state state to set
  44240. * @returns a promise that resolves once the render state has been updated
  44241. */
  44242. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44243. /**
  44244. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44245. * @param sessionMode defines the session to test
  44246. * @returns a promise with boolean as final value
  44247. */
  44248. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44249. private _createRenderTargetTexture;
  44250. }
  44251. }
  44252. declare module "babylonjs/XR/webXRCamera" {
  44253. import { Scene } from "babylonjs/scene";
  44254. import { Camera } from "babylonjs/Cameras/camera";
  44255. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44256. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44257. /**
  44258. * WebXR Camera which holds the views for the xrSession
  44259. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44260. */
  44261. export class WebXRCamera extends FreeCamera {
  44262. private _xrSessionManager;
  44263. private _firstFrame;
  44264. private _referenceQuaternion;
  44265. private _referencedPosition;
  44266. private _xrInvPositionCache;
  44267. private _xrInvQuaternionCache;
  44268. /**
  44269. * Should position compensation execute on first frame.
  44270. * This is used when copying the position from a native (non XR) camera
  44271. */
  44272. compensateOnFirstFrame: boolean;
  44273. /**
  44274. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44275. * @param name the name of the camera
  44276. * @param scene the scene to add the camera to
  44277. * @param _xrSessionManager a constructed xr session manager
  44278. */
  44279. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44280. /**
  44281. * Return the user's height, unrelated to the current ground.
  44282. * This will be the y position of this camera, when ground level is 0.
  44283. */
  44284. get realWorldHeight(): number;
  44285. /** @hidden */
  44286. _updateForDualEyeDebugging(): void;
  44287. /**
  44288. * Sets this camera's transformation based on a non-vr camera
  44289. * @param otherCamera the non-vr camera to copy the transformation from
  44290. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44291. */
  44292. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44293. /**
  44294. * Gets the current instance class name ("WebXRCamera").
  44295. * @returns the class name
  44296. */
  44297. getClassName(): string;
  44298. private _updateFromXRSession;
  44299. private _updateNumberOfRigCameras;
  44300. private _updateReferenceSpace;
  44301. private _updateReferenceSpaceOffset;
  44302. }
  44303. }
  44304. declare module "babylonjs/XR/webXRFeaturesManager" {
  44305. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44306. import { IDisposable } from "babylonjs/scene";
  44307. /**
  44308. * Defining the interface required for a (webxr) feature
  44309. */
  44310. export interface IWebXRFeature extends IDisposable {
  44311. /**
  44312. * Is this feature attached
  44313. */
  44314. attached: boolean;
  44315. /**
  44316. * Should auto-attach be disabled?
  44317. */
  44318. disableAutoAttach: boolean;
  44319. /**
  44320. * Attach the feature to the session
  44321. * Will usually be called by the features manager
  44322. *
  44323. * @param force should attachment be forced (even when already attached)
  44324. * @returns true if successful.
  44325. */
  44326. attach(force?: boolean): boolean;
  44327. /**
  44328. * Detach the feature from the session
  44329. * Will usually be called by the features manager
  44330. *
  44331. * @returns true if successful.
  44332. */
  44333. detach(): boolean;
  44334. }
  44335. /**
  44336. * A list of the currently available features without referencing them
  44337. */
  44338. export class WebXRFeatureName {
  44339. /**
  44340. * The name of the anchor system feature
  44341. */
  44342. static ANCHOR_SYSTEM: string;
  44343. /**
  44344. * The name of the background remover feature
  44345. */
  44346. static BACKGROUND_REMOVER: string;
  44347. /**
  44348. * The name of the hit test feature
  44349. */
  44350. static HIT_TEST: string;
  44351. /**
  44352. * physics impostors for xr controllers feature
  44353. */
  44354. static PHYSICS_CONTROLLERS: string;
  44355. /**
  44356. * The name of the plane detection feature
  44357. */
  44358. static PLANE_DETECTION: string;
  44359. /**
  44360. * The name of the pointer selection feature
  44361. */
  44362. static POINTER_SELECTION: string;
  44363. /**
  44364. * The name of the teleportation feature
  44365. */
  44366. static TELEPORTATION: string;
  44367. }
  44368. /**
  44369. * Defining the constructor of a feature. Used to register the modules.
  44370. */
  44371. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44372. /**
  44373. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44374. * It is mainly used in AR sessions.
  44375. *
  44376. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44377. */
  44378. export class WebXRFeaturesManager implements IDisposable {
  44379. private _xrSessionManager;
  44380. private static readonly _AvailableFeatures;
  44381. private _features;
  44382. /**
  44383. * constructs a new features manages.
  44384. *
  44385. * @param _xrSessionManager an instance of WebXRSessionManager
  44386. */
  44387. constructor(_xrSessionManager: WebXRSessionManager);
  44388. /**
  44389. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44390. * Mainly used internally.
  44391. *
  44392. * @param featureName the name of the feature to register
  44393. * @param constructorFunction the function used to construct the module
  44394. * @param version the (babylon) version of the module
  44395. * @param stable is that a stable version of this module
  44396. */
  44397. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44398. /**
  44399. * Returns a constructor of a specific feature.
  44400. *
  44401. * @param featureName the name of the feature to construct
  44402. * @param version the version of the feature to load
  44403. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44404. * @param options optional options provided to the module.
  44405. * @returns a function that, when called, will return a new instance of this feature
  44406. */
  44407. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44408. /**
  44409. * Can be used to return the list of features currently registered
  44410. *
  44411. * @returns an Array of available features
  44412. */
  44413. static GetAvailableFeatures(): string[];
  44414. /**
  44415. * Gets the versions available for a specific feature
  44416. * @param featureName the name of the feature
  44417. * @returns an array with the available versions
  44418. */
  44419. static GetAvailableVersions(featureName: string): string[];
  44420. /**
  44421. * Return the latest unstable version of this feature
  44422. * @param featureName the name of the feature to search
  44423. * @returns the version number. if not found will return -1
  44424. */
  44425. static GetLatestVersionOfFeature(featureName: string): number;
  44426. /**
  44427. * Return the latest stable version of this feature
  44428. * @param featureName the name of the feature to search
  44429. * @returns the version number. if not found will return -1
  44430. */
  44431. static GetStableVersionOfFeature(featureName: string): number;
  44432. /**
  44433. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44434. * Can be used during a session to start a feature
  44435. * @param featureName the name of feature to attach
  44436. */
  44437. attachFeature(featureName: string): void;
  44438. /**
  44439. * Can be used inside a session or when the session ends to detach a specific feature
  44440. * @param featureName the name of the feature to detach
  44441. */
  44442. detachFeature(featureName: string): void;
  44443. /**
  44444. * Used to disable an already-enabled feature
  44445. * The feature will be disposed and will be recreated once enabled.
  44446. * @param featureName the feature to disable
  44447. * @returns true if disable was successful
  44448. */
  44449. disableFeature(featureName: string | {
  44450. Name: string;
  44451. }): boolean;
  44452. /**
  44453. * dispose this features manager
  44454. */
  44455. dispose(): void;
  44456. /**
  44457. * 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.
  44458. * 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.
  44459. *
  44460. * @param featureName the name of the feature to load or the class of the feature
  44461. * @param version optional version to load. if not provided the latest version will be enabled
  44462. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44463. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44464. * @returns a new constructed feature or throws an error if feature not found.
  44465. */
  44466. enableFeature(featureName: string | {
  44467. Name: string;
  44468. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44469. /**
  44470. * get the implementation of an enabled feature.
  44471. * @param featureName the name of the feature to load
  44472. * @returns the feature class, if found
  44473. */
  44474. getEnabledFeature(featureName: string): IWebXRFeature;
  44475. /**
  44476. * Get the list of enabled features
  44477. * @returns an array of enabled features
  44478. */
  44479. getEnabledFeatures(): string[];
  44480. }
  44481. }
  44482. declare module "babylonjs/XR/webXRExperienceHelper" {
  44483. import { Observable } from "babylonjs/Misc/observable";
  44484. import { IDisposable, Scene } from "babylonjs/scene";
  44485. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44486. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44487. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44488. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44489. /**
  44490. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44491. * @see https://doc.babylonjs.com/how_to/webxr
  44492. */
  44493. export class WebXRExperienceHelper implements IDisposable {
  44494. private scene;
  44495. private _nonVRCamera;
  44496. private _originalSceneAutoClear;
  44497. private _supported;
  44498. /**
  44499. * Camera used to render xr content
  44500. */
  44501. camera: WebXRCamera;
  44502. /** A features manager for this xr session */
  44503. featuresManager: WebXRFeaturesManager;
  44504. /**
  44505. * Observers registered here will be triggered after the camera's initial transformation is set
  44506. * This can be used to set a different ground level or an extra rotation.
  44507. *
  44508. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44509. * to the position set after this observable is done executing.
  44510. */
  44511. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44512. /**
  44513. * Fires when the state of the experience helper has changed
  44514. */
  44515. onStateChangedObservable: Observable<WebXRState>;
  44516. /** Session manager used to keep track of xr session */
  44517. sessionManager: WebXRSessionManager;
  44518. /**
  44519. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44520. */
  44521. state: WebXRState;
  44522. /**
  44523. * Creates a WebXRExperienceHelper
  44524. * @param scene The scene the helper should be created in
  44525. */
  44526. private constructor();
  44527. /**
  44528. * Creates the experience helper
  44529. * @param scene the scene to attach the experience helper to
  44530. * @returns a promise for the experience helper
  44531. */
  44532. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44533. /**
  44534. * Disposes of the experience helper
  44535. */
  44536. dispose(): void;
  44537. /**
  44538. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44539. * @param sessionMode options for the XR session
  44540. * @param referenceSpaceType frame of reference of the XR session
  44541. * @param renderTarget the output canvas that will be used to enter XR mode
  44542. * @returns promise that resolves after xr mode has entered
  44543. */
  44544. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44545. /**
  44546. * Exits XR mode and returns the scene to its original state
  44547. * @returns promise that resolves after xr mode has exited
  44548. */
  44549. exitXRAsync(): Promise<void>;
  44550. private _nonXRToXRCamera;
  44551. private _setState;
  44552. }
  44553. }
  44554. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44555. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44556. import { Observable } from "babylonjs/Misc/observable";
  44557. import { IDisposable } from "babylonjs/scene";
  44558. /**
  44559. * X-Y values for axes in WebXR
  44560. */
  44561. export interface IWebXRMotionControllerAxesValue {
  44562. /**
  44563. * The value of the x axis
  44564. */
  44565. x: number;
  44566. /**
  44567. * The value of the y-axis
  44568. */
  44569. y: number;
  44570. }
  44571. /**
  44572. * changed / previous values for the values of this component
  44573. */
  44574. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44575. /**
  44576. * current (this frame) value
  44577. */
  44578. current: T;
  44579. /**
  44580. * previous (last change) value
  44581. */
  44582. previous: T;
  44583. }
  44584. /**
  44585. * Represents changes in the component between current frame and last values recorded
  44586. */
  44587. export interface IWebXRMotionControllerComponentChanges {
  44588. /**
  44589. * will be populated with previous and current values if axes changed
  44590. */
  44591. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44592. /**
  44593. * will be populated with previous and current values if pressed changed
  44594. */
  44595. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44596. /**
  44597. * will be populated with previous and current values if touched changed
  44598. */
  44599. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44600. /**
  44601. * will be populated with previous and current values if value changed
  44602. */
  44603. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44604. }
  44605. /**
  44606. * This class represents a single component (for example button or thumbstick) of a motion controller
  44607. */
  44608. export class WebXRControllerComponent implements IDisposable {
  44609. /**
  44610. * the id of this component
  44611. */
  44612. id: string;
  44613. /**
  44614. * the type of the component
  44615. */
  44616. type: MotionControllerComponentType;
  44617. private _buttonIndex;
  44618. private _axesIndices;
  44619. private _axes;
  44620. private _changes;
  44621. private _currentValue;
  44622. private _hasChanges;
  44623. private _pressed;
  44624. private _touched;
  44625. /**
  44626. * button component type
  44627. */
  44628. static BUTTON_TYPE: MotionControllerComponentType;
  44629. /**
  44630. * squeeze component type
  44631. */
  44632. static SQUEEZE_TYPE: MotionControllerComponentType;
  44633. /**
  44634. * Thumbstick component type
  44635. */
  44636. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44637. /**
  44638. * Touchpad component type
  44639. */
  44640. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44641. /**
  44642. * trigger component type
  44643. */
  44644. static TRIGGER_TYPE: MotionControllerComponentType;
  44645. /**
  44646. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44647. * the axes data changes
  44648. */
  44649. onAxisValueChangedObservable: Observable<{
  44650. x: number;
  44651. y: number;
  44652. }>;
  44653. /**
  44654. * Observers registered here will be triggered when the state of a button changes
  44655. * State change is either pressed / touched / value
  44656. */
  44657. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44658. /**
  44659. * Creates a new component for a motion controller.
  44660. * It is created by the motion controller itself
  44661. *
  44662. * @param id the id of this component
  44663. * @param type the type of the component
  44664. * @param _buttonIndex index in the buttons array of the gamepad
  44665. * @param _axesIndices indices of the values in the axes array of the gamepad
  44666. */
  44667. constructor(
  44668. /**
  44669. * the id of this component
  44670. */
  44671. id: string,
  44672. /**
  44673. * the type of the component
  44674. */
  44675. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44676. /**
  44677. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44678. */
  44679. get axes(): IWebXRMotionControllerAxesValue;
  44680. /**
  44681. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44682. */
  44683. get changes(): IWebXRMotionControllerComponentChanges;
  44684. /**
  44685. * Return whether or not the component changed the last frame
  44686. */
  44687. get hasChanges(): boolean;
  44688. /**
  44689. * is the button currently pressed
  44690. */
  44691. get pressed(): boolean;
  44692. /**
  44693. * is the button currently touched
  44694. */
  44695. get touched(): boolean;
  44696. /**
  44697. * Get the current value of this component
  44698. */
  44699. get value(): number;
  44700. /**
  44701. * Dispose this component
  44702. */
  44703. dispose(): void;
  44704. /**
  44705. * Are there axes correlating to this component
  44706. * @return true is axes data is available
  44707. */
  44708. isAxes(): boolean;
  44709. /**
  44710. * Is this component a button (hence - pressable)
  44711. * @returns true if can be pressed
  44712. */
  44713. isButton(): boolean;
  44714. /**
  44715. * update this component using the gamepad object it is in. Called on every frame
  44716. * @param nativeController the native gamepad controller object
  44717. */
  44718. update(nativeController: IMinimalMotionControllerObject): void;
  44719. }
  44720. }
  44721. declare module "babylonjs/Loading/sceneLoader" {
  44722. import { Observable } from "babylonjs/Misc/observable";
  44723. import { Nullable } from "babylonjs/types";
  44724. import { Scene } from "babylonjs/scene";
  44725. import { Engine } from "babylonjs/Engines/engine";
  44726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44727. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44728. import { AssetContainer } from "babylonjs/assetContainer";
  44729. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44730. import { Skeleton } from "babylonjs/Bones/skeleton";
  44731. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44732. import { WebRequest } from "babylonjs/Misc/webRequest";
  44733. /**
  44734. * Class used to represent data loading progression
  44735. */
  44736. export class SceneLoaderProgressEvent {
  44737. /** defines if data length to load can be evaluated */
  44738. readonly lengthComputable: boolean;
  44739. /** defines the loaded data length */
  44740. readonly loaded: number;
  44741. /** defines the data length to load */
  44742. readonly total: number;
  44743. /**
  44744. * Create a new progress event
  44745. * @param lengthComputable defines if data length to load can be evaluated
  44746. * @param loaded defines the loaded data length
  44747. * @param total defines the data length to load
  44748. */
  44749. constructor(
  44750. /** defines if data length to load can be evaluated */
  44751. lengthComputable: boolean,
  44752. /** defines the loaded data length */
  44753. loaded: number,
  44754. /** defines the data length to load */
  44755. total: number);
  44756. /**
  44757. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44758. * @param event defines the source event
  44759. * @returns a new SceneLoaderProgressEvent
  44760. */
  44761. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44762. }
  44763. /**
  44764. * Interface used by SceneLoader plugins to define supported file extensions
  44765. */
  44766. export interface ISceneLoaderPluginExtensions {
  44767. /**
  44768. * Defines the list of supported extensions
  44769. */
  44770. [extension: string]: {
  44771. isBinary: boolean;
  44772. };
  44773. }
  44774. /**
  44775. * Interface used by SceneLoader plugin factory
  44776. */
  44777. export interface ISceneLoaderPluginFactory {
  44778. /**
  44779. * Defines the name of the factory
  44780. */
  44781. name: string;
  44782. /**
  44783. * Function called to create a new plugin
  44784. * @return the new plugin
  44785. */
  44786. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44787. /**
  44788. * The callback that returns true if the data can be directly loaded.
  44789. * @param data string containing the file data
  44790. * @returns if the data can be loaded directly
  44791. */
  44792. canDirectLoad?(data: string): boolean;
  44793. }
  44794. /**
  44795. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44796. */
  44797. export interface ISceneLoaderPluginBase {
  44798. /**
  44799. * The friendly name of this plugin.
  44800. */
  44801. name: string;
  44802. /**
  44803. * The file extensions supported by this plugin.
  44804. */
  44805. extensions: string | ISceneLoaderPluginExtensions;
  44806. /**
  44807. * The callback called when loading from a url.
  44808. * @param scene scene loading this url
  44809. * @param url url to load
  44810. * @param onSuccess callback called when the file successfully loads
  44811. * @param onProgress callback called while file is loading (if the server supports this mode)
  44812. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44813. * @param onError callback called when the file fails to load
  44814. * @returns a file request object
  44815. */
  44816. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44817. /**
  44818. * The callback called when loading from a file object.
  44819. * @param scene scene loading this file
  44820. * @param file defines the file to load
  44821. * @param onSuccess defines the callback to call when data is loaded
  44822. * @param onProgress defines the callback to call during loading process
  44823. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44824. * @param onError defines the callback to call when an error occurs
  44825. * @returns a file request object
  44826. */
  44827. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44828. /**
  44829. * The callback that returns true if the data can be directly loaded.
  44830. * @param data string containing the file data
  44831. * @returns if the data can be loaded directly
  44832. */
  44833. canDirectLoad?(data: string): boolean;
  44834. /**
  44835. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44836. * @param scene scene loading this data
  44837. * @param data string containing the data
  44838. * @returns data to pass to the plugin
  44839. */
  44840. directLoad?(scene: Scene, data: string): any;
  44841. /**
  44842. * The callback that allows custom handling of the root url based on the response url.
  44843. * @param rootUrl the original root url
  44844. * @param responseURL the response url if available
  44845. * @returns the new root url
  44846. */
  44847. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44848. }
  44849. /**
  44850. * Interface used to define a SceneLoader plugin
  44851. */
  44852. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44853. /**
  44854. * Import meshes into a scene.
  44855. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44856. * @param scene The scene to import into
  44857. * @param data The data to import
  44858. * @param rootUrl The root url for scene and resources
  44859. * @param meshes The meshes array to import into
  44860. * @param particleSystems The particle systems array to import into
  44861. * @param skeletons The skeletons array to import into
  44862. * @param onError The callback when import fails
  44863. * @returns True if successful or false otherwise
  44864. */
  44865. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44866. /**
  44867. * Load into a scene.
  44868. * @param scene The scene to load into
  44869. * @param data The data to import
  44870. * @param rootUrl The root url for scene and resources
  44871. * @param onError The callback when import fails
  44872. * @returns True if successful or false otherwise
  44873. */
  44874. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44875. /**
  44876. * Load into an asset container.
  44877. * @param scene The scene to load into
  44878. * @param data The data to import
  44879. * @param rootUrl The root url for scene and resources
  44880. * @param onError The callback when import fails
  44881. * @returns The loaded asset container
  44882. */
  44883. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44884. }
  44885. /**
  44886. * Interface used to define an async SceneLoader plugin
  44887. */
  44888. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44889. /**
  44890. * Import meshes into a scene.
  44891. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44892. * @param scene The scene to import into
  44893. * @param data The data to import
  44894. * @param rootUrl The root url for scene and resources
  44895. * @param onProgress The callback when the load progresses
  44896. * @param fileName Defines the name of the file to load
  44897. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44898. */
  44899. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44900. meshes: AbstractMesh[];
  44901. particleSystems: IParticleSystem[];
  44902. skeletons: Skeleton[];
  44903. animationGroups: AnimationGroup[];
  44904. }>;
  44905. /**
  44906. * Load into a scene.
  44907. * @param scene The scene to load into
  44908. * @param data The data to import
  44909. * @param rootUrl The root url for scene and resources
  44910. * @param onProgress The callback when the load progresses
  44911. * @param fileName Defines the name of the file to load
  44912. * @returns Nothing
  44913. */
  44914. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44915. /**
  44916. * Load into an asset container.
  44917. * @param scene The scene to load into
  44918. * @param data The data to import
  44919. * @param rootUrl The root url for scene and resources
  44920. * @param onProgress The callback when the load progresses
  44921. * @param fileName Defines the name of the file to load
  44922. * @returns The loaded asset container
  44923. */
  44924. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44925. }
  44926. /**
  44927. * Mode that determines how to handle old animation groups before loading new ones.
  44928. */
  44929. export enum SceneLoaderAnimationGroupLoadingMode {
  44930. /**
  44931. * Reset all old animations to initial state then dispose them.
  44932. */
  44933. Clean = 0,
  44934. /**
  44935. * Stop all old animations.
  44936. */
  44937. Stop = 1,
  44938. /**
  44939. * Restart old animations from first frame.
  44940. */
  44941. Sync = 2,
  44942. /**
  44943. * Old animations remains untouched.
  44944. */
  44945. NoSync = 3
  44946. }
  44947. /**
  44948. * Class used to load scene from various file formats using registered plugins
  44949. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44950. */
  44951. export class SceneLoader {
  44952. /**
  44953. * No logging while loading
  44954. */
  44955. static readonly NO_LOGGING: number;
  44956. /**
  44957. * Minimal logging while loading
  44958. */
  44959. static readonly MINIMAL_LOGGING: number;
  44960. /**
  44961. * Summary logging while loading
  44962. */
  44963. static readonly SUMMARY_LOGGING: number;
  44964. /**
  44965. * Detailled logging while loading
  44966. */
  44967. static readonly DETAILED_LOGGING: number;
  44968. /**
  44969. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44970. */
  44971. static get ForceFullSceneLoadingForIncremental(): boolean;
  44972. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44973. /**
  44974. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44975. */
  44976. static get ShowLoadingScreen(): boolean;
  44977. static set ShowLoadingScreen(value: boolean);
  44978. /**
  44979. * Defines the current logging level (while loading the scene)
  44980. * @ignorenaming
  44981. */
  44982. static get loggingLevel(): number;
  44983. static set loggingLevel(value: number);
  44984. /**
  44985. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44986. */
  44987. static get CleanBoneMatrixWeights(): boolean;
  44988. static set CleanBoneMatrixWeights(value: boolean);
  44989. /**
  44990. * Event raised when a plugin is used to load a scene
  44991. */
  44992. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44993. private static _registeredPlugins;
  44994. private static _getDefaultPlugin;
  44995. private static _getPluginForExtension;
  44996. private static _getPluginForDirectLoad;
  44997. private static _getPluginForFilename;
  44998. private static _getDirectLoad;
  44999. private static _loadData;
  45000. private static _getFileInfo;
  45001. /**
  45002. * Gets a plugin that can load the given extension
  45003. * @param extension defines the extension to load
  45004. * @returns a plugin or null if none works
  45005. */
  45006. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45007. /**
  45008. * Gets a boolean indicating that the given extension can be loaded
  45009. * @param extension defines the extension to load
  45010. * @returns true if the extension is supported
  45011. */
  45012. static IsPluginForExtensionAvailable(extension: string): boolean;
  45013. /**
  45014. * Adds a new plugin to the list of registered plugins
  45015. * @param plugin defines the plugin to add
  45016. */
  45017. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45018. /**
  45019. * Import meshes into a scene
  45020. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45021. * @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)
  45022. * @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)
  45023. * @param scene the instance of BABYLON.Scene to append to
  45024. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45025. * @param onProgress a callback with a progress event for each file being loaded
  45026. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45027. * @param pluginExtension the extension used to determine the plugin
  45028. * @returns The loaded plugin
  45029. */
  45030. 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>;
  45031. /**
  45032. * Import meshes into a scene
  45033. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45034. * @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)
  45035. * @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)
  45036. * @param scene the instance of BABYLON.Scene to append to
  45037. * @param onProgress a callback with a progress event for each file being loaded
  45038. * @param pluginExtension the extension used to determine the plugin
  45039. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45040. */
  45041. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45042. meshes: AbstractMesh[];
  45043. particleSystems: IParticleSystem[];
  45044. skeletons: Skeleton[];
  45045. animationGroups: AnimationGroup[];
  45046. }>;
  45047. /**
  45048. * Load a scene
  45049. * @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)
  45050. * @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)
  45051. * @param engine is the instance of BABYLON.Engine to use to create the scene
  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. * @param pluginExtension the extension used to determine the plugin
  45056. * @returns The loaded plugin
  45057. */
  45058. 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>;
  45059. /**
  45060. * Load a scene
  45061. * @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)
  45062. * @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)
  45063. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45064. * @param onProgress a callback with a progress event for each file being loaded
  45065. * @param pluginExtension the extension used to determine the plugin
  45066. * @returns The loaded scene
  45067. */
  45068. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45069. /**
  45070. * Append a scene
  45071. * @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)
  45072. * @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)
  45073. * @param scene is the instance of BABYLON.Scene to append to
  45074. * @param onSuccess a callback with the scene when import succeeds
  45075. * @param onProgress a callback with a progress event for each file being loaded
  45076. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45077. * @param pluginExtension the extension used to determine the plugin
  45078. * @returns The loaded plugin
  45079. */
  45080. 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>;
  45081. /**
  45082. * Append a scene
  45083. * @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)
  45084. * @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)
  45085. * @param scene is the instance of BABYLON.Scene to append to
  45086. * @param onProgress a callback with a progress event for each file being loaded
  45087. * @param pluginExtension the extension used to determine the plugin
  45088. * @returns The given scene
  45089. */
  45090. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45091. /**
  45092. * Load a scene into an asset container
  45093. * @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)
  45094. * @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)
  45095. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45096. * @param onSuccess a callback with the scene when import succeeds
  45097. * @param onProgress a callback with a progress event for each file being loaded
  45098. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45099. * @param pluginExtension the extension used to determine the plugin
  45100. * @returns The loaded plugin
  45101. */
  45102. 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>;
  45103. /**
  45104. * Load a scene into an asset container
  45105. * @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)
  45106. * @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)
  45107. * @param scene is the instance of Scene to append to
  45108. * @param onProgress a callback with a progress event for each file being loaded
  45109. * @param pluginExtension the extension used to determine the plugin
  45110. * @returns The loaded asset container
  45111. */
  45112. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45113. /**
  45114. * Import animations from a file into a scene
  45115. * @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)
  45116. * @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)
  45117. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45118. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45119. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45120. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45121. * @param onSuccess a callback with the scene when import succeeds
  45122. * @param onProgress a callback with a progress event for each file being loaded
  45123. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45124. */
  45125. 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;
  45126. /**
  45127. * Import animations from a file into a scene
  45128. * @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)
  45129. * @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)
  45130. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45131. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45132. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45133. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45134. * @param onSuccess a callback with the scene when import succeeds
  45135. * @param onProgress a callback with a progress event for each file being loaded
  45136. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45137. * @returns the updated scene with imported animations
  45138. */
  45139. 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>;
  45140. }
  45141. }
  45142. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45143. import { IDisposable, Scene } from "babylonjs/scene";
  45144. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45145. import { Observable } from "babylonjs/Misc/observable";
  45146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45147. import { Nullable } from "babylonjs/types";
  45148. /**
  45149. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45150. */
  45151. export type MotionControllerHandness = "none" | "left" | "right";
  45152. /**
  45153. * The type of components available in motion controllers.
  45154. * This is not the name of the component.
  45155. */
  45156. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45157. /**
  45158. * The state of a controller component
  45159. */
  45160. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45161. /**
  45162. * The schema of motion controller layout.
  45163. * No object will be initialized using this interface
  45164. * This is used just to define the profile.
  45165. */
  45166. export interface IMotionControllerLayout {
  45167. /**
  45168. * Path to load the assets. Usually relative to the base path
  45169. */
  45170. assetPath: string;
  45171. /**
  45172. * Available components (unsorted)
  45173. */
  45174. components: {
  45175. /**
  45176. * A map of component Ids
  45177. */
  45178. [componentId: string]: {
  45179. /**
  45180. * The type of input the component outputs
  45181. */
  45182. type: MotionControllerComponentType;
  45183. /**
  45184. * The indices of this component in the gamepad object
  45185. */
  45186. gamepadIndices: {
  45187. /**
  45188. * Index of button
  45189. */
  45190. button?: number;
  45191. /**
  45192. * If available, index of x-axis
  45193. */
  45194. xAxis?: number;
  45195. /**
  45196. * If available, index of y-axis
  45197. */
  45198. yAxis?: number;
  45199. };
  45200. /**
  45201. * The mesh's root node name
  45202. */
  45203. rootNodeName: string;
  45204. /**
  45205. * Animation definitions for this model
  45206. */
  45207. visualResponses: {
  45208. [stateKey: string]: {
  45209. /**
  45210. * What property will be animated
  45211. */
  45212. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45213. /**
  45214. * What states influence this visual response
  45215. */
  45216. states: MotionControllerComponentStateType[];
  45217. /**
  45218. * Type of animation - movement or visibility
  45219. */
  45220. valueNodeProperty: "transform" | "visibility";
  45221. /**
  45222. * Base node name to move. Its position will be calculated according to the min and max nodes
  45223. */
  45224. valueNodeName?: string;
  45225. /**
  45226. * Minimum movement node
  45227. */
  45228. minNodeName?: string;
  45229. /**
  45230. * Max movement node
  45231. */
  45232. maxNodeName?: string;
  45233. };
  45234. };
  45235. /**
  45236. * If touch enabled, what is the name of node to display user feedback
  45237. */
  45238. touchPointNodeName?: string;
  45239. };
  45240. };
  45241. /**
  45242. * Is it xr standard mapping or not
  45243. */
  45244. gamepadMapping: "" | "xr-standard";
  45245. /**
  45246. * Base root node of this entire model
  45247. */
  45248. rootNodeName: string;
  45249. /**
  45250. * Defines the main button component id
  45251. */
  45252. selectComponentId: string;
  45253. }
  45254. /**
  45255. * A definition for the layout map in the input profile
  45256. */
  45257. export interface IMotionControllerLayoutMap {
  45258. /**
  45259. * Layouts with handness type as a key
  45260. */
  45261. [handness: string]: IMotionControllerLayout;
  45262. }
  45263. /**
  45264. * The XR Input profile schema
  45265. * Profiles can be found here:
  45266. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45267. */
  45268. export interface IMotionControllerProfile {
  45269. /**
  45270. * fallback profiles for this profileId
  45271. */
  45272. fallbackProfileIds: string[];
  45273. /**
  45274. * The layout map, with handness as key
  45275. */
  45276. layouts: IMotionControllerLayoutMap;
  45277. /**
  45278. * The id of this profile
  45279. * correlates to the profile(s) in the xrInput.profiles array
  45280. */
  45281. profileId: string;
  45282. }
  45283. /**
  45284. * A helper-interface for the 3 meshes needed for controller button animation
  45285. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45286. */
  45287. export interface IMotionControllerButtonMeshMap {
  45288. /**
  45289. * the mesh that defines the pressed value mesh position.
  45290. * This is used to find the max-position of this button
  45291. */
  45292. pressedMesh: AbstractMesh;
  45293. /**
  45294. * the mesh that defines the unpressed value mesh position.
  45295. * This is used to find the min (or initial) position of this button
  45296. */
  45297. unpressedMesh: AbstractMesh;
  45298. /**
  45299. * The mesh that will be changed when value changes
  45300. */
  45301. valueMesh: AbstractMesh;
  45302. }
  45303. /**
  45304. * A helper-interface for the 3 meshes needed for controller axis animation.
  45305. * This will be expanded when touchpad animations are fully supported
  45306. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45307. */
  45308. export interface IMotionControllerMeshMap {
  45309. /**
  45310. * the mesh that defines the maximum value mesh position.
  45311. */
  45312. maxMesh?: AbstractMesh;
  45313. /**
  45314. * the mesh that defines the minimum value mesh position.
  45315. */
  45316. minMesh?: AbstractMesh;
  45317. /**
  45318. * The mesh that will be changed when axis value changes
  45319. */
  45320. valueMesh: AbstractMesh;
  45321. }
  45322. /**
  45323. * The elements needed for change-detection of the gamepad objects in motion controllers
  45324. */
  45325. export interface IMinimalMotionControllerObject {
  45326. /**
  45327. * Available axes of this controller
  45328. */
  45329. axes: number[];
  45330. /**
  45331. * An array of available buttons
  45332. */
  45333. buttons: Array<{
  45334. /**
  45335. * Value of the button/trigger
  45336. */
  45337. value: number;
  45338. /**
  45339. * If the button/trigger is currently touched
  45340. */
  45341. touched: boolean;
  45342. /**
  45343. * If the button/trigger is currently pressed
  45344. */
  45345. pressed: boolean;
  45346. }>;
  45347. }
  45348. /**
  45349. * An Abstract Motion controller
  45350. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45351. * Each component has an observable to check for changes in value and state
  45352. */
  45353. export abstract class WebXRAbstractMotionController implements IDisposable {
  45354. protected scene: Scene;
  45355. protected layout: IMotionControllerLayout;
  45356. /**
  45357. * The gamepad object correlating to this controller
  45358. */
  45359. gamepadObject: IMinimalMotionControllerObject;
  45360. /**
  45361. * handness (left/right/none) of this controller
  45362. */
  45363. handness: MotionControllerHandness;
  45364. private _initComponent;
  45365. private _modelReady;
  45366. /**
  45367. * A map of components (WebXRControllerComponent) in this motion controller
  45368. * Components have a ComponentType and can also have both button and axis definitions
  45369. */
  45370. readonly components: {
  45371. [id: string]: WebXRControllerComponent;
  45372. };
  45373. /**
  45374. * Disable the model's animation. Can be set at any time.
  45375. */
  45376. disableAnimation: boolean;
  45377. /**
  45378. * Observers registered here will be triggered when the model of this controller is done loading
  45379. */
  45380. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45381. /**
  45382. * The profile id of this motion controller
  45383. */
  45384. abstract profileId: string;
  45385. /**
  45386. * The root mesh of the model. It is null if the model was not yet initialized
  45387. */
  45388. rootMesh: Nullable<AbstractMesh>;
  45389. /**
  45390. * constructs a new abstract motion controller
  45391. * @param scene the scene to which the model of the controller will be added
  45392. * @param layout The profile layout to load
  45393. * @param gamepadObject The gamepad object correlating to this controller
  45394. * @param handness handness (left/right/none) of this controller
  45395. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45396. */
  45397. constructor(scene: Scene, layout: IMotionControllerLayout,
  45398. /**
  45399. * The gamepad object correlating to this controller
  45400. */
  45401. gamepadObject: IMinimalMotionControllerObject,
  45402. /**
  45403. * handness (left/right/none) of this controller
  45404. */
  45405. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45406. /**
  45407. * Dispose this controller, the model mesh and all its components
  45408. */
  45409. dispose(): void;
  45410. /**
  45411. * Returns all components of specific type
  45412. * @param type the type to search for
  45413. * @return an array of components with this type
  45414. */
  45415. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45416. /**
  45417. * get a component based an its component id as defined in layout.components
  45418. * @param id the id of the component
  45419. * @returns the component correlates to the id or undefined if not found
  45420. */
  45421. getComponent(id: string): WebXRControllerComponent;
  45422. /**
  45423. * Get the list of components available in this motion controller
  45424. * @returns an array of strings correlating to available components
  45425. */
  45426. getComponentIds(): string[];
  45427. /**
  45428. * Get the first component of specific type
  45429. * @param type type of component to find
  45430. * @return a controller component or null if not found
  45431. */
  45432. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45433. /**
  45434. * Get the main (Select) component of this controller as defined in the layout
  45435. * @returns the main component of this controller
  45436. */
  45437. getMainComponent(): WebXRControllerComponent;
  45438. /**
  45439. * Loads the model correlating to this controller
  45440. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45441. * @returns A promise fulfilled with the result of the model loading
  45442. */
  45443. loadModel(): Promise<boolean>;
  45444. /**
  45445. * Update this model using the current XRFrame
  45446. * @param xrFrame the current xr frame to use and update the model
  45447. */
  45448. updateFromXRFrame(xrFrame: XRFrame): void;
  45449. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45450. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45451. /**
  45452. * Moves the axis on the controller mesh based on its current state
  45453. * @param axis the index of the axis
  45454. * @param axisValue the value of the axis which determines the meshes new position
  45455. * @hidden
  45456. */
  45457. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45458. /**
  45459. * Update the model itself with the current frame data
  45460. * @param xrFrame the frame to use for updating the model mesh
  45461. */
  45462. protected updateModel(xrFrame: XRFrame): void;
  45463. /**
  45464. * Get the filename and path for this controller's model
  45465. * @returns a map of filename and path
  45466. */
  45467. protected abstract _getFilenameAndPath(): {
  45468. filename: string;
  45469. path: string;
  45470. };
  45471. /**
  45472. * This function is called before the mesh is loaded. It checks for loading constraints.
  45473. * For example, this function can check if the GLB loader is available
  45474. * If this function returns false, the generic controller will be loaded instead
  45475. * @returns Is the client ready to load the mesh
  45476. */
  45477. protected abstract _getModelLoadingConstraints(): boolean;
  45478. /**
  45479. * This function will be called after the model was successfully loaded and can be used
  45480. * for mesh transformations before it is available for the user
  45481. * @param meshes the loaded meshes
  45482. */
  45483. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45484. /**
  45485. * Set the root mesh for this controller. Important for the WebXR controller class
  45486. * @param meshes the loaded meshes
  45487. */
  45488. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45489. /**
  45490. * A function executed each frame that updates the mesh (if needed)
  45491. * @param xrFrame the current xrFrame
  45492. */
  45493. protected abstract _updateModel(xrFrame: XRFrame): void;
  45494. private _getGenericFilenameAndPath;
  45495. private _getGenericParentMesh;
  45496. }
  45497. }
  45498. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45499. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45501. import { Scene } from "babylonjs/scene";
  45502. /**
  45503. * A generic trigger-only motion controller for WebXR
  45504. */
  45505. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45506. /**
  45507. * Static version of the profile id of this controller
  45508. */
  45509. static ProfileId: string;
  45510. profileId: string;
  45511. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45512. protected _getFilenameAndPath(): {
  45513. filename: string;
  45514. path: string;
  45515. };
  45516. protected _getModelLoadingConstraints(): boolean;
  45517. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45518. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45519. protected _updateModel(): void;
  45520. }
  45521. }
  45522. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45523. import { Vector4 } from "babylonjs/Maths/math.vector";
  45524. import { Mesh } from "babylonjs/Meshes/mesh";
  45525. import { Scene } from "babylonjs/scene";
  45526. import { Nullable } from "babylonjs/types";
  45527. /**
  45528. * Class containing static functions to help procedurally build meshes
  45529. */
  45530. export class SphereBuilder {
  45531. /**
  45532. * Creates a sphere mesh
  45533. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45534. * * 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`)
  45535. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45536. * * 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
  45537. * * 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)
  45538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45541. * @param name defines the name of the mesh
  45542. * @param options defines the options used to create the mesh
  45543. * @param scene defines the hosting scene
  45544. * @returns the sphere mesh
  45545. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45546. */
  45547. static CreateSphere(name: string, options: {
  45548. segments?: number;
  45549. diameter?: number;
  45550. diameterX?: number;
  45551. diameterY?: number;
  45552. diameterZ?: number;
  45553. arc?: number;
  45554. slice?: number;
  45555. sideOrientation?: number;
  45556. frontUVs?: Vector4;
  45557. backUVs?: Vector4;
  45558. updatable?: boolean;
  45559. }, scene?: Nullable<Scene>): Mesh;
  45560. }
  45561. }
  45562. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45564. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45565. import { Scene } from "babylonjs/scene";
  45566. /**
  45567. * A profiled motion controller has its profile loaded from an online repository.
  45568. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45569. */
  45570. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45571. private _repositoryUrl;
  45572. private _buttonMeshMapping;
  45573. private _touchDots;
  45574. /**
  45575. * The profile ID of this controller. Will be populated when the controller initializes.
  45576. */
  45577. profileId: string;
  45578. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45579. dispose(): void;
  45580. protected _getFilenameAndPath(): {
  45581. filename: string;
  45582. path: string;
  45583. };
  45584. protected _getModelLoadingConstraints(): boolean;
  45585. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45586. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45587. protected _updateModel(_xrFrame: XRFrame): void;
  45588. }
  45589. }
  45590. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45591. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45592. import { Scene } from "babylonjs/scene";
  45593. /**
  45594. * A construction function type to create a new controller based on an xrInput object
  45595. */
  45596. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45597. /**
  45598. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45599. *
  45600. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45601. * it should be replaced with auto-loaded controllers.
  45602. *
  45603. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45604. */
  45605. export class WebXRMotionControllerManager {
  45606. private static _AvailableControllers;
  45607. private static _Fallbacks;
  45608. private static _ProfileLoadingPromises;
  45609. private static _ProfilesList;
  45610. /**
  45611. * The base URL of the online controller repository. Can be changed at any time.
  45612. */
  45613. static BaseRepositoryUrl: string;
  45614. /**
  45615. * Which repository gets priority - local or online
  45616. */
  45617. static PrioritizeOnlineRepository: boolean;
  45618. /**
  45619. * Use the online repository, or use only locally-defined controllers
  45620. */
  45621. static UseOnlineRepository: boolean;
  45622. /**
  45623. * Clear the cache used for profile loading and reload when requested again
  45624. */
  45625. static ClearProfilesCache(): void;
  45626. /**
  45627. * Register the default fallbacks.
  45628. * This function is called automatically when this file is imported.
  45629. */
  45630. static DefaultFallbacks(): void;
  45631. /**
  45632. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45633. * @param profileId the profile to which a fallback needs to be found
  45634. * @return an array with corresponding fallback profiles
  45635. */
  45636. static FindFallbackWithProfileId(profileId: string): string[];
  45637. /**
  45638. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45639. * The order of search:
  45640. *
  45641. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45642. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45643. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45644. * 4) return the generic trigger controller if none were found
  45645. *
  45646. * @param xrInput the xrInput to which a new controller is initialized
  45647. * @param scene the scene to which the model will be added
  45648. * @param forceProfile force a certain profile for this controller
  45649. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45650. */
  45651. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45652. /**
  45653. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45654. *
  45655. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45656. *
  45657. * @param type the profile type to register
  45658. * @param constructFunction the function to be called when loading this profile
  45659. */
  45660. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45661. /**
  45662. * Register a fallback to a specific profile.
  45663. * @param profileId the profileId that will receive the fallbacks
  45664. * @param fallbacks A list of fallback profiles
  45665. */
  45666. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45667. /**
  45668. * Will update the list of profiles available in the repository
  45669. * @return a promise that resolves to a map of profiles available online
  45670. */
  45671. static UpdateProfilesList(): Promise<{
  45672. [profile: string]: string;
  45673. }>;
  45674. private static _LoadProfileFromRepository;
  45675. private static _LoadProfilesFromAvailableControllers;
  45676. }
  45677. }
  45678. declare module "babylonjs/XR/webXRInputSource" {
  45679. import { Observable } from "babylonjs/Misc/observable";
  45680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45681. import { Ray } from "babylonjs/Culling/ray";
  45682. import { Scene } from "babylonjs/scene";
  45683. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45684. /**
  45685. * Configuration options for the WebXR controller creation
  45686. */
  45687. export interface IWebXRControllerOptions {
  45688. /**
  45689. * Should the controller mesh be animated when a user interacts with it
  45690. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45691. */
  45692. disableMotionControllerAnimation?: boolean;
  45693. /**
  45694. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45695. */
  45696. doNotLoadControllerMesh?: boolean;
  45697. /**
  45698. * Force a specific controller type for this controller.
  45699. * This can be used when creating your own profile or when testing different controllers
  45700. */
  45701. forceControllerProfile?: string;
  45702. }
  45703. /**
  45704. * Represents an XR controller
  45705. */
  45706. export class WebXRInputSource {
  45707. private _scene;
  45708. /** The underlying input source for the controller */
  45709. inputSource: XRInputSource;
  45710. private _options;
  45711. private _tmpQuaternion;
  45712. private _tmpVector;
  45713. private _uniqueId;
  45714. /**
  45715. * 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
  45716. */
  45717. grip?: AbstractMesh;
  45718. /**
  45719. * If available, this is the gamepad object related to this controller.
  45720. * Using this object it is possible to get click events and trackpad changes of the
  45721. * webxr controller that is currently being used.
  45722. */
  45723. motionController?: WebXRAbstractMotionController;
  45724. /**
  45725. * Event that fires when the controller is removed/disposed.
  45726. * The object provided as event data is this controller, after associated assets were disposed.
  45727. * uniqueId is still available.
  45728. */
  45729. onDisposeObservable: Observable<WebXRInputSource>;
  45730. /**
  45731. * Will be triggered when the mesh associated with the motion controller is done loading.
  45732. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45733. * A shortened version of controller -> motion controller -> on mesh loaded.
  45734. */
  45735. onMeshLoadedObservable: Observable<AbstractMesh>;
  45736. /**
  45737. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45738. */
  45739. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45740. /**
  45741. * Pointer which can be used to select objects or attach a visible laser to
  45742. */
  45743. pointer: AbstractMesh;
  45744. /**
  45745. * Creates the controller
  45746. * @see https://doc.babylonjs.com/how_to/webxr
  45747. * @param _scene the scene which the controller should be associated to
  45748. * @param inputSource the underlying input source for the controller
  45749. * @param _options options for this controller creation
  45750. */
  45751. constructor(_scene: Scene,
  45752. /** The underlying input source for the controller */
  45753. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45754. /**
  45755. * Get this controllers unique id
  45756. */
  45757. get uniqueId(): string;
  45758. /**
  45759. * Disposes of the object
  45760. */
  45761. dispose(): void;
  45762. /**
  45763. * Gets a world space ray coming from the pointer or grip
  45764. * @param result the resulting ray
  45765. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45766. */
  45767. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45768. /**
  45769. * Updates the controller pose based on the given XRFrame
  45770. * @param xrFrame xr frame to update the pose with
  45771. * @param referenceSpace reference space to use
  45772. */
  45773. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45774. }
  45775. }
  45776. declare module "babylonjs/XR/webXRInput" {
  45777. import { Observable } from "babylonjs/Misc/observable";
  45778. import { IDisposable } from "babylonjs/scene";
  45779. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45780. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45781. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45782. /**
  45783. * The schema for initialization options of the XR Input class
  45784. */
  45785. export interface IWebXRInputOptions {
  45786. /**
  45787. * If set to true no model will be automatically loaded
  45788. */
  45789. doNotLoadControllerMeshes?: boolean;
  45790. /**
  45791. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45792. * If not found, the xr input profile data will be used.
  45793. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45794. */
  45795. forceInputProfile?: string;
  45796. /**
  45797. * Do not send a request to the controller repository to load the profile.
  45798. *
  45799. * Instead, use the controllers available in babylon itself.
  45800. */
  45801. disableOnlineControllerRepository?: boolean;
  45802. /**
  45803. * A custom URL for the controllers repository
  45804. */
  45805. customControllersRepositoryURL?: string;
  45806. /**
  45807. * Should the controller model's components not move according to the user input
  45808. */
  45809. disableControllerAnimation?: boolean;
  45810. }
  45811. /**
  45812. * XR input used to track XR inputs such as controllers/rays
  45813. */
  45814. export class WebXRInput implements IDisposable {
  45815. /**
  45816. * the xr session manager for this session
  45817. */
  45818. xrSessionManager: WebXRSessionManager;
  45819. /**
  45820. * the WebXR camera for this session. Mainly used for teleportation
  45821. */
  45822. xrCamera: WebXRCamera;
  45823. private readonly options;
  45824. /**
  45825. * XR controllers being tracked
  45826. */
  45827. controllers: Array<WebXRInputSource>;
  45828. private _frameObserver;
  45829. private _sessionEndedObserver;
  45830. private _sessionInitObserver;
  45831. /**
  45832. * Event when a controller has been connected/added
  45833. */
  45834. onControllerAddedObservable: Observable<WebXRInputSource>;
  45835. /**
  45836. * Event when a controller has been removed/disconnected
  45837. */
  45838. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45839. /**
  45840. * Initializes the WebXRInput
  45841. * @param xrSessionManager the xr session manager for this session
  45842. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45843. * @param options = initialization options for this xr input
  45844. */
  45845. constructor(
  45846. /**
  45847. * the xr session manager for this session
  45848. */
  45849. xrSessionManager: WebXRSessionManager,
  45850. /**
  45851. * the WebXR camera for this session. Mainly used for teleportation
  45852. */
  45853. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45854. private _onInputSourcesChange;
  45855. private _addAndRemoveControllers;
  45856. /**
  45857. * Disposes of the object
  45858. */
  45859. dispose(): void;
  45860. }
  45861. }
  45862. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45863. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45864. import { Observable, EventState } from "babylonjs/Misc/observable";
  45865. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45866. /**
  45867. * This is the base class for all WebXR features.
  45868. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45869. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45870. */
  45871. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45872. protected _xrSessionManager: WebXRSessionManager;
  45873. private _attached;
  45874. private _removeOnDetach;
  45875. /**
  45876. * Should auto-attach be disabled?
  45877. */
  45878. disableAutoAttach: boolean;
  45879. /**
  45880. * Construct a new (abstract) WebXR feature
  45881. * @param _xrSessionManager the xr session manager for this feature
  45882. */
  45883. constructor(_xrSessionManager: WebXRSessionManager);
  45884. /**
  45885. * Is this feature attached
  45886. */
  45887. get attached(): boolean;
  45888. /**
  45889. * attach this feature
  45890. *
  45891. * @param force should attachment be forced (even when already attached)
  45892. * @returns true if successful, false is failed or already attached
  45893. */
  45894. attach(force?: boolean): boolean;
  45895. /**
  45896. * detach this feature.
  45897. *
  45898. * @returns true if successful, false if failed or already detached
  45899. */
  45900. detach(): boolean;
  45901. /**
  45902. * Dispose this feature and all of the resources attached
  45903. */
  45904. dispose(): void;
  45905. /**
  45906. * This is used to register callbacks that will automatically be removed when detach is called.
  45907. * @param observable the observable to which the observer will be attached
  45908. * @param callback the callback to register
  45909. */
  45910. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45911. /**
  45912. * Code in this function will be executed on each xrFrame received from the browser.
  45913. * This function will not execute after the feature is detached.
  45914. * @param _xrFrame the current frame
  45915. */
  45916. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45917. }
  45918. }
  45919. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45920. import { IDisposable, Scene } from "babylonjs/scene";
  45921. import { Nullable } from "babylonjs/types";
  45922. import { Observable } from "babylonjs/Misc/observable";
  45923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45924. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45925. import { Camera } from "babylonjs/Cameras/camera";
  45926. /**
  45927. * Renders a layer on top of an existing scene
  45928. */
  45929. export class UtilityLayerRenderer implements IDisposable {
  45930. /** the original scene that will be rendered on top of */
  45931. originalScene: Scene;
  45932. private _pointerCaptures;
  45933. private _lastPointerEvents;
  45934. private static _DefaultUtilityLayer;
  45935. private static _DefaultKeepDepthUtilityLayer;
  45936. private _sharedGizmoLight;
  45937. private _renderCamera;
  45938. /**
  45939. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45940. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45941. * @returns the camera that is used when rendering the utility layer
  45942. */
  45943. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45944. /**
  45945. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45946. * @param cam the camera that should be used when rendering the utility layer
  45947. */
  45948. setRenderCamera(cam: Nullable<Camera>): void;
  45949. /**
  45950. * @hidden
  45951. * Light which used by gizmos to get light shading
  45952. */
  45953. _getSharedGizmoLight(): HemisphericLight;
  45954. /**
  45955. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45956. */
  45957. pickUtilitySceneFirst: boolean;
  45958. /**
  45959. * 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)
  45960. */
  45961. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45962. /**
  45963. * 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)
  45964. */
  45965. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45966. /**
  45967. * The scene that is rendered on top of the original scene
  45968. */
  45969. utilityLayerScene: Scene;
  45970. /**
  45971. * If the utility layer should automatically be rendered on top of existing scene
  45972. */
  45973. shouldRender: boolean;
  45974. /**
  45975. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45976. */
  45977. onlyCheckPointerDownEvents: boolean;
  45978. /**
  45979. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45980. */
  45981. processAllEvents: boolean;
  45982. /**
  45983. * Observable raised when the pointer move from the utility layer scene to the main scene
  45984. */
  45985. onPointerOutObservable: Observable<number>;
  45986. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45987. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45988. private _afterRenderObserver;
  45989. private _sceneDisposeObserver;
  45990. private _originalPointerObserver;
  45991. /**
  45992. * Instantiates a UtilityLayerRenderer
  45993. * @param originalScene the original scene that will be rendered on top of
  45994. * @param handleEvents boolean indicating if the utility layer should handle events
  45995. */
  45996. constructor(
  45997. /** the original scene that will be rendered on top of */
  45998. originalScene: Scene, handleEvents?: boolean);
  45999. private _notifyObservers;
  46000. /**
  46001. * Renders the utility layers scene on top of the original scene
  46002. */
  46003. render(): void;
  46004. /**
  46005. * Disposes of the renderer
  46006. */
  46007. dispose(): void;
  46008. private _updateCamera;
  46009. }
  46010. }
  46011. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46012. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46014. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46015. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46016. import { Scene } from "babylonjs/scene";
  46017. import { Nullable } from "babylonjs/types";
  46018. import { Color3 } from "babylonjs/Maths/math.color";
  46019. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46020. /**
  46021. * Options interface for the pointer selection module
  46022. */
  46023. export interface IWebXRControllerPointerSelectionOptions {
  46024. /**
  46025. * if provided, this scene will be used to render meshes.
  46026. */
  46027. customUtilityLayerScene?: Scene;
  46028. /**
  46029. * 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)
  46030. * If not disabled, the last picked point will be used to execute a pointer up event
  46031. * If disabled, pointer up event will be triggered right after the pointer down event.
  46032. * Used in screen and gaze target ray mode only
  46033. */
  46034. disablePointerUpOnTouchOut: boolean;
  46035. /**
  46036. * For gaze mode (time to select instead of press)
  46037. */
  46038. forceGazeMode: boolean;
  46039. /**
  46040. * 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
  46041. * to start a new countdown to the pointer down event.
  46042. * Defaults to 1.
  46043. */
  46044. gazeModePointerMovedFactor?: number;
  46045. /**
  46046. * Different button type to use instead of the main component
  46047. */
  46048. overrideButtonId?: string;
  46049. /**
  46050. * use this rendering group id for the meshes (optional)
  46051. */
  46052. renderingGroupId?: number;
  46053. /**
  46054. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46055. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46056. * 3000 means 3 seconds between pointing at something and selecting it
  46057. */
  46058. timeToSelect?: number;
  46059. /**
  46060. * Should meshes created here be added to a utility layer or the main scene
  46061. */
  46062. useUtilityLayer?: boolean;
  46063. /**
  46064. * the xr input to use with this pointer selection
  46065. */
  46066. xrInput: WebXRInput;
  46067. }
  46068. /**
  46069. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46070. */
  46071. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46072. private readonly _options;
  46073. private static _idCounter;
  46074. private _attachController;
  46075. private _controllers;
  46076. private _scene;
  46077. private _tmpVectorForPickCompare;
  46078. /**
  46079. * The module's name
  46080. */
  46081. static readonly Name: string;
  46082. /**
  46083. * The (Babylon) version of this module.
  46084. * This is an integer representing the implementation version.
  46085. * This number does not correspond to the WebXR specs version
  46086. */
  46087. static readonly Version: number;
  46088. /**
  46089. * Disable lighting on the laser pointer (so it will always be visible)
  46090. */
  46091. disablePointerLighting: boolean;
  46092. /**
  46093. * Disable lighting on the selection mesh (so it will always be visible)
  46094. */
  46095. disableSelectionMeshLighting: boolean;
  46096. /**
  46097. * Should the laser pointer be displayed
  46098. */
  46099. displayLaserPointer: boolean;
  46100. /**
  46101. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46102. */
  46103. displaySelectionMesh: boolean;
  46104. /**
  46105. * This color will be set to the laser pointer when selection is triggered
  46106. */
  46107. laserPointerPickedColor: Color3;
  46108. /**
  46109. * Default color of the laser pointer
  46110. */
  46111. lasterPointerDefaultColor: Color3;
  46112. /**
  46113. * default color of the selection ring
  46114. */
  46115. selectionMeshDefaultColor: Color3;
  46116. /**
  46117. * This color will be applied to the selection ring when selection is triggered
  46118. */
  46119. selectionMeshPickedColor: Color3;
  46120. /**
  46121. * constructs a new background remover module
  46122. * @param _xrSessionManager the session manager for this module
  46123. * @param _options read-only options to be used in this module
  46124. */
  46125. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46126. /**
  46127. * attach this feature
  46128. * Will usually be called by the features manager
  46129. *
  46130. * @returns true if successful.
  46131. */
  46132. attach(): boolean;
  46133. /**
  46134. * detach this feature.
  46135. * Will usually be called by the features manager
  46136. *
  46137. * @returns true if successful.
  46138. */
  46139. detach(): boolean;
  46140. /**
  46141. * Will get the mesh under a specific pointer.
  46142. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46143. * @param controllerId the controllerId to check
  46144. * @returns The mesh under pointer or null if no mesh is under the pointer
  46145. */
  46146. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46147. /**
  46148. * Get the xr controller that correlates to the pointer id in the pointer event
  46149. *
  46150. * @param id the pointer id to search for
  46151. * @returns the controller that correlates to this id or null if not found
  46152. */
  46153. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46154. protected _onXRFrame(_xrFrame: XRFrame): void;
  46155. private _attachGazeMode;
  46156. private _attachScreenRayMode;
  46157. private _attachTrackedPointerRayMode;
  46158. private _convertNormalToDirectionOfRay;
  46159. private _detachController;
  46160. private _generateNewMeshPair;
  46161. private _pickingMoved;
  46162. private _updatePointerDistance;
  46163. }
  46164. }
  46165. declare module "babylonjs/XR/webXREnterExitUI" {
  46166. import { Nullable } from "babylonjs/types";
  46167. import { Observable } from "babylonjs/Misc/observable";
  46168. import { IDisposable, Scene } from "babylonjs/scene";
  46169. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46170. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46171. /**
  46172. * Button which can be used to enter a different mode of XR
  46173. */
  46174. export class WebXREnterExitUIButton {
  46175. /** button element */
  46176. element: HTMLElement;
  46177. /** XR initialization options for the button */
  46178. sessionMode: XRSessionMode;
  46179. /** Reference space type */
  46180. referenceSpaceType: XRReferenceSpaceType;
  46181. /**
  46182. * Creates a WebXREnterExitUIButton
  46183. * @param element button element
  46184. * @param sessionMode XR initialization session mode
  46185. * @param referenceSpaceType the type of reference space to be used
  46186. */
  46187. constructor(
  46188. /** button element */
  46189. element: HTMLElement,
  46190. /** XR initialization options for the button */
  46191. sessionMode: XRSessionMode,
  46192. /** Reference space type */
  46193. referenceSpaceType: XRReferenceSpaceType);
  46194. /**
  46195. * Extendable function which can be used to update the button's visuals when the state changes
  46196. * @param activeButton the current active button in the UI
  46197. */
  46198. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46199. }
  46200. /**
  46201. * Options to create the webXR UI
  46202. */
  46203. export class WebXREnterExitUIOptions {
  46204. /**
  46205. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46206. */
  46207. customButtons?: Array<WebXREnterExitUIButton>;
  46208. /**
  46209. * A reference space type to use when creating the default button.
  46210. * Default is local-floor
  46211. */
  46212. referenceSpaceType?: XRReferenceSpaceType;
  46213. /**
  46214. * Context to enter xr with
  46215. */
  46216. renderTarget?: Nullable<WebXRRenderTarget>;
  46217. /**
  46218. * A session mode to use when creating the default button.
  46219. * Default is immersive-vr
  46220. */
  46221. sessionMode?: XRSessionMode;
  46222. }
  46223. /**
  46224. * UI to allow the user to enter/exit XR mode
  46225. */
  46226. export class WebXREnterExitUI implements IDisposable {
  46227. private scene;
  46228. /** version of the options passed to this UI */
  46229. options: WebXREnterExitUIOptions;
  46230. private _activeButton;
  46231. private _buttons;
  46232. private _overlay;
  46233. /**
  46234. * Fired every time the active button is changed.
  46235. *
  46236. * When xr is entered via a button that launches xr that button will be the callback parameter
  46237. *
  46238. * When exiting xr the callback parameter will be null)
  46239. */
  46240. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46241. /**
  46242. *
  46243. * @param scene babylon scene object to use
  46244. * @param options (read-only) version of the options passed to this UI
  46245. */
  46246. private constructor();
  46247. /**
  46248. * Creates UI to allow the user to enter/exit XR mode
  46249. * @param scene the scene to add the ui to
  46250. * @param helper the xr experience helper to enter/exit xr with
  46251. * @param options options to configure the UI
  46252. * @returns the created ui
  46253. */
  46254. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46255. /**
  46256. * Disposes of the XR UI component
  46257. */
  46258. dispose(): void;
  46259. private _updateButtons;
  46260. }
  46261. }
  46262. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46263. import { Vector3 } from "babylonjs/Maths/math.vector";
  46264. import { Color4 } from "babylonjs/Maths/math.color";
  46265. import { Nullable } from "babylonjs/types";
  46266. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46267. import { Scene } from "babylonjs/scene";
  46268. /**
  46269. * Class containing static functions to help procedurally build meshes
  46270. */
  46271. export class LinesBuilder {
  46272. /**
  46273. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46274. * * 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
  46275. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46276. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46277. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46278. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46279. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46280. * * 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
  46281. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46284. * @param name defines the name of the new line system
  46285. * @param options defines the options used to create the line system
  46286. * @param scene defines the hosting scene
  46287. * @returns a new line system mesh
  46288. */
  46289. static CreateLineSystem(name: string, options: {
  46290. lines: Vector3[][];
  46291. updatable?: boolean;
  46292. instance?: Nullable<LinesMesh>;
  46293. colors?: Nullable<Color4[][]>;
  46294. useVertexAlpha?: boolean;
  46295. }, scene: Nullable<Scene>): LinesMesh;
  46296. /**
  46297. * Creates a line mesh
  46298. * 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
  46299. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46300. * * The parameter `points` is an array successive Vector3
  46301. * * 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
  46302. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46303. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46304. * * When updating an instance, remember that only point positions can change, not the number of points
  46305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46307. * @param name defines the name of the new line system
  46308. * @param options defines the options used to create the line system
  46309. * @param scene defines the hosting scene
  46310. * @returns a new line mesh
  46311. */
  46312. static CreateLines(name: string, options: {
  46313. points: Vector3[];
  46314. updatable?: boolean;
  46315. instance?: Nullable<LinesMesh>;
  46316. colors?: Color4[];
  46317. useVertexAlpha?: boolean;
  46318. }, scene?: Nullable<Scene>): LinesMesh;
  46319. /**
  46320. * Creates a dashed line mesh
  46321. * * 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
  46322. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46323. * * The parameter `points` is an array successive Vector3
  46324. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46325. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46326. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46327. * * 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
  46328. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46329. * * When updating an instance, remember that only point positions can change, not the number of points
  46330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46331. * @param name defines the name of the mesh
  46332. * @param options defines the options used to create the mesh
  46333. * @param scene defines the hosting scene
  46334. * @returns the dashed line mesh
  46335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46336. */
  46337. static CreateDashedLines(name: string, options: {
  46338. points: Vector3[];
  46339. dashSize?: number;
  46340. gapSize?: number;
  46341. dashNb?: number;
  46342. updatable?: boolean;
  46343. instance?: LinesMesh;
  46344. useVertexAlpha?: boolean;
  46345. }, scene?: Nullable<Scene>): LinesMesh;
  46346. }
  46347. }
  46348. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46349. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46350. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46351. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46353. import { Vector3 } from "babylonjs/Maths/math.vector";
  46354. import { Material } from "babylonjs/Materials/material";
  46355. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46356. import { Scene } from "babylonjs/scene";
  46357. /**
  46358. * The options container for the teleportation module
  46359. */
  46360. export interface IWebXRTeleportationOptions {
  46361. /**
  46362. * if provided, this scene will be used to render meshes.
  46363. */
  46364. customUtilityLayerScene?: Scene;
  46365. /**
  46366. * Values to configure the default target mesh
  46367. */
  46368. defaultTargetMeshOptions?: {
  46369. /**
  46370. * Fill color of the teleportation area
  46371. */
  46372. teleportationFillColor?: string;
  46373. /**
  46374. * Border color for the teleportation area
  46375. */
  46376. teleportationBorderColor?: string;
  46377. /**
  46378. * Disable the mesh's animation sequence
  46379. */
  46380. disableAnimation?: boolean;
  46381. /**
  46382. * Disable lighting on the material or the ring and arrow
  46383. */
  46384. disableLighting?: boolean;
  46385. /**
  46386. * Override the default material of the torus and arrow
  46387. */
  46388. torusArrowMaterial?: Material;
  46389. };
  46390. /**
  46391. * A list of meshes to use as floor meshes.
  46392. * Meshes can be added and removed after initializing the feature using the
  46393. * addFloorMesh and removeFloorMesh functions
  46394. * If empty, rotation will still work
  46395. */
  46396. floorMeshes?: AbstractMesh[];
  46397. /**
  46398. * use this rendering group id for the meshes (optional)
  46399. */
  46400. renderingGroupId?: number;
  46401. /**
  46402. * Should teleportation move only to snap points
  46403. */
  46404. snapPointsOnly?: boolean;
  46405. /**
  46406. * An array of points to which the teleportation will snap to.
  46407. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46408. */
  46409. snapPositions?: Vector3[];
  46410. /**
  46411. * How close should the teleportation ray be in order to snap to position.
  46412. * Default to 0.8 units (meters)
  46413. */
  46414. snapToPositionRadius?: number;
  46415. /**
  46416. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46417. * If you want to support rotation, make sure your mesh has a direction indicator.
  46418. *
  46419. * When left untouched, the default mesh will be initialized.
  46420. */
  46421. teleportationTargetMesh?: AbstractMesh;
  46422. /**
  46423. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46424. */
  46425. timeToTeleport?: number;
  46426. /**
  46427. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46428. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46429. */
  46430. useMainComponentOnly?: boolean;
  46431. /**
  46432. * Should meshes created here be added to a utility layer or the main scene
  46433. */
  46434. useUtilityLayer?: boolean;
  46435. /**
  46436. * Babylon XR Input class for controller
  46437. */
  46438. xrInput: WebXRInput;
  46439. }
  46440. /**
  46441. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46442. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46443. * the input of the attached controllers.
  46444. */
  46445. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46446. private _options;
  46447. private _controllers;
  46448. private _currentTeleportationControllerId;
  46449. private _floorMeshes;
  46450. private _quadraticBezierCurve;
  46451. private _selectionFeature;
  46452. private _snapToPositions;
  46453. private _snappedToPoint;
  46454. private _teleportationRingMaterial?;
  46455. private _tmpRay;
  46456. private _tmpVector;
  46457. /**
  46458. * The module's name
  46459. */
  46460. static readonly Name: string;
  46461. /**
  46462. * The (Babylon) version of this module.
  46463. * This is an integer representing the implementation version.
  46464. * This number does not correspond to the webxr specs version
  46465. */
  46466. static readonly Version: number;
  46467. /**
  46468. * Is movement backwards enabled
  46469. */
  46470. backwardsMovementEnabled: boolean;
  46471. /**
  46472. * Distance to travel when moving backwards
  46473. */
  46474. backwardsTeleportationDistance: number;
  46475. /**
  46476. * The distance from the user to the inspection point in the direction of the controller
  46477. * A higher number will allow the user to move further
  46478. * defaults to 5 (meters, in xr units)
  46479. */
  46480. parabolicCheckRadius: number;
  46481. /**
  46482. * Should the module support parabolic ray on top of direct ray
  46483. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46484. * Very helpful when moving between floors / different heights
  46485. */
  46486. parabolicRayEnabled: boolean;
  46487. /**
  46488. * How much rotation should be applied when rotating right and left
  46489. */
  46490. rotationAngle: number;
  46491. /**
  46492. * Is rotation enabled when moving forward?
  46493. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46494. */
  46495. rotationEnabled: boolean;
  46496. /**
  46497. * constructs a new anchor system
  46498. * @param _xrSessionManager an instance of WebXRSessionManager
  46499. * @param _options configuration object for this feature
  46500. */
  46501. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46502. /**
  46503. * Get the snapPointsOnly flag
  46504. */
  46505. get snapPointsOnly(): boolean;
  46506. /**
  46507. * Sets the snapPointsOnly flag
  46508. * @param snapToPoints should teleportation be exclusively to snap points
  46509. */
  46510. set snapPointsOnly(snapToPoints: boolean);
  46511. /**
  46512. * Add a new mesh to the floor meshes array
  46513. * @param mesh the mesh to use as floor mesh
  46514. */
  46515. addFloorMesh(mesh: AbstractMesh): void;
  46516. /**
  46517. * Add a new snap-to point to fix teleportation to this position
  46518. * @param newSnapPoint The new Snap-To point
  46519. */
  46520. addSnapPoint(newSnapPoint: Vector3): void;
  46521. attach(): boolean;
  46522. detach(): boolean;
  46523. dispose(): void;
  46524. /**
  46525. * Remove a mesh from the floor meshes array
  46526. * @param mesh the mesh to remove
  46527. */
  46528. removeFloorMesh(mesh: AbstractMesh): void;
  46529. /**
  46530. * Remove a mesh from the floor meshes array using its name
  46531. * @param name the mesh name to remove
  46532. */
  46533. removeFloorMeshByName(name: string): void;
  46534. /**
  46535. * 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
  46536. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46537. * @returns was the point found and removed or not
  46538. */
  46539. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46540. /**
  46541. * This function sets a selection feature that will be disabled when
  46542. * the forward ray is shown and will be reattached when hidden.
  46543. * This is used to remove the selection rays when moving.
  46544. * @param selectionFeature the feature to disable when forward movement is enabled
  46545. */
  46546. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46547. protected _onXRFrame(_xrFrame: XRFrame): void;
  46548. private _attachController;
  46549. private _createDefaultTargetMesh;
  46550. private _detachController;
  46551. private _findClosestSnapPointWithRadius;
  46552. private _setTargetMeshPosition;
  46553. private _setTargetMeshVisibility;
  46554. private _showParabolicPath;
  46555. private _teleportForward;
  46556. }
  46557. }
  46558. declare module "babylonjs/XR/webXRDefaultExperience" {
  46559. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46560. import { Scene } from "babylonjs/scene";
  46561. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46562. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46563. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46564. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46566. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46567. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46568. /**
  46569. * Options for the default xr helper
  46570. */
  46571. export class WebXRDefaultExperienceOptions {
  46572. /**
  46573. * Enable or disable default UI to enter XR
  46574. */
  46575. disableDefaultUI?: boolean;
  46576. /**
  46577. * Should teleportation not initialize. defaults to false.
  46578. */
  46579. disableTeleportation?: boolean;
  46580. /**
  46581. * Floor meshes that will be used for teleport
  46582. */
  46583. floorMeshes?: Array<AbstractMesh>;
  46584. /**
  46585. * If set to true, the first frame will not be used to reset position
  46586. * The first frame is mainly used when copying transformation from the old camera
  46587. * Mainly used in AR
  46588. */
  46589. ignoreNativeCameraTransformation?: boolean;
  46590. /**
  46591. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46592. */
  46593. inputOptions?: IWebXRInputOptions;
  46594. /**
  46595. * optional configuration for the output canvas
  46596. */
  46597. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46598. /**
  46599. * optional UI options. This can be used among other to change session mode and reference space type
  46600. */
  46601. uiOptions?: WebXREnterExitUIOptions;
  46602. /**
  46603. * When loading teleportation and pointer select, use stable versions instead of latest.
  46604. */
  46605. useStablePlugins?: boolean;
  46606. }
  46607. /**
  46608. * Default experience which provides a similar setup to the previous webVRExperience
  46609. */
  46610. export class WebXRDefaultExperience {
  46611. /**
  46612. * Base experience
  46613. */
  46614. baseExperience: WebXRExperienceHelper;
  46615. /**
  46616. * Enables ui for entering/exiting xr
  46617. */
  46618. enterExitUI: WebXREnterExitUI;
  46619. /**
  46620. * Input experience extension
  46621. */
  46622. input: WebXRInput;
  46623. /**
  46624. * Enables laser pointer and selection
  46625. */
  46626. pointerSelection: WebXRControllerPointerSelection;
  46627. /**
  46628. * Default target xr should render to
  46629. */
  46630. renderTarget: WebXRRenderTarget;
  46631. /**
  46632. * Enables teleportation
  46633. */
  46634. teleportation: WebXRMotionControllerTeleportation;
  46635. private constructor();
  46636. /**
  46637. * Creates the default xr experience
  46638. * @param scene scene
  46639. * @param options options for basic configuration
  46640. * @returns resulting WebXRDefaultExperience
  46641. */
  46642. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46643. /**
  46644. * DIsposes of the experience helper
  46645. */
  46646. dispose(): void;
  46647. }
  46648. }
  46649. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46650. import { Observable } from "babylonjs/Misc/observable";
  46651. import { Nullable } from "babylonjs/types";
  46652. import { Camera } from "babylonjs/Cameras/camera";
  46653. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46654. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46655. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46656. import { Scene } from "babylonjs/scene";
  46657. import { Vector3 } from "babylonjs/Maths/math.vector";
  46658. import { Color3 } from "babylonjs/Maths/math.color";
  46659. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46661. import { Mesh } from "babylonjs/Meshes/mesh";
  46662. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46663. import { EasingFunction } from "babylonjs/Animations/easing";
  46664. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46665. import "babylonjs/Meshes/Builders/groundBuilder";
  46666. import "babylonjs/Meshes/Builders/torusBuilder";
  46667. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46668. import "babylonjs/Gamepads/gamepadSceneComponent";
  46669. import "babylonjs/Animations/animatable";
  46670. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46671. /**
  46672. * Options to modify the vr teleportation behavior.
  46673. */
  46674. export interface VRTeleportationOptions {
  46675. /**
  46676. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46677. */
  46678. floorMeshName?: string;
  46679. /**
  46680. * A list of meshes to be used as the teleportation floor. (default: empty)
  46681. */
  46682. floorMeshes?: Mesh[];
  46683. /**
  46684. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46685. */
  46686. teleportationMode?: number;
  46687. /**
  46688. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46689. */
  46690. teleportationTime?: number;
  46691. /**
  46692. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46693. */
  46694. teleportationSpeed?: number;
  46695. /**
  46696. * The easing function used in the animation or null for Linear. (default CircleEase)
  46697. */
  46698. easingFunction?: EasingFunction;
  46699. }
  46700. /**
  46701. * Options to modify the vr experience helper's behavior.
  46702. */
  46703. export interface VRExperienceHelperOptions extends WebVROptions {
  46704. /**
  46705. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46706. */
  46707. createDeviceOrientationCamera?: boolean;
  46708. /**
  46709. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46710. */
  46711. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46712. /**
  46713. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46714. */
  46715. laserToggle?: boolean;
  46716. /**
  46717. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46718. */
  46719. floorMeshes?: Mesh[];
  46720. /**
  46721. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46722. */
  46723. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46724. /**
  46725. * Defines if WebXR should be used instead of WebVR (if available)
  46726. */
  46727. useXR?: boolean;
  46728. }
  46729. /**
  46730. * Event containing information after VR has been entered
  46731. */
  46732. export class OnAfterEnteringVRObservableEvent {
  46733. /**
  46734. * If entering vr was successful
  46735. */
  46736. success: boolean;
  46737. }
  46738. /**
  46739. * Helps to quickly add VR support to an existing scene.
  46740. * See http://doc.babylonjs.com/how_to/webvr_helper
  46741. */
  46742. export class VRExperienceHelper {
  46743. /** Options to modify the vr experience helper's behavior. */
  46744. webVROptions: VRExperienceHelperOptions;
  46745. private _scene;
  46746. private _position;
  46747. private _btnVR;
  46748. private _btnVRDisplayed;
  46749. private _webVRsupported;
  46750. private _webVRready;
  46751. private _webVRrequesting;
  46752. private _webVRpresenting;
  46753. private _hasEnteredVR;
  46754. private _fullscreenVRpresenting;
  46755. private _inputElement;
  46756. private _webVRCamera;
  46757. private _vrDeviceOrientationCamera;
  46758. private _deviceOrientationCamera;
  46759. private _existingCamera;
  46760. private _onKeyDown;
  46761. private _onVrDisplayPresentChange;
  46762. private _onVRDisplayChanged;
  46763. private _onVRRequestPresentStart;
  46764. private _onVRRequestPresentComplete;
  46765. /**
  46766. * 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)
  46767. */
  46768. enableGazeEvenWhenNoPointerLock: boolean;
  46769. /**
  46770. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46771. */
  46772. exitVROnDoubleTap: boolean;
  46773. /**
  46774. * Observable raised right before entering VR.
  46775. */
  46776. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46777. /**
  46778. * Observable raised when entering VR has completed.
  46779. */
  46780. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46781. /**
  46782. * Observable raised when exiting VR.
  46783. */
  46784. onExitingVRObservable: Observable<VRExperienceHelper>;
  46785. /**
  46786. * Observable raised when controller mesh is loaded.
  46787. */
  46788. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46789. /** Return this.onEnteringVRObservable
  46790. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46791. */
  46792. get onEnteringVR(): Observable<VRExperienceHelper>;
  46793. /** Return this.onExitingVRObservable
  46794. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46795. */
  46796. get onExitingVR(): Observable<VRExperienceHelper>;
  46797. /** Return this.onControllerMeshLoadedObservable
  46798. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46799. */
  46800. get onControllerMeshLoaded(): Observable<WebVRController>;
  46801. private _rayLength;
  46802. private _useCustomVRButton;
  46803. private _teleportationRequested;
  46804. private _teleportActive;
  46805. private _floorMeshName;
  46806. private _floorMeshesCollection;
  46807. private _teleportationMode;
  46808. private _teleportationTime;
  46809. private _teleportationSpeed;
  46810. private _teleportationEasing;
  46811. private _rotationAllowed;
  46812. private _teleportBackwardsVector;
  46813. private _teleportationTarget;
  46814. private _isDefaultTeleportationTarget;
  46815. private _postProcessMove;
  46816. private _teleportationFillColor;
  46817. private _teleportationBorderColor;
  46818. private _rotationAngle;
  46819. private _haloCenter;
  46820. private _cameraGazer;
  46821. private _padSensibilityUp;
  46822. private _padSensibilityDown;
  46823. private _leftController;
  46824. private _rightController;
  46825. private _gazeColor;
  46826. private _laserColor;
  46827. private _pickedLaserColor;
  46828. private _pickedGazeColor;
  46829. /**
  46830. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46831. */
  46832. onNewMeshSelected: Observable<AbstractMesh>;
  46833. /**
  46834. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46835. * This observable will provide the mesh and the controller used to select the mesh
  46836. */
  46837. onMeshSelectedWithController: Observable<{
  46838. mesh: AbstractMesh;
  46839. controller: WebVRController;
  46840. }>;
  46841. /**
  46842. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46843. */
  46844. onNewMeshPicked: Observable<PickingInfo>;
  46845. private _circleEase;
  46846. /**
  46847. * Observable raised before camera teleportation
  46848. */
  46849. onBeforeCameraTeleport: Observable<Vector3>;
  46850. /**
  46851. * Observable raised after camera teleportation
  46852. */
  46853. onAfterCameraTeleport: Observable<Vector3>;
  46854. /**
  46855. * Observable raised when current selected mesh gets unselected
  46856. */
  46857. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46858. private _raySelectionPredicate;
  46859. /**
  46860. * To be optionaly changed by user to define custom ray selection
  46861. */
  46862. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46863. /**
  46864. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46865. */
  46866. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46867. /**
  46868. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46869. */
  46870. teleportationEnabled: boolean;
  46871. private _defaultHeight;
  46872. private _teleportationInitialized;
  46873. private _interactionsEnabled;
  46874. private _interactionsRequested;
  46875. private _displayGaze;
  46876. private _displayLaserPointer;
  46877. /**
  46878. * The mesh used to display where the user is going to teleport.
  46879. */
  46880. get teleportationTarget(): Mesh;
  46881. /**
  46882. * Sets the mesh to be used to display where the user is going to teleport.
  46883. */
  46884. set teleportationTarget(value: Mesh);
  46885. /**
  46886. * 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
  46887. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46888. * See http://doc.babylonjs.com/resources/baking_transformations
  46889. */
  46890. get gazeTrackerMesh(): Mesh;
  46891. set gazeTrackerMesh(value: Mesh);
  46892. /**
  46893. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46894. */
  46895. updateGazeTrackerScale: boolean;
  46896. /**
  46897. * If the gaze trackers color should be updated when selecting meshes
  46898. */
  46899. updateGazeTrackerColor: boolean;
  46900. /**
  46901. * If the controller laser color should be updated when selecting meshes
  46902. */
  46903. updateControllerLaserColor: boolean;
  46904. /**
  46905. * The gaze tracking mesh corresponding to the left controller
  46906. */
  46907. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46908. /**
  46909. * The gaze tracking mesh corresponding to the right controller
  46910. */
  46911. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46912. /**
  46913. * If the ray of the gaze should be displayed.
  46914. */
  46915. get displayGaze(): boolean;
  46916. /**
  46917. * Sets if the ray of the gaze should be displayed.
  46918. */
  46919. set displayGaze(value: boolean);
  46920. /**
  46921. * If the ray of the LaserPointer should be displayed.
  46922. */
  46923. get displayLaserPointer(): boolean;
  46924. /**
  46925. * Sets if the ray of the LaserPointer should be displayed.
  46926. */
  46927. set displayLaserPointer(value: boolean);
  46928. /**
  46929. * The deviceOrientationCamera used as the camera when not in VR.
  46930. */
  46931. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46932. /**
  46933. * Based on the current WebVR support, returns the current VR camera used.
  46934. */
  46935. get currentVRCamera(): Nullable<Camera>;
  46936. /**
  46937. * The webVRCamera which is used when in VR.
  46938. */
  46939. get webVRCamera(): WebVRFreeCamera;
  46940. /**
  46941. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46942. */
  46943. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46944. /**
  46945. * The html button that is used to trigger entering into VR.
  46946. */
  46947. get vrButton(): Nullable<HTMLButtonElement>;
  46948. private get _teleportationRequestInitiated();
  46949. /**
  46950. * Defines whether or not Pointer lock should be requested when switching to
  46951. * full screen.
  46952. */
  46953. requestPointerLockOnFullScreen: boolean;
  46954. /**
  46955. * If asking to force XR, this will be populated with the default xr experience
  46956. */
  46957. xr: WebXRDefaultExperience;
  46958. /**
  46959. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46960. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46961. */
  46962. xrTestDone: boolean;
  46963. /**
  46964. * Instantiates a VRExperienceHelper.
  46965. * Helps to quickly add VR support to an existing scene.
  46966. * @param scene The scene the VRExperienceHelper belongs to.
  46967. * @param webVROptions Options to modify the vr experience helper's behavior.
  46968. */
  46969. constructor(scene: Scene,
  46970. /** Options to modify the vr experience helper's behavior. */
  46971. webVROptions?: VRExperienceHelperOptions);
  46972. private completeVRInit;
  46973. private _onDefaultMeshLoaded;
  46974. private _onResize;
  46975. private _onFullscreenChange;
  46976. /**
  46977. * Gets a value indicating if we are currently in VR mode.
  46978. */
  46979. get isInVRMode(): boolean;
  46980. private onVrDisplayPresentChange;
  46981. private onVRDisplayChanged;
  46982. private moveButtonToBottomRight;
  46983. private displayVRButton;
  46984. private updateButtonVisibility;
  46985. private _cachedAngularSensibility;
  46986. /**
  46987. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46988. * Otherwise, will use the fullscreen API.
  46989. */
  46990. enterVR(): void;
  46991. /**
  46992. * Attempt to exit VR, or fullscreen.
  46993. */
  46994. exitVR(): void;
  46995. /**
  46996. * The position of the vr experience helper.
  46997. */
  46998. get position(): Vector3;
  46999. /**
  47000. * Sets the position of the vr experience helper.
  47001. */
  47002. set position(value: Vector3);
  47003. /**
  47004. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47005. */
  47006. enableInteractions(): void;
  47007. private get _noControllerIsActive();
  47008. private beforeRender;
  47009. private _isTeleportationFloor;
  47010. /**
  47011. * Adds a floor mesh to be used for teleportation.
  47012. * @param floorMesh the mesh to be used for teleportation.
  47013. */
  47014. addFloorMesh(floorMesh: Mesh): void;
  47015. /**
  47016. * Removes a floor mesh from being used for teleportation.
  47017. * @param floorMesh the mesh to be removed.
  47018. */
  47019. removeFloorMesh(floorMesh: Mesh): void;
  47020. /**
  47021. * Enables interactions and teleportation using the VR controllers and gaze.
  47022. * @param vrTeleportationOptions options to modify teleportation behavior.
  47023. */
  47024. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47025. private _onNewGamepadConnected;
  47026. private _tryEnableInteractionOnController;
  47027. private _onNewGamepadDisconnected;
  47028. private _enableInteractionOnController;
  47029. private _checkTeleportWithRay;
  47030. private _checkRotate;
  47031. private _checkTeleportBackwards;
  47032. private _enableTeleportationOnController;
  47033. private _createTeleportationCircles;
  47034. private _displayTeleportationTarget;
  47035. private _hideTeleportationTarget;
  47036. private _rotateCamera;
  47037. private _moveTeleportationSelectorTo;
  47038. private _workingVector;
  47039. private _workingQuaternion;
  47040. private _workingMatrix;
  47041. /**
  47042. * Time Constant Teleportation Mode
  47043. */
  47044. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47045. /**
  47046. * Speed Constant Teleportation Mode
  47047. */
  47048. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47049. /**
  47050. * Teleports the users feet to the desired location
  47051. * @param location The location where the user's feet should be placed
  47052. */
  47053. teleportCamera(location: Vector3): void;
  47054. private _convertNormalToDirectionOfRay;
  47055. private _castRayAndSelectObject;
  47056. private _notifySelectedMeshUnselected;
  47057. /**
  47058. * Permanently set new colors for the laser pointer
  47059. * @param color the new laser color
  47060. * @param pickedColor the new laser color when picked mesh detected
  47061. */
  47062. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47063. /**
  47064. * Set lighting enabled / disabled on the laser pointer of both controllers
  47065. * @param enabled should the lighting be enabled on the laser pointer
  47066. */
  47067. setLaserLightingState(enabled?: boolean): void;
  47068. /**
  47069. * Permanently set new colors for the gaze pointer
  47070. * @param color the new gaze color
  47071. * @param pickedColor the new gaze color when picked mesh detected
  47072. */
  47073. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47074. /**
  47075. * Sets the color of the laser ray from the vr controllers.
  47076. * @param color new color for the ray.
  47077. */
  47078. changeLaserColor(color: Color3): void;
  47079. /**
  47080. * Sets the color of the ray from the vr headsets gaze.
  47081. * @param color new color for the ray.
  47082. */
  47083. changeGazeColor(color: Color3): void;
  47084. /**
  47085. * Exits VR and disposes of the vr experience helper
  47086. */
  47087. dispose(): void;
  47088. /**
  47089. * Gets the name of the VRExperienceHelper class
  47090. * @returns "VRExperienceHelper"
  47091. */
  47092. getClassName(): string;
  47093. }
  47094. }
  47095. declare module "babylonjs/Cameras/VR/index" {
  47096. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47097. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47098. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47099. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47100. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47101. export * from "babylonjs/Cameras/VR/webVRCamera";
  47102. }
  47103. declare module "babylonjs/Cameras/RigModes/index" {
  47104. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47105. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47106. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47107. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47108. }
  47109. declare module "babylonjs/Cameras/index" {
  47110. export * from "babylonjs/Cameras/Inputs/index";
  47111. export * from "babylonjs/Cameras/cameraInputsManager";
  47112. export * from "babylonjs/Cameras/camera";
  47113. export * from "babylonjs/Cameras/targetCamera";
  47114. export * from "babylonjs/Cameras/freeCamera";
  47115. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47116. export * from "babylonjs/Cameras/touchCamera";
  47117. export * from "babylonjs/Cameras/arcRotateCamera";
  47118. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47119. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47120. export * from "babylonjs/Cameras/flyCamera";
  47121. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47122. export * from "babylonjs/Cameras/followCamera";
  47123. export * from "babylonjs/Cameras/followCameraInputsManager";
  47124. export * from "babylonjs/Cameras/gamepadCamera";
  47125. export * from "babylonjs/Cameras/Stereoscopic/index";
  47126. export * from "babylonjs/Cameras/universalCamera";
  47127. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47128. export * from "babylonjs/Cameras/VR/index";
  47129. export * from "babylonjs/Cameras/RigModes/index";
  47130. }
  47131. declare module "babylonjs/Collisions/index" {
  47132. export * from "babylonjs/Collisions/collider";
  47133. export * from "babylonjs/Collisions/collisionCoordinator";
  47134. export * from "babylonjs/Collisions/pickingInfo";
  47135. export * from "babylonjs/Collisions/intersectionInfo";
  47136. export * from "babylonjs/Collisions/meshCollisionData";
  47137. }
  47138. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47139. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47140. import { Vector3 } from "babylonjs/Maths/math.vector";
  47141. import { Ray } from "babylonjs/Culling/ray";
  47142. import { Plane } from "babylonjs/Maths/math.plane";
  47143. /**
  47144. * Contains an array of blocks representing the octree
  47145. */
  47146. export interface IOctreeContainer<T> {
  47147. /**
  47148. * Blocks within the octree
  47149. */
  47150. blocks: Array<OctreeBlock<T>>;
  47151. }
  47152. /**
  47153. * Class used to store a cell in an octree
  47154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47155. */
  47156. export class OctreeBlock<T> {
  47157. /**
  47158. * Gets the content of the current block
  47159. */
  47160. entries: T[];
  47161. /**
  47162. * Gets the list of block children
  47163. */
  47164. blocks: Array<OctreeBlock<T>>;
  47165. private _depth;
  47166. private _maxDepth;
  47167. private _capacity;
  47168. private _minPoint;
  47169. private _maxPoint;
  47170. private _boundingVectors;
  47171. private _creationFunc;
  47172. /**
  47173. * Creates a new block
  47174. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47175. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47176. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47177. * @param depth defines the current depth of this block in the octree
  47178. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47179. * @param creationFunc defines a callback to call when an element is added to the block
  47180. */
  47181. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47182. /**
  47183. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47184. */
  47185. get capacity(): number;
  47186. /**
  47187. * Gets the minimum vector (in world space) of the block's bounding box
  47188. */
  47189. get minPoint(): Vector3;
  47190. /**
  47191. * Gets the maximum vector (in world space) of the block's bounding box
  47192. */
  47193. get maxPoint(): Vector3;
  47194. /**
  47195. * Add a new element to this block
  47196. * @param entry defines the element to add
  47197. */
  47198. addEntry(entry: T): void;
  47199. /**
  47200. * Remove an element from this block
  47201. * @param entry defines the element to remove
  47202. */
  47203. removeEntry(entry: T): void;
  47204. /**
  47205. * Add an array of elements to this block
  47206. * @param entries defines the array of elements to add
  47207. */
  47208. addEntries(entries: T[]): void;
  47209. /**
  47210. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47211. * @param frustumPlanes defines the frustum planes to test
  47212. * @param selection defines the array to store current content if selection is positive
  47213. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47214. */
  47215. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47216. /**
  47217. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47218. * @param sphereCenter defines the bounding sphere center
  47219. * @param sphereRadius defines the bounding sphere radius
  47220. * @param selection defines the array to store current content if selection is positive
  47221. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47222. */
  47223. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47224. /**
  47225. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47226. * @param ray defines the ray to test with
  47227. * @param selection defines the array to store current content if selection is positive
  47228. */
  47229. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47230. /**
  47231. * Subdivide the content into child blocks (this block will then be empty)
  47232. */
  47233. createInnerBlocks(): void;
  47234. /**
  47235. * @hidden
  47236. */
  47237. 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;
  47238. }
  47239. }
  47240. declare module "babylonjs/Culling/Octrees/octree" {
  47241. import { SmartArray } from "babylonjs/Misc/smartArray";
  47242. import { Vector3 } from "babylonjs/Maths/math.vector";
  47243. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47245. import { Ray } from "babylonjs/Culling/ray";
  47246. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47247. import { Plane } from "babylonjs/Maths/math.plane";
  47248. /**
  47249. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47250. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47251. */
  47252. export class Octree<T> {
  47253. /** 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.) */
  47254. maxDepth: number;
  47255. /**
  47256. * Blocks within the octree containing objects
  47257. */
  47258. blocks: Array<OctreeBlock<T>>;
  47259. /**
  47260. * Content stored in the octree
  47261. */
  47262. dynamicContent: T[];
  47263. private _maxBlockCapacity;
  47264. private _selectionContent;
  47265. private _creationFunc;
  47266. /**
  47267. * Creates a octree
  47268. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47269. * @param creationFunc function to be used to instatiate the octree
  47270. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47271. * @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.)
  47272. */
  47273. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47274. /** 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.) */
  47275. maxDepth?: number);
  47276. /**
  47277. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47278. * @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);
  47279. * @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);
  47280. * @param entries meshes to be added to the octree blocks
  47281. */
  47282. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47283. /**
  47284. * Adds a mesh to the octree
  47285. * @param entry Mesh to add to the octree
  47286. */
  47287. addMesh(entry: T): void;
  47288. /**
  47289. * Remove an element from the octree
  47290. * @param entry defines the element to remove
  47291. */
  47292. removeMesh(entry: T): void;
  47293. /**
  47294. * Selects an array of meshes within the frustum
  47295. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47296. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47297. * @returns array of meshes within the frustum
  47298. */
  47299. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47300. /**
  47301. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47302. * @param sphereCenter defines the bounding sphere center
  47303. * @param sphereRadius defines the bounding sphere radius
  47304. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47305. * @returns an array of objects that intersect the sphere
  47306. */
  47307. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47308. /**
  47309. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47310. * @param ray defines the ray to test with
  47311. * @returns array of intersected objects
  47312. */
  47313. intersectsRay(ray: Ray): SmartArray<T>;
  47314. /**
  47315. * Adds a mesh into the octree block if it intersects the block
  47316. */
  47317. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47318. /**
  47319. * Adds a submesh into the octree block if it intersects the block
  47320. */
  47321. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47322. }
  47323. }
  47324. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47325. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47326. import { Scene } from "babylonjs/scene";
  47327. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47329. import { Ray } from "babylonjs/Culling/ray";
  47330. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47331. import { Collider } from "babylonjs/Collisions/collider";
  47332. module "babylonjs/scene" {
  47333. interface Scene {
  47334. /**
  47335. * @hidden
  47336. * Backing Filed
  47337. */
  47338. _selectionOctree: Octree<AbstractMesh>;
  47339. /**
  47340. * Gets the octree used to boost mesh selection (picking)
  47341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47342. */
  47343. selectionOctree: Octree<AbstractMesh>;
  47344. /**
  47345. * Creates or updates the octree used to boost selection (picking)
  47346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47347. * @param maxCapacity defines the maximum capacity per leaf
  47348. * @param maxDepth defines the maximum depth of the octree
  47349. * @returns an octree of AbstractMesh
  47350. */
  47351. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47352. }
  47353. }
  47354. module "babylonjs/Meshes/abstractMesh" {
  47355. interface AbstractMesh {
  47356. /**
  47357. * @hidden
  47358. * Backing Field
  47359. */
  47360. _submeshesOctree: Octree<SubMesh>;
  47361. /**
  47362. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47363. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47364. * @param maxCapacity defines the maximum size of each block (64 by default)
  47365. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47366. * @returns the new octree
  47367. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47369. */
  47370. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47371. }
  47372. }
  47373. /**
  47374. * Defines the octree scene component responsible to manage any octrees
  47375. * in a given scene.
  47376. */
  47377. export class OctreeSceneComponent {
  47378. /**
  47379. * The component name help to identify the component in the list of scene components.
  47380. */
  47381. readonly name: string;
  47382. /**
  47383. * The scene the component belongs to.
  47384. */
  47385. scene: Scene;
  47386. /**
  47387. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47388. */
  47389. readonly checksIsEnabled: boolean;
  47390. /**
  47391. * Creates a new instance of the component for the given scene
  47392. * @param scene Defines the scene to register the component in
  47393. */
  47394. constructor(scene: Scene);
  47395. /**
  47396. * Registers the component in a given scene
  47397. */
  47398. register(): void;
  47399. /**
  47400. * Return the list of active meshes
  47401. * @returns the list of active meshes
  47402. */
  47403. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47404. /**
  47405. * Return the list of active sub meshes
  47406. * @param mesh The mesh to get the candidates sub meshes from
  47407. * @returns the list of active sub meshes
  47408. */
  47409. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47410. private _tempRay;
  47411. /**
  47412. * Return the list of sub meshes intersecting with a given local ray
  47413. * @param mesh defines the mesh to find the submesh for
  47414. * @param localRay defines the ray in local space
  47415. * @returns the list of intersecting sub meshes
  47416. */
  47417. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47418. /**
  47419. * Return the list of sub meshes colliding with a collider
  47420. * @param mesh defines the mesh to find the submesh for
  47421. * @param collider defines the collider to evaluate the collision against
  47422. * @returns the list of colliding sub meshes
  47423. */
  47424. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47425. /**
  47426. * Rebuilds the elements related to this component in case of
  47427. * context lost for instance.
  47428. */
  47429. rebuild(): void;
  47430. /**
  47431. * Disposes the component and the associated ressources.
  47432. */
  47433. dispose(): void;
  47434. }
  47435. }
  47436. declare module "babylonjs/Culling/Octrees/index" {
  47437. export * from "babylonjs/Culling/Octrees/octree";
  47438. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47439. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47440. }
  47441. declare module "babylonjs/Culling/index" {
  47442. export * from "babylonjs/Culling/boundingBox";
  47443. export * from "babylonjs/Culling/boundingInfo";
  47444. export * from "babylonjs/Culling/boundingSphere";
  47445. export * from "babylonjs/Culling/Octrees/index";
  47446. export * from "babylonjs/Culling/ray";
  47447. }
  47448. declare module "babylonjs/Gizmos/gizmo" {
  47449. import { Nullable } from "babylonjs/types";
  47450. import { IDisposable } from "babylonjs/scene";
  47451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47452. import { Mesh } from "babylonjs/Meshes/mesh";
  47453. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47454. /**
  47455. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47456. */
  47457. export class Gizmo implements IDisposable {
  47458. /** The utility layer the gizmo will be added to */
  47459. gizmoLayer: UtilityLayerRenderer;
  47460. /**
  47461. * The root mesh of the gizmo
  47462. */
  47463. _rootMesh: Mesh;
  47464. private _attachedMesh;
  47465. /**
  47466. * Ratio for the scale of the gizmo (Default: 1)
  47467. */
  47468. scaleRatio: number;
  47469. /**
  47470. * If a custom mesh has been set (Default: false)
  47471. */
  47472. protected _customMeshSet: boolean;
  47473. /**
  47474. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47475. * * When set, interactions will be enabled
  47476. */
  47477. get attachedMesh(): Nullable<AbstractMesh>;
  47478. set attachedMesh(value: Nullable<AbstractMesh>);
  47479. /**
  47480. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47481. * @param mesh The mesh to replace the default mesh of the gizmo
  47482. */
  47483. setCustomMesh(mesh: Mesh): void;
  47484. /**
  47485. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47486. */
  47487. updateGizmoRotationToMatchAttachedMesh: boolean;
  47488. /**
  47489. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47490. */
  47491. updateGizmoPositionToMatchAttachedMesh: boolean;
  47492. /**
  47493. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47494. */
  47495. updateScale: boolean;
  47496. protected _interactionsEnabled: boolean;
  47497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47498. private _beforeRenderObserver;
  47499. private _tempVector;
  47500. /**
  47501. * Creates a gizmo
  47502. * @param gizmoLayer The utility layer the gizmo will be added to
  47503. */
  47504. constructor(
  47505. /** The utility layer the gizmo will be added to */
  47506. gizmoLayer?: UtilityLayerRenderer);
  47507. /**
  47508. * Updates the gizmo to match the attached mesh's position/rotation
  47509. */
  47510. protected _update(): void;
  47511. /**
  47512. * Disposes of the gizmo
  47513. */
  47514. dispose(): void;
  47515. }
  47516. }
  47517. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47518. import { Observable } from "babylonjs/Misc/observable";
  47519. import { Nullable } from "babylonjs/types";
  47520. import { Vector3 } from "babylonjs/Maths/math.vector";
  47521. import { Color3 } from "babylonjs/Maths/math.color";
  47522. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47524. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47525. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47526. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47527. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47528. import { Scene } from "babylonjs/scene";
  47529. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47530. /**
  47531. * Single plane drag gizmo
  47532. */
  47533. export class PlaneDragGizmo extends Gizmo {
  47534. /**
  47535. * Drag behavior responsible for the gizmos dragging interactions
  47536. */
  47537. dragBehavior: PointerDragBehavior;
  47538. private _pointerObserver;
  47539. /**
  47540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47541. */
  47542. snapDistance: number;
  47543. /**
  47544. * Event that fires each time the gizmo snaps to a new location.
  47545. * * snapDistance is the the change in distance
  47546. */
  47547. onSnapObservable: Observable<{
  47548. snapDistance: number;
  47549. }>;
  47550. private _plane;
  47551. private _coloredMaterial;
  47552. private _hoverMaterial;
  47553. private _isEnabled;
  47554. private _parent;
  47555. /** @hidden */
  47556. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47557. /** @hidden */
  47558. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47559. /**
  47560. * Creates a PlaneDragGizmo
  47561. * @param gizmoLayer The utility layer the gizmo will be added to
  47562. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47563. * @param color The color of the gizmo
  47564. */
  47565. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47567. /**
  47568. * If the gizmo is enabled
  47569. */
  47570. set isEnabled(value: boolean);
  47571. get isEnabled(): boolean;
  47572. /**
  47573. * Disposes of the gizmo
  47574. */
  47575. dispose(): void;
  47576. }
  47577. }
  47578. declare module "babylonjs/Gizmos/positionGizmo" {
  47579. import { Observable } from "babylonjs/Misc/observable";
  47580. import { Nullable } from "babylonjs/types";
  47581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47582. import { Mesh } from "babylonjs/Meshes/mesh";
  47583. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47584. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47585. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47586. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47587. /**
  47588. * Gizmo that enables dragging a mesh along 3 axis
  47589. */
  47590. export class PositionGizmo extends Gizmo {
  47591. /**
  47592. * Internal gizmo used for interactions on the x axis
  47593. */
  47594. xGizmo: AxisDragGizmo;
  47595. /**
  47596. * Internal gizmo used for interactions on the y axis
  47597. */
  47598. yGizmo: AxisDragGizmo;
  47599. /**
  47600. * Internal gizmo used for interactions on the z axis
  47601. */
  47602. zGizmo: AxisDragGizmo;
  47603. /**
  47604. * Internal gizmo used for interactions on the yz plane
  47605. */
  47606. xPlaneGizmo: PlaneDragGizmo;
  47607. /**
  47608. * Internal gizmo used for interactions on the xz plane
  47609. */
  47610. yPlaneGizmo: PlaneDragGizmo;
  47611. /**
  47612. * Internal gizmo used for interactions on the xy plane
  47613. */
  47614. zPlaneGizmo: PlaneDragGizmo;
  47615. /**
  47616. * private variables
  47617. */
  47618. private _meshAttached;
  47619. private _updateGizmoRotationToMatchAttachedMesh;
  47620. private _snapDistance;
  47621. private _scaleRatio;
  47622. /** Fires an event when any of it's sub gizmos are dragged */
  47623. onDragStartObservable: Observable<unknown>;
  47624. /** Fires an event when any of it's sub gizmos are released from dragging */
  47625. onDragEndObservable: Observable<unknown>;
  47626. /**
  47627. * If set to true, planar drag is enabled
  47628. */
  47629. private _planarGizmoEnabled;
  47630. get attachedMesh(): Nullable<AbstractMesh>;
  47631. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47632. /**
  47633. * Creates a PositionGizmo
  47634. * @param gizmoLayer The utility layer the gizmo will be added to
  47635. */
  47636. constructor(gizmoLayer?: UtilityLayerRenderer);
  47637. /**
  47638. * If the planar drag gizmo is enabled
  47639. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47640. */
  47641. set planarGizmoEnabled(value: boolean);
  47642. get planarGizmoEnabled(): boolean;
  47643. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47644. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47645. /**
  47646. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47647. */
  47648. set snapDistance(value: number);
  47649. get snapDistance(): number;
  47650. /**
  47651. * Ratio for the scale of the gizmo (Default: 1)
  47652. */
  47653. set scaleRatio(value: number);
  47654. get scaleRatio(): number;
  47655. /**
  47656. * Disposes of the gizmo
  47657. */
  47658. dispose(): void;
  47659. /**
  47660. * CustomMeshes are not supported by this gizmo
  47661. * @param mesh The mesh to replace the default mesh of the gizmo
  47662. */
  47663. setCustomMesh(mesh: Mesh): void;
  47664. }
  47665. }
  47666. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47667. import { Observable } from "babylonjs/Misc/observable";
  47668. import { Nullable } from "babylonjs/types";
  47669. import { Vector3 } from "babylonjs/Maths/math.vector";
  47670. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47672. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47673. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47674. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47675. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47676. import { Scene } from "babylonjs/scene";
  47677. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47678. import { Color3 } from "babylonjs/Maths/math.color";
  47679. /**
  47680. * Single axis drag gizmo
  47681. */
  47682. export class AxisDragGizmo extends Gizmo {
  47683. /**
  47684. * Drag behavior responsible for the gizmos dragging interactions
  47685. */
  47686. dragBehavior: PointerDragBehavior;
  47687. private _pointerObserver;
  47688. /**
  47689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47690. */
  47691. snapDistance: number;
  47692. /**
  47693. * Event that fires each time the gizmo snaps to a new location.
  47694. * * snapDistance is the the change in distance
  47695. */
  47696. onSnapObservable: Observable<{
  47697. snapDistance: number;
  47698. }>;
  47699. private _isEnabled;
  47700. private _parent;
  47701. private _arrow;
  47702. private _coloredMaterial;
  47703. private _hoverMaterial;
  47704. /** @hidden */
  47705. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47706. /** @hidden */
  47707. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47708. /**
  47709. * Creates an AxisDragGizmo
  47710. * @param gizmoLayer The utility layer the gizmo will be added to
  47711. * @param dragAxis The axis which the gizmo will be able to drag on
  47712. * @param color The color of the gizmo
  47713. */
  47714. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47715. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47716. /**
  47717. * If the gizmo is enabled
  47718. */
  47719. set isEnabled(value: boolean);
  47720. get isEnabled(): boolean;
  47721. /**
  47722. * Disposes of the gizmo
  47723. */
  47724. dispose(): void;
  47725. }
  47726. }
  47727. declare module "babylonjs/Debug/axesViewer" {
  47728. import { Vector3 } from "babylonjs/Maths/math.vector";
  47729. import { Nullable } from "babylonjs/types";
  47730. import { Scene } from "babylonjs/scene";
  47731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47732. /**
  47733. * The Axes viewer will show 3 axes in a specific point in space
  47734. */
  47735. export class AxesViewer {
  47736. private _xAxis;
  47737. private _yAxis;
  47738. private _zAxis;
  47739. private _scaleLinesFactor;
  47740. private _instanced;
  47741. /**
  47742. * Gets the hosting scene
  47743. */
  47744. scene: Scene;
  47745. /**
  47746. * Gets or sets a number used to scale line length
  47747. */
  47748. scaleLines: number;
  47749. /** Gets the node hierarchy used to render x-axis */
  47750. get xAxis(): TransformNode;
  47751. /** Gets the node hierarchy used to render y-axis */
  47752. get yAxis(): TransformNode;
  47753. /** Gets the node hierarchy used to render z-axis */
  47754. get zAxis(): TransformNode;
  47755. /**
  47756. * Creates a new AxesViewer
  47757. * @param scene defines the hosting scene
  47758. * @param scaleLines defines a number used to scale line length (1 by default)
  47759. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47760. * @param xAxis defines the node hierarchy used to render the x-axis
  47761. * @param yAxis defines the node hierarchy used to render the y-axis
  47762. * @param zAxis defines the node hierarchy used to render the z-axis
  47763. */
  47764. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47765. /**
  47766. * Force the viewer to update
  47767. * @param position defines the position of the viewer
  47768. * @param xaxis defines the x axis of the viewer
  47769. * @param yaxis defines the y axis of the viewer
  47770. * @param zaxis defines the z axis of the viewer
  47771. */
  47772. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47773. /**
  47774. * Creates an instance of this axes viewer.
  47775. * @returns a new axes viewer with instanced meshes
  47776. */
  47777. createInstance(): AxesViewer;
  47778. /** Releases resources */
  47779. dispose(): void;
  47780. private static _SetRenderingGroupId;
  47781. }
  47782. }
  47783. declare module "babylonjs/Debug/boneAxesViewer" {
  47784. import { Nullable } from "babylonjs/types";
  47785. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47786. import { Vector3 } from "babylonjs/Maths/math.vector";
  47787. import { Mesh } from "babylonjs/Meshes/mesh";
  47788. import { Bone } from "babylonjs/Bones/bone";
  47789. import { Scene } from "babylonjs/scene";
  47790. /**
  47791. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47792. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47793. */
  47794. export class BoneAxesViewer extends AxesViewer {
  47795. /**
  47796. * Gets or sets the target mesh where to display the axes viewer
  47797. */
  47798. mesh: Nullable<Mesh>;
  47799. /**
  47800. * Gets or sets the target bone where to display the axes viewer
  47801. */
  47802. bone: Nullable<Bone>;
  47803. /** Gets current position */
  47804. pos: Vector3;
  47805. /** Gets direction of X axis */
  47806. xaxis: Vector3;
  47807. /** Gets direction of Y axis */
  47808. yaxis: Vector3;
  47809. /** Gets direction of Z axis */
  47810. zaxis: Vector3;
  47811. /**
  47812. * Creates a new BoneAxesViewer
  47813. * @param scene defines the hosting scene
  47814. * @param bone defines the target bone
  47815. * @param mesh defines the target mesh
  47816. * @param scaleLines defines a scaling factor for line length (1 by default)
  47817. */
  47818. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47819. /**
  47820. * Force the viewer to update
  47821. */
  47822. update(): void;
  47823. /** Releases resources */
  47824. dispose(): void;
  47825. }
  47826. }
  47827. declare module "babylonjs/Debug/debugLayer" {
  47828. import { Scene } from "babylonjs/scene";
  47829. /**
  47830. * Interface used to define scene explorer extensibility option
  47831. */
  47832. export interface IExplorerExtensibilityOption {
  47833. /**
  47834. * Define the option label
  47835. */
  47836. label: string;
  47837. /**
  47838. * Defines the action to execute on click
  47839. */
  47840. action: (entity: any) => void;
  47841. }
  47842. /**
  47843. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47844. */
  47845. export interface IExplorerExtensibilityGroup {
  47846. /**
  47847. * Defines a predicate to test if a given type mut be extended
  47848. */
  47849. predicate: (entity: any) => boolean;
  47850. /**
  47851. * Gets the list of options added to a type
  47852. */
  47853. entries: IExplorerExtensibilityOption[];
  47854. }
  47855. /**
  47856. * Interface used to define the options to use to create the Inspector
  47857. */
  47858. export interface IInspectorOptions {
  47859. /**
  47860. * Display in overlay mode (default: false)
  47861. */
  47862. overlay?: boolean;
  47863. /**
  47864. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47865. */
  47866. globalRoot?: HTMLElement;
  47867. /**
  47868. * Display the Scene explorer
  47869. */
  47870. showExplorer?: boolean;
  47871. /**
  47872. * Display the property inspector
  47873. */
  47874. showInspector?: boolean;
  47875. /**
  47876. * Display in embed mode (both panes on the right)
  47877. */
  47878. embedMode?: boolean;
  47879. /**
  47880. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47881. */
  47882. handleResize?: boolean;
  47883. /**
  47884. * Allow the panes to popup (default: true)
  47885. */
  47886. enablePopup?: boolean;
  47887. /**
  47888. * Allow the panes to be closed by users (default: true)
  47889. */
  47890. enableClose?: boolean;
  47891. /**
  47892. * Optional list of extensibility entries
  47893. */
  47894. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47895. /**
  47896. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47897. */
  47898. inspectorURL?: string;
  47899. /**
  47900. * Optional initial tab (default to DebugLayerTab.Properties)
  47901. */
  47902. initialTab?: DebugLayerTab;
  47903. }
  47904. module "babylonjs/scene" {
  47905. interface Scene {
  47906. /**
  47907. * @hidden
  47908. * Backing field
  47909. */
  47910. _debugLayer: DebugLayer;
  47911. /**
  47912. * Gets the debug layer (aka Inspector) associated with the scene
  47913. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47914. */
  47915. debugLayer: DebugLayer;
  47916. }
  47917. }
  47918. /**
  47919. * Enum of inspector action tab
  47920. */
  47921. export enum DebugLayerTab {
  47922. /**
  47923. * Properties tag (default)
  47924. */
  47925. Properties = 0,
  47926. /**
  47927. * Debug tab
  47928. */
  47929. Debug = 1,
  47930. /**
  47931. * Statistics tab
  47932. */
  47933. Statistics = 2,
  47934. /**
  47935. * Tools tab
  47936. */
  47937. Tools = 3,
  47938. /**
  47939. * Settings tab
  47940. */
  47941. Settings = 4
  47942. }
  47943. /**
  47944. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47945. * what is happening in your scene
  47946. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47947. */
  47948. export class DebugLayer {
  47949. /**
  47950. * Define the url to get the inspector script from.
  47951. * By default it uses the babylonjs CDN.
  47952. * @ignoreNaming
  47953. */
  47954. static InspectorURL: string;
  47955. private _scene;
  47956. private BJSINSPECTOR;
  47957. private _onPropertyChangedObservable?;
  47958. /**
  47959. * Observable triggered when a property is changed through the inspector.
  47960. */
  47961. get onPropertyChangedObservable(): any;
  47962. /**
  47963. * Instantiates a new debug layer.
  47964. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47965. * what is happening in your scene
  47966. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47967. * @param scene Defines the scene to inspect
  47968. */
  47969. constructor(scene: Scene);
  47970. /** Creates the inspector window. */
  47971. private _createInspector;
  47972. /**
  47973. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47974. * @param entity defines the entity to select
  47975. * @param lineContainerTitle defines the specific block to highlight
  47976. */
  47977. select(entity: any, lineContainerTitle?: string): void;
  47978. /** Get the inspector from bundle or global */
  47979. private _getGlobalInspector;
  47980. /**
  47981. * Get if the inspector is visible or not.
  47982. * @returns true if visible otherwise, false
  47983. */
  47984. isVisible(): boolean;
  47985. /**
  47986. * Hide the inspector and close its window.
  47987. */
  47988. hide(): void;
  47989. /**
  47990. * Launch the debugLayer.
  47991. * @param config Define the configuration of the inspector
  47992. * @return a promise fulfilled when the debug layer is visible
  47993. */
  47994. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47995. }
  47996. }
  47997. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47998. import { Nullable } from "babylonjs/types";
  47999. import { Scene } from "babylonjs/scene";
  48000. import { Vector4 } from "babylonjs/Maths/math.vector";
  48001. import { Color4 } from "babylonjs/Maths/math.color";
  48002. import { Mesh } from "babylonjs/Meshes/mesh";
  48003. /**
  48004. * Class containing static functions to help procedurally build meshes
  48005. */
  48006. export class BoxBuilder {
  48007. /**
  48008. * Creates a box mesh
  48009. * * The parameter `size` sets the size (float) of each box side (default 1)
  48010. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48011. * * 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)
  48012. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48016. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48017. * @param name defines the name of the mesh
  48018. * @param options defines the options used to create the mesh
  48019. * @param scene defines the hosting scene
  48020. * @returns the box mesh
  48021. */
  48022. static CreateBox(name: string, options: {
  48023. size?: number;
  48024. width?: number;
  48025. height?: number;
  48026. depth?: number;
  48027. faceUV?: Vector4[];
  48028. faceColors?: Color4[];
  48029. sideOrientation?: number;
  48030. frontUVs?: Vector4;
  48031. backUVs?: Vector4;
  48032. wrap?: boolean;
  48033. topBaseAt?: number;
  48034. bottomBaseAt?: number;
  48035. updatable?: boolean;
  48036. }, scene?: Nullable<Scene>): Mesh;
  48037. }
  48038. }
  48039. declare module "babylonjs/Debug/physicsViewer" {
  48040. import { Nullable } from "babylonjs/types";
  48041. import { Scene } from "babylonjs/scene";
  48042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48043. import { Mesh } from "babylonjs/Meshes/mesh";
  48044. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48045. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48046. /**
  48047. * Used to show the physics impostor around the specific mesh
  48048. */
  48049. export class PhysicsViewer {
  48050. /** @hidden */
  48051. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48052. /** @hidden */
  48053. protected _meshes: Array<Nullable<AbstractMesh>>;
  48054. /** @hidden */
  48055. protected _scene: Nullable<Scene>;
  48056. /** @hidden */
  48057. protected _numMeshes: number;
  48058. /** @hidden */
  48059. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48060. private _renderFunction;
  48061. private _utilityLayer;
  48062. private _debugBoxMesh;
  48063. private _debugSphereMesh;
  48064. private _debugCylinderMesh;
  48065. private _debugMaterial;
  48066. private _debugMeshMeshes;
  48067. /**
  48068. * Creates a new PhysicsViewer
  48069. * @param scene defines the hosting scene
  48070. */
  48071. constructor(scene: Scene);
  48072. /** @hidden */
  48073. protected _updateDebugMeshes(): void;
  48074. /**
  48075. * Renders a specified physic impostor
  48076. * @param impostor defines the impostor to render
  48077. * @param targetMesh defines the mesh represented by the impostor
  48078. * @returns the new debug mesh used to render the impostor
  48079. */
  48080. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48081. /**
  48082. * Hides a specified physic impostor
  48083. * @param impostor defines the impostor to hide
  48084. */
  48085. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48086. private _getDebugMaterial;
  48087. private _getDebugBoxMesh;
  48088. private _getDebugSphereMesh;
  48089. private _getDebugCylinderMesh;
  48090. private _getDebugMeshMesh;
  48091. private _getDebugMesh;
  48092. /** Releases all resources */
  48093. dispose(): void;
  48094. }
  48095. }
  48096. declare module "babylonjs/Debug/rayHelper" {
  48097. import { Nullable } from "babylonjs/types";
  48098. import { Ray } from "babylonjs/Culling/ray";
  48099. import { Vector3 } from "babylonjs/Maths/math.vector";
  48100. import { Color3 } from "babylonjs/Maths/math.color";
  48101. import { Scene } from "babylonjs/scene";
  48102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48103. import "babylonjs/Meshes/Builders/linesBuilder";
  48104. /**
  48105. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48106. * in order to better appreciate the issue one might have.
  48107. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48108. */
  48109. export class RayHelper {
  48110. /**
  48111. * Defines the ray we are currently tryin to visualize.
  48112. */
  48113. ray: Nullable<Ray>;
  48114. private _renderPoints;
  48115. private _renderLine;
  48116. private _renderFunction;
  48117. private _scene;
  48118. private _updateToMeshFunction;
  48119. private _attachedToMesh;
  48120. private _meshSpaceDirection;
  48121. private _meshSpaceOrigin;
  48122. /**
  48123. * Helper function to create a colored helper in a scene in one line.
  48124. * @param ray Defines the ray we are currently tryin to visualize
  48125. * @param scene Defines the scene the ray is used in
  48126. * @param color Defines the color we want to see the ray in
  48127. * @returns The newly created ray helper.
  48128. */
  48129. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48130. /**
  48131. * Instantiate a new ray helper.
  48132. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48133. * in order to better appreciate the issue one might have.
  48134. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48135. * @param ray Defines the ray we are currently tryin to visualize
  48136. */
  48137. constructor(ray: Ray);
  48138. /**
  48139. * Shows the ray we are willing to debug.
  48140. * @param scene Defines the scene the ray needs to be rendered in
  48141. * @param color Defines the color the ray needs to be rendered in
  48142. */
  48143. show(scene: Scene, color?: Color3): void;
  48144. /**
  48145. * Hides the ray we are debugging.
  48146. */
  48147. hide(): void;
  48148. private _render;
  48149. /**
  48150. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48151. * @param mesh Defines the mesh we want the helper attached to
  48152. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48153. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48154. * @param length Defines the length of the ray
  48155. */
  48156. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48157. /**
  48158. * Detach the ray helper from the mesh it has previously been attached to.
  48159. */
  48160. detachFromMesh(): void;
  48161. private _updateToMesh;
  48162. /**
  48163. * Dispose the helper and release its associated resources.
  48164. */
  48165. dispose(): void;
  48166. }
  48167. }
  48168. declare module "babylonjs/Debug/skeletonViewer" {
  48169. import { Color3 } from "babylonjs/Maths/math.color";
  48170. import { Scene } from "babylonjs/scene";
  48171. import { Nullable } from "babylonjs/types";
  48172. import { Skeleton } from "babylonjs/Bones/skeleton";
  48173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48174. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48175. /**
  48176. * Class used to render a debug view of a given skeleton
  48177. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48178. */
  48179. export class SkeletonViewer {
  48180. /** defines the skeleton to render */
  48181. skeleton: Skeleton;
  48182. /** defines the mesh attached to the skeleton */
  48183. mesh: AbstractMesh;
  48184. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48185. autoUpdateBonesMatrices: boolean;
  48186. /** defines the rendering group id to use with the viewer */
  48187. renderingGroupId: number;
  48188. /** Gets or sets the color used to render the skeleton */
  48189. color: Color3;
  48190. private _scene;
  48191. private _debugLines;
  48192. private _debugMesh;
  48193. private _isEnabled;
  48194. private _renderFunction;
  48195. private _utilityLayer;
  48196. /**
  48197. * Returns the mesh used to render the bones
  48198. */
  48199. get debugMesh(): Nullable<LinesMesh>;
  48200. /**
  48201. * Creates a new SkeletonViewer
  48202. * @param skeleton defines the skeleton to render
  48203. * @param mesh defines the mesh attached to the skeleton
  48204. * @param scene defines the hosting scene
  48205. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48206. * @param renderingGroupId defines the rendering group id to use with the viewer
  48207. */
  48208. constructor(
  48209. /** defines the skeleton to render */
  48210. skeleton: Skeleton,
  48211. /** defines the mesh attached to the skeleton */
  48212. mesh: AbstractMesh, scene: Scene,
  48213. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48214. autoUpdateBonesMatrices?: boolean,
  48215. /** defines the rendering group id to use with the viewer */
  48216. renderingGroupId?: number);
  48217. /** Gets or sets a boolean indicating if the viewer is enabled */
  48218. set isEnabled(value: boolean);
  48219. get isEnabled(): boolean;
  48220. private _getBonePosition;
  48221. private _getLinesForBonesWithLength;
  48222. private _getLinesForBonesNoLength;
  48223. /** Update the viewer to sync with current skeleton state */
  48224. update(): void;
  48225. /** Release associated resources */
  48226. dispose(): void;
  48227. }
  48228. }
  48229. declare module "babylonjs/Debug/index" {
  48230. export * from "babylonjs/Debug/axesViewer";
  48231. export * from "babylonjs/Debug/boneAxesViewer";
  48232. export * from "babylonjs/Debug/debugLayer";
  48233. export * from "babylonjs/Debug/physicsViewer";
  48234. export * from "babylonjs/Debug/rayHelper";
  48235. export * from "babylonjs/Debug/skeletonViewer";
  48236. }
  48237. declare module "babylonjs/Engines/nullEngine" {
  48238. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48239. import { Engine } from "babylonjs/Engines/engine";
  48240. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48241. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48243. import { Effect } from "babylonjs/Materials/effect";
  48244. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48245. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48246. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48247. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48248. /**
  48249. * Options to create the null engine
  48250. */
  48251. export class NullEngineOptions {
  48252. /**
  48253. * Render width (Default: 512)
  48254. */
  48255. renderWidth: number;
  48256. /**
  48257. * Render height (Default: 256)
  48258. */
  48259. renderHeight: number;
  48260. /**
  48261. * Texture size (Default: 512)
  48262. */
  48263. textureSize: number;
  48264. /**
  48265. * If delta time between frames should be constant
  48266. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48267. */
  48268. deterministicLockstep: boolean;
  48269. /**
  48270. * Maximum about of steps between frames (Default: 4)
  48271. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48272. */
  48273. lockstepMaxSteps: number;
  48274. }
  48275. /**
  48276. * The null engine class provides support for headless version of babylon.js.
  48277. * This can be used in server side scenario or for testing purposes
  48278. */
  48279. export class NullEngine extends Engine {
  48280. private _options;
  48281. /**
  48282. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48283. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48284. * @returns true if engine is in deterministic lock step mode
  48285. */
  48286. isDeterministicLockStep(): boolean;
  48287. /**
  48288. * Gets the max steps when engine is running in deterministic lock step
  48289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48290. * @returns the max steps
  48291. */
  48292. getLockstepMaxSteps(): number;
  48293. /**
  48294. * Gets the current hardware scaling level.
  48295. * By default the hardware scaling level is computed from the window device ratio.
  48296. * 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.
  48297. * @returns a number indicating the current hardware scaling level
  48298. */
  48299. getHardwareScalingLevel(): number;
  48300. constructor(options?: NullEngineOptions);
  48301. /**
  48302. * Creates a vertex buffer
  48303. * @param vertices the data for the vertex buffer
  48304. * @returns the new WebGL static buffer
  48305. */
  48306. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48307. /**
  48308. * Creates a new index buffer
  48309. * @param indices defines the content of the index buffer
  48310. * @param updatable defines if the index buffer must be updatable
  48311. * @returns a new webGL buffer
  48312. */
  48313. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48314. /**
  48315. * Clear the current render buffer or the current render target (if any is set up)
  48316. * @param color defines the color to use
  48317. * @param backBuffer defines if the back buffer must be cleared
  48318. * @param depth defines if the depth buffer must be cleared
  48319. * @param stencil defines if the stencil buffer must be cleared
  48320. */
  48321. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48322. /**
  48323. * Gets the current render width
  48324. * @param useScreen defines if screen size must be used (or the current render target if any)
  48325. * @returns a number defining the current render width
  48326. */
  48327. getRenderWidth(useScreen?: boolean): number;
  48328. /**
  48329. * Gets the current render height
  48330. * @param useScreen defines if screen size must be used (or the current render target if any)
  48331. * @returns a number defining the current render height
  48332. */
  48333. getRenderHeight(useScreen?: boolean): number;
  48334. /**
  48335. * Set the WebGL's viewport
  48336. * @param viewport defines the viewport element to be used
  48337. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48338. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48339. */
  48340. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48341. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48342. /**
  48343. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48344. * @param pipelineContext defines the pipeline context to use
  48345. * @param uniformsNames defines the list of uniform names
  48346. * @returns an array of webGL uniform locations
  48347. */
  48348. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48349. /**
  48350. * Gets the lsit of active attributes for a given webGL program
  48351. * @param pipelineContext defines the pipeline context to use
  48352. * @param attributesNames defines the list of attribute names to get
  48353. * @returns an array of indices indicating the offset of each attribute
  48354. */
  48355. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48356. /**
  48357. * Binds an effect to the webGL context
  48358. * @param effect defines the effect to bind
  48359. */
  48360. bindSamplers(effect: Effect): void;
  48361. /**
  48362. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48363. * @param effect defines the effect to activate
  48364. */
  48365. enableEffect(effect: Effect): void;
  48366. /**
  48367. * Set various states to the webGL context
  48368. * @param culling defines backface culling state
  48369. * @param zOffset defines the value to apply to zOffset (0 by default)
  48370. * @param force defines if states must be applied even if cache is up to date
  48371. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48372. */
  48373. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48374. /**
  48375. * Set the value of an uniform to an array of int32
  48376. * @param uniform defines the webGL uniform location where to store the value
  48377. * @param array defines the array of int32 to store
  48378. */
  48379. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48380. /**
  48381. * Set the value of an uniform to an array of int32 (stored as vec2)
  48382. * @param uniform defines the webGL uniform location where to store the value
  48383. * @param array defines the array of int32 to store
  48384. */
  48385. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48386. /**
  48387. * Set the value of an uniform to an array of int32 (stored as vec3)
  48388. * @param uniform defines the webGL uniform location where to store the value
  48389. * @param array defines the array of int32 to store
  48390. */
  48391. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48392. /**
  48393. * Set the value of an uniform to an array of int32 (stored as vec4)
  48394. * @param uniform defines the webGL uniform location where to store the value
  48395. * @param array defines the array of int32 to store
  48396. */
  48397. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48398. /**
  48399. * Set the value of an uniform to an array of float32
  48400. * @param uniform defines the webGL uniform location where to store the value
  48401. * @param array defines the array of float32 to store
  48402. */
  48403. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48404. /**
  48405. * Set the value of an uniform to an array of float32 (stored as vec2)
  48406. * @param uniform defines the webGL uniform location where to store the value
  48407. * @param array defines the array of float32 to store
  48408. */
  48409. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48410. /**
  48411. * Set the value of an uniform to an array of float32 (stored as vec3)
  48412. * @param uniform defines the webGL uniform location where to store the value
  48413. * @param array defines the array of float32 to store
  48414. */
  48415. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48416. /**
  48417. * Set the value of an uniform to an array of float32 (stored as vec4)
  48418. * @param uniform defines the webGL uniform location where to store the value
  48419. * @param array defines the array of float32 to store
  48420. */
  48421. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48422. /**
  48423. * Set the value of an uniform to an array of number
  48424. * @param uniform defines the webGL uniform location where to store the value
  48425. * @param array defines the array of number to store
  48426. */
  48427. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48428. /**
  48429. * Set the value of an uniform to an array of number (stored as vec2)
  48430. * @param uniform defines the webGL uniform location where to store the value
  48431. * @param array defines the array of number to store
  48432. */
  48433. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48434. /**
  48435. * Set the value of an uniform to an array of number (stored as vec3)
  48436. * @param uniform defines the webGL uniform location where to store the value
  48437. * @param array defines the array of number to store
  48438. */
  48439. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48440. /**
  48441. * Set the value of an uniform to an array of number (stored as vec4)
  48442. * @param uniform defines the webGL uniform location where to store the value
  48443. * @param array defines the array of number to store
  48444. */
  48445. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48446. /**
  48447. * Set the value of an uniform to an array of float32 (stored as matrices)
  48448. * @param uniform defines the webGL uniform location where to store the value
  48449. * @param matrices defines the array of float32 to store
  48450. */
  48451. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48452. /**
  48453. * Set the value of an uniform to a matrix (3x3)
  48454. * @param uniform defines the webGL uniform location where to store the value
  48455. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48456. */
  48457. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48458. /**
  48459. * Set the value of an uniform to a matrix (2x2)
  48460. * @param uniform defines the webGL uniform location where to store the value
  48461. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48462. */
  48463. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48464. /**
  48465. * Set the value of an uniform to a number (float)
  48466. * @param uniform defines the webGL uniform location where to store the value
  48467. * @param value defines the float number to store
  48468. */
  48469. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48470. /**
  48471. * Set the value of an uniform to a vec2
  48472. * @param uniform defines the webGL uniform location where to store the value
  48473. * @param x defines the 1st component of the value
  48474. * @param y defines the 2nd component of the value
  48475. */
  48476. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48477. /**
  48478. * Set the value of an uniform to a vec3
  48479. * @param uniform defines the webGL uniform location where to store the value
  48480. * @param x defines the 1st component of the value
  48481. * @param y defines the 2nd component of the value
  48482. * @param z defines the 3rd component of the value
  48483. */
  48484. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48485. /**
  48486. * Set the value of an uniform to a boolean
  48487. * @param uniform defines the webGL uniform location where to store the value
  48488. * @param bool defines the boolean to store
  48489. */
  48490. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48491. /**
  48492. * Set the value of an uniform to a vec4
  48493. * @param uniform defines the webGL uniform location where to store the value
  48494. * @param x defines the 1st component of the value
  48495. * @param y defines the 2nd component of the value
  48496. * @param z defines the 3rd component of the value
  48497. * @param w defines the 4th component of the value
  48498. */
  48499. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48500. /**
  48501. * Sets the current alpha mode
  48502. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48503. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48505. */
  48506. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48507. /**
  48508. * Bind webGl buffers directly to the webGL context
  48509. * @param vertexBuffers defines the vertex buffer to bind
  48510. * @param indexBuffer defines the index buffer to bind
  48511. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48512. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48513. * @param effect defines the effect associated with the vertex buffer
  48514. */
  48515. bindBuffers(vertexBuffers: {
  48516. [key: string]: VertexBuffer;
  48517. }, indexBuffer: DataBuffer, effect: Effect): void;
  48518. /**
  48519. * Force the entire cache to be cleared
  48520. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48521. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48522. */
  48523. wipeCaches(bruteForce?: boolean): void;
  48524. /**
  48525. * Send a draw order
  48526. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48527. * @param indexStart defines the starting index
  48528. * @param indexCount defines the number of index to draw
  48529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48530. */
  48531. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48532. /**
  48533. * Draw a list of indexed primitives
  48534. * @param fillMode defines the primitive to use
  48535. * @param indexStart defines the starting index
  48536. * @param indexCount defines the number of index to draw
  48537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48538. */
  48539. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48540. /**
  48541. * Draw a list of unindexed primitives
  48542. * @param fillMode defines the primitive to use
  48543. * @param verticesStart defines the index of first vertex to draw
  48544. * @param verticesCount defines the count of vertices to draw
  48545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48546. */
  48547. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48548. /** @hidden */
  48549. _createTexture(): WebGLTexture;
  48550. /** @hidden */
  48551. _releaseTexture(texture: InternalTexture): void;
  48552. /**
  48553. * Usually called from Texture.ts.
  48554. * Passed information to create a WebGLTexture
  48555. * @param urlArg defines a value which contains one of the following:
  48556. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48557. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48558. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48560. * @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)
  48561. * @param scene needed for loading to the correct scene
  48562. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48563. * @param onLoad optional callback to be called upon successful completion
  48564. * @param onError optional callback to be called upon failure
  48565. * @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
  48566. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48567. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48568. * @param forcedExtension defines the extension to use to pick the right loader
  48569. * @param mimeType defines an optional mime type
  48570. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48571. */
  48572. 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;
  48573. /**
  48574. * Creates a new render target texture
  48575. * @param size defines the size of the texture
  48576. * @param options defines the options used to create the texture
  48577. * @returns a new render target texture stored in an InternalTexture
  48578. */
  48579. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48580. /**
  48581. * Update the sampling mode of a given texture
  48582. * @param samplingMode defines the required sampling mode
  48583. * @param texture defines the texture to update
  48584. */
  48585. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48586. /**
  48587. * Binds the frame buffer to the specified texture.
  48588. * @param texture The texture to render to or null for the default canvas
  48589. * @param faceIndex The face of the texture to render to in case of cube texture
  48590. * @param requiredWidth The width of the target to render to
  48591. * @param requiredHeight The height of the target to render to
  48592. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48593. * @param lodLevel defines le lod level to bind to the frame buffer
  48594. */
  48595. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48596. /**
  48597. * Unbind the current render target texture from the webGL context
  48598. * @param texture defines the render target texture to unbind
  48599. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48600. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48601. */
  48602. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48603. /**
  48604. * Creates a dynamic vertex buffer
  48605. * @param vertices the data for the dynamic vertex buffer
  48606. * @returns the new WebGL dynamic buffer
  48607. */
  48608. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48609. /**
  48610. * Update the content of a dynamic texture
  48611. * @param texture defines the texture to update
  48612. * @param canvas defines the canvas containing the source
  48613. * @param invertY defines if data must be stored with Y axis inverted
  48614. * @param premulAlpha defines if alpha is stored as premultiplied
  48615. * @param format defines the format of the data
  48616. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48617. */
  48618. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48619. /**
  48620. * Gets a boolean indicating if all created effects are ready
  48621. * @returns true if all effects are ready
  48622. */
  48623. areAllEffectsReady(): boolean;
  48624. /**
  48625. * @hidden
  48626. * Get the current error code of the webGL context
  48627. * @returns the error code
  48628. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48629. */
  48630. getError(): number;
  48631. /** @hidden */
  48632. _getUnpackAlignement(): number;
  48633. /** @hidden */
  48634. _unpackFlipY(value: boolean): void;
  48635. /**
  48636. * Update a dynamic index buffer
  48637. * @param indexBuffer defines the target index buffer
  48638. * @param indices defines the data to update
  48639. * @param offset defines the offset in the target index buffer where update should start
  48640. */
  48641. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48642. /**
  48643. * Updates a dynamic vertex buffer.
  48644. * @param vertexBuffer the vertex buffer to update
  48645. * @param vertices the data used to update the vertex buffer
  48646. * @param byteOffset the byte offset of the data (optional)
  48647. * @param byteLength the byte length of the data (optional)
  48648. */
  48649. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48650. /** @hidden */
  48651. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48652. /** @hidden */
  48653. _bindTexture(channel: number, texture: InternalTexture): void;
  48654. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48655. /**
  48656. * 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
  48657. */
  48658. releaseEffects(): void;
  48659. displayLoadingUI(): void;
  48660. hideLoadingUI(): void;
  48661. /** @hidden */
  48662. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48663. /** @hidden */
  48664. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48665. /** @hidden */
  48666. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48667. /** @hidden */
  48668. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48669. }
  48670. }
  48671. declare module "babylonjs/Instrumentation/timeToken" {
  48672. import { Nullable } from "babylonjs/types";
  48673. /**
  48674. * @hidden
  48675. **/
  48676. export class _TimeToken {
  48677. _startTimeQuery: Nullable<WebGLQuery>;
  48678. _endTimeQuery: Nullable<WebGLQuery>;
  48679. _timeElapsedQuery: Nullable<WebGLQuery>;
  48680. _timeElapsedQueryEnded: boolean;
  48681. }
  48682. }
  48683. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48684. import { Nullable, int } from "babylonjs/types";
  48685. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48686. /** @hidden */
  48687. export class _OcclusionDataStorage {
  48688. /** @hidden */
  48689. occlusionInternalRetryCounter: number;
  48690. /** @hidden */
  48691. isOcclusionQueryInProgress: boolean;
  48692. /** @hidden */
  48693. isOccluded: boolean;
  48694. /** @hidden */
  48695. occlusionRetryCount: number;
  48696. /** @hidden */
  48697. occlusionType: number;
  48698. /** @hidden */
  48699. occlusionQueryAlgorithmType: number;
  48700. }
  48701. module "babylonjs/Engines/engine" {
  48702. interface Engine {
  48703. /**
  48704. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48705. * @return the new query
  48706. */
  48707. createQuery(): WebGLQuery;
  48708. /**
  48709. * Delete and release a webGL query
  48710. * @param query defines the query to delete
  48711. * @return the current engine
  48712. */
  48713. deleteQuery(query: WebGLQuery): Engine;
  48714. /**
  48715. * Check if a given query has resolved and got its value
  48716. * @param query defines the query to check
  48717. * @returns true if the query got its value
  48718. */
  48719. isQueryResultAvailable(query: WebGLQuery): boolean;
  48720. /**
  48721. * Gets the value of a given query
  48722. * @param query defines the query to check
  48723. * @returns the value of the query
  48724. */
  48725. getQueryResult(query: WebGLQuery): number;
  48726. /**
  48727. * Initiates an occlusion query
  48728. * @param algorithmType defines the algorithm to use
  48729. * @param query defines the query to use
  48730. * @returns the current engine
  48731. * @see http://doc.babylonjs.com/features/occlusionquery
  48732. */
  48733. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48734. /**
  48735. * Ends an occlusion query
  48736. * @see http://doc.babylonjs.com/features/occlusionquery
  48737. * @param algorithmType defines the algorithm to use
  48738. * @returns the current engine
  48739. */
  48740. endOcclusionQuery(algorithmType: number): Engine;
  48741. /**
  48742. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48743. * Please note that only one query can be issued at a time
  48744. * @returns a time token used to track the time span
  48745. */
  48746. startTimeQuery(): Nullable<_TimeToken>;
  48747. /**
  48748. * Ends a time query
  48749. * @param token defines the token used to measure the time span
  48750. * @returns the time spent (in ns)
  48751. */
  48752. endTimeQuery(token: _TimeToken): int;
  48753. /** @hidden */
  48754. _currentNonTimestampToken: Nullable<_TimeToken>;
  48755. /** @hidden */
  48756. _createTimeQuery(): WebGLQuery;
  48757. /** @hidden */
  48758. _deleteTimeQuery(query: WebGLQuery): void;
  48759. /** @hidden */
  48760. _getGlAlgorithmType(algorithmType: number): number;
  48761. /** @hidden */
  48762. _getTimeQueryResult(query: WebGLQuery): any;
  48763. /** @hidden */
  48764. _getTimeQueryAvailability(query: WebGLQuery): any;
  48765. }
  48766. }
  48767. module "babylonjs/Meshes/abstractMesh" {
  48768. interface AbstractMesh {
  48769. /**
  48770. * Backing filed
  48771. * @hidden
  48772. */
  48773. __occlusionDataStorage: _OcclusionDataStorage;
  48774. /**
  48775. * Access property
  48776. * @hidden
  48777. */
  48778. _occlusionDataStorage: _OcclusionDataStorage;
  48779. /**
  48780. * 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.
  48781. * The default value is -1 which means don't break the query and wait till the result
  48782. * @see http://doc.babylonjs.com/features/occlusionquery
  48783. */
  48784. occlusionRetryCount: number;
  48785. /**
  48786. * 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:
  48787. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48788. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48789. * * 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.
  48790. * @see http://doc.babylonjs.com/features/occlusionquery
  48791. */
  48792. occlusionType: number;
  48793. /**
  48794. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48795. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48796. * * 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.
  48797. * @see http://doc.babylonjs.com/features/occlusionquery
  48798. */
  48799. occlusionQueryAlgorithmType: number;
  48800. /**
  48801. * 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
  48802. * @see http://doc.babylonjs.com/features/occlusionquery
  48803. */
  48804. isOccluded: boolean;
  48805. /**
  48806. * Flag to check the progress status of the query
  48807. * @see http://doc.babylonjs.com/features/occlusionquery
  48808. */
  48809. isOcclusionQueryInProgress: boolean;
  48810. }
  48811. }
  48812. }
  48813. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48814. import { Nullable } from "babylonjs/types";
  48815. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48816. /** @hidden */
  48817. export var _forceTransformFeedbackToBundle: boolean;
  48818. module "babylonjs/Engines/engine" {
  48819. interface Engine {
  48820. /**
  48821. * Creates a webGL transform feedback object
  48822. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48823. * @returns the webGL transform feedback object
  48824. */
  48825. createTransformFeedback(): WebGLTransformFeedback;
  48826. /**
  48827. * Delete a webGL transform feedback object
  48828. * @param value defines the webGL transform feedback object to delete
  48829. */
  48830. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48831. /**
  48832. * Bind a webGL transform feedback object to the webgl context
  48833. * @param value defines the webGL transform feedback object to bind
  48834. */
  48835. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48836. /**
  48837. * Begins a transform feedback operation
  48838. * @param usePoints defines if points or triangles must be used
  48839. */
  48840. beginTransformFeedback(usePoints: boolean): void;
  48841. /**
  48842. * Ends a transform feedback operation
  48843. */
  48844. endTransformFeedback(): void;
  48845. /**
  48846. * Specify the varyings to use with transform feedback
  48847. * @param program defines the associated webGL program
  48848. * @param value defines the list of strings representing the varying names
  48849. */
  48850. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48851. /**
  48852. * Bind a webGL buffer for a transform feedback operation
  48853. * @param value defines the webGL buffer to bind
  48854. */
  48855. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48856. }
  48857. }
  48858. }
  48859. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48860. import { Scene } from "babylonjs/scene";
  48861. import { Engine } from "babylonjs/Engines/engine";
  48862. import { Texture } from "babylonjs/Materials/Textures/texture";
  48863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48864. import "babylonjs/Engines/Extensions/engine.multiRender";
  48865. /**
  48866. * Creation options of the multi render target texture.
  48867. */
  48868. export interface IMultiRenderTargetOptions {
  48869. /**
  48870. * Define if the texture needs to create mip maps after render.
  48871. */
  48872. generateMipMaps?: boolean;
  48873. /**
  48874. * Define the types of all the draw buffers we want to create
  48875. */
  48876. types?: number[];
  48877. /**
  48878. * Define the sampling modes of all the draw buffers we want to create
  48879. */
  48880. samplingModes?: number[];
  48881. /**
  48882. * Define if a depth buffer is required
  48883. */
  48884. generateDepthBuffer?: boolean;
  48885. /**
  48886. * Define if a stencil buffer is required
  48887. */
  48888. generateStencilBuffer?: boolean;
  48889. /**
  48890. * Define if a depth texture is required instead of a depth buffer
  48891. */
  48892. generateDepthTexture?: boolean;
  48893. /**
  48894. * Define the number of desired draw buffers
  48895. */
  48896. textureCount?: number;
  48897. /**
  48898. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48899. */
  48900. doNotChangeAspectRatio?: boolean;
  48901. /**
  48902. * Define the default type of the buffers we are creating
  48903. */
  48904. defaultType?: number;
  48905. }
  48906. /**
  48907. * A multi render target, like a render target provides the ability to render to a texture.
  48908. * Unlike the render target, it can render to several draw buffers in one draw.
  48909. * This is specially interesting in deferred rendering or for any effects requiring more than
  48910. * just one color from a single pass.
  48911. */
  48912. export class MultiRenderTarget extends RenderTargetTexture {
  48913. private _internalTextures;
  48914. private _textures;
  48915. private _multiRenderTargetOptions;
  48916. /**
  48917. * Get if draw buffers are currently supported by the used hardware and browser.
  48918. */
  48919. get isSupported(): boolean;
  48920. /**
  48921. * Get the list of textures generated by the multi render target.
  48922. */
  48923. get textures(): Texture[];
  48924. /**
  48925. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48926. */
  48927. get depthTexture(): Texture;
  48928. /**
  48929. * Set the wrapping mode on U of all the textures we are rendering to.
  48930. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48931. */
  48932. set wrapU(wrap: number);
  48933. /**
  48934. * Set the wrapping mode on V of all the textures we are rendering to.
  48935. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48936. */
  48937. set wrapV(wrap: number);
  48938. /**
  48939. * Instantiate a new multi render target texture.
  48940. * A multi render target, like a render target provides the ability to render to a texture.
  48941. * Unlike the render target, it can render to several draw buffers in one draw.
  48942. * This is specially interesting in deferred rendering or for any effects requiring more than
  48943. * just one color from a single pass.
  48944. * @param name Define the name of the texture
  48945. * @param size Define the size of the buffers to render to
  48946. * @param count Define the number of target we are rendering into
  48947. * @param scene Define the scene the texture belongs to
  48948. * @param options Define the options used to create the multi render target
  48949. */
  48950. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48951. /** @hidden */
  48952. _rebuild(): void;
  48953. private _createInternalTextures;
  48954. private _createTextures;
  48955. /**
  48956. * Define the number of samples used if MSAA is enabled.
  48957. */
  48958. get samples(): number;
  48959. set samples(value: number);
  48960. /**
  48961. * Resize all the textures in the multi render target.
  48962. * Be carrefull as it will recreate all the data in the new texture.
  48963. * @param size Define the new size
  48964. */
  48965. resize(size: any): void;
  48966. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48967. /**
  48968. * Dispose the render targets and their associated resources
  48969. */
  48970. dispose(): void;
  48971. /**
  48972. * Release all the underlying texture used as draw buffers.
  48973. */
  48974. releaseInternalTextures(): void;
  48975. }
  48976. }
  48977. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48978. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48979. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48980. import { Nullable } from "babylonjs/types";
  48981. module "babylonjs/Engines/thinEngine" {
  48982. interface ThinEngine {
  48983. /**
  48984. * Unbind a list of render target textures from the webGL context
  48985. * This is used only when drawBuffer extension or webGL2 are active
  48986. * @param textures defines the render target textures to unbind
  48987. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48988. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48989. */
  48990. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48991. /**
  48992. * Create a multi render target texture
  48993. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48994. * @param size defines the size of the texture
  48995. * @param options defines the creation options
  48996. * @returns the cube texture as an InternalTexture
  48997. */
  48998. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48999. /**
  49000. * Update the sample count for a given multiple render target texture
  49001. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49002. * @param textures defines the textures to update
  49003. * @param samples defines the sample count to set
  49004. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49005. */
  49006. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49007. }
  49008. }
  49009. }
  49010. declare module "babylonjs/Engines/Extensions/engine.views" {
  49011. import { Camera } from "babylonjs/Cameras/camera";
  49012. import { Nullable } from "babylonjs/types";
  49013. /**
  49014. * Class used to define an additional view for the engine
  49015. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49016. */
  49017. export class EngineView {
  49018. /** Defines the canvas where to render the view */
  49019. target: HTMLCanvasElement;
  49020. /** Defines an optional camera used to render the view (will use active camera else) */
  49021. camera?: Camera;
  49022. }
  49023. module "babylonjs/Engines/engine" {
  49024. interface Engine {
  49025. /**
  49026. * Gets or sets the HTML element to use for attaching events
  49027. */
  49028. inputElement: Nullable<HTMLElement>;
  49029. /**
  49030. * Gets the current engine view
  49031. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49032. */
  49033. activeView: Nullable<EngineView>;
  49034. /** Gets or sets the list of views */
  49035. views: EngineView[];
  49036. /**
  49037. * Register a new child canvas
  49038. * @param canvas defines the canvas to register
  49039. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49040. * @returns the associated view
  49041. */
  49042. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49043. /**
  49044. * Remove a registered child canvas
  49045. * @param canvas defines the canvas to remove
  49046. * @returns the current engine
  49047. */
  49048. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49049. }
  49050. }
  49051. }
  49052. declare module "babylonjs/Engines/Extensions/index" {
  49053. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49054. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49055. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49056. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49057. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49058. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49059. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49060. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49061. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49062. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49063. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49064. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49065. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49066. export * from "babylonjs/Engines/Extensions/engine.views";
  49067. }
  49068. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49069. import { Nullable } from "babylonjs/types";
  49070. /**
  49071. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49072. */
  49073. export interface CubeMapInfo {
  49074. /**
  49075. * The pixel array for the front face.
  49076. * This is stored in format, left to right, up to down format.
  49077. */
  49078. front: Nullable<ArrayBufferView>;
  49079. /**
  49080. * The pixel array for the back face.
  49081. * This is stored in format, left to right, up to down format.
  49082. */
  49083. back: Nullable<ArrayBufferView>;
  49084. /**
  49085. * The pixel array for the left face.
  49086. * This is stored in format, left to right, up to down format.
  49087. */
  49088. left: Nullable<ArrayBufferView>;
  49089. /**
  49090. * The pixel array for the right face.
  49091. * This is stored in format, left to right, up to down format.
  49092. */
  49093. right: Nullable<ArrayBufferView>;
  49094. /**
  49095. * The pixel array for the up face.
  49096. * This is stored in format, left to right, up to down format.
  49097. */
  49098. up: Nullable<ArrayBufferView>;
  49099. /**
  49100. * The pixel array for the down face.
  49101. * This is stored in format, left to right, up to down format.
  49102. */
  49103. down: Nullable<ArrayBufferView>;
  49104. /**
  49105. * The size of the cubemap stored.
  49106. *
  49107. * Each faces will be size * size pixels.
  49108. */
  49109. size: number;
  49110. /**
  49111. * The format of the texture.
  49112. *
  49113. * RGBA, RGB.
  49114. */
  49115. format: number;
  49116. /**
  49117. * The type of the texture data.
  49118. *
  49119. * UNSIGNED_INT, FLOAT.
  49120. */
  49121. type: number;
  49122. /**
  49123. * Specifies whether the texture is in gamma space.
  49124. */
  49125. gammaSpace: boolean;
  49126. }
  49127. /**
  49128. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49129. */
  49130. export class PanoramaToCubeMapTools {
  49131. private static FACE_FRONT;
  49132. private static FACE_BACK;
  49133. private static FACE_RIGHT;
  49134. private static FACE_LEFT;
  49135. private static FACE_DOWN;
  49136. private static FACE_UP;
  49137. /**
  49138. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49139. *
  49140. * @param float32Array The source data.
  49141. * @param inputWidth The width of the input panorama.
  49142. * @param inputHeight The height of the input panorama.
  49143. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49144. * @return The cubemap data
  49145. */
  49146. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49147. private static CreateCubemapTexture;
  49148. private static CalcProjectionSpherical;
  49149. }
  49150. }
  49151. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49152. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49153. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49154. import { Nullable } from "babylonjs/types";
  49155. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49156. /**
  49157. * Helper class dealing with the extraction of spherical polynomial dataArray
  49158. * from a cube map.
  49159. */
  49160. export class CubeMapToSphericalPolynomialTools {
  49161. private static FileFaces;
  49162. /**
  49163. * Converts a texture to the according Spherical Polynomial data.
  49164. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49165. *
  49166. * @param texture The texture to extract the information from.
  49167. * @return The Spherical Polynomial data.
  49168. */
  49169. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49170. /**
  49171. * Converts a cubemap to the according Spherical Polynomial data.
  49172. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49173. *
  49174. * @param cubeInfo The Cube map to extract the information from.
  49175. * @return The Spherical Polynomial data.
  49176. */
  49177. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49178. }
  49179. }
  49180. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49181. import { Nullable } from "babylonjs/types";
  49182. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49183. module "babylonjs/Materials/Textures/baseTexture" {
  49184. interface BaseTexture {
  49185. /**
  49186. * Get the polynomial representation of the texture data.
  49187. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49188. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49189. */
  49190. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49191. }
  49192. }
  49193. }
  49194. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49195. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49196. /** @hidden */
  49197. export var rgbdEncodePixelShader: {
  49198. name: string;
  49199. shader: string;
  49200. };
  49201. }
  49202. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49203. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49204. /** @hidden */
  49205. export var rgbdDecodePixelShader: {
  49206. name: string;
  49207. shader: string;
  49208. };
  49209. }
  49210. declare module "babylonjs/Misc/environmentTextureTools" {
  49211. import { Nullable } from "babylonjs/types";
  49212. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49213. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49214. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49215. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49216. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49217. import "babylonjs/Shaders/rgbdEncode.fragment";
  49218. import "babylonjs/Shaders/rgbdDecode.fragment";
  49219. /**
  49220. * Raw texture data and descriptor sufficient for WebGL texture upload
  49221. */
  49222. export interface EnvironmentTextureInfo {
  49223. /**
  49224. * Version of the environment map
  49225. */
  49226. version: number;
  49227. /**
  49228. * Width of image
  49229. */
  49230. width: number;
  49231. /**
  49232. * Irradiance information stored in the file.
  49233. */
  49234. irradiance: any;
  49235. /**
  49236. * Specular information stored in the file.
  49237. */
  49238. specular: any;
  49239. }
  49240. /**
  49241. * Defines One Image in the file. It requires only the position in the file
  49242. * as well as the length.
  49243. */
  49244. interface BufferImageData {
  49245. /**
  49246. * Length of the image data.
  49247. */
  49248. length: number;
  49249. /**
  49250. * Position of the data from the null terminator delimiting the end of the JSON.
  49251. */
  49252. position: number;
  49253. }
  49254. /**
  49255. * Defines the specular data enclosed in the file.
  49256. * This corresponds to the version 1 of the data.
  49257. */
  49258. export interface EnvironmentTextureSpecularInfoV1 {
  49259. /**
  49260. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49261. */
  49262. specularDataPosition?: number;
  49263. /**
  49264. * This contains all the images data needed to reconstruct the cubemap.
  49265. */
  49266. mipmaps: Array<BufferImageData>;
  49267. /**
  49268. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49269. */
  49270. lodGenerationScale: number;
  49271. }
  49272. /**
  49273. * Sets of helpers addressing the serialization and deserialization of environment texture
  49274. * stored in a BabylonJS env file.
  49275. * Those files are usually stored as .env files.
  49276. */
  49277. export class EnvironmentTextureTools {
  49278. /**
  49279. * Magic number identifying the env file.
  49280. */
  49281. private static _MagicBytes;
  49282. /**
  49283. * Gets the environment info from an env file.
  49284. * @param data The array buffer containing the .env bytes.
  49285. * @returns the environment file info (the json header) if successfully parsed.
  49286. */
  49287. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49288. /**
  49289. * Creates an environment texture from a loaded cube texture.
  49290. * @param texture defines the cube texture to convert in env file
  49291. * @return a promise containing the environment data if succesfull.
  49292. */
  49293. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49294. /**
  49295. * Creates a JSON representation of the spherical data.
  49296. * @param texture defines the texture containing the polynomials
  49297. * @return the JSON representation of the spherical info
  49298. */
  49299. private static _CreateEnvTextureIrradiance;
  49300. /**
  49301. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49302. * @param data the image data
  49303. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49304. * @return the views described by info providing access to the underlying buffer
  49305. */
  49306. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49307. /**
  49308. * Uploads the texture info contained in the env file to the GPU.
  49309. * @param texture defines the internal texture to upload to
  49310. * @param data defines the data to load
  49311. * @param info defines the texture info retrieved through the GetEnvInfo method
  49312. * @returns a promise
  49313. */
  49314. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49315. private static _OnImageReadyAsync;
  49316. /**
  49317. * Uploads the levels of image data to the GPU.
  49318. * @param texture defines the internal texture to upload to
  49319. * @param imageData defines the array buffer views of image data [mipmap][face]
  49320. * @returns a promise
  49321. */
  49322. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49323. /**
  49324. * Uploads spherical polynomials information to the texture.
  49325. * @param texture defines the texture we are trying to upload the information to
  49326. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49327. */
  49328. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49329. /** @hidden */
  49330. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49331. }
  49332. }
  49333. declare module "babylonjs/Maths/math.vertexFormat" {
  49334. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49335. /**
  49336. * Contains position and normal vectors for a vertex
  49337. */
  49338. export class PositionNormalVertex {
  49339. /** the position of the vertex (defaut: 0,0,0) */
  49340. position: Vector3;
  49341. /** the normal of the vertex (defaut: 0,1,0) */
  49342. normal: Vector3;
  49343. /**
  49344. * Creates a PositionNormalVertex
  49345. * @param position the position of the vertex (defaut: 0,0,0)
  49346. * @param normal the normal of the vertex (defaut: 0,1,0)
  49347. */
  49348. constructor(
  49349. /** the position of the vertex (defaut: 0,0,0) */
  49350. position?: Vector3,
  49351. /** the normal of the vertex (defaut: 0,1,0) */
  49352. normal?: Vector3);
  49353. /**
  49354. * Clones the PositionNormalVertex
  49355. * @returns the cloned PositionNormalVertex
  49356. */
  49357. clone(): PositionNormalVertex;
  49358. }
  49359. /**
  49360. * Contains position, normal and uv vectors for a vertex
  49361. */
  49362. export class PositionNormalTextureVertex {
  49363. /** the position of the vertex (defaut: 0,0,0) */
  49364. position: Vector3;
  49365. /** the normal of the vertex (defaut: 0,1,0) */
  49366. normal: Vector3;
  49367. /** the uv of the vertex (default: 0,0) */
  49368. uv: Vector2;
  49369. /**
  49370. * Creates a PositionNormalTextureVertex
  49371. * @param position the position of the vertex (defaut: 0,0,0)
  49372. * @param normal the normal of the vertex (defaut: 0,1,0)
  49373. * @param uv the uv of the vertex (default: 0,0)
  49374. */
  49375. constructor(
  49376. /** the position of the vertex (defaut: 0,0,0) */
  49377. position?: Vector3,
  49378. /** the normal of the vertex (defaut: 0,1,0) */
  49379. normal?: Vector3,
  49380. /** the uv of the vertex (default: 0,0) */
  49381. uv?: Vector2);
  49382. /**
  49383. * Clones the PositionNormalTextureVertex
  49384. * @returns the cloned PositionNormalTextureVertex
  49385. */
  49386. clone(): PositionNormalTextureVertex;
  49387. }
  49388. }
  49389. declare module "babylonjs/Maths/math" {
  49390. export * from "babylonjs/Maths/math.axis";
  49391. export * from "babylonjs/Maths/math.color";
  49392. export * from "babylonjs/Maths/math.constants";
  49393. export * from "babylonjs/Maths/math.frustum";
  49394. export * from "babylonjs/Maths/math.path";
  49395. export * from "babylonjs/Maths/math.plane";
  49396. export * from "babylonjs/Maths/math.size";
  49397. export * from "babylonjs/Maths/math.vector";
  49398. export * from "babylonjs/Maths/math.vertexFormat";
  49399. export * from "babylonjs/Maths/math.viewport";
  49400. }
  49401. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49402. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49403. /** @hidden */
  49404. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49405. private _genericAttributeLocation;
  49406. private _varyingLocationCount;
  49407. private _varyingLocationMap;
  49408. private _replacements;
  49409. private _textureCount;
  49410. private _uniforms;
  49411. lineProcessor(line: string): string;
  49412. attributeProcessor(attribute: string): string;
  49413. varyingProcessor(varying: string, isFragment: boolean): string;
  49414. uniformProcessor(uniform: string): string;
  49415. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49416. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49417. }
  49418. }
  49419. declare module "babylonjs/Engines/nativeEngine" {
  49420. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49421. import { Engine } from "babylonjs/Engines/engine";
  49422. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49425. import { Effect } from "babylonjs/Materials/effect";
  49426. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49427. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49428. import { IColor4Like } from "babylonjs/Maths/math.like";
  49429. import { Scene } from "babylonjs/scene";
  49430. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49431. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49432. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49433. /**
  49434. * Container for accessors for natively-stored mesh data buffers.
  49435. */
  49436. class NativeDataBuffer extends DataBuffer {
  49437. /**
  49438. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49439. */
  49440. nativeIndexBuffer?: any;
  49441. /**
  49442. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49443. */
  49444. nativeVertexBuffer?: any;
  49445. }
  49446. /** @hidden */
  49447. class NativeTexture extends InternalTexture {
  49448. getInternalTexture(): InternalTexture;
  49449. getViewCount(): number;
  49450. }
  49451. /** @hidden */
  49452. export class NativeEngine extends Engine {
  49453. private readonly _native;
  49454. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49455. private readonly INVALID_HANDLE;
  49456. getHardwareScalingLevel(): number;
  49457. constructor();
  49458. /**
  49459. * Can be used to override the current requestAnimationFrame requester.
  49460. * @hidden
  49461. */
  49462. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49463. /**
  49464. * Override default engine behavior.
  49465. * @param color
  49466. * @param backBuffer
  49467. * @param depth
  49468. * @param stencil
  49469. */
  49470. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49471. /**
  49472. * Gets host document
  49473. * @returns the host document object
  49474. */
  49475. getHostDocument(): Nullable<Document>;
  49476. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49477. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49478. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49479. recordVertexArrayObject(vertexBuffers: {
  49480. [key: string]: VertexBuffer;
  49481. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49482. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49483. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49484. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49485. /**
  49486. * Draw a list of indexed primitives
  49487. * @param fillMode defines the primitive to use
  49488. * @param indexStart defines the starting index
  49489. * @param indexCount defines the number of index to draw
  49490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49491. */
  49492. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49493. /**
  49494. * Draw a list of unindexed primitives
  49495. * @param fillMode defines the primitive to use
  49496. * @param verticesStart defines the index of first vertex to draw
  49497. * @param verticesCount defines the count of vertices to draw
  49498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49499. */
  49500. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49501. createPipelineContext(): IPipelineContext;
  49502. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49503. /** @hidden */
  49504. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49505. /** @hidden */
  49506. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49507. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49508. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49509. protected _setProgram(program: WebGLProgram): void;
  49510. _releaseEffect(effect: Effect): void;
  49511. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49512. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49513. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49514. bindSamplers(effect: Effect): void;
  49515. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49516. getRenderWidth(useScreen?: boolean): number;
  49517. getRenderHeight(useScreen?: boolean): number;
  49518. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49519. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49520. /**
  49521. * Set the z offset to apply to current rendering
  49522. * @param value defines the offset to apply
  49523. */
  49524. setZOffset(value: number): void;
  49525. /**
  49526. * Gets the current value of the zOffset
  49527. * @returns the current zOffset state
  49528. */
  49529. getZOffset(): number;
  49530. /**
  49531. * Enable or disable depth buffering
  49532. * @param enable defines the state to set
  49533. */
  49534. setDepthBuffer(enable: boolean): void;
  49535. /**
  49536. * Gets a boolean indicating if depth writing is enabled
  49537. * @returns the current depth writing state
  49538. */
  49539. getDepthWrite(): boolean;
  49540. /**
  49541. * Enable or disable depth writing
  49542. * @param enable defines the state to set
  49543. */
  49544. setDepthWrite(enable: boolean): void;
  49545. /**
  49546. * Enable or disable color writing
  49547. * @param enable defines the state to set
  49548. */
  49549. setColorWrite(enable: boolean): void;
  49550. /**
  49551. * Gets a boolean indicating if color writing is enabled
  49552. * @returns the current color writing state
  49553. */
  49554. getColorWrite(): boolean;
  49555. /**
  49556. * Sets alpha constants used by some alpha blending modes
  49557. * @param r defines the red component
  49558. * @param g defines the green component
  49559. * @param b defines the blue component
  49560. * @param a defines the alpha component
  49561. */
  49562. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49563. /**
  49564. * Sets the current alpha mode
  49565. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49566. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49567. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49568. */
  49569. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49570. /**
  49571. * Gets the current alpha mode
  49572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49573. * @returns the current alpha mode
  49574. */
  49575. getAlphaMode(): number;
  49576. setInt(uniform: WebGLUniformLocation, int: number): void;
  49577. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49578. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49579. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49580. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49581. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49582. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49583. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49584. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49585. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49586. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49587. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49588. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49589. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49590. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49591. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49592. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49593. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49594. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49595. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49596. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49597. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49598. wipeCaches(bruteForce?: boolean): void;
  49599. _createTexture(): WebGLTexture;
  49600. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49601. /**
  49602. * Usually called from Texture.ts.
  49603. * Passed information to create a WebGLTexture
  49604. * @param urlArg defines a value which contains one of the following:
  49605. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49606. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49607. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49608. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49609. * @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)
  49610. * @param scene needed for loading to the correct scene
  49611. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49612. * @param onLoad optional callback to be called upon successful completion
  49613. * @param onError optional callback to be called upon failure
  49614. * @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
  49615. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49616. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49617. * @param forcedExtension defines the extension to use to pick the right loader
  49618. * @param mimeType defines an optional mime type
  49619. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49620. */
  49621. 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;
  49622. /**
  49623. * Creates a cube texture
  49624. * @param rootUrl defines the url where the files to load is located
  49625. * @param scene defines the current scene
  49626. * @param files defines the list of files to load (1 per face)
  49627. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49628. * @param onLoad defines an optional callback raised when the texture is loaded
  49629. * @param onError defines an optional callback raised if there is an issue to load the texture
  49630. * @param format defines the format of the data
  49631. * @param forcedExtension defines the extension to use to pick the right loader
  49632. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49633. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49634. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49635. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49636. * @returns the cube texture as an InternalTexture
  49637. */
  49638. 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;
  49639. private _getSamplingFilter;
  49640. private static _GetNativeTextureFormat;
  49641. createRenderTargetTexture(size: number | {
  49642. width: number;
  49643. height: number;
  49644. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49645. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49646. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49647. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49648. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49649. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49650. /**
  49651. * Updates a dynamic vertex buffer.
  49652. * @param vertexBuffer the vertex buffer to update
  49653. * @param data the data used to update the vertex buffer
  49654. * @param byteOffset the byte offset of the data (optional)
  49655. * @param byteLength the byte length of the data (optional)
  49656. */
  49657. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49658. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49659. private _updateAnisotropicLevel;
  49660. private _getAddressMode;
  49661. /** @hidden */
  49662. _bindTexture(channel: number, texture: InternalTexture): void;
  49663. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49664. releaseEffects(): void;
  49665. /** @hidden */
  49666. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49667. /** @hidden */
  49668. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49669. /** @hidden */
  49670. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49671. /** @hidden */
  49672. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49673. }
  49674. }
  49675. declare module "babylonjs/Engines/index" {
  49676. export * from "babylonjs/Engines/constants";
  49677. export * from "babylonjs/Engines/engineCapabilities";
  49678. export * from "babylonjs/Engines/instancingAttributeInfo";
  49679. export * from "babylonjs/Engines/thinEngine";
  49680. export * from "babylonjs/Engines/engine";
  49681. export * from "babylonjs/Engines/engineStore";
  49682. export * from "babylonjs/Engines/nullEngine";
  49683. export * from "babylonjs/Engines/Extensions/index";
  49684. export * from "babylonjs/Engines/IPipelineContext";
  49685. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49686. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49687. export * from "babylonjs/Engines/nativeEngine";
  49688. }
  49689. declare module "babylonjs/Events/clipboardEvents" {
  49690. /**
  49691. * Gather the list of clipboard event types as constants.
  49692. */
  49693. export class ClipboardEventTypes {
  49694. /**
  49695. * The clipboard event is fired when a copy command is active (pressed).
  49696. */
  49697. static readonly COPY: number;
  49698. /**
  49699. * The clipboard event is fired when a cut command is active (pressed).
  49700. */
  49701. static readonly CUT: number;
  49702. /**
  49703. * The clipboard event is fired when a paste command is active (pressed).
  49704. */
  49705. static readonly PASTE: number;
  49706. }
  49707. /**
  49708. * This class is used to store clipboard related info for the onClipboardObservable event.
  49709. */
  49710. export class ClipboardInfo {
  49711. /**
  49712. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49713. */
  49714. type: number;
  49715. /**
  49716. * Defines the related dom event
  49717. */
  49718. event: ClipboardEvent;
  49719. /**
  49720. *Creates an instance of ClipboardInfo.
  49721. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49722. * @param event Defines the related dom event
  49723. */
  49724. constructor(
  49725. /**
  49726. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49727. */
  49728. type: number,
  49729. /**
  49730. * Defines the related dom event
  49731. */
  49732. event: ClipboardEvent);
  49733. /**
  49734. * Get the clipboard event's type from the keycode.
  49735. * @param keyCode Defines the keyCode for the current keyboard event.
  49736. * @return {number}
  49737. */
  49738. static GetTypeFromCharacter(keyCode: number): number;
  49739. }
  49740. }
  49741. declare module "babylonjs/Events/index" {
  49742. export * from "babylonjs/Events/keyboardEvents";
  49743. export * from "babylonjs/Events/pointerEvents";
  49744. export * from "babylonjs/Events/clipboardEvents";
  49745. }
  49746. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49747. import { Scene } from "babylonjs/scene";
  49748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49749. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49750. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49751. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49752. /**
  49753. * Google Daydream controller
  49754. */
  49755. export class DaydreamController extends WebVRController {
  49756. /**
  49757. * Base Url for the controller model.
  49758. */
  49759. static MODEL_BASE_URL: string;
  49760. /**
  49761. * File name for the controller model.
  49762. */
  49763. static MODEL_FILENAME: string;
  49764. /**
  49765. * Gamepad Id prefix used to identify Daydream Controller.
  49766. */
  49767. static readonly GAMEPAD_ID_PREFIX: string;
  49768. /**
  49769. * Creates a new DaydreamController from a gamepad
  49770. * @param vrGamepad the gamepad that the controller should be created from
  49771. */
  49772. constructor(vrGamepad: any);
  49773. /**
  49774. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49775. * @param scene scene in which to add meshes
  49776. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49777. */
  49778. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49779. /**
  49780. * Called once for each button that changed state since the last frame
  49781. * @param buttonIdx Which button index changed
  49782. * @param state New state of the button
  49783. * @param changes Which properties on the state changed since last frame
  49784. */
  49785. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49786. }
  49787. }
  49788. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49789. import { Scene } from "babylonjs/scene";
  49790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49791. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49792. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49793. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49794. /**
  49795. * Gear VR Controller
  49796. */
  49797. export class GearVRController extends WebVRController {
  49798. /**
  49799. * Base Url for the controller model.
  49800. */
  49801. static MODEL_BASE_URL: string;
  49802. /**
  49803. * File name for the controller model.
  49804. */
  49805. static MODEL_FILENAME: string;
  49806. /**
  49807. * Gamepad Id prefix used to identify this controller.
  49808. */
  49809. static readonly GAMEPAD_ID_PREFIX: string;
  49810. private readonly _buttonIndexToObservableNameMap;
  49811. /**
  49812. * Creates a new GearVRController from a gamepad
  49813. * @param vrGamepad the gamepad that the controller should be created from
  49814. */
  49815. constructor(vrGamepad: any);
  49816. /**
  49817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49818. * @param scene scene in which to add meshes
  49819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49820. */
  49821. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49822. /**
  49823. * Called once for each button that changed state since the last frame
  49824. * @param buttonIdx Which button index changed
  49825. * @param state New state of the button
  49826. * @param changes Which properties on the state changed since last frame
  49827. */
  49828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49829. }
  49830. }
  49831. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49832. import { Scene } from "babylonjs/scene";
  49833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49834. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49835. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49836. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49837. /**
  49838. * Generic Controller
  49839. */
  49840. export class GenericController extends WebVRController {
  49841. /**
  49842. * Base Url for the controller model.
  49843. */
  49844. static readonly MODEL_BASE_URL: string;
  49845. /**
  49846. * File name for the controller model.
  49847. */
  49848. static readonly MODEL_FILENAME: string;
  49849. /**
  49850. * Creates a new GenericController from a gamepad
  49851. * @param vrGamepad the gamepad that the controller should be created from
  49852. */
  49853. constructor(vrGamepad: any);
  49854. /**
  49855. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49856. * @param scene scene in which to add meshes
  49857. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49858. */
  49859. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49860. /**
  49861. * Called once for each button that changed state since the last frame
  49862. * @param buttonIdx Which button index changed
  49863. * @param state New state of the button
  49864. * @param changes Which properties on the state changed since last frame
  49865. */
  49866. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49867. }
  49868. }
  49869. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49870. import { Observable } from "babylonjs/Misc/observable";
  49871. import { Scene } from "babylonjs/scene";
  49872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49873. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49874. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49875. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49876. /**
  49877. * Oculus Touch Controller
  49878. */
  49879. export class OculusTouchController extends WebVRController {
  49880. /**
  49881. * Base Url for the controller model.
  49882. */
  49883. static MODEL_BASE_URL: string;
  49884. /**
  49885. * File name for the left controller model.
  49886. */
  49887. static MODEL_LEFT_FILENAME: string;
  49888. /**
  49889. * File name for the right controller model.
  49890. */
  49891. static MODEL_RIGHT_FILENAME: string;
  49892. /**
  49893. * Base Url for the Quest controller model.
  49894. */
  49895. static QUEST_MODEL_BASE_URL: string;
  49896. /**
  49897. * @hidden
  49898. * If the controllers are running on a device that needs the updated Quest controller models
  49899. */
  49900. static _IsQuest: boolean;
  49901. /**
  49902. * Fired when the secondary trigger on this controller is modified
  49903. */
  49904. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49905. /**
  49906. * Fired when the thumb rest on this controller is modified
  49907. */
  49908. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49909. /**
  49910. * Creates a new OculusTouchController from a gamepad
  49911. * @param vrGamepad the gamepad that the controller should be created from
  49912. */
  49913. constructor(vrGamepad: any);
  49914. /**
  49915. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49916. * @param scene scene in which to add meshes
  49917. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49918. */
  49919. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49920. /**
  49921. * Fired when the A button on this controller is modified
  49922. */
  49923. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49924. /**
  49925. * Fired when the B button on this controller is modified
  49926. */
  49927. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49928. /**
  49929. * Fired when the X button on this controller is modified
  49930. */
  49931. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49932. /**
  49933. * Fired when the Y button on this controller is modified
  49934. */
  49935. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49936. /**
  49937. * Called once for each button that changed state since the last frame
  49938. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49939. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49940. * 2) secondary trigger (same)
  49941. * 3) A (right) X (left), touch, pressed = value
  49942. * 4) B / Y
  49943. * 5) thumb rest
  49944. * @param buttonIdx Which button index changed
  49945. * @param state New state of the button
  49946. * @param changes Which properties on the state changed since last frame
  49947. */
  49948. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49949. }
  49950. }
  49951. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49952. import { Scene } from "babylonjs/scene";
  49953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49954. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49955. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49956. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49957. import { Observable } from "babylonjs/Misc/observable";
  49958. /**
  49959. * Vive Controller
  49960. */
  49961. export class ViveController extends WebVRController {
  49962. /**
  49963. * Base Url for the controller model.
  49964. */
  49965. static MODEL_BASE_URL: string;
  49966. /**
  49967. * File name for the controller model.
  49968. */
  49969. static MODEL_FILENAME: string;
  49970. /**
  49971. * Creates a new ViveController from a gamepad
  49972. * @param vrGamepad the gamepad that the controller should be created from
  49973. */
  49974. constructor(vrGamepad: any);
  49975. /**
  49976. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49977. * @param scene scene in which to add meshes
  49978. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49979. */
  49980. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49981. /**
  49982. * Fired when the left button on this controller is modified
  49983. */
  49984. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49985. /**
  49986. * Fired when the right button on this controller is modified
  49987. */
  49988. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49989. /**
  49990. * Fired when the menu button on this controller is modified
  49991. */
  49992. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49993. /**
  49994. * Called once for each button that changed state since the last frame
  49995. * Vive mapping:
  49996. * 0: touchpad
  49997. * 1: trigger
  49998. * 2: left AND right buttons
  49999. * 3: menu button
  50000. * @param buttonIdx Which button index changed
  50001. * @param state New state of the button
  50002. * @param changes Which properties on the state changed since last frame
  50003. */
  50004. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50005. }
  50006. }
  50007. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50008. import { Observable } from "babylonjs/Misc/observable";
  50009. import { Scene } from "babylonjs/scene";
  50010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50011. import { Ray } from "babylonjs/Culling/ray";
  50012. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50013. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50014. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50015. /**
  50016. * Defines the WindowsMotionController object that the state of the windows motion controller
  50017. */
  50018. export class WindowsMotionController extends WebVRController {
  50019. /**
  50020. * The base url used to load the left and right controller models
  50021. */
  50022. static MODEL_BASE_URL: string;
  50023. /**
  50024. * The name of the left controller model file
  50025. */
  50026. static MODEL_LEFT_FILENAME: string;
  50027. /**
  50028. * The name of the right controller model file
  50029. */
  50030. static MODEL_RIGHT_FILENAME: string;
  50031. /**
  50032. * The controller name prefix for this controller type
  50033. */
  50034. static readonly GAMEPAD_ID_PREFIX: string;
  50035. /**
  50036. * The controller id pattern for this controller type
  50037. */
  50038. private static readonly GAMEPAD_ID_PATTERN;
  50039. private _loadedMeshInfo;
  50040. protected readonly _mapping: {
  50041. buttons: string[];
  50042. buttonMeshNames: {
  50043. 'trigger': string;
  50044. 'menu': string;
  50045. 'grip': string;
  50046. 'thumbstick': string;
  50047. 'trackpad': string;
  50048. };
  50049. buttonObservableNames: {
  50050. 'trigger': string;
  50051. 'menu': string;
  50052. 'grip': string;
  50053. 'thumbstick': string;
  50054. 'trackpad': string;
  50055. };
  50056. axisMeshNames: string[];
  50057. pointingPoseMeshName: string;
  50058. };
  50059. /**
  50060. * Fired when the trackpad on this controller is clicked
  50061. */
  50062. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50063. /**
  50064. * Fired when the trackpad on this controller is modified
  50065. */
  50066. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50067. /**
  50068. * The current x and y values of this controller's trackpad
  50069. */
  50070. trackpad: StickValues;
  50071. /**
  50072. * Creates a new WindowsMotionController from a gamepad
  50073. * @param vrGamepad the gamepad that the controller should be created from
  50074. */
  50075. constructor(vrGamepad: any);
  50076. /**
  50077. * Fired when the trigger on this controller is modified
  50078. */
  50079. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50080. /**
  50081. * Fired when the menu button on this controller is modified
  50082. */
  50083. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50084. /**
  50085. * Fired when the grip button on this controller is modified
  50086. */
  50087. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50088. /**
  50089. * Fired when the thumbstick button on this controller is modified
  50090. */
  50091. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50092. /**
  50093. * Fired when the touchpad button on this controller is modified
  50094. */
  50095. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50096. /**
  50097. * Fired when the touchpad values on this controller are modified
  50098. */
  50099. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50100. protected _updateTrackpad(): void;
  50101. /**
  50102. * Called once per frame by the engine.
  50103. */
  50104. update(): void;
  50105. /**
  50106. * Called once for each button that changed state since the last frame
  50107. * @param buttonIdx Which button index changed
  50108. * @param state New state of the button
  50109. * @param changes Which properties on the state changed since last frame
  50110. */
  50111. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50112. /**
  50113. * Moves the buttons on the controller mesh based on their current state
  50114. * @param buttonName the name of the button to move
  50115. * @param buttonValue the value of the button which determines the buttons new position
  50116. */
  50117. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50118. /**
  50119. * Moves the axis on the controller mesh based on its current state
  50120. * @param axis the index of the axis
  50121. * @param axisValue the value of the axis which determines the meshes new position
  50122. * @hidden
  50123. */
  50124. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50125. /**
  50126. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50127. * @param scene scene in which to add meshes
  50128. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50129. */
  50130. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50131. /**
  50132. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50133. * can be transformed by button presses and axes values, based on this._mapping.
  50134. *
  50135. * @param scene scene in which the meshes exist
  50136. * @param meshes list of meshes that make up the controller model to process
  50137. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50138. */
  50139. private processModel;
  50140. private createMeshInfo;
  50141. /**
  50142. * Gets the ray of the controller in the direction the controller is pointing
  50143. * @param length the length the resulting ray should be
  50144. * @returns a ray in the direction the controller is pointing
  50145. */
  50146. getForwardRay(length?: number): Ray;
  50147. /**
  50148. * Disposes of the controller
  50149. */
  50150. dispose(): void;
  50151. }
  50152. /**
  50153. * This class represents a new windows motion controller in XR.
  50154. */
  50155. export class XRWindowsMotionController extends WindowsMotionController {
  50156. /**
  50157. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50158. */
  50159. protected readonly _mapping: {
  50160. buttons: string[];
  50161. buttonMeshNames: {
  50162. 'trigger': string;
  50163. 'menu': string;
  50164. 'grip': string;
  50165. 'thumbstick': string;
  50166. 'trackpad': string;
  50167. };
  50168. buttonObservableNames: {
  50169. 'trigger': string;
  50170. 'menu': string;
  50171. 'grip': string;
  50172. 'thumbstick': string;
  50173. 'trackpad': string;
  50174. };
  50175. axisMeshNames: string[];
  50176. pointingPoseMeshName: string;
  50177. };
  50178. /**
  50179. * Construct a new XR-Based windows motion controller
  50180. *
  50181. * @param gamepadInfo the gamepad object from the browser
  50182. */
  50183. constructor(gamepadInfo: any);
  50184. /**
  50185. * holds the thumbstick values (X,Y)
  50186. */
  50187. thumbstickValues: StickValues;
  50188. /**
  50189. * Fired when the thumbstick on this controller is clicked
  50190. */
  50191. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50192. /**
  50193. * Fired when the thumbstick on this controller is modified
  50194. */
  50195. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50196. /**
  50197. * Fired when the touchpad button on this controller is modified
  50198. */
  50199. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50200. /**
  50201. * Fired when the touchpad values on this controller are modified
  50202. */
  50203. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50204. /**
  50205. * Fired when the thumbstick button on this controller is modified
  50206. * here to prevent breaking changes
  50207. */
  50208. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50209. /**
  50210. * updating the thumbstick(!) and not the trackpad.
  50211. * This is named this way due to the difference between WebVR and XR and to avoid
  50212. * changing the parent class.
  50213. */
  50214. protected _updateTrackpad(): void;
  50215. /**
  50216. * Disposes the class with joy
  50217. */
  50218. dispose(): void;
  50219. }
  50220. }
  50221. declare module "babylonjs/Gamepads/Controllers/index" {
  50222. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50223. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50224. export * from "babylonjs/Gamepads/Controllers/genericController";
  50225. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50226. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50227. export * from "babylonjs/Gamepads/Controllers/viveController";
  50228. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50229. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50230. }
  50231. declare module "babylonjs/Gamepads/index" {
  50232. export * from "babylonjs/Gamepads/Controllers/index";
  50233. export * from "babylonjs/Gamepads/gamepad";
  50234. export * from "babylonjs/Gamepads/gamepadManager";
  50235. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50236. export * from "babylonjs/Gamepads/xboxGamepad";
  50237. export * from "babylonjs/Gamepads/dualShockGamepad";
  50238. }
  50239. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50240. import { Scene } from "babylonjs/scene";
  50241. import { Vector4 } from "babylonjs/Maths/math.vector";
  50242. import { Color4 } from "babylonjs/Maths/math.color";
  50243. import { Mesh } from "babylonjs/Meshes/mesh";
  50244. import { Nullable } from "babylonjs/types";
  50245. /**
  50246. * Class containing static functions to help procedurally build meshes
  50247. */
  50248. export class PolyhedronBuilder {
  50249. /**
  50250. * Creates a polyhedron mesh
  50251. * * 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
  50252. * * The parameter `size` (positive float, default 1) sets the polygon size
  50253. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50254. * * 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`
  50255. * * 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
  50256. * * 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)`)
  50257. * * 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
  50258. * * 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
  50259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50262. * @param name defines the name of the mesh
  50263. * @param options defines the options used to create the mesh
  50264. * @param scene defines the hosting scene
  50265. * @returns the polyhedron mesh
  50266. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50267. */
  50268. static CreatePolyhedron(name: string, options: {
  50269. type?: number;
  50270. size?: number;
  50271. sizeX?: number;
  50272. sizeY?: number;
  50273. sizeZ?: number;
  50274. custom?: any;
  50275. faceUV?: Vector4[];
  50276. faceColors?: Color4[];
  50277. flat?: boolean;
  50278. updatable?: boolean;
  50279. sideOrientation?: number;
  50280. frontUVs?: Vector4;
  50281. backUVs?: Vector4;
  50282. }, scene?: Nullable<Scene>): Mesh;
  50283. }
  50284. }
  50285. declare module "babylonjs/Gizmos/scaleGizmo" {
  50286. import { Observable } from "babylonjs/Misc/observable";
  50287. import { Nullable } from "babylonjs/types";
  50288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50289. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50290. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50291. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50292. /**
  50293. * Gizmo that enables scaling a mesh along 3 axis
  50294. */
  50295. export class ScaleGizmo extends Gizmo {
  50296. /**
  50297. * Internal gizmo used for interactions on the x axis
  50298. */
  50299. xGizmo: AxisScaleGizmo;
  50300. /**
  50301. * Internal gizmo used for interactions on the y axis
  50302. */
  50303. yGizmo: AxisScaleGizmo;
  50304. /**
  50305. * Internal gizmo used for interactions on the z axis
  50306. */
  50307. zGizmo: AxisScaleGizmo;
  50308. /**
  50309. * Internal gizmo used to scale all axis equally
  50310. */
  50311. uniformScaleGizmo: AxisScaleGizmo;
  50312. private _meshAttached;
  50313. private _updateGizmoRotationToMatchAttachedMesh;
  50314. private _snapDistance;
  50315. private _scaleRatio;
  50316. private _uniformScalingMesh;
  50317. private _octahedron;
  50318. private _sensitivity;
  50319. /** Fires an event when any of it's sub gizmos are dragged */
  50320. onDragStartObservable: Observable<unknown>;
  50321. /** Fires an event when any of it's sub gizmos are released from dragging */
  50322. onDragEndObservable: Observable<unknown>;
  50323. get attachedMesh(): Nullable<AbstractMesh>;
  50324. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50325. /**
  50326. * Creates a ScaleGizmo
  50327. * @param gizmoLayer The utility layer the gizmo will be added to
  50328. */
  50329. constructor(gizmoLayer?: UtilityLayerRenderer);
  50330. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50331. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50332. /**
  50333. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50334. */
  50335. set snapDistance(value: number);
  50336. get snapDistance(): number;
  50337. /**
  50338. * Ratio for the scale of the gizmo (Default: 1)
  50339. */
  50340. set scaleRatio(value: number);
  50341. get scaleRatio(): number;
  50342. /**
  50343. * Sensitivity factor for dragging (Default: 1)
  50344. */
  50345. set sensitivity(value: number);
  50346. get sensitivity(): number;
  50347. /**
  50348. * Disposes of the gizmo
  50349. */
  50350. dispose(): void;
  50351. }
  50352. }
  50353. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50354. import { Observable } from "babylonjs/Misc/observable";
  50355. import { Nullable } from "babylonjs/types";
  50356. import { Vector3 } from "babylonjs/Maths/math.vector";
  50357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50358. import { Mesh } from "babylonjs/Meshes/mesh";
  50359. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50360. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50361. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50362. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50363. import { Color3 } from "babylonjs/Maths/math.color";
  50364. /**
  50365. * Single axis scale gizmo
  50366. */
  50367. export class AxisScaleGizmo extends Gizmo {
  50368. /**
  50369. * Drag behavior responsible for the gizmos dragging interactions
  50370. */
  50371. dragBehavior: PointerDragBehavior;
  50372. private _pointerObserver;
  50373. /**
  50374. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50375. */
  50376. snapDistance: number;
  50377. /**
  50378. * Event that fires each time the gizmo snaps to a new location.
  50379. * * snapDistance is the the change in distance
  50380. */
  50381. onSnapObservable: Observable<{
  50382. snapDistance: number;
  50383. }>;
  50384. /**
  50385. * If the scaling operation should be done on all axis (default: false)
  50386. */
  50387. uniformScaling: boolean;
  50388. /**
  50389. * Custom sensitivity value for the drag strength
  50390. */
  50391. sensitivity: number;
  50392. private _isEnabled;
  50393. private _parent;
  50394. private _arrow;
  50395. private _coloredMaterial;
  50396. private _hoverMaterial;
  50397. /**
  50398. * Creates an AxisScaleGizmo
  50399. * @param gizmoLayer The utility layer the gizmo will be added to
  50400. * @param dragAxis The axis which the gizmo will be able to scale on
  50401. * @param color The color of the gizmo
  50402. */
  50403. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50404. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50405. /**
  50406. * If the gizmo is enabled
  50407. */
  50408. set isEnabled(value: boolean);
  50409. get isEnabled(): boolean;
  50410. /**
  50411. * Disposes of the gizmo
  50412. */
  50413. dispose(): void;
  50414. /**
  50415. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50416. * @param mesh The mesh to replace the default mesh of the gizmo
  50417. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50418. */
  50419. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50420. }
  50421. }
  50422. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50423. import { Observable } from "babylonjs/Misc/observable";
  50424. import { Nullable } from "babylonjs/types";
  50425. import { Vector3 } from "babylonjs/Maths/math.vector";
  50426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50427. import { Mesh } from "babylonjs/Meshes/mesh";
  50428. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50429. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50430. import { Color3 } from "babylonjs/Maths/math.color";
  50431. import "babylonjs/Meshes/Builders/boxBuilder";
  50432. /**
  50433. * Bounding box gizmo
  50434. */
  50435. export class BoundingBoxGizmo extends Gizmo {
  50436. private _lineBoundingBox;
  50437. private _rotateSpheresParent;
  50438. private _scaleBoxesParent;
  50439. private _boundingDimensions;
  50440. private _renderObserver;
  50441. private _pointerObserver;
  50442. private _scaleDragSpeed;
  50443. private _tmpQuaternion;
  50444. private _tmpVector;
  50445. private _tmpRotationMatrix;
  50446. /**
  50447. * 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)
  50448. */
  50449. ignoreChildren: boolean;
  50450. /**
  50451. * 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)
  50452. */
  50453. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50454. /**
  50455. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50456. */
  50457. rotationSphereSize: number;
  50458. /**
  50459. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50460. */
  50461. scaleBoxSize: number;
  50462. /**
  50463. * 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)
  50464. */
  50465. fixedDragMeshScreenSize: boolean;
  50466. /**
  50467. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50468. */
  50469. fixedDragMeshScreenSizeDistanceFactor: number;
  50470. /**
  50471. * Fired when a rotation sphere or scale box is dragged
  50472. */
  50473. onDragStartObservable: Observable<{}>;
  50474. /**
  50475. * Fired when a scale box is dragged
  50476. */
  50477. onScaleBoxDragObservable: Observable<{}>;
  50478. /**
  50479. * Fired when a scale box drag is ended
  50480. */
  50481. onScaleBoxDragEndObservable: Observable<{}>;
  50482. /**
  50483. * Fired when a rotation sphere is dragged
  50484. */
  50485. onRotationSphereDragObservable: Observable<{}>;
  50486. /**
  50487. * Fired when a rotation sphere drag is ended
  50488. */
  50489. onRotationSphereDragEndObservable: Observable<{}>;
  50490. /**
  50491. * 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)
  50492. */
  50493. scalePivot: Nullable<Vector3>;
  50494. /**
  50495. * Mesh used as a pivot to rotate the attached mesh
  50496. */
  50497. private _anchorMesh;
  50498. private _existingMeshScale;
  50499. private _dragMesh;
  50500. private pointerDragBehavior;
  50501. private coloredMaterial;
  50502. private hoverColoredMaterial;
  50503. /**
  50504. * Sets the color of the bounding box gizmo
  50505. * @param color the color to set
  50506. */
  50507. setColor(color: Color3): void;
  50508. /**
  50509. * Creates an BoundingBoxGizmo
  50510. * @param gizmoLayer The utility layer the gizmo will be added to
  50511. * @param color The color of the gizmo
  50512. */
  50513. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50514. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50515. private _selectNode;
  50516. /**
  50517. * Updates the bounding box information for the Gizmo
  50518. */
  50519. updateBoundingBox(): void;
  50520. private _updateRotationSpheres;
  50521. private _updateScaleBoxes;
  50522. /**
  50523. * Enables rotation on the specified axis and disables rotation on the others
  50524. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50525. */
  50526. setEnabledRotationAxis(axis: string): void;
  50527. /**
  50528. * Enables/disables scaling
  50529. * @param enable if scaling should be enabled
  50530. */
  50531. setEnabledScaling(enable: boolean): void;
  50532. private _updateDummy;
  50533. /**
  50534. * Enables a pointer drag behavior on the bounding box of the gizmo
  50535. */
  50536. enableDragBehavior(): void;
  50537. /**
  50538. * Disposes of the gizmo
  50539. */
  50540. dispose(): void;
  50541. /**
  50542. * 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)
  50543. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50544. * @returns the bounding box mesh with the passed in mesh as a child
  50545. */
  50546. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50547. /**
  50548. * CustomMeshes are not supported by this gizmo
  50549. * @param mesh The mesh to replace the default mesh of the gizmo
  50550. */
  50551. setCustomMesh(mesh: Mesh): void;
  50552. }
  50553. }
  50554. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50555. import { Observable } from "babylonjs/Misc/observable";
  50556. import { Nullable } from "babylonjs/types";
  50557. import { Vector3 } from "babylonjs/Maths/math.vector";
  50558. import { Color3 } from "babylonjs/Maths/math.color";
  50559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50560. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50561. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50562. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50563. import "babylonjs/Meshes/Builders/linesBuilder";
  50564. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50565. /**
  50566. * Single plane rotation gizmo
  50567. */
  50568. export class PlaneRotationGizmo extends Gizmo {
  50569. /**
  50570. * Drag behavior responsible for the gizmos dragging interactions
  50571. */
  50572. dragBehavior: PointerDragBehavior;
  50573. private _pointerObserver;
  50574. /**
  50575. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50576. */
  50577. snapDistance: number;
  50578. /**
  50579. * Event that fires each time the gizmo snaps to a new location.
  50580. * * snapDistance is the the change in distance
  50581. */
  50582. onSnapObservable: Observable<{
  50583. snapDistance: number;
  50584. }>;
  50585. private _isEnabled;
  50586. private _parent;
  50587. /**
  50588. * Creates a PlaneRotationGizmo
  50589. * @param gizmoLayer The utility layer the gizmo will be added to
  50590. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50591. * @param color The color of the gizmo
  50592. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50593. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50594. */
  50595. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50597. /**
  50598. * If the gizmo is enabled
  50599. */
  50600. set isEnabled(value: boolean);
  50601. get isEnabled(): boolean;
  50602. /**
  50603. * Disposes of the gizmo
  50604. */
  50605. dispose(): void;
  50606. }
  50607. }
  50608. declare module "babylonjs/Gizmos/rotationGizmo" {
  50609. import { Observable } from "babylonjs/Misc/observable";
  50610. import { Nullable } from "babylonjs/types";
  50611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50612. import { Mesh } from "babylonjs/Meshes/mesh";
  50613. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50614. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50615. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50616. /**
  50617. * Gizmo that enables rotating a mesh along 3 axis
  50618. */
  50619. export class RotationGizmo extends Gizmo {
  50620. /**
  50621. * Internal gizmo used for interactions on the x axis
  50622. */
  50623. xGizmo: PlaneRotationGizmo;
  50624. /**
  50625. * Internal gizmo used for interactions on the y axis
  50626. */
  50627. yGizmo: PlaneRotationGizmo;
  50628. /**
  50629. * Internal gizmo used for interactions on the z axis
  50630. */
  50631. zGizmo: PlaneRotationGizmo;
  50632. /** Fires an event when any of it's sub gizmos are dragged */
  50633. onDragStartObservable: Observable<unknown>;
  50634. /** Fires an event when any of it's sub gizmos are released from dragging */
  50635. onDragEndObservable: Observable<unknown>;
  50636. private _meshAttached;
  50637. get attachedMesh(): Nullable<AbstractMesh>;
  50638. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50639. /**
  50640. * Creates a RotationGizmo
  50641. * @param gizmoLayer The utility layer the gizmo will be added to
  50642. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50643. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50644. */
  50645. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50646. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50647. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50648. /**
  50649. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50650. */
  50651. set snapDistance(value: number);
  50652. get snapDistance(): number;
  50653. /**
  50654. * Ratio for the scale of the gizmo (Default: 1)
  50655. */
  50656. set scaleRatio(value: number);
  50657. get scaleRatio(): number;
  50658. /**
  50659. * Disposes of the gizmo
  50660. */
  50661. dispose(): void;
  50662. /**
  50663. * CustomMeshes are not supported by this gizmo
  50664. * @param mesh The mesh to replace the default mesh of the gizmo
  50665. */
  50666. setCustomMesh(mesh: Mesh): void;
  50667. }
  50668. }
  50669. declare module "babylonjs/Gizmos/gizmoManager" {
  50670. import { Observable } from "babylonjs/Misc/observable";
  50671. import { Nullable } from "babylonjs/types";
  50672. import { Scene, IDisposable } from "babylonjs/scene";
  50673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50674. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50675. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50676. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50677. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50678. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50679. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50680. /**
  50681. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50682. */
  50683. export class GizmoManager implements IDisposable {
  50684. private scene;
  50685. /**
  50686. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50687. */
  50688. gizmos: {
  50689. positionGizmo: Nullable<PositionGizmo>;
  50690. rotationGizmo: Nullable<RotationGizmo>;
  50691. scaleGizmo: Nullable<ScaleGizmo>;
  50692. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50693. };
  50694. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50695. clearGizmoOnEmptyPointerEvent: boolean;
  50696. /** Fires an event when the manager is attached to a mesh */
  50697. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50698. private _gizmosEnabled;
  50699. private _pointerObserver;
  50700. private _attachedMesh;
  50701. private _boundingBoxColor;
  50702. private _defaultUtilityLayer;
  50703. private _defaultKeepDepthUtilityLayer;
  50704. /**
  50705. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50706. */
  50707. boundingBoxDragBehavior: SixDofDragBehavior;
  50708. /**
  50709. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50710. */
  50711. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50712. /**
  50713. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50714. */
  50715. usePointerToAttachGizmos: boolean;
  50716. /**
  50717. * Utility layer that the bounding box gizmo belongs to
  50718. */
  50719. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50720. /**
  50721. * Utility layer that all gizmos besides bounding box belong to
  50722. */
  50723. get utilityLayer(): UtilityLayerRenderer;
  50724. /**
  50725. * Instatiates a gizmo manager
  50726. * @param scene the scene to overlay the gizmos on top of
  50727. */
  50728. constructor(scene: Scene);
  50729. /**
  50730. * Attaches a set of gizmos to the specified mesh
  50731. * @param mesh The mesh the gizmo's should be attached to
  50732. */
  50733. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50734. /**
  50735. * If the position gizmo is enabled
  50736. */
  50737. set positionGizmoEnabled(value: boolean);
  50738. get positionGizmoEnabled(): boolean;
  50739. /**
  50740. * If the rotation gizmo is enabled
  50741. */
  50742. set rotationGizmoEnabled(value: boolean);
  50743. get rotationGizmoEnabled(): boolean;
  50744. /**
  50745. * If the scale gizmo is enabled
  50746. */
  50747. set scaleGizmoEnabled(value: boolean);
  50748. get scaleGizmoEnabled(): boolean;
  50749. /**
  50750. * If the boundingBox gizmo is enabled
  50751. */
  50752. set boundingBoxGizmoEnabled(value: boolean);
  50753. get boundingBoxGizmoEnabled(): boolean;
  50754. /**
  50755. * Disposes of the gizmo manager
  50756. */
  50757. dispose(): void;
  50758. }
  50759. }
  50760. declare module "babylonjs/Lights/directionalLight" {
  50761. import { Camera } from "babylonjs/Cameras/camera";
  50762. import { Scene } from "babylonjs/scene";
  50763. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50765. import { Light } from "babylonjs/Lights/light";
  50766. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50767. import { Effect } from "babylonjs/Materials/effect";
  50768. /**
  50769. * A directional light is defined by a direction (what a surprise!).
  50770. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50771. * 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.
  50772. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50773. */
  50774. export class DirectionalLight extends ShadowLight {
  50775. private _shadowFrustumSize;
  50776. /**
  50777. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50778. */
  50779. get shadowFrustumSize(): number;
  50780. /**
  50781. * Specifies a fix frustum size for the shadow generation.
  50782. */
  50783. set shadowFrustumSize(value: number);
  50784. private _shadowOrthoScale;
  50785. /**
  50786. * Gets the shadow projection scale against the optimal computed one.
  50787. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50788. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50789. */
  50790. get shadowOrthoScale(): number;
  50791. /**
  50792. * Sets the shadow projection scale against the optimal computed one.
  50793. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50794. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50795. */
  50796. set shadowOrthoScale(value: number);
  50797. /**
  50798. * Automatically compute the projection matrix to best fit (including all the casters)
  50799. * on each frame.
  50800. */
  50801. autoUpdateExtends: boolean;
  50802. /**
  50803. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50804. * on each frame. autoUpdateExtends must be set to true for this to work
  50805. */
  50806. autoCalcShadowZBounds: boolean;
  50807. private _orthoLeft;
  50808. private _orthoRight;
  50809. private _orthoTop;
  50810. private _orthoBottom;
  50811. /**
  50812. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50813. * The directional light is emitted from everywhere in the given direction.
  50814. * It can cast shadows.
  50815. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50816. * @param name The friendly name of the light
  50817. * @param direction The direction of the light
  50818. * @param scene The scene the light belongs to
  50819. */
  50820. constructor(name: string, direction: Vector3, scene: Scene);
  50821. /**
  50822. * Returns the string "DirectionalLight".
  50823. * @return The class name
  50824. */
  50825. getClassName(): string;
  50826. /**
  50827. * Returns the integer 1.
  50828. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50829. */
  50830. getTypeID(): number;
  50831. /**
  50832. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50833. * Returns the DirectionalLight Shadow projection matrix.
  50834. */
  50835. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50836. /**
  50837. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50838. * Returns the DirectionalLight Shadow projection matrix.
  50839. */
  50840. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50841. /**
  50842. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50843. * Returns the DirectionalLight Shadow projection matrix.
  50844. */
  50845. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50846. protected _buildUniformLayout(): void;
  50847. /**
  50848. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50849. * @param effect The effect to update
  50850. * @param lightIndex The index of the light in the effect to update
  50851. * @returns The directional light
  50852. */
  50853. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50854. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50855. /**
  50856. * Gets the minZ used for shadow according to both the scene and the light.
  50857. *
  50858. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50859. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50860. * @param activeCamera The camera we are returning the min for
  50861. * @returns the depth min z
  50862. */
  50863. getDepthMinZ(activeCamera: Camera): number;
  50864. /**
  50865. * Gets the maxZ used for shadow according to both the scene and the light.
  50866. *
  50867. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50868. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50869. * @param activeCamera The camera we are returning the max for
  50870. * @returns the depth max z
  50871. */
  50872. getDepthMaxZ(activeCamera: Camera): number;
  50873. /**
  50874. * Prepares the list of defines specific to the light type.
  50875. * @param defines the list of defines
  50876. * @param lightIndex defines the index of the light for the effect
  50877. */
  50878. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50879. }
  50880. }
  50881. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50882. import { Mesh } from "babylonjs/Meshes/mesh";
  50883. /**
  50884. * Class containing static functions to help procedurally build meshes
  50885. */
  50886. export class HemisphereBuilder {
  50887. /**
  50888. * Creates a hemisphere mesh
  50889. * @param name defines the name of the mesh
  50890. * @param options defines the options used to create the mesh
  50891. * @param scene defines the hosting scene
  50892. * @returns the hemisphere mesh
  50893. */
  50894. static CreateHemisphere(name: string, options: {
  50895. segments?: number;
  50896. diameter?: number;
  50897. sideOrientation?: number;
  50898. }, scene: any): Mesh;
  50899. }
  50900. }
  50901. declare module "babylonjs/Lights/spotLight" {
  50902. import { Nullable } from "babylonjs/types";
  50903. import { Scene } from "babylonjs/scene";
  50904. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50906. import { Effect } from "babylonjs/Materials/effect";
  50907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50908. import { Light } from "babylonjs/Lights/light";
  50909. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50910. /**
  50911. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50912. * These values define a cone of light starting from the position, emitting toward the direction.
  50913. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50914. * and the exponent defines the speed of the decay of the light with distance (reach).
  50915. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50916. */
  50917. export class SpotLight extends ShadowLight {
  50918. private _angle;
  50919. private _innerAngle;
  50920. private _cosHalfAngle;
  50921. private _lightAngleScale;
  50922. private _lightAngleOffset;
  50923. /**
  50924. * Gets the cone angle of the spot light in Radians.
  50925. */
  50926. get angle(): number;
  50927. /**
  50928. * Sets the cone angle of the spot light in Radians.
  50929. */
  50930. set angle(value: number);
  50931. /**
  50932. * Only used in gltf falloff mode, this defines the angle where
  50933. * the directional falloff will start before cutting at angle which could be seen
  50934. * as outer angle.
  50935. */
  50936. get innerAngle(): number;
  50937. /**
  50938. * Only used in gltf falloff mode, this defines the angle where
  50939. * the directional falloff will start before cutting at angle which could be seen
  50940. * as outer angle.
  50941. */
  50942. set innerAngle(value: number);
  50943. private _shadowAngleScale;
  50944. /**
  50945. * Allows scaling the angle of the light for shadow generation only.
  50946. */
  50947. get shadowAngleScale(): number;
  50948. /**
  50949. * Allows scaling the angle of the light for shadow generation only.
  50950. */
  50951. set shadowAngleScale(value: number);
  50952. /**
  50953. * The light decay speed with the distance from the emission spot.
  50954. */
  50955. exponent: number;
  50956. private _projectionTextureMatrix;
  50957. /**
  50958. * Allows reading the projecton texture
  50959. */
  50960. get projectionTextureMatrix(): Matrix;
  50961. protected _projectionTextureLightNear: number;
  50962. /**
  50963. * Gets the near clip of the Spotlight for texture projection.
  50964. */
  50965. get projectionTextureLightNear(): number;
  50966. /**
  50967. * Sets the near clip of the Spotlight for texture projection.
  50968. */
  50969. set projectionTextureLightNear(value: number);
  50970. protected _projectionTextureLightFar: number;
  50971. /**
  50972. * Gets the far clip of the Spotlight for texture projection.
  50973. */
  50974. get projectionTextureLightFar(): number;
  50975. /**
  50976. * Sets the far clip of the Spotlight for texture projection.
  50977. */
  50978. set projectionTextureLightFar(value: number);
  50979. protected _projectionTextureUpDirection: Vector3;
  50980. /**
  50981. * Gets the Up vector of the Spotlight for texture projection.
  50982. */
  50983. get projectionTextureUpDirection(): Vector3;
  50984. /**
  50985. * Sets the Up vector of the Spotlight for texture projection.
  50986. */
  50987. set projectionTextureUpDirection(value: Vector3);
  50988. private _projectionTexture;
  50989. /**
  50990. * Gets the projection texture of the light.
  50991. */
  50992. get projectionTexture(): Nullable<BaseTexture>;
  50993. /**
  50994. * Sets the projection texture of the light.
  50995. */
  50996. set projectionTexture(value: Nullable<BaseTexture>);
  50997. private _projectionTextureViewLightDirty;
  50998. private _projectionTextureProjectionLightDirty;
  50999. private _projectionTextureDirty;
  51000. private _projectionTextureViewTargetVector;
  51001. private _projectionTextureViewLightMatrix;
  51002. private _projectionTextureProjectionLightMatrix;
  51003. private _projectionTextureScalingMatrix;
  51004. /**
  51005. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51006. * It can cast shadows.
  51007. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51008. * @param name The light friendly name
  51009. * @param position The position of the spot light in the scene
  51010. * @param direction The direction of the light in the scene
  51011. * @param angle The cone angle of the light in Radians
  51012. * @param exponent The light decay speed with the distance from the emission spot
  51013. * @param scene The scene the lights belongs to
  51014. */
  51015. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51016. /**
  51017. * Returns the string "SpotLight".
  51018. * @returns the class name
  51019. */
  51020. getClassName(): string;
  51021. /**
  51022. * Returns the integer 2.
  51023. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51024. */
  51025. getTypeID(): number;
  51026. /**
  51027. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51028. */
  51029. protected _setDirection(value: Vector3): void;
  51030. /**
  51031. * Overrides the position setter to recompute the projection texture view light Matrix.
  51032. */
  51033. protected _setPosition(value: Vector3): void;
  51034. /**
  51035. * 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.
  51036. * Returns the SpotLight.
  51037. */
  51038. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51039. protected _computeProjectionTextureViewLightMatrix(): void;
  51040. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51041. /**
  51042. * Main function for light texture projection matrix computing.
  51043. */
  51044. protected _computeProjectionTextureMatrix(): void;
  51045. protected _buildUniformLayout(): void;
  51046. private _computeAngleValues;
  51047. /**
  51048. * Sets the passed Effect "effect" with the Light textures.
  51049. * @param effect The effect to update
  51050. * @param lightIndex The index of the light in the effect to update
  51051. * @returns The light
  51052. */
  51053. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51054. /**
  51055. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51056. * @param effect The effect to update
  51057. * @param lightIndex The index of the light in the effect to update
  51058. * @returns The spot light
  51059. */
  51060. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51061. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51062. /**
  51063. * Disposes the light and the associated resources.
  51064. */
  51065. dispose(): void;
  51066. /**
  51067. * Prepares the list of defines specific to the light type.
  51068. * @param defines the list of defines
  51069. * @param lightIndex defines the index of the light for the effect
  51070. */
  51071. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51072. }
  51073. }
  51074. declare module "babylonjs/Gizmos/lightGizmo" {
  51075. import { Nullable } from "babylonjs/types";
  51076. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51077. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51078. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51079. import { Light } from "babylonjs/Lights/light";
  51080. /**
  51081. * Gizmo that enables viewing a light
  51082. */
  51083. export class LightGizmo extends Gizmo {
  51084. private _lightMesh;
  51085. private _material;
  51086. private _cachedPosition;
  51087. private _cachedForward;
  51088. private _attachedMeshParent;
  51089. /**
  51090. * Creates a LightGizmo
  51091. * @param gizmoLayer The utility layer the gizmo will be added to
  51092. */
  51093. constructor(gizmoLayer?: UtilityLayerRenderer);
  51094. private _light;
  51095. /**
  51096. * The light that the gizmo is attached to
  51097. */
  51098. set light(light: Nullable<Light>);
  51099. get light(): Nullable<Light>;
  51100. /**
  51101. * Gets the material used to render the light gizmo
  51102. */
  51103. get material(): StandardMaterial;
  51104. /**
  51105. * @hidden
  51106. * Updates the gizmo to match the attached mesh's position/rotation
  51107. */
  51108. protected _update(): void;
  51109. private static _Scale;
  51110. /**
  51111. * Creates the lines for a light mesh
  51112. */
  51113. private static _CreateLightLines;
  51114. /**
  51115. * Disposes of the light gizmo
  51116. */
  51117. dispose(): void;
  51118. private static _CreateHemisphericLightMesh;
  51119. private static _CreatePointLightMesh;
  51120. private static _CreateSpotLightMesh;
  51121. private static _CreateDirectionalLightMesh;
  51122. }
  51123. }
  51124. declare module "babylonjs/Gizmos/index" {
  51125. export * from "babylonjs/Gizmos/axisDragGizmo";
  51126. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51127. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51128. export * from "babylonjs/Gizmos/gizmo";
  51129. export * from "babylonjs/Gizmos/gizmoManager";
  51130. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51131. export * from "babylonjs/Gizmos/positionGizmo";
  51132. export * from "babylonjs/Gizmos/rotationGizmo";
  51133. export * from "babylonjs/Gizmos/scaleGizmo";
  51134. export * from "babylonjs/Gizmos/lightGizmo";
  51135. export * from "babylonjs/Gizmos/planeDragGizmo";
  51136. }
  51137. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51138. /** @hidden */
  51139. export var backgroundFragmentDeclaration: {
  51140. name: string;
  51141. shader: string;
  51142. };
  51143. }
  51144. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51145. /** @hidden */
  51146. export var backgroundUboDeclaration: {
  51147. name: string;
  51148. shader: string;
  51149. };
  51150. }
  51151. declare module "babylonjs/Shaders/background.fragment" {
  51152. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51153. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51154. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51155. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51156. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51157. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51158. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51159. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51160. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51161. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51162. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51163. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51164. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51165. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51166. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51167. /** @hidden */
  51168. export var backgroundPixelShader: {
  51169. name: string;
  51170. shader: string;
  51171. };
  51172. }
  51173. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51174. /** @hidden */
  51175. export var backgroundVertexDeclaration: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module "babylonjs/Shaders/background.vertex" {
  51181. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51182. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51183. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51184. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51185. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51186. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51187. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51188. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51189. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51190. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51191. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51192. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51193. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51194. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51195. /** @hidden */
  51196. export var backgroundVertexShader: {
  51197. name: string;
  51198. shader: string;
  51199. };
  51200. }
  51201. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51202. import { Nullable, int, float } from "babylonjs/types";
  51203. import { Scene } from "babylonjs/scene";
  51204. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51205. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51207. import { Mesh } from "babylonjs/Meshes/mesh";
  51208. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51209. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51210. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51212. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51213. import { Color3 } from "babylonjs/Maths/math.color";
  51214. import "babylonjs/Shaders/background.fragment";
  51215. import "babylonjs/Shaders/background.vertex";
  51216. /**
  51217. * Background material used to create an efficient environement around your scene.
  51218. */
  51219. export class BackgroundMaterial extends PushMaterial {
  51220. /**
  51221. * Standard reflectance value at parallel view angle.
  51222. */
  51223. static StandardReflectance0: number;
  51224. /**
  51225. * Standard reflectance value at grazing angle.
  51226. */
  51227. static StandardReflectance90: number;
  51228. protected _primaryColor: Color3;
  51229. /**
  51230. * Key light Color (multiply against the environement texture)
  51231. */
  51232. primaryColor: Color3;
  51233. protected __perceptualColor: Nullable<Color3>;
  51234. /**
  51235. * Experimental Internal Use Only.
  51236. *
  51237. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51238. * This acts as a helper to set the primary color to a more "human friendly" value.
  51239. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51240. * output color as close as possible from the chosen value.
  51241. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51242. * part of lighting setup.)
  51243. */
  51244. get _perceptualColor(): Nullable<Color3>;
  51245. set _perceptualColor(value: Nullable<Color3>);
  51246. protected _primaryColorShadowLevel: float;
  51247. /**
  51248. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51249. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51250. */
  51251. get primaryColorShadowLevel(): float;
  51252. set primaryColorShadowLevel(value: float);
  51253. protected _primaryColorHighlightLevel: float;
  51254. /**
  51255. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51256. * The primary color is used at the level chosen to define what the white area would look.
  51257. */
  51258. get primaryColorHighlightLevel(): float;
  51259. set primaryColorHighlightLevel(value: float);
  51260. protected _reflectionTexture: Nullable<BaseTexture>;
  51261. /**
  51262. * Reflection Texture used in the material.
  51263. * Should be author in a specific way for the best result (refer to the documentation).
  51264. */
  51265. reflectionTexture: Nullable<BaseTexture>;
  51266. protected _reflectionBlur: float;
  51267. /**
  51268. * Reflection Texture level of blur.
  51269. *
  51270. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51271. * texture twice.
  51272. */
  51273. reflectionBlur: float;
  51274. protected _diffuseTexture: Nullable<BaseTexture>;
  51275. /**
  51276. * Diffuse Texture used in the material.
  51277. * Should be author in a specific way for the best result (refer to the documentation).
  51278. */
  51279. diffuseTexture: Nullable<BaseTexture>;
  51280. protected _shadowLights: Nullable<IShadowLight[]>;
  51281. /**
  51282. * Specify the list of lights casting shadow on the material.
  51283. * All scene shadow lights will be included if null.
  51284. */
  51285. shadowLights: Nullable<IShadowLight[]>;
  51286. protected _shadowLevel: float;
  51287. /**
  51288. * Helps adjusting the shadow to a softer level if required.
  51289. * 0 means black shadows and 1 means no shadows.
  51290. */
  51291. shadowLevel: float;
  51292. protected _sceneCenter: Vector3;
  51293. /**
  51294. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51295. * It is usually zero but might be interesting to modify according to your setup.
  51296. */
  51297. sceneCenter: Vector3;
  51298. protected _opacityFresnel: boolean;
  51299. /**
  51300. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51301. * This helps ensuring a nice transition when the camera goes under the ground.
  51302. */
  51303. opacityFresnel: boolean;
  51304. protected _reflectionFresnel: boolean;
  51305. /**
  51306. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51307. * This helps adding a mirror texture on the ground.
  51308. */
  51309. reflectionFresnel: boolean;
  51310. protected _reflectionFalloffDistance: number;
  51311. /**
  51312. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51313. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51314. */
  51315. reflectionFalloffDistance: number;
  51316. protected _reflectionAmount: number;
  51317. /**
  51318. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51319. */
  51320. reflectionAmount: number;
  51321. protected _reflectionReflectance0: number;
  51322. /**
  51323. * This specifies the weight of the reflection at grazing angle.
  51324. */
  51325. reflectionReflectance0: number;
  51326. protected _reflectionReflectance90: number;
  51327. /**
  51328. * This specifies the weight of the reflection at a perpendicular point of view.
  51329. */
  51330. reflectionReflectance90: number;
  51331. /**
  51332. * Sets the reflection reflectance fresnel values according to the default standard
  51333. * empirically know to work well :-)
  51334. */
  51335. set reflectionStandardFresnelWeight(value: number);
  51336. protected _useRGBColor: boolean;
  51337. /**
  51338. * Helps to directly use the maps channels instead of their level.
  51339. */
  51340. useRGBColor: boolean;
  51341. protected _enableNoise: boolean;
  51342. /**
  51343. * This helps reducing the banding effect that could occur on the background.
  51344. */
  51345. enableNoise: boolean;
  51346. /**
  51347. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51348. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51349. * Recommended to be keep at 1.0 except for special cases.
  51350. */
  51351. get fovMultiplier(): number;
  51352. set fovMultiplier(value: number);
  51353. private _fovMultiplier;
  51354. /**
  51355. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51356. */
  51357. useEquirectangularFOV: boolean;
  51358. private _maxSimultaneousLights;
  51359. /**
  51360. * Number of Simultaneous lights allowed on the material.
  51361. */
  51362. maxSimultaneousLights: int;
  51363. /**
  51364. * Default configuration related to image processing available in the Background Material.
  51365. */
  51366. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51367. /**
  51368. * Keep track of the image processing observer to allow dispose and replace.
  51369. */
  51370. private _imageProcessingObserver;
  51371. /**
  51372. * Attaches a new image processing configuration to the PBR Material.
  51373. * @param configuration (if null the scene configuration will be use)
  51374. */
  51375. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51376. /**
  51377. * Gets the image processing configuration used either in this material.
  51378. */
  51379. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51380. /**
  51381. * Sets the Default image processing configuration used either in the this material.
  51382. *
  51383. * If sets to null, the scene one is in use.
  51384. */
  51385. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51386. /**
  51387. * Gets wether the color curves effect is enabled.
  51388. */
  51389. get cameraColorCurvesEnabled(): boolean;
  51390. /**
  51391. * Sets wether the color curves effect is enabled.
  51392. */
  51393. set cameraColorCurvesEnabled(value: boolean);
  51394. /**
  51395. * Gets wether the color grading effect is enabled.
  51396. */
  51397. get cameraColorGradingEnabled(): boolean;
  51398. /**
  51399. * Gets wether the color grading effect is enabled.
  51400. */
  51401. set cameraColorGradingEnabled(value: boolean);
  51402. /**
  51403. * Gets wether tonemapping is enabled or not.
  51404. */
  51405. get cameraToneMappingEnabled(): boolean;
  51406. /**
  51407. * Sets wether tonemapping is enabled or not
  51408. */
  51409. set cameraToneMappingEnabled(value: boolean);
  51410. /**
  51411. * The camera exposure used on this material.
  51412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51413. * This corresponds to a photographic exposure.
  51414. */
  51415. get cameraExposure(): float;
  51416. /**
  51417. * The camera exposure used on this material.
  51418. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51419. * This corresponds to a photographic exposure.
  51420. */
  51421. set cameraExposure(value: float);
  51422. /**
  51423. * Gets The camera contrast used on this material.
  51424. */
  51425. get cameraContrast(): float;
  51426. /**
  51427. * Sets The camera contrast used on this material.
  51428. */
  51429. set cameraContrast(value: float);
  51430. /**
  51431. * Gets the Color Grading 2D Lookup Texture.
  51432. */
  51433. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51434. /**
  51435. * Sets the Color Grading 2D Lookup Texture.
  51436. */
  51437. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51438. /**
  51439. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51440. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51441. * 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;
  51442. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51443. */
  51444. get cameraColorCurves(): Nullable<ColorCurves>;
  51445. /**
  51446. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51447. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51448. * 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;
  51449. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51450. */
  51451. set cameraColorCurves(value: Nullable<ColorCurves>);
  51452. /**
  51453. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51454. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51455. */
  51456. switchToBGR: boolean;
  51457. private _renderTargets;
  51458. private _reflectionControls;
  51459. private _white;
  51460. private _primaryShadowColor;
  51461. private _primaryHighlightColor;
  51462. /**
  51463. * Instantiates a Background Material in the given scene
  51464. * @param name The friendly name of the material
  51465. * @param scene The scene to add the material to
  51466. */
  51467. constructor(name: string, scene: Scene);
  51468. /**
  51469. * Gets a boolean indicating that current material needs to register RTT
  51470. */
  51471. get hasRenderTargetTextures(): boolean;
  51472. /**
  51473. * The entire material has been created in order to prevent overdraw.
  51474. * @returns false
  51475. */
  51476. needAlphaTesting(): boolean;
  51477. /**
  51478. * The entire material has been created in order to prevent overdraw.
  51479. * @returns true if blending is enable
  51480. */
  51481. needAlphaBlending(): boolean;
  51482. /**
  51483. * Checks wether the material is ready to be rendered for a given mesh.
  51484. * @param mesh The mesh to render
  51485. * @param subMesh The submesh to check against
  51486. * @param useInstances Specify wether or not the material is used with instances
  51487. * @returns true if all the dependencies are ready (Textures, Effects...)
  51488. */
  51489. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51490. /**
  51491. * Compute the primary color according to the chosen perceptual color.
  51492. */
  51493. private _computePrimaryColorFromPerceptualColor;
  51494. /**
  51495. * Compute the highlights and shadow colors according to their chosen levels.
  51496. */
  51497. private _computePrimaryColors;
  51498. /**
  51499. * Build the uniform buffer used in the material.
  51500. */
  51501. buildUniformLayout(): void;
  51502. /**
  51503. * Unbind the material.
  51504. */
  51505. unbind(): void;
  51506. /**
  51507. * Bind only the world matrix to the material.
  51508. * @param world The world matrix to bind.
  51509. */
  51510. bindOnlyWorldMatrix(world: Matrix): void;
  51511. /**
  51512. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51513. * @param world The world matrix to bind.
  51514. * @param subMesh The submesh to bind for.
  51515. */
  51516. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51517. /**
  51518. * Checks to see if a texture is used in the material.
  51519. * @param texture - Base texture to use.
  51520. * @returns - Boolean specifying if a texture is used in the material.
  51521. */
  51522. hasTexture(texture: BaseTexture): boolean;
  51523. /**
  51524. * Dispose the material.
  51525. * @param forceDisposeEffect Force disposal of the associated effect.
  51526. * @param forceDisposeTextures Force disposal of the associated textures.
  51527. */
  51528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51529. /**
  51530. * Clones the material.
  51531. * @param name The cloned name.
  51532. * @returns The cloned material.
  51533. */
  51534. clone(name: string): BackgroundMaterial;
  51535. /**
  51536. * Serializes the current material to its JSON representation.
  51537. * @returns The JSON representation.
  51538. */
  51539. serialize(): any;
  51540. /**
  51541. * Gets the class name of the material
  51542. * @returns "BackgroundMaterial"
  51543. */
  51544. getClassName(): string;
  51545. /**
  51546. * Parse a JSON input to create back a background material.
  51547. * @param source The JSON data to parse
  51548. * @param scene The scene to create the parsed material in
  51549. * @param rootUrl The root url of the assets the material depends upon
  51550. * @returns the instantiated BackgroundMaterial.
  51551. */
  51552. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51553. }
  51554. }
  51555. declare module "babylonjs/Helpers/environmentHelper" {
  51556. import { Observable } from "babylonjs/Misc/observable";
  51557. import { Nullable } from "babylonjs/types";
  51558. import { Scene } from "babylonjs/scene";
  51559. import { Vector3 } from "babylonjs/Maths/math.vector";
  51560. import { Color3 } from "babylonjs/Maths/math.color";
  51561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51562. import { Mesh } from "babylonjs/Meshes/mesh";
  51563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51564. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51565. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51566. import "babylonjs/Meshes/Builders/planeBuilder";
  51567. import "babylonjs/Meshes/Builders/boxBuilder";
  51568. /**
  51569. * Represents the different options available during the creation of
  51570. * a Environment helper.
  51571. *
  51572. * This can control the default ground, skybox and image processing setup of your scene.
  51573. */
  51574. export interface IEnvironmentHelperOptions {
  51575. /**
  51576. * Specifies whether or not to create a ground.
  51577. * True by default.
  51578. */
  51579. createGround: boolean;
  51580. /**
  51581. * Specifies the ground size.
  51582. * 15 by default.
  51583. */
  51584. groundSize: number;
  51585. /**
  51586. * The texture used on the ground for the main color.
  51587. * Comes from the BabylonJS CDN by default.
  51588. *
  51589. * Remarks: Can be either a texture or a url.
  51590. */
  51591. groundTexture: string | BaseTexture;
  51592. /**
  51593. * The color mixed in the ground texture by default.
  51594. * BabylonJS clearColor by default.
  51595. */
  51596. groundColor: Color3;
  51597. /**
  51598. * Specifies the ground opacity.
  51599. * 1 by default.
  51600. */
  51601. groundOpacity: number;
  51602. /**
  51603. * Enables the ground to receive shadows.
  51604. * True by default.
  51605. */
  51606. enableGroundShadow: boolean;
  51607. /**
  51608. * Helps preventing the shadow to be fully black on the ground.
  51609. * 0.5 by default.
  51610. */
  51611. groundShadowLevel: number;
  51612. /**
  51613. * Creates a mirror texture attach to the ground.
  51614. * false by default.
  51615. */
  51616. enableGroundMirror: boolean;
  51617. /**
  51618. * Specifies the ground mirror size ratio.
  51619. * 0.3 by default as the default kernel is 64.
  51620. */
  51621. groundMirrorSizeRatio: number;
  51622. /**
  51623. * Specifies the ground mirror blur kernel size.
  51624. * 64 by default.
  51625. */
  51626. groundMirrorBlurKernel: number;
  51627. /**
  51628. * Specifies the ground mirror visibility amount.
  51629. * 1 by default
  51630. */
  51631. groundMirrorAmount: number;
  51632. /**
  51633. * Specifies the ground mirror reflectance weight.
  51634. * This uses the standard weight of the background material to setup the fresnel effect
  51635. * of the mirror.
  51636. * 1 by default.
  51637. */
  51638. groundMirrorFresnelWeight: number;
  51639. /**
  51640. * Specifies the ground mirror Falloff distance.
  51641. * This can helps reducing the size of the reflection.
  51642. * 0 by Default.
  51643. */
  51644. groundMirrorFallOffDistance: number;
  51645. /**
  51646. * Specifies the ground mirror texture type.
  51647. * Unsigned Int by Default.
  51648. */
  51649. groundMirrorTextureType: number;
  51650. /**
  51651. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51652. * the shown objects.
  51653. */
  51654. groundYBias: number;
  51655. /**
  51656. * Specifies whether or not to create a skybox.
  51657. * True by default.
  51658. */
  51659. createSkybox: boolean;
  51660. /**
  51661. * Specifies the skybox size.
  51662. * 20 by default.
  51663. */
  51664. skyboxSize: number;
  51665. /**
  51666. * The texture used on the skybox for the main color.
  51667. * Comes from the BabylonJS CDN by default.
  51668. *
  51669. * Remarks: Can be either a texture or a url.
  51670. */
  51671. skyboxTexture: string | BaseTexture;
  51672. /**
  51673. * The color mixed in the skybox texture by default.
  51674. * BabylonJS clearColor by default.
  51675. */
  51676. skyboxColor: Color3;
  51677. /**
  51678. * The background rotation around the Y axis of the scene.
  51679. * This helps aligning the key lights of your scene with the background.
  51680. * 0 by default.
  51681. */
  51682. backgroundYRotation: number;
  51683. /**
  51684. * Compute automatically the size of the elements to best fit with the scene.
  51685. */
  51686. sizeAuto: boolean;
  51687. /**
  51688. * Default position of the rootMesh if autoSize is not true.
  51689. */
  51690. rootPosition: Vector3;
  51691. /**
  51692. * Sets up the image processing in the scene.
  51693. * true by default.
  51694. */
  51695. setupImageProcessing: boolean;
  51696. /**
  51697. * The texture used as your environment texture in the scene.
  51698. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51699. *
  51700. * Remarks: Can be either a texture or a url.
  51701. */
  51702. environmentTexture: string | BaseTexture;
  51703. /**
  51704. * The value of the exposure to apply to the scene.
  51705. * 0.6 by default if setupImageProcessing is true.
  51706. */
  51707. cameraExposure: number;
  51708. /**
  51709. * The value of the contrast to apply to the scene.
  51710. * 1.6 by default if setupImageProcessing is true.
  51711. */
  51712. cameraContrast: number;
  51713. /**
  51714. * Specifies whether or not tonemapping should be enabled in the scene.
  51715. * true by default if setupImageProcessing is true.
  51716. */
  51717. toneMappingEnabled: boolean;
  51718. }
  51719. /**
  51720. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51721. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51722. * It also helps with the default setup of your imageProcessing configuration.
  51723. */
  51724. export class EnvironmentHelper {
  51725. /**
  51726. * Default ground texture URL.
  51727. */
  51728. private static _groundTextureCDNUrl;
  51729. /**
  51730. * Default skybox texture URL.
  51731. */
  51732. private static _skyboxTextureCDNUrl;
  51733. /**
  51734. * Default environment texture URL.
  51735. */
  51736. private static _environmentTextureCDNUrl;
  51737. /**
  51738. * Creates the default options for the helper.
  51739. */
  51740. private static _getDefaultOptions;
  51741. private _rootMesh;
  51742. /**
  51743. * Gets the root mesh created by the helper.
  51744. */
  51745. get rootMesh(): Mesh;
  51746. private _skybox;
  51747. /**
  51748. * Gets the skybox created by the helper.
  51749. */
  51750. get skybox(): Nullable<Mesh>;
  51751. private _skyboxTexture;
  51752. /**
  51753. * Gets the skybox texture created by the helper.
  51754. */
  51755. get skyboxTexture(): Nullable<BaseTexture>;
  51756. private _skyboxMaterial;
  51757. /**
  51758. * Gets the skybox material created by the helper.
  51759. */
  51760. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51761. private _ground;
  51762. /**
  51763. * Gets the ground mesh created by the helper.
  51764. */
  51765. get ground(): Nullable<Mesh>;
  51766. private _groundTexture;
  51767. /**
  51768. * Gets the ground texture created by the helper.
  51769. */
  51770. get groundTexture(): Nullable<BaseTexture>;
  51771. private _groundMirror;
  51772. /**
  51773. * Gets the ground mirror created by the helper.
  51774. */
  51775. get groundMirror(): Nullable<MirrorTexture>;
  51776. /**
  51777. * Gets the ground mirror render list to helps pushing the meshes
  51778. * you wish in the ground reflection.
  51779. */
  51780. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51781. private _groundMaterial;
  51782. /**
  51783. * Gets the ground material created by the helper.
  51784. */
  51785. get groundMaterial(): Nullable<BackgroundMaterial>;
  51786. /**
  51787. * Stores the creation options.
  51788. */
  51789. private readonly _scene;
  51790. private _options;
  51791. /**
  51792. * This observable will be notified with any error during the creation of the environment,
  51793. * mainly texture creation errors.
  51794. */
  51795. onErrorObservable: Observable<{
  51796. message?: string;
  51797. exception?: any;
  51798. }>;
  51799. /**
  51800. * constructor
  51801. * @param options Defines the options we want to customize the helper
  51802. * @param scene The scene to add the material to
  51803. */
  51804. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51805. /**
  51806. * Updates the background according to the new options
  51807. * @param options
  51808. */
  51809. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51810. /**
  51811. * Sets the primary color of all the available elements.
  51812. * @param color the main color to affect to the ground and the background
  51813. */
  51814. setMainColor(color: Color3): void;
  51815. /**
  51816. * Setup the image processing according to the specified options.
  51817. */
  51818. private _setupImageProcessing;
  51819. /**
  51820. * Setup the environment texture according to the specified options.
  51821. */
  51822. private _setupEnvironmentTexture;
  51823. /**
  51824. * Setup the background according to the specified options.
  51825. */
  51826. private _setupBackground;
  51827. /**
  51828. * Get the scene sizes according to the setup.
  51829. */
  51830. private _getSceneSize;
  51831. /**
  51832. * Setup the ground according to the specified options.
  51833. */
  51834. private _setupGround;
  51835. /**
  51836. * Setup the ground material according to the specified options.
  51837. */
  51838. private _setupGroundMaterial;
  51839. /**
  51840. * Setup the ground diffuse texture according to the specified options.
  51841. */
  51842. private _setupGroundDiffuseTexture;
  51843. /**
  51844. * Setup the ground mirror texture according to the specified options.
  51845. */
  51846. private _setupGroundMirrorTexture;
  51847. /**
  51848. * Setup the ground to receive the mirror texture.
  51849. */
  51850. private _setupMirrorInGroundMaterial;
  51851. /**
  51852. * Setup the skybox according to the specified options.
  51853. */
  51854. private _setupSkybox;
  51855. /**
  51856. * Setup the skybox material according to the specified options.
  51857. */
  51858. private _setupSkyboxMaterial;
  51859. /**
  51860. * Setup the skybox reflection texture according to the specified options.
  51861. */
  51862. private _setupSkyboxReflectionTexture;
  51863. private _errorHandler;
  51864. /**
  51865. * Dispose all the elements created by the Helper.
  51866. */
  51867. dispose(): void;
  51868. }
  51869. }
  51870. declare module "babylonjs/Helpers/photoDome" {
  51871. import { Observable } from "babylonjs/Misc/observable";
  51872. import { Nullable } from "babylonjs/types";
  51873. import { Scene } from "babylonjs/scene";
  51874. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51875. import { Mesh } from "babylonjs/Meshes/mesh";
  51876. import { Texture } from "babylonjs/Materials/Textures/texture";
  51877. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51878. import "babylonjs/Meshes/Builders/sphereBuilder";
  51879. /**
  51880. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51881. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51882. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51883. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51884. */
  51885. export class PhotoDome extends TransformNode {
  51886. /**
  51887. * Define the image as a Monoscopic panoramic 360 image.
  51888. */
  51889. static readonly MODE_MONOSCOPIC: number;
  51890. /**
  51891. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51892. */
  51893. static readonly MODE_TOPBOTTOM: number;
  51894. /**
  51895. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51896. */
  51897. static readonly MODE_SIDEBYSIDE: number;
  51898. private _useDirectMapping;
  51899. /**
  51900. * The texture being displayed on the sphere
  51901. */
  51902. protected _photoTexture: Texture;
  51903. /**
  51904. * Gets or sets the texture being displayed on the sphere
  51905. */
  51906. get photoTexture(): Texture;
  51907. set photoTexture(value: Texture);
  51908. /**
  51909. * Observable raised when an error occured while loading the 360 image
  51910. */
  51911. onLoadErrorObservable: Observable<string>;
  51912. /**
  51913. * The skybox material
  51914. */
  51915. protected _material: BackgroundMaterial;
  51916. /**
  51917. * The surface used for the skybox
  51918. */
  51919. protected _mesh: Mesh;
  51920. /**
  51921. * Gets the mesh used for the skybox.
  51922. */
  51923. get mesh(): Mesh;
  51924. /**
  51925. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51926. * Also see the options.resolution property.
  51927. */
  51928. get fovMultiplier(): number;
  51929. set fovMultiplier(value: number);
  51930. private _imageMode;
  51931. /**
  51932. * Gets or set the current video mode for the video. It can be:
  51933. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51934. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51935. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51936. */
  51937. get imageMode(): number;
  51938. set imageMode(value: number);
  51939. /**
  51940. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51941. * @param name Element's name, child elements will append suffixes for their own names.
  51942. * @param urlsOfPhoto defines the url of the photo to display
  51943. * @param options defines an object containing optional or exposed sub element properties
  51944. * @param onError defines a callback called when an error occured while loading the texture
  51945. */
  51946. constructor(name: string, urlOfPhoto: string, options: {
  51947. resolution?: number;
  51948. size?: number;
  51949. useDirectMapping?: boolean;
  51950. faceForward?: boolean;
  51951. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51952. private _onBeforeCameraRenderObserver;
  51953. private _changeImageMode;
  51954. /**
  51955. * Releases resources associated with this node.
  51956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51958. */
  51959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51960. }
  51961. }
  51962. declare module "babylonjs/Misc/rgbdTextureTools" {
  51963. import "babylonjs/Shaders/rgbdDecode.fragment";
  51964. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51965. import { Texture } from "babylonjs/Materials/Textures/texture";
  51966. /**
  51967. * Class used to host RGBD texture specific utilities
  51968. */
  51969. export class RGBDTextureTools {
  51970. /**
  51971. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51972. * @param texture the texture to expand.
  51973. */
  51974. static ExpandRGBDTexture(texture: Texture): void;
  51975. }
  51976. }
  51977. declare module "babylonjs/Misc/brdfTextureTools" {
  51978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51979. import { Scene } from "babylonjs/scene";
  51980. /**
  51981. * Class used to host texture specific utilities
  51982. */
  51983. export class BRDFTextureTools {
  51984. /**
  51985. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51986. * @param scene defines the hosting scene
  51987. * @returns the environment BRDF texture
  51988. */
  51989. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51990. private static _environmentBRDFBase64Texture;
  51991. }
  51992. }
  51993. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51994. import { Nullable } from "babylonjs/types";
  51995. import { Color3 } from "babylonjs/Maths/math.color";
  51996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51997. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51999. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52000. import { Engine } from "babylonjs/Engines/engine";
  52001. import { Scene } from "babylonjs/scene";
  52002. /**
  52003. * @hidden
  52004. */
  52005. export interface IMaterialClearCoatDefines {
  52006. CLEARCOAT: boolean;
  52007. CLEARCOAT_DEFAULTIOR: boolean;
  52008. CLEARCOAT_TEXTURE: boolean;
  52009. CLEARCOAT_TEXTUREDIRECTUV: number;
  52010. CLEARCOAT_BUMP: boolean;
  52011. CLEARCOAT_BUMPDIRECTUV: number;
  52012. CLEARCOAT_TINT: boolean;
  52013. CLEARCOAT_TINT_TEXTURE: boolean;
  52014. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52015. /** @hidden */
  52016. _areTexturesDirty: boolean;
  52017. }
  52018. /**
  52019. * Define the code related to the clear coat parameters of the pbr material.
  52020. */
  52021. export class PBRClearCoatConfiguration {
  52022. /**
  52023. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52024. * The default fits with a polyurethane material.
  52025. */
  52026. private static readonly _DefaultIndexOfRefraction;
  52027. private _isEnabled;
  52028. /**
  52029. * Defines if the clear coat is enabled in the material.
  52030. */
  52031. isEnabled: boolean;
  52032. /**
  52033. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52034. */
  52035. intensity: number;
  52036. /**
  52037. * Defines the clear coat layer roughness.
  52038. */
  52039. roughness: number;
  52040. private _indexOfRefraction;
  52041. /**
  52042. * Defines the index of refraction of the clear coat.
  52043. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52044. * The default fits with a polyurethane material.
  52045. * Changing the default value is more performance intensive.
  52046. */
  52047. indexOfRefraction: number;
  52048. private _texture;
  52049. /**
  52050. * Stores the clear coat values in a texture.
  52051. */
  52052. texture: Nullable<BaseTexture>;
  52053. private _bumpTexture;
  52054. /**
  52055. * Define the clear coat specific bump texture.
  52056. */
  52057. bumpTexture: Nullable<BaseTexture>;
  52058. private _isTintEnabled;
  52059. /**
  52060. * Defines if the clear coat tint is enabled in the material.
  52061. */
  52062. isTintEnabled: boolean;
  52063. /**
  52064. * Defines the clear coat tint of the material.
  52065. * This is only use if tint is enabled
  52066. */
  52067. tintColor: Color3;
  52068. /**
  52069. * Defines the distance at which the tint color should be found in the
  52070. * clear coat media.
  52071. * This is only use if tint is enabled
  52072. */
  52073. tintColorAtDistance: number;
  52074. /**
  52075. * Defines the clear coat layer thickness.
  52076. * This is only use if tint is enabled
  52077. */
  52078. tintThickness: number;
  52079. private _tintTexture;
  52080. /**
  52081. * Stores the clear tint values in a texture.
  52082. * rgb is tint
  52083. * a is a thickness factor
  52084. */
  52085. tintTexture: Nullable<BaseTexture>;
  52086. /** @hidden */
  52087. private _internalMarkAllSubMeshesAsTexturesDirty;
  52088. /** @hidden */
  52089. _markAllSubMeshesAsTexturesDirty(): void;
  52090. /**
  52091. * Instantiate a new istance of clear coat configuration.
  52092. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52093. */
  52094. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52095. /**
  52096. * Gets wehter the submesh is ready to be used or not.
  52097. * @param defines the list of "defines" to update.
  52098. * @param scene defines the scene the material belongs to.
  52099. * @param engine defines the engine the material belongs to.
  52100. * @param disableBumpMap defines wether the material disables bump or not.
  52101. * @returns - boolean indicating that the submesh is ready or not.
  52102. */
  52103. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52104. /**
  52105. * Checks to see if a texture is used in the material.
  52106. * @param defines the list of "defines" to update.
  52107. * @param scene defines the scene to the material belongs to.
  52108. */
  52109. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52110. /**
  52111. * Binds the material data.
  52112. * @param uniformBuffer defines the Uniform buffer to fill in.
  52113. * @param scene defines the scene the material belongs to.
  52114. * @param engine defines the engine the material belongs to.
  52115. * @param disableBumpMap defines wether the material disables bump or not.
  52116. * @param isFrozen defines wether the material is frozen or not.
  52117. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52118. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52119. */
  52120. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52121. /**
  52122. * Checks to see if a texture is used in the material.
  52123. * @param texture - Base texture to use.
  52124. * @returns - Boolean specifying if a texture is used in the material.
  52125. */
  52126. hasTexture(texture: BaseTexture): boolean;
  52127. /**
  52128. * Returns an array of the actively used textures.
  52129. * @param activeTextures Array of BaseTextures
  52130. */
  52131. getActiveTextures(activeTextures: BaseTexture[]): void;
  52132. /**
  52133. * Returns the animatable textures.
  52134. * @param animatables Array of animatable textures.
  52135. */
  52136. getAnimatables(animatables: IAnimatable[]): void;
  52137. /**
  52138. * Disposes the resources of the material.
  52139. * @param forceDisposeTextures - Forces the disposal of all textures.
  52140. */
  52141. dispose(forceDisposeTextures?: boolean): void;
  52142. /**
  52143. * Get the current class name of the texture useful for serialization or dynamic coding.
  52144. * @returns "PBRClearCoatConfiguration"
  52145. */
  52146. getClassName(): string;
  52147. /**
  52148. * Add fallbacks to the effect fallbacks list.
  52149. * @param defines defines the Base texture to use.
  52150. * @param fallbacks defines the current fallback list.
  52151. * @param currentRank defines the current fallback rank.
  52152. * @returns the new fallback rank.
  52153. */
  52154. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52155. /**
  52156. * Add the required uniforms to the current list.
  52157. * @param uniforms defines the current uniform list.
  52158. */
  52159. static AddUniforms(uniforms: string[]): void;
  52160. /**
  52161. * Add the required samplers to the current list.
  52162. * @param samplers defines the current sampler list.
  52163. */
  52164. static AddSamplers(samplers: string[]): void;
  52165. /**
  52166. * Add the required uniforms to the current buffer.
  52167. * @param uniformBuffer defines the current uniform buffer.
  52168. */
  52169. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52170. /**
  52171. * Makes a duplicate of the current configuration into another one.
  52172. * @param clearCoatConfiguration define the config where to copy the info
  52173. */
  52174. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52175. /**
  52176. * Serializes this clear coat configuration.
  52177. * @returns - An object with the serialized config.
  52178. */
  52179. serialize(): any;
  52180. /**
  52181. * Parses a anisotropy Configuration from a serialized object.
  52182. * @param source - Serialized object.
  52183. * @param scene Defines the scene we are parsing for
  52184. * @param rootUrl Defines the rootUrl to load from
  52185. */
  52186. parse(source: any, scene: Scene, rootUrl: string): void;
  52187. }
  52188. }
  52189. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52190. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52192. import { Vector2 } from "babylonjs/Maths/math.vector";
  52193. import { Scene } from "babylonjs/scene";
  52194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52195. import { Nullable } from "babylonjs/types";
  52196. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52197. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52198. /**
  52199. * @hidden
  52200. */
  52201. export interface IMaterialAnisotropicDefines {
  52202. ANISOTROPIC: boolean;
  52203. ANISOTROPIC_TEXTURE: boolean;
  52204. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52205. MAINUV1: boolean;
  52206. _areTexturesDirty: boolean;
  52207. _needUVs: boolean;
  52208. }
  52209. /**
  52210. * Define the code related to the anisotropic parameters of the pbr material.
  52211. */
  52212. export class PBRAnisotropicConfiguration {
  52213. private _isEnabled;
  52214. /**
  52215. * Defines if the anisotropy is enabled in the material.
  52216. */
  52217. isEnabled: boolean;
  52218. /**
  52219. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52220. */
  52221. intensity: number;
  52222. /**
  52223. * Defines if the effect is along the tangents, bitangents or in between.
  52224. * By default, the effect is "strectching" the highlights along the tangents.
  52225. */
  52226. direction: Vector2;
  52227. private _texture;
  52228. /**
  52229. * Stores the anisotropy values in a texture.
  52230. * rg is direction (like normal from -1 to 1)
  52231. * b is a intensity
  52232. */
  52233. texture: Nullable<BaseTexture>;
  52234. /** @hidden */
  52235. private _internalMarkAllSubMeshesAsTexturesDirty;
  52236. /** @hidden */
  52237. _markAllSubMeshesAsTexturesDirty(): void;
  52238. /**
  52239. * Instantiate a new istance of anisotropy configuration.
  52240. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52241. */
  52242. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52243. /**
  52244. * Specifies that the submesh is ready to be used.
  52245. * @param defines the list of "defines" to update.
  52246. * @param scene defines the scene the material belongs to.
  52247. * @returns - boolean indicating that the submesh is ready or not.
  52248. */
  52249. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52250. /**
  52251. * Checks to see if a texture is used in the material.
  52252. * @param defines the list of "defines" to update.
  52253. * @param mesh the mesh we are preparing the defines for.
  52254. * @param scene defines the scene the material belongs to.
  52255. */
  52256. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52257. /**
  52258. * Binds the material data.
  52259. * @param uniformBuffer defines the Uniform buffer to fill in.
  52260. * @param scene defines the scene the material belongs to.
  52261. * @param isFrozen defines wether the material is frozen or not.
  52262. */
  52263. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52264. /**
  52265. * Checks to see if a texture is used in the material.
  52266. * @param texture - Base texture to use.
  52267. * @returns - Boolean specifying if a texture is used in the material.
  52268. */
  52269. hasTexture(texture: BaseTexture): boolean;
  52270. /**
  52271. * Returns an array of the actively used textures.
  52272. * @param activeTextures Array of BaseTextures
  52273. */
  52274. getActiveTextures(activeTextures: BaseTexture[]): void;
  52275. /**
  52276. * Returns the animatable textures.
  52277. * @param animatables Array of animatable textures.
  52278. */
  52279. getAnimatables(animatables: IAnimatable[]): void;
  52280. /**
  52281. * Disposes the resources of the material.
  52282. * @param forceDisposeTextures - Forces the disposal of all textures.
  52283. */
  52284. dispose(forceDisposeTextures?: boolean): void;
  52285. /**
  52286. * Get the current class name of the texture useful for serialization or dynamic coding.
  52287. * @returns "PBRAnisotropicConfiguration"
  52288. */
  52289. getClassName(): string;
  52290. /**
  52291. * Add fallbacks to the effect fallbacks list.
  52292. * @param defines defines the Base texture to use.
  52293. * @param fallbacks defines the current fallback list.
  52294. * @param currentRank defines the current fallback rank.
  52295. * @returns the new fallback rank.
  52296. */
  52297. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52298. /**
  52299. * Add the required uniforms to the current list.
  52300. * @param uniforms defines the current uniform list.
  52301. */
  52302. static AddUniforms(uniforms: string[]): void;
  52303. /**
  52304. * Add the required uniforms to the current buffer.
  52305. * @param uniformBuffer defines the current uniform buffer.
  52306. */
  52307. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52308. /**
  52309. * Add the required samplers to the current list.
  52310. * @param samplers defines the current sampler list.
  52311. */
  52312. static AddSamplers(samplers: string[]): void;
  52313. /**
  52314. * Makes a duplicate of the current configuration into another one.
  52315. * @param anisotropicConfiguration define the config where to copy the info
  52316. */
  52317. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52318. /**
  52319. * Serializes this anisotropy configuration.
  52320. * @returns - An object with the serialized config.
  52321. */
  52322. serialize(): any;
  52323. /**
  52324. * Parses a anisotropy Configuration from a serialized object.
  52325. * @param source - Serialized object.
  52326. * @param scene Defines the scene we are parsing for
  52327. * @param rootUrl Defines the rootUrl to load from
  52328. */
  52329. parse(source: any, scene: Scene, rootUrl: string): void;
  52330. }
  52331. }
  52332. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52333. import { Scene } from "babylonjs/scene";
  52334. /**
  52335. * @hidden
  52336. */
  52337. export interface IMaterialBRDFDefines {
  52338. BRDF_V_HEIGHT_CORRELATED: boolean;
  52339. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52340. SPHERICAL_HARMONICS: boolean;
  52341. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52342. /** @hidden */
  52343. _areMiscDirty: boolean;
  52344. }
  52345. /**
  52346. * Define the code related to the BRDF parameters of the pbr material.
  52347. */
  52348. export class PBRBRDFConfiguration {
  52349. /**
  52350. * Default value used for the energy conservation.
  52351. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52352. */
  52353. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52354. /**
  52355. * Default value used for the Smith Visibility Height Correlated mode.
  52356. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52357. */
  52358. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52359. /**
  52360. * Default value used for the IBL diffuse part.
  52361. * This can help switching back to the polynomials mode globally which is a tiny bit
  52362. * less GPU intensive at the drawback of a lower quality.
  52363. */
  52364. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52365. /**
  52366. * Default value used for activating energy conservation for the specular workflow.
  52367. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52368. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52369. */
  52370. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52371. private _useEnergyConservation;
  52372. /**
  52373. * Defines if the material uses energy conservation.
  52374. */
  52375. useEnergyConservation: boolean;
  52376. private _useSmithVisibilityHeightCorrelated;
  52377. /**
  52378. * LEGACY Mode set to false
  52379. * Defines if the material uses height smith correlated visibility term.
  52380. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52381. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52382. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52383. * Not relying on height correlated will also disable energy conservation.
  52384. */
  52385. useSmithVisibilityHeightCorrelated: boolean;
  52386. private _useSphericalHarmonics;
  52387. /**
  52388. * LEGACY Mode set to false
  52389. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52390. * diffuse part of the IBL.
  52391. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52392. * to the ground truth.
  52393. */
  52394. useSphericalHarmonics: boolean;
  52395. private _useSpecularGlossinessInputEnergyConservation;
  52396. /**
  52397. * Defines if the material uses energy conservation, when the specular workflow is active.
  52398. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52399. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52400. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52401. */
  52402. useSpecularGlossinessInputEnergyConservation: boolean;
  52403. /** @hidden */
  52404. private _internalMarkAllSubMeshesAsMiscDirty;
  52405. /** @hidden */
  52406. _markAllSubMeshesAsMiscDirty(): void;
  52407. /**
  52408. * Instantiate a new istance of clear coat configuration.
  52409. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52410. */
  52411. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52412. /**
  52413. * Checks to see if a texture is used in the material.
  52414. * @param defines the list of "defines" to update.
  52415. */
  52416. prepareDefines(defines: IMaterialBRDFDefines): void;
  52417. /**
  52418. * Get the current class name of the texture useful for serialization or dynamic coding.
  52419. * @returns "PBRClearCoatConfiguration"
  52420. */
  52421. getClassName(): string;
  52422. /**
  52423. * Makes a duplicate of the current configuration into another one.
  52424. * @param brdfConfiguration define the config where to copy the info
  52425. */
  52426. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52427. /**
  52428. * Serializes this BRDF configuration.
  52429. * @returns - An object with the serialized config.
  52430. */
  52431. serialize(): any;
  52432. /**
  52433. * Parses a anisotropy Configuration from a serialized object.
  52434. * @param source - Serialized object.
  52435. * @param scene Defines the scene we are parsing for
  52436. * @param rootUrl Defines the rootUrl to load from
  52437. */
  52438. parse(source: any, scene: Scene, rootUrl: string): void;
  52439. }
  52440. }
  52441. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52442. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52443. import { Color3 } from "babylonjs/Maths/math.color";
  52444. import { Scene } from "babylonjs/scene";
  52445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52446. import { Nullable } from "babylonjs/types";
  52447. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52448. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52449. /**
  52450. * @hidden
  52451. */
  52452. export interface IMaterialSheenDefines {
  52453. SHEEN: boolean;
  52454. SHEEN_TEXTURE: boolean;
  52455. SHEEN_TEXTUREDIRECTUV: number;
  52456. SHEEN_LINKWITHALBEDO: boolean;
  52457. /** @hidden */
  52458. _areTexturesDirty: boolean;
  52459. }
  52460. /**
  52461. * Define the code related to the Sheen parameters of the pbr material.
  52462. */
  52463. export class PBRSheenConfiguration {
  52464. private _isEnabled;
  52465. /**
  52466. * Defines if the material uses sheen.
  52467. */
  52468. isEnabled: boolean;
  52469. private _linkSheenWithAlbedo;
  52470. /**
  52471. * Defines if the sheen is linked to the sheen color.
  52472. */
  52473. linkSheenWithAlbedo: boolean;
  52474. /**
  52475. * Defines the sheen intensity.
  52476. */
  52477. intensity: number;
  52478. /**
  52479. * Defines the sheen color.
  52480. */
  52481. color: Color3;
  52482. private _texture;
  52483. /**
  52484. * Stores the sheen tint values in a texture.
  52485. * rgb is tint
  52486. * a is a intensity
  52487. */
  52488. texture: Nullable<BaseTexture>;
  52489. /** @hidden */
  52490. private _internalMarkAllSubMeshesAsTexturesDirty;
  52491. /** @hidden */
  52492. _markAllSubMeshesAsTexturesDirty(): void;
  52493. /**
  52494. * Instantiate a new istance of clear coat configuration.
  52495. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52496. */
  52497. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52498. /**
  52499. * Specifies that the submesh is ready to be used.
  52500. * @param defines the list of "defines" to update.
  52501. * @param scene defines the scene the material belongs to.
  52502. * @returns - boolean indicating that the submesh is ready or not.
  52503. */
  52504. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52505. /**
  52506. * Checks to see if a texture is used in the material.
  52507. * @param defines the list of "defines" to update.
  52508. * @param scene defines the scene the material belongs to.
  52509. */
  52510. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52511. /**
  52512. * Binds the material data.
  52513. * @param uniformBuffer defines the Uniform buffer to fill in.
  52514. * @param scene defines the scene the material belongs to.
  52515. * @param isFrozen defines wether the material is frozen or not.
  52516. */
  52517. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52518. /**
  52519. * Checks to see if a texture is used in the material.
  52520. * @param texture - Base texture to use.
  52521. * @returns - Boolean specifying if a texture is used in the material.
  52522. */
  52523. hasTexture(texture: BaseTexture): boolean;
  52524. /**
  52525. * Returns an array of the actively used textures.
  52526. * @param activeTextures Array of BaseTextures
  52527. */
  52528. getActiveTextures(activeTextures: BaseTexture[]): void;
  52529. /**
  52530. * Returns the animatable textures.
  52531. * @param animatables Array of animatable textures.
  52532. */
  52533. getAnimatables(animatables: IAnimatable[]): void;
  52534. /**
  52535. * Disposes the resources of the material.
  52536. * @param forceDisposeTextures - Forces the disposal of all textures.
  52537. */
  52538. dispose(forceDisposeTextures?: boolean): void;
  52539. /**
  52540. * Get the current class name of the texture useful for serialization or dynamic coding.
  52541. * @returns "PBRSheenConfiguration"
  52542. */
  52543. getClassName(): string;
  52544. /**
  52545. * Add fallbacks to the effect fallbacks list.
  52546. * @param defines defines the Base texture to use.
  52547. * @param fallbacks defines the current fallback list.
  52548. * @param currentRank defines the current fallback rank.
  52549. * @returns the new fallback rank.
  52550. */
  52551. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52552. /**
  52553. * Add the required uniforms to the current list.
  52554. * @param uniforms defines the current uniform list.
  52555. */
  52556. static AddUniforms(uniforms: string[]): void;
  52557. /**
  52558. * Add the required uniforms to the current buffer.
  52559. * @param uniformBuffer defines the current uniform buffer.
  52560. */
  52561. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52562. /**
  52563. * Add the required samplers to the current list.
  52564. * @param samplers defines the current sampler list.
  52565. */
  52566. static AddSamplers(samplers: string[]): void;
  52567. /**
  52568. * Makes a duplicate of the current configuration into another one.
  52569. * @param sheenConfiguration define the config where to copy the info
  52570. */
  52571. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52572. /**
  52573. * Serializes this BRDF configuration.
  52574. * @returns - An object with the serialized config.
  52575. */
  52576. serialize(): any;
  52577. /**
  52578. * Parses a anisotropy Configuration from a serialized object.
  52579. * @param source - Serialized object.
  52580. * @param scene Defines the scene we are parsing for
  52581. * @param rootUrl Defines the rootUrl to load from
  52582. */
  52583. parse(source: any, scene: Scene, rootUrl: string): void;
  52584. }
  52585. }
  52586. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52587. import { Nullable } from "babylonjs/types";
  52588. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52589. import { Color3 } from "babylonjs/Maths/math.color";
  52590. import { SmartArray } from "babylonjs/Misc/smartArray";
  52591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52593. import { Effect } from "babylonjs/Materials/effect";
  52594. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52595. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52596. import { Engine } from "babylonjs/Engines/engine";
  52597. import { Scene } from "babylonjs/scene";
  52598. /**
  52599. * @hidden
  52600. */
  52601. export interface IMaterialSubSurfaceDefines {
  52602. SUBSURFACE: boolean;
  52603. SS_REFRACTION: boolean;
  52604. SS_TRANSLUCENCY: boolean;
  52605. SS_SCATERRING: boolean;
  52606. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52607. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52608. SS_REFRACTIONMAP_3D: boolean;
  52609. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52610. SS_LODINREFRACTIONALPHA: boolean;
  52611. SS_GAMMAREFRACTION: boolean;
  52612. SS_RGBDREFRACTION: boolean;
  52613. SS_LINEARSPECULARREFRACTION: boolean;
  52614. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52615. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52616. /** @hidden */
  52617. _areTexturesDirty: boolean;
  52618. }
  52619. /**
  52620. * Define the code related to the sub surface parameters of the pbr material.
  52621. */
  52622. export class PBRSubSurfaceConfiguration {
  52623. private _isRefractionEnabled;
  52624. /**
  52625. * Defines if the refraction is enabled in the material.
  52626. */
  52627. isRefractionEnabled: boolean;
  52628. private _isTranslucencyEnabled;
  52629. /**
  52630. * Defines if the translucency is enabled in the material.
  52631. */
  52632. isTranslucencyEnabled: boolean;
  52633. private _isScatteringEnabled;
  52634. /**
  52635. * Defines the refraction intensity of the material.
  52636. * The refraction when enabled replaces the Diffuse part of the material.
  52637. * The intensity helps transitionning between diffuse and refraction.
  52638. */
  52639. refractionIntensity: number;
  52640. /**
  52641. * Defines the translucency intensity of the material.
  52642. * When translucency has been enabled, this defines how much of the "translucency"
  52643. * is addded to the diffuse part of the material.
  52644. */
  52645. translucencyIntensity: number;
  52646. /**
  52647. * Defines the scattering intensity of the material.
  52648. * When scattering has been enabled, this defines how much of the "scattered light"
  52649. * is addded to the diffuse part of the material.
  52650. */
  52651. scatteringIntensity: number;
  52652. private _thicknessTexture;
  52653. /**
  52654. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52655. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52656. * 0 would mean minimumThickness
  52657. * 1 would mean maximumThickness
  52658. * The other channels might be use as a mask to vary the different effects intensity.
  52659. */
  52660. thicknessTexture: Nullable<BaseTexture>;
  52661. private _refractionTexture;
  52662. /**
  52663. * Defines the texture to use for refraction.
  52664. */
  52665. refractionTexture: Nullable<BaseTexture>;
  52666. private _indexOfRefraction;
  52667. /**
  52668. * Defines the index of refraction used in the material.
  52669. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52670. */
  52671. indexOfRefraction: number;
  52672. private _invertRefractionY;
  52673. /**
  52674. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52675. */
  52676. invertRefractionY: boolean;
  52677. private _linkRefractionWithTransparency;
  52678. /**
  52679. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52680. * Materials half opaque for instance using refraction could benefit from this control.
  52681. */
  52682. linkRefractionWithTransparency: boolean;
  52683. /**
  52684. * Defines the minimum thickness stored in the thickness map.
  52685. * If no thickness map is defined, this value will be used to simulate thickness.
  52686. */
  52687. minimumThickness: number;
  52688. /**
  52689. * Defines the maximum thickness stored in the thickness map.
  52690. */
  52691. maximumThickness: number;
  52692. /**
  52693. * Defines the volume tint of the material.
  52694. * This is used for both translucency and scattering.
  52695. */
  52696. tintColor: Color3;
  52697. /**
  52698. * Defines the distance at which the tint color should be found in the media.
  52699. * This is used for refraction only.
  52700. */
  52701. tintColorAtDistance: number;
  52702. /**
  52703. * Defines how far each channel transmit through the media.
  52704. * It is defined as a color to simplify it selection.
  52705. */
  52706. diffusionDistance: Color3;
  52707. private _useMaskFromThicknessTexture;
  52708. /**
  52709. * Stores the intensity of the different subsurface effects in the thickness texture.
  52710. * * the green channel is the translucency intensity.
  52711. * * the blue channel is the scattering intensity.
  52712. * * the alpha channel is the refraction intensity.
  52713. */
  52714. useMaskFromThicknessTexture: boolean;
  52715. /** @hidden */
  52716. private _internalMarkAllSubMeshesAsTexturesDirty;
  52717. /** @hidden */
  52718. _markAllSubMeshesAsTexturesDirty(): void;
  52719. /**
  52720. * Instantiate a new istance of sub surface configuration.
  52721. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52722. */
  52723. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52724. /**
  52725. * Gets wehter the submesh is ready to be used or not.
  52726. * @param defines the list of "defines" to update.
  52727. * @param scene defines the scene the material belongs to.
  52728. * @returns - boolean indicating that the submesh is ready or not.
  52729. */
  52730. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52731. /**
  52732. * Checks to see if a texture is used in the material.
  52733. * @param defines the list of "defines" to update.
  52734. * @param scene defines the scene to the material belongs to.
  52735. */
  52736. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52737. /**
  52738. * Binds the material data.
  52739. * @param uniformBuffer defines the Uniform buffer to fill in.
  52740. * @param scene defines the scene the material belongs to.
  52741. * @param engine defines the engine the material belongs to.
  52742. * @param isFrozen defines wether the material is frozen or not.
  52743. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52744. */
  52745. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52746. /**
  52747. * Unbinds the material from the mesh.
  52748. * @param activeEffect defines the effect that should be unbound from.
  52749. * @returns true if unbound, otherwise false
  52750. */
  52751. unbind(activeEffect: Effect): boolean;
  52752. /**
  52753. * Returns the texture used for refraction or null if none is used.
  52754. * @param scene defines the scene the material belongs to.
  52755. * @returns - Refraction texture if present. If no refraction texture and refraction
  52756. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52757. */
  52758. private _getRefractionTexture;
  52759. /**
  52760. * Returns true if alpha blending should be disabled.
  52761. */
  52762. get disableAlphaBlending(): boolean;
  52763. /**
  52764. * Fills the list of render target textures.
  52765. * @param renderTargets the list of render targets to update
  52766. */
  52767. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52768. /**
  52769. * Checks to see if a texture is used in the material.
  52770. * @param texture - Base texture to use.
  52771. * @returns - Boolean specifying if a texture is used in the material.
  52772. */
  52773. hasTexture(texture: BaseTexture): boolean;
  52774. /**
  52775. * Gets a boolean indicating that current material needs to register RTT
  52776. * @returns true if this uses a render target otherwise false.
  52777. */
  52778. hasRenderTargetTextures(): boolean;
  52779. /**
  52780. * Returns an array of the actively used textures.
  52781. * @param activeTextures Array of BaseTextures
  52782. */
  52783. getActiveTextures(activeTextures: BaseTexture[]): void;
  52784. /**
  52785. * Returns the animatable textures.
  52786. * @param animatables Array of animatable textures.
  52787. */
  52788. getAnimatables(animatables: IAnimatable[]): void;
  52789. /**
  52790. * Disposes the resources of the material.
  52791. * @param forceDisposeTextures - Forces the disposal of all textures.
  52792. */
  52793. dispose(forceDisposeTextures?: boolean): void;
  52794. /**
  52795. * Get the current class name of the texture useful for serialization or dynamic coding.
  52796. * @returns "PBRSubSurfaceConfiguration"
  52797. */
  52798. getClassName(): string;
  52799. /**
  52800. * Add fallbacks to the effect fallbacks list.
  52801. * @param defines defines the Base texture to use.
  52802. * @param fallbacks defines the current fallback list.
  52803. * @param currentRank defines the current fallback rank.
  52804. * @returns the new fallback rank.
  52805. */
  52806. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52807. /**
  52808. * Add the required uniforms to the current list.
  52809. * @param uniforms defines the current uniform list.
  52810. */
  52811. static AddUniforms(uniforms: string[]): void;
  52812. /**
  52813. * Add the required samplers to the current list.
  52814. * @param samplers defines the current sampler list.
  52815. */
  52816. static AddSamplers(samplers: string[]): void;
  52817. /**
  52818. * Add the required uniforms to the current buffer.
  52819. * @param uniformBuffer defines the current uniform buffer.
  52820. */
  52821. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52822. /**
  52823. * Makes a duplicate of the current configuration into another one.
  52824. * @param configuration define the config where to copy the info
  52825. */
  52826. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52827. /**
  52828. * Serializes this Sub Surface configuration.
  52829. * @returns - An object with the serialized config.
  52830. */
  52831. serialize(): any;
  52832. /**
  52833. * Parses a anisotropy Configuration from a serialized object.
  52834. * @param source - Serialized object.
  52835. * @param scene Defines the scene we are parsing for
  52836. * @param rootUrl Defines the rootUrl to load from
  52837. */
  52838. parse(source: any, scene: Scene, rootUrl: string): void;
  52839. }
  52840. }
  52841. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52842. /** @hidden */
  52843. export var pbrFragmentDeclaration: {
  52844. name: string;
  52845. shader: string;
  52846. };
  52847. }
  52848. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52849. /** @hidden */
  52850. export var pbrUboDeclaration: {
  52851. name: string;
  52852. shader: string;
  52853. };
  52854. }
  52855. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52856. /** @hidden */
  52857. export var pbrFragmentExtraDeclaration: {
  52858. name: string;
  52859. shader: string;
  52860. };
  52861. }
  52862. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52863. /** @hidden */
  52864. export var pbrFragmentSamplersDeclaration: {
  52865. name: string;
  52866. shader: string;
  52867. };
  52868. }
  52869. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52870. /** @hidden */
  52871. export var pbrHelperFunctions: {
  52872. name: string;
  52873. shader: string;
  52874. };
  52875. }
  52876. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52877. /** @hidden */
  52878. export var harmonicsFunctions: {
  52879. name: string;
  52880. shader: string;
  52881. };
  52882. }
  52883. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52884. /** @hidden */
  52885. export var pbrDirectLightingSetupFunctions: {
  52886. name: string;
  52887. shader: string;
  52888. };
  52889. }
  52890. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52891. /** @hidden */
  52892. export var pbrDirectLightingFalloffFunctions: {
  52893. name: string;
  52894. shader: string;
  52895. };
  52896. }
  52897. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52898. /** @hidden */
  52899. export var pbrBRDFFunctions: {
  52900. name: string;
  52901. shader: string;
  52902. };
  52903. }
  52904. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52905. /** @hidden */
  52906. export var pbrDirectLightingFunctions: {
  52907. name: string;
  52908. shader: string;
  52909. };
  52910. }
  52911. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52912. /** @hidden */
  52913. export var pbrIBLFunctions: {
  52914. name: string;
  52915. shader: string;
  52916. };
  52917. }
  52918. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52919. /** @hidden */
  52920. export var pbrDebug: {
  52921. name: string;
  52922. shader: string;
  52923. };
  52924. }
  52925. declare module "babylonjs/Shaders/pbr.fragment" {
  52926. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52927. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52928. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52929. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52930. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52931. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52932. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52933. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52934. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52935. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52936. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52937. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52938. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52939. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52940. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52941. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52942. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52943. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52944. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52945. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52946. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52947. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52948. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52949. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52950. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52951. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52952. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52953. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52954. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52955. /** @hidden */
  52956. export var pbrPixelShader: {
  52957. name: string;
  52958. shader: string;
  52959. };
  52960. }
  52961. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52962. /** @hidden */
  52963. export var pbrVertexDeclaration: {
  52964. name: string;
  52965. shader: string;
  52966. };
  52967. }
  52968. declare module "babylonjs/Shaders/pbr.vertex" {
  52969. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52970. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52972. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52973. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52974. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52975. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52976. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52977. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52978. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52979. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52981. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52982. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52983. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52984. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52985. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52986. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52987. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52988. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52989. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52990. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52991. /** @hidden */
  52992. export var pbrVertexShader: {
  52993. name: string;
  52994. shader: string;
  52995. };
  52996. }
  52997. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52998. import { Nullable } from "babylonjs/types";
  52999. import { Scene } from "babylonjs/scene";
  53000. import { Matrix } from "babylonjs/Maths/math.vector";
  53001. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53003. import { Mesh } from "babylonjs/Meshes/mesh";
  53004. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53005. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53006. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53007. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53008. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53009. import { Color3 } from "babylonjs/Maths/math.color";
  53010. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53011. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53012. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53013. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53015. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53016. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53017. import "babylonjs/Shaders/pbr.fragment";
  53018. import "babylonjs/Shaders/pbr.vertex";
  53019. /**
  53020. * Manages the defines for the PBR Material.
  53021. * @hidden
  53022. */
  53023. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53024. PBR: boolean;
  53025. MAINUV1: boolean;
  53026. MAINUV2: boolean;
  53027. UV1: boolean;
  53028. UV2: boolean;
  53029. ALBEDO: boolean;
  53030. GAMMAALBEDO: boolean;
  53031. ALBEDODIRECTUV: number;
  53032. VERTEXCOLOR: boolean;
  53033. AMBIENT: boolean;
  53034. AMBIENTDIRECTUV: number;
  53035. AMBIENTINGRAYSCALE: boolean;
  53036. OPACITY: boolean;
  53037. VERTEXALPHA: boolean;
  53038. OPACITYDIRECTUV: number;
  53039. OPACITYRGB: boolean;
  53040. ALPHATEST: boolean;
  53041. DEPTHPREPASS: boolean;
  53042. ALPHABLEND: boolean;
  53043. ALPHAFROMALBEDO: boolean;
  53044. ALPHATESTVALUE: string;
  53045. SPECULAROVERALPHA: boolean;
  53046. RADIANCEOVERALPHA: boolean;
  53047. ALPHAFRESNEL: boolean;
  53048. LINEARALPHAFRESNEL: boolean;
  53049. PREMULTIPLYALPHA: boolean;
  53050. EMISSIVE: boolean;
  53051. EMISSIVEDIRECTUV: number;
  53052. REFLECTIVITY: boolean;
  53053. REFLECTIVITYDIRECTUV: number;
  53054. SPECULARTERM: boolean;
  53055. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53056. MICROSURFACEAUTOMATIC: boolean;
  53057. LODBASEDMICROSFURACE: boolean;
  53058. MICROSURFACEMAP: boolean;
  53059. MICROSURFACEMAPDIRECTUV: number;
  53060. METALLICWORKFLOW: boolean;
  53061. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53062. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53063. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53064. AOSTOREINMETALMAPRED: boolean;
  53065. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53066. ENVIRONMENTBRDF: boolean;
  53067. ENVIRONMENTBRDF_RGBD: boolean;
  53068. NORMAL: boolean;
  53069. TANGENT: boolean;
  53070. BUMP: boolean;
  53071. BUMPDIRECTUV: number;
  53072. OBJECTSPACE_NORMALMAP: boolean;
  53073. PARALLAX: boolean;
  53074. PARALLAXOCCLUSION: boolean;
  53075. NORMALXYSCALE: boolean;
  53076. LIGHTMAP: boolean;
  53077. LIGHTMAPDIRECTUV: number;
  53078. USELIGHTMAPASSHADOWMAP: boolean;
  53079. GAMMALIGHTMAP: boolean;
  53080. RGBDLIGHTMAP: boolean;
  53081. REFLECTION: boolean;
  53082. REFLECTIONMAP_3D: boolean;
  53083. REFLECTIONMAP_SPHERICAL: boolean;
  53084. REFLECTIONMAP_PLANAR: boolean;
  53085. REFLECTIONMAP_CUBIC: boolean;
  53086. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53087. REFLECTIONMAP_PROJECTION: boolean;
  53088. REFLECTIONMAP_SKYBOX: boolean;
  53089. REFLECTIONMAP_EXPLICIT: boolean;
  53090. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53091. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53092. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53093. INVERTCUBICMAP: boolean;
  53094. USESPHERICALFROMREFLECTIONMAP: boolean;
  53095. USEIRRADIANCEMAP: boolean;
  53096. SPHERICAL_HARMONICS: boolean;
  53097. USESPHERICALINVERTEX: boolean;
  53098. REFLECTIONMAP_OPPOSITEZ: boolean;
  53099. LODINREFLECTIONALPHA: boolean;
  53100. GAMMAREFLECTION: boolean;
  53101. RGBDREFLECTION: boolean;
  53102. LINEARSPECULARREFLECTION: boolean;
  53103. RADIANCEOCCLUSION: boolean;
  53104. HORIZONOCCLUSION: boolean;
  53105. INSTANCES: boolean;
  53106. NUM_BONE_INFLUENCERS: number;
  53107. BonesPerMesh: number;
  53108. BONETEXTURE: boolean;
  53109. NONUNIFORMSCALING: boolean;
  53110. MORPHTARGETS: boolean;
  53111. MORPHTARGETS_NORMAL: boolean;
  53112. MORPHTARGETS_TANGENT: boolean;
  53113. MORPHTARGETS_UV: boolean;
  53114. NUM_MORPH_INFLUENCERS: number;
  53115. IMAGEPROCESSING: boolean;
  53116. VIGNETTE: boolean;
  53117. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53118. VIGNETTEBLENDMODEOPAQUE: boolean;
  53119. TONEMAPPING: boolean;
  53120. TONEMAPPING_ACES: boolean;
  53121. CONTRAST: boolean;
  53122. COLORCURVES: boolean;
  53123. COLORGRADING: boolean;
  53124. COLORGRADING3D: boolean;
  53125. SAMPLER3DGREENDEPTH: boolean;
  53126. SAMPLER3DBGRMAP: boolean;
  53127. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53128. EXPOSURE: boolean;
  53129. MULTIVIEW: boolean;
  53130. USEPHYSICALLIGHTFALLOFF: boolean;
  53131. USEGLTFLIGHTFALLOFF: boolean;
  53132. TWOSIDEDLIGHTING: boolean;
  53133. SHADOWFLOAT: boolean;
  53134. CLIPPLANE: boolean;
  53135. CLIPPLANE2: boolean;
  53136. CLIPPLANE3: boolean;
  53137. CLIPPLANE4: boolean;
  53138. CLIPPLANE5: boolean;
  53139. CLIPPLANE6: boolean;
  53140. POINTSIZE: boolean;
  53141. FOG: boolean;
  53142. LOGARITHMICDEPTH: boolean;
  53143. FORCENORMALFORWARD: boolean;
  53144. SPECULARAA: boolean;
  53145. CLEARCOAT: boolean;
  53146. CLEARCOAT_DEFAULTIOR: boolean;
  53147. CLEARCOAT_TEXTURE: boolean;
  53148. CLEARCOAT_TEXTUREDIRECTUV: number;
  53149. CLEARCOAT_BUMP: boolean;
  53150. CLEARCOAT_BUMPDIRECTUV: number;
  53151. CLEARCOAT_TINT: boolean;
  53152. CLEARCOAT_TINT_TEXTURE: boolean;
  53153. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53154. ANISOTROPIC: boolean;
  53155. ANISOTROPIC_TEXTURE: boolean;
  53156. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53157. BRDF_V_HEIGHT_CORRELATED: boolean;
  53158. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53159. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53160. SHEEN: boolean;
  53161. SHEEN_TEXTURE: boolean;
  53162. SHEEN_TEXTUREDIRECTUV: number;
  53163. SHEEN_LINKWITHALBEDO: boolean;
  53164. SUBSURFACE: boolean;
  53165. SS_REFRACTION: boolean;
  53166. SS_TRANSLUCENCY: boolean;
  53167. SS_SCATERRING: boolean;
  53168. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53169. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53170. SS_REFRACTIONMAP_3D: boolean;
  53171. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53172. SS_LODINREFRACTIONALPHA: boolean;
  53173. SS_GAMMAREFRACTION: boolean;
  53174. SS_RGBDREFRACTION: boolean;
  53175. SS_LINEARSPECULARREFRACTION: boolean;
  53176. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53177. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53178. UNLIT: boolean;
  53179. DEBUGMODE: number;
  53180. /**
  53181. * Initializes the PBR Material defines.
  53182. */
  53183. constructor();
  53184. /**
  53185. * Resets the PBR Material defines.
  53186. */
  53187. reset(): void;
  53188. }
  53189. /**
  53190. * The Physically based material base class of BJS.
  53191. *
  53192. * This offers the main features of a standard PBR material.
  53193. * For more information, please refer to the documentation :
  53194. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53195. */
  53196. export abstract class PBRBaseMaterial extends PushMaterial {
  53197. /**
  53198. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53199. */
  53200. static readonly PBRMATERIAL_OPAQUE: number;
  53201. /**
  53202. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53203. */
  53204. static readonly PBRMATERIAL_ALPHATEST: number;
  53205. /**
  53206. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53207. */
  53208. static readonly PBRMATERIAL_ALPHABLEND: number;
  53209. /**
  53210. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53211. * They are also discarded below the alpha cutoff threshold to improve performances.
  53212. */
  53213. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53214. /**
  53215. * Defines the default value of how much AO map is occluding the analytical lights
  53216. * (point spot...).
  53217. */
  53218. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53219. /**
  53220. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53221. */
  53222. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53223. /**
  53224. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53225. * to enhance interoperability with other engines.
  53226. */
  53227. static readonly LIGHTFALLOFF_GLTF: number;
  53228. /**
  53229. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53230. * to enhance interoperability with other materials.
  53231. */
  53232. static readonly LIGHTFALLOFF_STANDARD: number;
  53233. /**
  53234. * Intensity of the direct lights e.g. the four lights available in your scene.
  53235. * This impacts both the direct diffuse and specular highlights.
  53236. */
  53237. protected _directIntensity: number;
  53238. /**
  53239. * Intensity of the emissive part of the material.
  53240. * This helps controlling the emissive effect without modifying the emissive color.
  53241. */
  53242. protected _emissiveIntensity: number;
  53243. /**
  53244. * Intensity of the environment e.g. how much the environment will light the object
  53245. * either through harmonics for rough material or through the refelction for shiny ones.
  53246. */
  53247. protected _environmentIntensity: number;
  53248. /**
  53249. * This is a special control allowing the reduction of the specular highlights coming from the
  53250. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53251. */
  53252. protected _specularIntensity: number;
  53253. /**
  53254. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53255. */
  53256. private _lightingInfos;
  53257. /**
  53258. * Debug Control allowing disabling the bump map on this material.
  53259. */
  53260. protected _disableBumpMap: boolean;
  53261. /**
  53262. * AKA Diffuse Texture in standard nomenclature.
  53263. */
  53264. protected _albedoTexture: Nullable<BaseTexture>;
  53265. /**
  53266. * AKA Occlusion Texture in other nomenclature.
  53267. */
  53268. protected _ambientTexture: Nullable<BaseTexture>;
  53269. /**
  53270. * AKA Occlusion Texture Intensity in other nomenclature.
  53271. */
  53272. protected _ambientTextureStrength: number;
  53273. /**
  53274. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53275. * 1 means it completely occludes it
  53276. * 0 mean it has no impact
  53277. */
  53278. protected _ambientTextureImpactOnAnalyticalLights: number;
  53279. /**
  53280. * Stores the alpha values in a texture.
  53281. */
  53282. protected _opacityTexture: Nullable<BaseTexture>;
  53283. /**
  53284. * Stores the reflection values in a texture.
  53285. */
  53286. protected _reflectionTexture: Nullable<BaseTexture>;
  53287. /**
  53288. * Stores the emissive values in a texture.
  53289. */
  53290. protected _emissiveTexture: Nullable<BaseTexture>;
  53291. /**
  53292. * AKA Specular texture in other nomenclature.
  53293. */
  53294. protected _reflectivityTexture: Nullable<BaseTexture>;
  53295. /**
  53296. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53297. */
  53298. protected _metallicTexture: Nullable<BaseTexture>;
  53299. /**
  53300. * Specifies the metallic scalar of the metallic/roughness workflow.
  53301. * Can also be used to scale the metalness values of the metallic texture.
  53302. */
  53303. protected _metallic: Nullable<number>;
  53304. /**
  53305. * Specifies the roughness scalar of the metallic/roughness workflow.
  53306. * Can also be used to scale the roughness values of the metallic texture.
  53307. */
  53308. protected _roughness: Nullable<number>;
  53309. /**
  53310. * Specifies the an F0 factor to help configuring the material F0.
  53311. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53312. * to 0.5 the previously hard coded value stays the same.
  53313. * Can also be used to scale the F0 values of the metallic texture.
  53314. */
  53315. protected _metallicF0Factor: number;
  53316. /**
  53317. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53318. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53319. * your expectation as it multiplies with the texture data.
  53320. */
  53321. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53322. /**
  53323. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53324. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53325. */
  53326. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53327. /**
  53328. * Stores surface normal data used to displace a mesh in a texture.
  53329. */
  53330. protected _bumpTexture: Nullable<BaseTexture>;
  53331. /**
  53332. * Stores the pre-calculated light information of a mesh in a texture.
  53333. */
  53334. protected _lightmapTexture: Nullable<BaseTexture>;
  53335. /**
  53336. * The color of a material in ambient lighting.
  53337. */
  53338. protected _ambientColor: Color3;
  53339. /**
  53340. * AKA Diffuse Color in other nomenclature.
  53341. */
  53342. protected _albedoColor: Color3;
  53343. /**
  53344. * AKA Specular Color in other nomenclature.
  53345. */
  53346. protected _reflectivityColor: Color3;
  53347. /**
  53348. * The color applied when light is reflected from a material.
  53349. */
  53350. protected _reflectionColor: Color3;
  53351. /**
  53352. * The color applied when light is emitted from a material.
  53353. */
  53354. protected _emissiveColor: Color3;
  53355. /**
  53356. * AKA Glossiness in other nomenclature.
  53357. */
  53358. protected _microSurface: number;
  53359. /**
  53360. * Specifies that the material will use the light map as a show map.
  53361. */
  53362. protected _useLightmapAsShadowmap: boolean;
  53363. /**
  53364. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53365. * makes the reflect vector face the model (under horizon).
  53366. */
  53367. protected _useHorizonOcclusion: boolean;
  53368. /**
  53369. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53370. * too much the area relying on ambient texture to define their ambient occlusion.
  53371. */
  53372. protected _useRadianceOcclusion: boolean;
  53373. /**
  53374. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53375. */
  53376. protected _useAlphaFromAlbedoTexture: boolean;
  53377. /**
  53378. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53379. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53380. */
  53381. protected _useSpecularOverAlpha: boolean;
  53382. /**
  53383. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53384. */
  53385. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53386. /**
  53387. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53388. */
  53389. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53390. /**
  53391. * Specifies if the metallic texture contains the roughness information in its green channel.
  53392. */
  53393. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53394. /**
  53395. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53396. */
  53397. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53398. /**
  53399. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53400. */
  53401. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53402. /**
  53403. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53404. */
  53405. protected _useAmbientInGrayScale: boolean;
  53406. /**
  53407. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53408. * The material will try to infer what glossiness each pixel should be.
  53409. */
  53410. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53411. /**
  53412. * Defines the falloff type used in this material.
  53413. * It by default is Physical.
  53414. */
  53415. protected _lightFalloff: number;
  53416. /**
  53417. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53418. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53419. */
  53420. protected _useRadianceOverAlpha: boolean;
  53421. /**
  53422. * Allows using an object space normal map (instead of tangent space).
  53423. */
  53424. protected _useObjectSpaceNormalMap: boolean;
  53425. /**
  53426. * Allows using the bump map in parallax mode.
  53427. */
  53428. protected _useParallax: boolean;
  53429. /**
  53430. * Allows using the bump map in parallax occlusion mode.
  53431. */
  53432. protected _useParallaxOcclusion: boolean;
  53433. /**
  53434. * Controls the scale bias of the parallax mode.
  53435. */
  53436. protected _parallaxScaleBias: number;
  53437. /**
  53438. * If sets to true, disables all the lights affecting the material.
  53439. */
  53440. protected _disableLighting: boolean;
  53441. /**
  53442. * Number of Simultaneous lights allowed on the material.
  53443. */
  53444. protected _maxSimultaneousLights: number;
  53445. /**
  53446. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53447. */
  53448. protected _invertNormalMapX: boolean;
  53449. /**
  53450. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53451. */
  53452. protected _invertNormalMapY: boolean;
  53453. /**
  53454. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53455. */
  53456. protected _twoSidedLighting: boolean;
  53457. /**
  53458. * Defines the alpha limits in alpha test mode.
  53459. */
  53460. protected _alphaCutOff: number;
  53461. /**
  53462. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53463. */
  53464. protected _forceAlphaTest: boolean;
  53465. /**
  53466. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53467. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53468. */
  53469. protected _useAlphaFresnel: boolean;
  53470. /**
  53471. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53472. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53473. */
  53474. protected _useLinearAlphaFresnel: boolean;
  53475. /**
  53476. * The transparency mode of the material.
  53477. */
  53478. protected _transparencyMode: Nullable<number>;
  53479. /**
  53480. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53481. * from cos thetav and roughness:
  53482. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53483. */
  53484. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53485. /**
  53486. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53487. */
  53488. protected _forceIrradianceInFragment: boolean;
  53489. /**
  53490. * Force normal to face away from face.
  53491. */
  53492. protected _forceNormalForward: boolean;
  53493. /**
  53494. * Enables specular anti aliasing in the PBR shader.
  53495. * It will both interacts on the Geometry for analytical and IBL lighting.
  53496. * It also prefilter the roughness map based on the bump values.
  53497. */
  53498. protected _enableSpecularAntiAliasing: boolean;
  53499. /**
  53500. * Default configuration related to image processing available in the PBR Material.
  53501. */
  53502. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53503. /**
  53504. * Keep track of the image processing observer to allow dispose and replace.
  53505. */
  53506. private _imageProcessingObserver;
  53507. /**
  53508. * Attaches a new image processing configuration to the PBR Material.
  53509. * @param configuration
  53510. */
  53511. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53512. /**
  53513. * Stores the available render targets.
  53514. */
  53515. private _renderTargets;
  53516. /**
  53517. * Sets the global ambient color for the material used in lighting calculations.
  53518. */
  53519. private _globalAmbientColor;
  53520. /**
  53521. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53522. */
  53523. private _useLogarithmicDepth;
  53524. /**
  53525. * If set to true, no lighting calculations will be applied.
  53526. */
  53527. private _unlit;
  53528. private _debugMode;
  53529. /**
  53530. * @hidden
  53531. * This is reserved for the inspector.
  53532. * Defines the material debug mode.
  53533. * It helps seeing only some components of the material while troubleshooting.
  53534. */
  53535. debugMode: number;
  53536. /**
  53537. * @hidden
  53538. * This is reserved for the inspector.
  53539. * Specify from where on screen the debug mode should start.
  53540. * The value goes from -1 (full screen) to 1 (not visible)
  53541. * It helps with side by side comparison against the final render
  53542. * This defaults to -1
  53543. */
  53544. private debugLimit;
  53545. /**
  53546. * @hidden
  53547. * This is reserved for the inspector.
  53548. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53549. * You can use the factor to better multiply the final value.
  53550. */
  53551. private debugFactor;
  53552. /**
  53553. * Defines the clear coat layer parameters for the material.
  53554. */
  53555. readonly clearCoat: PBRClearCoatConfiguration;
  53556. /**
  53557. * Defines the anisotropic parameters for the material.
  53558. */
  53559. readonly anisotropy: PBRAnisotropicConfiguration;
  53560. /**
  53561. * Defines the BRDF parameters for the material.
  53562. */
  53563. readonly brdf: PBRBRDFConfiguration;
  53564. /**
  53565. * Defines the Sheen parameters for the material.
  53566. */
  53567. readonly sheen: PBRSheenConfiguration;
  53568. /**
  53569. * Defines the SubSurface parameters for the material.
  53570. */
  53571. readonly subSurface: PBRSubSurfaceConfiguration;
  53572. /**
  53573. * Custom callback helping to override the default shader used in the material.
  53574. */
  53575. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53576. protected _rebuildInParallel: boolean;
  53577. /**
  53578. * Instantiates a new PBRMaterial instance.
  53579. *
  53580. * @param name The material name
  53581. * @param scene The scene the material will be use in.
  53582. */
  53583. constructor(name: string, scene: Scene);
  53584. /**
  53585. * Gets a boolean indicating that current material needs to register RTT
  53586. */
  53587. get hasRenderTargetTextures(): boolean;
  53588. /**
  53589. * Gets the name of the material class.
  53590. */
  53591. getClassName(): string;
  53592. /**
  53593. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53594. */
  53595. get useLogarithmicDepth(): boolean;
  53596. /**
  53597. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53598. */
  53599. set useLogarithmicDepth(value: boolean);
  53600. /**
  53601. * Gets the current transparency mode.
  53602. */
  53603. get transparencyMode(): Nullable<number>;
  53604. /**
  53605. * Sets the transparency mode of the material.
  53606. *
  53607. * | Value | Type | Description |
  53608. * | ----- | ----------------------------------- | ----------- |
  53609. * | 0 | OPAQUE | |
  53610. * | 1 | ALPHATEST | |
  53611. * | 2 | ALPHABLEND | |
  53612. * | 3 | ALPHATESTANDBLEND | |
  53613. *
  53614. */
  53615. set transparencyMode(value: Nullable<number>);
  53616. /**
  53617. * Returns true if alpha blending should be disabled.
  53618. */
  53619. private get _disableAlphaBlending();
  53620. /**
  53621. * Specifies whether or not this material should be rendered in alpha blend mode.
  53622. */
  53623. needAlphaBlending(): boolean;
  53624. /**
  53625. * Specifies if the mesh will require alpha blending.
  53626. * @param mesh - BJS mesh.
  53627. */
  53628. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53629. /**
  53630. * Specifies whether or not this material should be rendered in alpha test mode.
  53631. */
  53632. needAlphaTesting(): boolean;
  53633. /**
  53634. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53635. */
  53636. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53637. /**
  53638. * Gets the texture used for the alpha test.
  53639. */
  53640. getAlphaTestTexture(): Nullable<BaseTexture>;
  53641. /**
  53642. * Specifies that the submesh is ready to be used.
  53643. * @param mesh - BJS mesh.
  53644. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53645. * @param useInstances - Specifies that instances should be used.
  53646. * @returns - boolean indicating that the submesh is ready or not.
  53647. */
  53648. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53649. /**
  53650. * Specifies if the material uses metallic roughness workflow.
  53651. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53652. */
  53653. isMetallicWorkflow(): boolean;
  53654. private _prepareEffect;
  53655. private _prepareDefines;
  53656. /**
  53657. * Force shader compilation
  53658. */
  53659. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53660. /**
  53661. * Initializes the uniform buffer layout for the shader.
  53662. */
  53663. buildUniformLayout(): void;
  53664. /**
  53665. * Unbinds the material from the mesh
  53666. */
  53667. unbind(): void;
  53668. /**
  53669. * Binds the submesh data.
  53670. * @param world - The world matrix.
  53671. * @param mesh - The BJS mesh.
  53672. * @param subMesh - A submesh of the BJS mesh.
  53673. */
  53674. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53675. /**
  53676. * Returns the animatable textures.
  53677. * @returns - Array of animatable textures.
  53678. */
  53679. getAnimatables(): IAnimatable[];
  53680. /**
  53681. * Returns the texture used for reflections.
  53682. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53683. */
  53684. private _getReflectionTexture;
  53685. /**
  53686. * Returns an array of the actively used textures.
  53687. * @returns - Array of BaseTextures
  53688. */
  53689. getActiveTextures(): BaseTexture[];
  53690. /**
  53691. * Checks to see if a texture is used in the material.
  53692. * @param texture - Base texture to use.
  53693. * @returns - Boolean specifying if a texture is used in the material.
  53694. */
  53695. hasTexture(texture: BaseTexture): boolean;
  53696. /**
  53697. * Disposes the resources of the material.
  53698. * @param forceDisposeEffect - Forces the disposal of effects.
  53699. * @param forceDisposeTextures - Forces the disposal of all textures.
  53700. */
  53701. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53702. }
  53703. }
  53704. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53705. import { Nullable } from "babylonjs/types";
  53706. import { Scene } from "babylonjs/scene";
  53707. import { Color3 } from "babylonjs/Maths/math.color";
  53708. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53709. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53711. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53712. /**
  53713. * The Physically based material of BJS.
  53714. *
  53715. * This offers the main features of a standard PBR material.
  53716. * For more information, please refer to the documentation :
  53717. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53718. */
  53719. export class PBRMaterial extends PBRBaseMaterial {
  53720. /**
  53721. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53722. */
  53723. static readonly PBRMATERIAL_OPAQUE: number;
  53724. /**
  53725. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53726. */
  53727. static readonly PBRMATERIAL_ALPHATEST: number;
  53728. /**
  53729. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53730. */
  53731. static readonly PBRMATERIAL_ALPHABLEND: number;
  53732. /**
  53733. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53734. * They are also discarded below the alpha cutoff threshold to improve performances.
  53735. */
  53736. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53737. /**
  53738. * Defines the default value of how much AO map is occluding the analytical lights
  53739. * (point spot...).
  53740. */
  53741. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53742. /**
  53743. * Intensity of the direct lights e.g. the four lights available in your scene.
  53744. * This impacts both the direct diffuse and specular highlights.
  53745. */
  53746. directIntensity: number;
  53747. /**
  53748. * Intensity of the emissive part of the material.
  53749. * This helps controlling the emissive effect without modifying the emissive color.
  53750. */
  53751. emissiveIntensity: number;
  53752. /**
  53753. * Intensity of the environment e.g. how much the environment will light the object
  53754. * either through harmonics for rough material or through the refelction for shiny ones.
  53755. */
  53756. environmentIntensity: number;
  53757. /**
  53758. * This is a special control allowing the reduction of the specular highlights coming from the
  53759. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53760. */
  53761. specularIntensity: number;
  53762. /**
  53763. * Debug Control allowing disabling the bump map on this material.
  53764. */
  53765. disableBumpMap: boolean;
  53766. /**
  53767. * AKA Diffuse Texture in standard nomenclature.
  53768. */
  53769. albedoTexture: BaseTexture;
  53770. /**
  53771. * AKA Occlusion Texture in other nomenclature.
  53772. */
  53773. ambientTexture: BaseTexture;
  53774. /**
  53775. * AKA Occlusion Texture Intensity in other nomenclature.
  53776. */
  53777. ambientTextureStrength: number;
  53778. /**
  53779. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53780. * 1 means it completely occludes it
  53781. * 0 mean it has no impact
  53782. */
  53783. ambientTextureImpactOnAnalyticalLights: number;
  53784. /**
  53785. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53786. */
  53787. opacityTexture: BaseTexture;
  53788. /**
  53789. * Stores the reflection values in a texture.
  53790. */
  53791. reflectionTexture: Nullable<BaseTexture>;
  53792. /**
  53793. * Stores the emissive values in a texture.
  53794. */
  53795. emissiveTexture: BaseTexture;
  53796. /**
  53797. * AKA Specular texture in other nomenclature.
  53798. */
  53799. reflectivityTexture: BaseTexture;
  53800. /**
  53801. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53802. */
  53803. metallicTexture: BaseTexture;
  53804. /**
  53805. * Specifies the metallic scalar of the metallic/roughness workflow.
  53806. * Can also be used to scale the metalness values of the metallic texture.
  53807. */
  53808. metallic: Nullable<number>;
  53809. /**
  53810. * Specifies the roughness scalar of the metallic/roughness workflow.
  53811. * Can also be used to scale the roughness values of the metallic texture.
  53812. */
  53813. roughness: Nullable<number>;
  53814. /**
  53815. * Specifies the an F0 factor to help configuring the material F0.
  53816. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53817. * to 0.5 the previously hard coded value stays the same.
  53818. * Can also be used to scale the F0 values of the metallic texture.
  53819. */
  53820. metallicF0Factor: number;
  53821. /**
  53822. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53823. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53824. * your expectation as it multiplies with the texture data.
  53825. */
  53826. useMetallicF0FactorFromMetallicTexture: boolean;
  53827. /**
  53828. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53829. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53830. */
  53831. microSurfaceTexture: BaseTexture;
  53832. /**
  53833. * Stores surface normal data used to displace a mesh in a texture.
  53834. */
  53835. bumpTexture: BaseTexture;
  53836. /**
  53837. * Stores the pre-calculated light information of a mesh in a texture.
  53838. */
  53839. lightmapTexture: BaseTexture;
  53840. /**
  53841. * Stores the refracted light information in a texture.
  53842. */
  53843. get refractionTexture(): Nullable<BaseTexture>;
  53844. set refractionTexture(value: Nullable<BaseTexture>);
  53845. /**
  53846. * The color of a material in ambient lighting.
  53847. */
  53848. ambientColor: Color3;
  53849. /**
  53850. * AKA Diffuse Color in other nomenclature.
  53851. */
  53852. albedoColor: Color3;
  53853. /**
  53854. * AKA Specular Color in other nomenclature.
  53855. */
  53856. reflectivityColor: Color3;
  53857. /**
  53858. * The color reflected from the material.
  53859. */
  53860. reflectionColor: Color3;
  53861. /**
  53862. * The color emitted from the material.
  53863. */
  53864. emissiveColor: Color3;
  53865. /**
  53866. * AKA Glossiness in other nomenclature.
  53867. */
  53868. microSurface: number;
  53869. /**
  53870. * source material index of refraction (IOR)' / 'destination material IOR.
  53871. */
  53872. get indexOfRefraction(): number;
  53873. set indexOfRefraction(value: number);
  53874. /**
  53875. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53876. */
  53877. get invertRefractionY(): boolean;
  53878. set invertRefractionY(value: boolean);
  53879. /**
  53880. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53881. * Materials half opaque for instance using refraction could benefit from this control.
  53882. */
  53883. get linkRefractionWithTransparency(): boolean;
  53884. set linkRefractionWithTransparency(value: boolean);
  53885. /**
  53886. * If true, the light map contains occlusion information instead of lighting info.
  53887. */
  53888. useLightmapAsShadowmap: boolean;
  53889. /**
  53890. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53891. */
  53892. useAlphaFromAlbedoTexture: boolean;
  53893. /**
  53894. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53895. */
  53896. forceAlphaTest: boolean;
  53897. /**
  53898. * Defines the alpha limits in alpha test mode.
  53899. */
  53900. alphaCutOff: number;
  53901. /**
  53902. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53903. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53904. */
  53905. useSpecularOverAlpha: boolean;
  53906. /**
  53907. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53908. */
  53909. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53910. /**
  53911. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53912. */
  53913. useRoughnessFromMetallicTextureAlpha: boolean;
  53914. /**
  53915. * Specifies if the metallic texture contains the roughness information in its green channel.
  53916. */
  53917. useRoughnessFromMetallicTextureGreen: boolean;
  53918. /**
  53919. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53920. */
  53921. useMetallnessFromMetallicTextureBlue: boolean;
  53922. /**
  53923. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53924. */
  53925. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53926. /**
  53927. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53928. */
  53929. useAmbientInGrayScale: boolean;
  53930. /**
  53931. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53932. * The material will try to infer what glossiness each pixel should be.
  53933. */
  53934. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53935. /**
  53936. * BJS is using an harcoded light falloff based on a manually sets up range.
  53937. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53938. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53939. */
  53940. get usePhysicalLightFalloff(): boolean;
  53941. /**
  53942. * BJS is using an harcoded light falloff based on a manually sets up range.
  53943. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53944. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53945. */
  53946. set usePhysicalLightFalloff(value: boolean);
  53947. /**
  53948. * In order to support the falloff compatibility with gltf, a special mode has been added
  53949. * to reproduce the gltf light falloff.
  53950. */
  53951. get useGLTFLightFalloff(): boolean;
  53952. /**
  53953. * In order to support the falloff compatibility with gltf, a special mode has been added
  53954. * to reproduce the gltf light falloff.
  53955. */
  53956. set useGLTFLightFalloff(value: boolean);
  53957. /**
  53958. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53959. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53960. */
  53961. useRadianceOverAlpha: boolean;
  53962. /**
  53963. * Allows using an object space normal map (instead of tangent space).
  53964. */
  53965. useObjectSpaceNormalMap: boolean;
  53966. /**
  53967. * Allows using the bump map in parallax mode.
  53968. */
  53969. useParallax: boolean;
  53970. /**
  53971. * Allows using the bump map in parallax occlusion mode.
  53972. */
  53973. useParallaxOcclusion: boolean;
  53974. /**
  53975. * Controls the scale bias of the parallax mode.
  53976. */
  53977. parallaxScaleBias: number;
  53978. /**
  53979. * If sets to true, disables all the lights affecting the material.
  53980. */
  53981. disableLighting: boolean;
  53982. /**
  53983. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53984. */
  53985. forceIrradianceInFragment: boolean;
  53986. /**
  53987. * Number of Simultaneous lights allowed on the material.
  53988. */
  53989. maxSimultaneousLights: number;
  53990. /**
  53991. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53992. */
  53993. invertNormalMapX: boolean;
  53994. /**
  53995. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53996. */
  53997. invertNormalMapY: boolean;
  53998. /**
  53999. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54000. */
  54001. twoSidedLighting: boolean;
  54002. /**
  54003. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54004. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54005. */
  54006. useAlphaFresnel: boolean;
  54007. /**
  54008. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54009. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54010. */
  54011. useLinearAlphaFresnel: boolean;
  54012. /**
  54013. * Let user defines the brdf lookup texture used for IBL.
  54014. * A default 8bit version is embedded but you could point at :
  54015. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54016. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54017. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54018. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54019. */
  54020. environmentBRDFTexture: Nullable<BaseTexture>;
  54021. /**
  54022. * Force normal to face away from face.
  54023. */
  54024. forceNormalForward: boolean;
  54025. /**
  54026. * Enables specular anti aliasing in the PBR shader.
  54027. * It will both interacts on the Geometry for analytical and IBL lighting.
  54028. * It also prefilter the roughness map based on the bump values.
  54029. */
  54030. enableSpecularAntiAliasing: boolean;
  54031. /**
  54032. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54033. * makes the reflect vector face the model (under horizon).
  54034. */
  54035. useHorizonOcclusion: boolean;
  54036. /**
  54037. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54038. * too much the area relying on ambient texture to define their ambient occlusion.
  54039. */
  54040. useRadianceOcclusion: boolean;
  54041. /**
  54042. * If set to true, no lighting calculations will be applied.
  54043. */
  54044. unlit: boolean;
  54045. /**
  54046. * Gets the image processing configuration used either in this material.
  54047. */
  54048. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54049. /**
  54050. * Sets the Default image processing configuration used either in the this material.
  54051. *
  54052. * If sets to null, the scene one is in use.
  54053. */
  54054. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54055. /**
  54056. * Gets wether the color curves effect is enabled.
  54057. */
  54058. get cameraColorCurvesEnabled(): boolean;
  54059. /**
  54060. * Sets wether the color curves effect is enabled.
  54061. */
  54062. set cameraColorCurvesEnabled(value: boolean);
  54063. /**
  54064. * Gets wether the color grading effect is enabled.
  54065. */
  54066. get cameraColorGradingEnabled(): boolean;
  54067. /**
  54068. * Gets wether the color grading effect is enabled.
  54069. */
  54070. set cameraColorGradingEnabled(value: boolean);
  54071. /**
  54072. * Gets wether tonemapping is enabled or not.
  54073. */
  54074. get cameraToneMappingEnabled(): boolean;
  54075. /**
  54076. * Sets wether tonemapping is enabled or not
  54077. */
  54078. set cameraToneMappingEnabled(value: boolean);
  54079. /**
  54080. * The camera exposure used on this material.
  54081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54082. * This corresponds to a photographic exposure.
  54083. */
  54084. get cameraExposure(): number;
  54085. /**
  54086. * The camera exposure used on this material.
  54087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54088. * This corresponds to a photographic exposure.
  54089. */
  54090. set cameraExposure(value: number);
  54091. /**
  54092. * Gets The camera contrast used on this material.
  54093. */
  54094. get cameraContrast(): number;
  54095. /**
  54096. * Sets The camera contrast used on this material.
  54097. */
  54098. set cameraContrast(value: number);
  54099. /**
  54100. * Gets the Color Grading 2D Lookup Texture.
  54101. */
  54102. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54103. /**
  54104. * Sets the Color Grading 2D Lookup Texture.
  54105. */
  54106. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54107. /**
  54108. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54109. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54110. * 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;
  54111. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54112. */
  54113. get cameraColorCurves(): Nullable<ColorCurves>;
  54114. /**
  54115. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54116. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54117. * 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;
  54118. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54119. */
  54120. set cameraColorCurves(value: Nullable<ColorCurves>);
  54121. /**
  54122. * Instantiates a new PBRMaterial instance.
  54123. *
  54124. * @param name The material name
  54125. * @param scene The scene the material will be use in.
  54126. */
  54127. constructor(name: string, scene: Scene);
  54128. /**
  54129. * Returns the name of this material class.
  54130. */
  54131. getClassName(): string;
  54132. /**
  54133. * Makes a duplicate of the current material.
  54134. * @param name - name to use for the new material.
  54135. */
  54136. clone(name: string): PBRMaterial;
  54137. /**
  54138. * Serializes this PBR Material.
  54139. * @returns - An object with the serialized material.
  54140. */
  54141. serialize(): any;
  54142. /**
  54143. * Parses a PBR Material from a serialized object.
  54144. * @param source - Serialized object.
  54145. * @param scene - BJS scene instance.
  54146. * @param rootUrl - url for the scene object
  54147. * @returns - PBRMaterial
  54148. */
  54149. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54150. }
  54151. }
  54152. declare module "babylonjs/Misc/dds" {
  54153. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54154. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54155. import { Nullable } from "babylonjs/types";
  54156. import { Scene } from "babylonjs/scene";
  54157. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54158. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54159. /**
  54160. * Direct draw surface info
  54161. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54162. */
  54163. export interface DDSInfo {
  54164. /**
  54165. * Width of the texture
  54166. */
  54167. width: number;
  54168. /**
  54169. * Width of the texture
  54170. */
  54171. height: number;
  54172. /**
  54173. * Number of Mipmaps for the texture
  54174. * @see https://en.wikipedia.org/wiki/Mipmap
  54175. */
  54176. mipmapCount: number;
  54177. /**
  54178. * If the textures format is a known fourCC format
  54179. * @see https://www.fourcc.org/
  54180. */
  54181. isFourCC: boolean;
  54182. /**
  54183. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54184. */
  54185. isRGB: boolean;
  54186. /**
  54187. * If the texture is a lumincance format
  54188. */
  54189. isLuminance: boolean;
  54190. /**
  54191. * If this is a cube texture
  54192. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54193. */
  54194. isCube: boolean;
  54195. /**
  54196. * If the texture is a compressed format eg. FOURCC_DXT1
  54197. */
  54198. isCompressed: boolean;
  54199. /**
  54200. * The dxgiFormat of the texture
  54201. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54202. */
  54203. dxgiFormat: number;
  54204. /**
  54205. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54206. */
  54207. textureType: number;
  54208. /**
  54209. * Sphericle polynomial created for the dds texture
  54210. */
  54211. sphericalPolynomial?: SphericalPolynomial;
  54212. }
  54213. /**
  54214. * Class used to provide DDS decompression tools
  54215. */
  54216. export class DDSTools {
  54217. /**
  54218. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54219. */
  54220. static StoreLODInAlphaChannel: boolean;
  54221. /**
  54222. * Gets DDS information from an array buffer
  54223. * @param data defines the array buffer view to read data from
  54224. * @returns the DDS information
  54225. */
  54226. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54227. private static _FloatView;
  54228. private static _Int32View;
  54229. private static _ToHalfFloat;
  54230. private static _FromHalfFloat;
  54231. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54232. private static _GetHalfFloatRGBAArrayBuffer;
  54233. private static _GetFloatRGBAArrayBuffer;
  54234. private static _GetFloatAsUIntRGBAArrayBuffer;
  54235. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54236. private static _GetRGBAArrayBuffer;
  54237. private static _ExtractLongWordOrder;
  54238. private static _GetRGBArrayBuffer;
  54239. private static _GetLuminanceArrayBuffer;
  54240. /**
  54241. * Uploads DDS Levels to a Babylon Texture
  54242. * @hidden
  54243. */
  54244. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54245. }
  54246. module "babylonjs/Engines/thinEngine" {
  54247. interface ThinEngine {
  54248. /**
  54249. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54250. * @param rootUrl defines the url where the file to load is located
  54251. * @param scene defines the current scene
  54252. * @param lodScale defines scale to apply to the mip map selection
  54253. * @param lodOffset defines offset to apply to the mip map selection
  54254. * @param onLoad defines an optional callback raised when the texture is loaded
  54255. * @param onError defines an optional callback raised if there is an issue to load the texture
  54256. * @param format defines the format of the data
  54257. * @param forcedExtension defines the extension to use to pick the right loader
  54258. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54259. * @returns the cube texture as an InternalTexture
  54260. */
  54261. 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;
  54262. }
  54263. }
  54264. }
  54265. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54266. import { Nullable } from "babylonjs/types";
  54267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54268. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54269. /**
  54270. * Implementation of the DDS Texture Loader.
  54271. * @hidden
  54272. */
  54273. export class _DDSTextureLoader implements IInternalTextureLoader {
  54274. /**
  54275. * Defines wether the loader supports cascade loading the different faces.
  54276. */
  54277. readonly supportCascades: boolean;
  54278. /**
  54279. * This returns if the loader support the current file information.
  54280. * @param extension defines the file extension of the file being loaded
  54281. * @returns true if the loader can load the specified file
  54282. */
  54283. canLoad(extension: string): boolean;
  54284. /**
  54285. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54286. * @param data contains the texture data
  54287. * @param texture defines the BabylonJS internal texture
  54288. * @param createPolynomials will be true if polynomials have been requested
  54289. * @param onLoad defines the callback to trigger once the texture is ready
  54290. * @param onError defines the callback to trigger in case of error
  54291. */
  54292. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54293. /**
  54294. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54295. * @param data contains the texture data
  54296. * @param texture defines the BabylonJS internal texture
  54297. * @param callback defines the method to call once ready to upload
  54298. */
  54299. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54300. }
  54301. }
  54302. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54303. import { Nullable } from "babylonjs/types";
  54304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54305. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54306. /**
  54307. * Implementation of the ENV Texture Loader.
  54308. * @hidden
  54309. */
  54310. export class _ENVTextureLoader implements IInternalTextureLoader {
  54311. /**
  54312. * Defines wether the loader supports cascade loading the different faces.
  54313. */
  54314. readonly supportCascades: boolean;
  54315. /**
  54316. * This returns if the loader support the current file information.
  54317. * @param extension defines the file extension of the file being loaded
  54318. * @returns true if the loader can load the specified file
  54319. */
  54320. canLoad(extension: string): boolean;
  54321. /**
  54322. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54323. * @param data contains the texture data
  54324. * @param texture defines the BabylonJS internal texture
  54325. * @param createPolynomials will be true if polynomials have been requested
  54326. * @param onLoad defines the callback to trigger once the texture is ready
  54327. * @param onError defines the callback to trigger in case of error
  54328. */
  54329. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54330. /**
  54331. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54332. * @param data contains the texture data
  54333. * @param texture defines the BabylonJS internal texture
  54334. * @param callback defines the method to call once ready to upload
  54335. */
  54336. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54337. }
  54338. }
  54339. declare module "babylonjs/Misc/khronosTextureContainer" {
  54340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54341. /**
  54342. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54343. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54344. */
  54345. export class KhronosTextureContainer {
  54346. /** contents of the KTX container file */
  54347. data: ArrayBufferView;
  54348. private static HEADER_LEN;
  54349. private static COMPRESSED_2D;
  54350. private static COMPRESSED_3D;
  54351. private static TEX_2D;
  54352. private static TEX_3D;
  54353. /**
  54354. * Gets the openGL type
  54355. */
  54356. glType: number;
  54357. /**
  54358. * Gets the openGL type size
  54359. */
  54360. glTypeSize: number;
  54361. /**
  54362. * Gets the openGL format
  54363. */
  54364. glFormat: number;
  54365. /**
  54366. * Gets the openGL internal format
  54367. */
  54368. glInternalFormat: number;
  54369. /**
  54370. * Gets the base internal format
  54371. */
  54372. glBaseInternalFormat: number;
  54373. /**
  54374. * Gets image width in pixel
  54375. */
  54376. pixelWidth: number;
  54377. /**
  54378. * Gets image height in pixel
  54379. */
  54380. pixelHeight: number;
  54381. /**
  54382. * Gets image depth in pixels
  54383. */
  54384. pixelDepth: number;
  54385. /**
  54386. * Gets the number of array elements
  54387. */
  54388. numberOfArrayElements: number;
  54389. /**
  54390. * Gets the number of faces
  54391. */
  54392. numberOfFaces: number;
  54393. /**
  54394. * Gets the number of mipmap levels
  54395. */
  54396. numberOfMipmapLevels: number;
  54397. /**
  54398. * Gets the bytes of key value data
  54399. */
  54400. bytesOfKeyValueData: number;
  54401. /**
  54402. * Gets the load type
  54403. */
  54404. loadType: number;
  54405. /**
  54406. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54407. */
  54408. isInvalid: boolean;
  54409. /**
  54410. * Creates a new KhronosTextureContainer
  54411. * @param data contents of the KTX container file
  54412. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54413. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54414. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54415. */
  54416. constructor(
  54417. /** contents of the KTX container file */
  54418. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54419. /**
  54420. * Uploads KTX content to a Babylon Texture.
  54421. * It is assumed that the texture has already been created & is currently bound
  54422. * @hidden
  54423. */
  54424. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54425. private _upload2DCompressedLevels;
  54426. /**
  54427. * Checks if the given data starts with a KTX file identifier.
  54428. * @param data the data to check
  54429. * @returns true if the data is a KTX file or false otherwise
  54430. */
  54431. static IsValid(data: ArrayBufferView): boolean;
  54432. }
  54433. }
  54434. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54435. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54436. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54437. /**
  54438. * Class for loading KTX2 files
  54439. * !!! Experimental Extension Subject to Changes !!!
  54440. * @hidden
  54441. */
  54442. export class KhronosTextureContainer2 {
  54443. private static _ModulePromise;
  54444. private static _TranscodeFormat;
  54445. constructor(engine: ThinEngine);
  54446. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54447. private _determineTranscodeFormat;
  54448. /**
  54449. * Checks if the given data starts with a KTX2 file identifier.
  54450. * @param data the data to check
  54451. * @returns true if the data is a KTX2 file or false otherwise
  54452. */
  54453. static IsValid(data: ArrayBufferView): boolean;
  54454. }
  54455. }
  54456. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54457. import { Nullable } from "babylonjs/types";
  54458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54459. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54460. /**
  54461. * Implementation of the KTX Texture Loader.
  54462. * @hidden
  54463. */
  54464. export class _KTXTextureLoader implements IInternalTextureLoader {
  54465. /**
  54466. * Defines wether the loader supports cascade loading the different faces.
  54467. */
  54468. readonly supportCascades: boolean;
  54469. /**
  54470. * This returns if the loader support the current file information.
  54471. * @param extension defines the file extension of the file being loaded
  54472. * @returns true if the loader can load the specified file
  54473. */
  54474. canLoad(extension: string): boolean;
  54475. /**
  54476. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54477. * @param data contains the texture data
  54478. * @param texture defines the BabylonJS internal texture
  54479. * @param createPolynomials will be true if polynomials have been requested
  54480. * @param onLoad defines the callback to trigger once the texture is ready
  54481. * @param onError defines the callback to trigger in case of error
  54482. */
  54483. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54484. /**
  54485. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54486. * @param data contains the texture data
  54487. * @param texture defines the BabylonJS internal texture
  54488. * @param callback defines the method to call once ready to upload
  54489. */
  54490. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54491. }
  54492. }
  54493. declare module "babylonjs/Helpers/sceneHelpers" {
  54494. import { Nullable } from "babylonjs/types";
  54495. import { Mesh } from "babylonjs/Meshes/mesh";
  54496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54497. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54498. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54499. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54500. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54501. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54502. import "babylonjs/Meshes/Builders/boxBuilder";
  54503. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54504. /** @hidden */
  54505. export var _forceSceneHelpersToBundle: boolean;
  54506. module "babylonjs/scene" {
  54507. interface Scene {
  54508. /**
  54509. * Creates a default light for the scene.
  54510. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54511. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54512. */
  54513. createDefaultLight(replace?: boolean): void;
  54514. /**
  54515. * Creates a default camera for the scene.
  54516. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54517. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54518. * @param replace has default false, when true replaces the active camera in the scene
  54519. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54520. */
  54521. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54522. /**
  54523. * Creates a default camera and a default light.
  54524. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54525. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54526. * @param replace has the default false, when true replaces the active camera/light in the scene
  54527. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54528. */
  54529. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54530. /**
  54531. * Creates a new sky box
  54532. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54533. * @param environmentTexture defines the texture to use as environment texture
  54534. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54535. * @param scale defines the overall scale of the skybox
  54536. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54537. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54538. * @returns a new mesh holding the sky box
  54539. */
  54540. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54541. /**
  54542. * Creates a new environment
  54543. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54544. * @param options defines the options you can use to configure the environment
  54545. * @returns the new EnvironmentHelper
  54546. */
  54547. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54548. /**
  54549. * Creates a new VREXperienceHelper
  54550. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54551. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54552. * @returns a new VREXperienceHelper
  54553. */
  54554. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54555. /**
  54556. * Creates a new WebXRDefaultExperience
  54557. * @see http://doc.babylonjs.com/how_to/webxr
  54558. * @param options experience options
  54559. * @returns a promise for a new WebXRDefaultExperience
  54560. */
  54561. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54562. }
  54563. }
  54564. }
  54565. declare module "babylonjs/Helpers/videoDome" {
  54566. import { Scene } from "babylonjs/scene";
  54567. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54568. import { Mesh } from "babylonjs/Meshes/mesh";
  54569. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54570. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54571. import "babylonjs/Meshes/Builders/sphereBuilder";
  54572. /**
  54573. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54574. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54575. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54576. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54577. */
  54578. export class VideoDome extends TransformNode {
  54579. /**
  54580. * Define the video source as a Monoscopic panoramic 360 video.
  54581. */
  54582. static readonly MODE_MONOSCOPIC: number;
  54583. /**
  54584. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54585. */
  54586. static readonly MODE_TOPBOTTOM: number;
  54587. /**
  54588. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54589. */
  54590. static readonly MODE_SIDEBYSIDE: number;
  54591. private _halfDome;
  54592. private _useDirectMapping;
  54593. /**
  54594. * The video texture being displayed on the sphere
  54595. */
  54596. protected _videoTexture: VideoTexture;
  54597. /**
  54598. * Gets the video texture being displayed on the sphere
  54599. */
  54600. get videoTexture(): VideoTexture;
  54601. /**
  54602. * The skybox material
  54603. */
  54604. protected _material: BackgroundMaterial;
  54605. /**
  54606. * The surface used for the skybox
  54607. */
  54608. protected _mesh: Mesh;
  54609. /**
  54610. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54611. */
  54612. private _halfDomeMask;
  54613. /**
  54614. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54615. * Also see the options.resolution property.
  54616. */
  54617. get fovMultiplier(): number;
  54618. set fovMultiplier(value: number);
  54619. private _videoMode;
  54620. /**
  54621. * Gets or set the current video mode for the video. It can be:
  54622. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54623. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54624. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54625. */
  54626. get videoMode(): number;
  54627. set videoMode(value: number);
  54628. /**
  54629. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54630. *
  54631. */
  54632. get halfDome(): boolean;
  54633. /**
  54634. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54635. */
  54636. set halfDome(enabled: boolean);
  54637. /**
  54638. * Oberserver used in Stereoscopic VR Mode.
  54639. */
  54640. private _onBeforeCameraRenderObserver;
  54641. /**
  54642. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54643. * @param name Element's name, child elements will append suffixes for their own names.
  54644. * @param urlsOrVideo defines the url(s) or the video element to use
  54645. * @param options An object containing optional or exposed sub element properties
  54646. */
  54647. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54648. resolution?: number;
  54649. clickToPlay?: boolean;
  54650. autoPlay?: boolean;
  54651. loop?: boolean;
  54652. size?: number;
  54653. poster?: string;
  54654. faceForward?: boolean;
  54655. useDirectMapping?: boolean;
  54656. halfDomeMode?: boolean;
  54657. }, scene: Scene);
  54658. private _changeVideoMode;
  54659. /**
  54660. * Releases resources associated with this node.
  54661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54663. */
  54664. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54665. }
  54666. }
  54667. declare module "babylonjs/Helpers/index" {
  54668. export * from "babylonjs/Helpers/environmentHelper";
  54669. export * from "babylonjs/Helpers/photoDome";
  54670. export * from "babylonjs/Helpers/sceneHelpers";
  54671. export * from "babylonjs/Helpers/videoDome";
  54672. }
  54673. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54674. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54675. import { IDisposable } from "babylonjs/scene";
  54676. import { Engine } from "babylonjs/Engines/engine";
  54677. /**
  54678. * This class can be used to get instrumentation data from a Babylon engine
  54679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54680. */
  54681. export class EngineInstrumentation implements IDisposable {
  54682. /**
  54683. * Define the instrumented engine.
  54684. */
  54685. engine: Engine;
  54686. private _captureGPUFrameTime;
  54687. private _gpuFrameTimeToken;
  54688. private _gpuFrameTime;
  54689. private _captureShaderCompilationTime;
  54690. private _shaderCompilationTime;
  54691. private _onBeginFrameObserver;
  54692. private _onEndFrameObserver;
  54693. private _onBeforeShaderCompilationObserver;
  54694. private _onAfterShaderCompilationObserver;
  54695. /**
  54696. * Gets the perf counter used for GPU frame time
  54697. */
  54698. get gpuFrameTimeCounter(): PerfCounter;
  54699. /**
  54700. * Gets the GPU frame time capture status
  54701. */
  54702. get captureGPUFrameTime(): boolean;
  54703. /**
  54704. * Enable or disable the GPU frame time capture
  54705. */
  54706. set captureGPUFrameTime(value: boolean);
  54707. /**
  54708. * Gets the perf counter used for shader compilation time
  54709. */
  54710. get shaderCompilationTimeCounter(): PerfCounter;
  54711. /**
  54712. * Gets the shader compilation time capture status
  54713. */
  54714. get captureShaderCompilationTime(): boolean;
  54715. /**
  54716. * Enable or disable the shader compilation time capture
  54717. */
  54718. set captureShaderCompilationTime(value: boolean);
  54719. /**
  54720. * Instantiates a new engine instrumentation.
  54721. * This class can be used to get instrumentation data from a Babylon engine
  54722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54723. * @param engine Defines the engine to instrument
  54724. */
  54725. constructor(
  54726. /**
  54727. * Define the instrumented engine.
  54728. */
  54729. engine: Engine);
  54730. /**
  54731. * Dispose and release associated resources.
  54732. */
  54733. dispose(): void;
  54734. }
  54735. }
  54736. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54737. import { Scene, IDisposable } from "babylonjs/scene";
  54738. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54739. /**
  54740. * This class can be used to get instrumentation data from a Babylon engine
  54741. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54742. */
  54743. export class SceneInstrumentation implements IDisposable {
  54744. /**
  54745. * Defines the scene to instrument
  54746. */
  54747. scene: Scene;
  54748. private _captureActiveMeshesEvaluationTime;
  54749. private _activeMeshesEvaluationTime;
  54750. private _captureRenderTargetsRenderTime;
  54751. private _renderTargetsRenderTime;
  54752. private _captureFrameTime;
  54753. private _frameTime;
  54754. private _captureRenderTime;
  54755. private _renderTime;
  54756. private _captureInterFrameTime;
  54757. private _interFrameTime;
  54758. private _captureParticlesRenderTime;
  54759. private _particlesRenderTime;
  54760. private _captureSpritesRenderTime;
  54761. private _spritesRenderTime;
  54762. private _capturePhysicsTime;
  54763. private _physicsTime;
  54764. private _captureAnimationsTime;
  54765. private _animationsTime;
  54766. private _captureCameraRenderTime;
  54767. private _cameraRenderTime;
  54768. private _onBeforeActiveMeshesEvaluationObserver;
  54769. private _onAfterActiveMeshesEvaluationObserver;
  54770. private _onBeforeRenderTargetsRenderObserver;
  54771. private _onAfterRenderTargetsRenderObserver;
  54772. private _onAfterRenderObserver;
  54773. private _onBeforeDrawPhaseObserver;
  54774. private _onAfterDrawPhaseObserver;
  54775. private _onBeforeAnimationsObserver;
  54776. private _onBeforeParticlesRenderingObserver;
  54777. private _onAfterParticlesRenderingObserver;
  54778. private _onBeforeSpritesRenderingObserver;
  54779. private _onAfterSpritesRenderingObserver;
  54780. private _onBeforePhysicsObserver;
  54781. private _onAfterPhysicsObserver;
  54782. private _onAfterAnimationsObserver;
  54783. private _onBeforeCameraRenderObserver;
  54784. private _onAfterCameraRenderObserver;
  54785. /**
  54786. * Gets the perf counter used for active meshes evaluation time
  54787. */
  54788. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54789. /**
  54790. * Gets the active meshes evaluation time capture status
  54791. */
  54792. get captureActiveMeshesEvaluationTime(): boolean;
  54793. /**
  54794. * Enable or disable the active meshes evaluation time capture
  54795. */
  54796. set captureActiveMeshesEvaluationTime(value: boolean);
  54797. /**
  54798. * Gets the perf counter used for render targets render time
  54799. */
  54800. get renderTargetsRenderTimeCounter(): PerfCounter;
  54801. /**
  54802. * Gets the render targets render time capture status
  54803. */
  54804. get captureRenderTargetsRenderTime(): boolean;
  54805. /**
  54806. * Enable or disable the render targets render time capture
  54807. */
  54808. set captureRenderTargetsRenderTime(value: boolean);
  54809. /**
  54810. * Gets the perf counter used for particles render time
  54811. */
  54812. get particlesRenderTimeCounter(): PerfCounter;
  54813. /**
  54814. * Gets the particles render time capture status
  54815. */
  54816. get captureParticlesRenderTime(): boolean;
  54817. /**
  54818. * Enable or disable the particles render time capture
  54819. */
  54820. set captureParticlesRenderTime(value: boolean);
  54821. /**
  54822. * Gets the perf counter used for sprites render time
  54823. */
  54824. get spritesRenderTimeCounter(): PerfCounter;
  54825. /**
  54826. * Gets the sprites render time capture status
  54827. */
  54828. get captureSpritesRenderTime(): boolean;
  54829. /**
  54830. * Enable or disable the sprites render time capture
  54831. */
  54832. set captureSpritesRenderTime(value: boolean);
  54833. /**
  54834. * Gets the perf counter used for physics time
  54835. */
  54836. get physicsTimeCounter(): PerfCounter;
  54837. /**
  54838. * Gets the physics time capture status
  54839. */
  54840. get capturePhysicsTime(): boolean;
  54841. /**
  54842. * Enable or disable the physics time capture
  54843. */
  54844. set capturePhysicsTime(value: boolean);
  54845. /**
  54846. * Gets the perf counter used for animations time
  54847. */
  54848. get animationsTimeCounter(): PerfCounter;
  54849. /**
  54850. * Gets the animations time capture status
  54851. */
  54852. get captureAnimationsTime(): boolean;
  54853. /**
  54854. * Enable or disable the animations time capture
  54855. */
  54856. set captureAnimationsTime(value: boolean);
  54857. /**
  54858. * Gets the perf counter used for frame time capture
  54859. */
  54860. get frameTimeCounter(): PerfCounter;
  54861. /**
  54862. * Gets the frame time capture status
  54863. */
  54864. get captureFrameTime(): boolean;
  54865. /**
  54866. * Enable or disable the frame time capture
  54867. */
  54868. set captureFrameTime(value: boolean);
  54869. /**
  54870. * Gets the perf counter used for inter-frames time capture
  54871. */
  54872. get interFrameTimeCounter(): PerfCounter;
  54873. /**
  54874. * Gets the inter-frames time capture status
  54875. */
  54876. get captureInterFrameTime(): boolean;
  54877. /**
  54878. * Enable or disable the inter-frames time capture
  54879. */
  54880. set captureInterFrameTime(value: boolean);
  54881. /**
  54882. * Gets the perf counter used for render time capture
  54883. */
  54884. get renderTimeCounter(): PerfCounter;
  54885. /**
  54886. * Gets the render time capture status
  54887. */
  54888. get captureRenderTime(): boolean;
  54889. /**
  54890. * Enable or disable the render time capture
  54891. */
  54892. set captureRenderTime(value: boolean);
  54893. /**
  54894. * Gets the perf counter used for camera render time capture
  54895. */
  54896. get cameraRenderTimeCounter(): PerfCounter;
  54897. /**
  54898. * Gets the camera render time capture status
  54899. */
  54900. get captureCameraRenderTime(): boolean;
  54901. /**
  54902. * Enable or disable the camera render time capture
  54903. */
  54904. set captureCameraRenderTime(value: boolean);
  54905. /**
  54906. * Gets the perf counter used for draw calls
  54907. */
  54908. get drawCallsCounter(): PerfCounter;
  54909. /**
  54910. * Instantiates a new scene instrumentation.
  54911. * This class can be used to get instrumentation data from a Babylon engine
  54912. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54913. * @param scene Defines the scene to instrument
  54914. */
  54915. constructor(
  54916. /**
  54917. * Defines the scene to instrument
  54918. */
  54919. scene: Scene);
  54920. /**
  54921. * Dispose and release associated resources.
  54922. */
  54923. dispose(): void;
  54924. }
  54925. }
  54926. declare module "babylonjs/Instrumentation/index" {
  54927. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54928. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54929. export * from "babylonjs/Instrumentation/timeToken";
  54930. }
  54931. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54932. /** @hidden */
  54933. export var glowMapGenerationPixelShader: {
  54934. name: string;
  54935. shader: string;
  54936. };
  54937. }
  54938. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54939. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54941. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54942. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54944. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54945. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54946. /** @hidden */
  54947. export var glowMapGenerationVertexShader: {
  54948. name: string;
  54949. shader: string;
  54950. };
  54951. }
  54952. declare module "babylonjs/Layers/effectLayer" {
  54953. import { Observable } from "babylonjs/Misc/observable";
  54954. import { Nullable } from "babylonjs/types";
  54955. import { Camera } from "babylonjs/Cameras/camera";
  54956. import { Scene } from "babylonjs/scene";
  54957. import { ISize } from "babylonjs/Maths/math.size";
  54958. import { Color4 } from "babylonjs/Maths/math.color";
  54959. import { Engine } from "babylonjs/Engines/engine";
  54960. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54962. import { Mesh } from "babylonjs/Meshes/mesh";
  54963. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54966. import { Effect } from "babylonjs/Materials/effect";
  54967. import { Material } from "babylonjs/Materials/material";
  54968. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54969. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54970. /**
  54971. * Effect layer options. This helps customizing the behaviour
  54972. * of the effect layer.
  54973. */
  54974. export interface IEffectLayerOptions {
  54975. /**
  54976. * Multiplication factor apply to the canvas size to compute the render target size
  54977. * used to generated the objects (the smaller the faster).
  54978. */
  54979. mainTextureRatio: number;
  54980. /**
  54981. * Enforces a fixed size texture to ensure effect stability across devices.
  54982. */
  54983. mainTextureFixedSize?: number;
  54984. /**
  54985. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54986. */
  54987. alphaBlendingMode: number;
  54988. /**
  54989. * The camera attached to the layer.
  54990. */
  54991. camera: Nullable<Camera>;
  54992. /**
  54993. * The rendering group to draw the layer in.
  54994. */
  54995. renderingGroupId: number;
  54996. }
  54997. /**
  54998. * The effect layer Helps adding post process effect blended with the main pass.
  54999. *
  55000. * This can be for instance use to generate glow or higlight effects on the scene.
  55001. *
  55002. * The effect layer class can not be used directly and is intented to inherited from to be
  55003. * customized per effects.
  55004. */
  55005. export abstract class EffectLayer {
  55006. private _vertexBuffers;
  55007. private _indexBuffer;
  55008. private _cachedDefines;
  55009. private _effectLayerMapGenerationEffect;
  55010. private _effectLayerOptions;
  55011. private _mergeEffect;
  55012. protected _scene: Scene;
  55013. protected _engine: Engine;
  55014. protected _maxSize: number;
  55015. protected _mainTextureDesiredSize: ISize;
  55016. protected _mainTexture: RenderTargetTexture;
  55017. protected _shouldRender: boolean;
  55018. protected _postProcesses: PostProcess[];
  55019. protected _textures: BaseTexture[];
  55020. protected _emissiveTextureAndColor: {
  55021. texture: Nullable<BaseTexture>;
  55022. color: Color4;
  55023. };
  55024. /**
  55025. * The name of the layer
  55026. */
  55027. name: string;
  55028. /**
  55029. * The clear color of the texture used to generate the glow map.
  55030. */
  55031. neutralColor: Color4;
  55032. /**
  55033. * Specifies whether the highlight layer is enabled or not.
  55034. */
  55035. isEnabled: boolean;
  55036. /**
  55037. * Gets the camera attached to the layer.
  55038. */
  55039. get camera(): Nullable<Camera>;
  55040. /**
  55041. * Gets the rendering group id the layer should render in.
  55042. */
  55043. get renderingGroupId(): number;
  55044. set renderingGroupId(renderingGroupId: number);
  55045. /**
  55046. * An event triggered when the effect layer has been disposed.
  55047. */
  55048. onDisposeObservable: Observable<EffectLayer>;
  55049. /**
  55050. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55051. */
  55052. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55053. /**
  55054. * An event triggered when the generated texture is being merged in the scene.
  55055. */
  55056. onBeforeComposeObservable: Observable<EffectLayer>;
  55057. /**
  55058. * An event triggered when the mesh is rendered into the effect render target.
  55059. */
  55060. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55061. /**
  55062. * An event triggered after the mesh has been rendered into the effect render target.
  55063. */
  55064. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55065. /**
  55066. * An event triggered when the generated texture has been merged in the scene.
  55067. */
  55068. onAfterComposeObservable: Observable<EffectLayer>;
  55069. /**
  55070. * An event triggered when the efffect layer changes its size.
  55071. */
  55072. onSizeChangedObservable: Observable<EffectLayer>;
  55073. /** @hidden */
  55074. static _SceneComponentInitialization: (scene: Scene) => void;
  55075. /**
  55076. * Instantiates a new effect Layer and references it in the scene.
  55077. * @param name The name of the layer
  55078. * @param scene The scene to use the layer in
  55079. */
  55080. constructor(
  55081. /** The Friendly of the effect in the scene */
  55082. name: string, scene: Scene);
  55083. /**
  55084. * Get the effect name of the layer.
  55085. * @return The effect name
  55086. */
  55087. abstract getEffectName(): string;
  55088. /**
  55089. * Checks for the readiness of the element composing the layer.
  55090. * @param subMesh the mesh to check for
  55091. * @param useInstances specify whether or not to use instances to render the mesh
  55092. * @return true if ready otherwise, false
  55093. */
  55094. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55095. /**
  55096. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55097. * @returns true if the effect requires stencil during the main canvas render pass.
  55098. */
  55099. abstract needStencil(): boolean;
  55100. /**
  55101. * Create the merge effect. This is the shader use to blit the information back
  55102. * to the main canvas at the end of the scene rendering.
  55103. * @returns The effect containing the shader used to merge the effect on the main canvas
  55104. */
  55105. protected abstract _createMergeEffect(): Effect;
  55106. /**
  55107. * Creates the render target textures and post processes used in the effect layer.
  55108. */
  55109. protected abstract _createTextureAndPostProcesses(): void;
  55110. /**
  55111. * Implementation specific of rendering the generating effect on the main canvas.
  55112. * @param effect The effect used to render through
  55113. */
  55114. protected abstract _internalRender(effect: Effect): void;
  55115. /**
  55116. * Sets the required values for both the emissive texture and and the main color.
  55117. */
  55118. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55119. /**
  55120. * Free any resources and references associated to a mesh.
  55121. * Internal use
  55122. * @param mesh The mesh to free.
  55123. */
  55124. abstract _disposeMesh(mesh: Mesh): void;
  55125. /**
  55126. * Serializes this layer (Glow or Highlight for example)
  55127. * @returns a serialized layer object
  55128. */
  55129. abstract serialize?(): any;
  55130. /**
  55131. * Initializes the effect layer with the required options.
  55132. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55133. */
  55134. protected _init(options: Partial<IEffectLayerOptions>): void;
  55135. /**
  55136. * Generates the index buffer of the full screen quad blending to the main canvas.
  55137. */
  55138. private _generateIndexBuffer;
  55139. /**
  55140. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55141. */
  55142. private _generateVertexBuffer;
  55143. /**
  55144. * Sets the main texture desired size which is the closest power of two
  55145. * of the engine canvas size.
  55146. */
  55147. private _setMainTextureSize;
  55148. /**
  55149. * Creates the main texture for the effect layer.
  55150. */
  55151. protected _createMainTexture(): void;
  55152. /**
  55153. * Adds specific effects defines.
  55154. * @param defines The defines to add specifics to.
  55155. */
  55156. protected _addCustomEffectDefines(defines: string[]): void;
  55157. /**
  55158. * Checks for the readiness of the element composing the layer.
  55159. * @param subMesh the mesh to check for
  55160. * @param useInstances specify whether or not to use instances to render the mesh
  55161. * @param emissiveTexture the associated emissive texture used to generate the glow
  55162. * @return true if ready otherwise, false
  55163. */
  55164. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55165. /**
  55166. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55167. */
  55168. render(): void;
  55169. /**
  55170. * Determine if a given mesh will be used in the current effect.
  55171. * @param mesh mesh to test
  55172. * @returns true if the mesh will be used
  55173. */
  55174. hasMesh(mesh: AbstractMesh): boolean;
  55175. /**
  55176. * Returns true if the layer contains information to display, otherwise false.
  55177. * @returns true if the glow layer should be rendered
  55178. */
  55179. shouldRender(): boolean;
  55180. /**
  55181. * Returns true if the mesh should render, otherwise false.
  55182. * @param mesh The mesh to render
  55183. * @returns true if it should render otherwise false
  55184. */
  55185. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55186. /**
  55187. * Returns true if the mesh can be rendered, otherwise false.
  55188. * @param mesh The mesh to render
  55189. * @param material The material used on the mesh
  55190. * @returns true if it can be rendered otherwise false
  55191. */
  55192. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55193. /**
  55194. * Returns true if the mesh should render, otherwise false.
  55195. * @param mesh The mesh to render
  55196. * @returns true if it should render otherwise false
  55197. */
  55198. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55199. /**
  55200. * Renders the submesh passed in parameter to the generation map.
  55201. */
  55202. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55203. /**
  55204. * Defines whether the current material of the mesh should be use to render the effect.
  55205. * @param mesh defines the current mesh to render
  55206. */
  55207. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55208. /**
  55209. * Rebuild the required buffers.
  55210. * @hidden Internal use only.
  55211. */
  55212. _rebuild(): void;
  55213. /**
  55214. * Dispose only the render target textures and post process.
  55215. */
  55216. private _disposeTextureAndPostProcesses;
  55217. /**
  55218. * Dispose the highlight layer and free resources.
  55219. */
  55220. dispose(): void;
  55221. /**
  55222. * Gets the class name of the effect layer
  55223. * @returns the string with the class name of the effect layer
  55224. */
  55225. getClassName(): string;
  55226. /**
  55227. * Creates an effect layer from parsed effect layer data
  55228. * @param parsedEffectLayer defines effect layer data
  55229. * @param scene defines the current scene
  55230. * @param rootUrl defines the root URL containing the effect layer information
  55231. * @returns a parsed effect Layer
  55232. */
  55233. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55234. }
  55235. }
  55236. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55237. import { Scene } from "babylonjs/scene";
  55238. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55239. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55240. import { AbstractScene } from "babylonjs/abstractScene";
  55241. module "babylonjs/abstractScene" {
  55242. interface AbstractScene {
  55243. /**
  55244. * The list of effect layers (highlights/glow) added to the scene
  55245. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55246. * @see http://doc.babylonjs.com/how_to/glow_layer
  55247. */
  55248. effectLayers: Array<EffectLayer>;
  55249. /**
  55250. * Removes the given effect layer from this scene.
  55251. * @param toRemove defines the effect layer to remove
  55252. * @returns the index of the removed effect layer
  55253. */
  55254. removeEffectLayer(toRemove: EffectLayer): number;
  55255. /**
  55256. * Adds the given effect layer to this scene
  55257. * @param newEffectLayer defines the effect layer to add
  55258. */
  55259. addEffectLayer(newEffectLayer: EffectLayer): void;
  55260. }
  55261. }
  55262. /**
  55263. * Defines the layer scene component responsible to manage any effect layers
  55264. * in a given scene.
  55265. */
  55266. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55267. /**
  55268. * The component name helpfull to identify the component in the list of scene components.
  55269. */
  55270. readonly name: string;
  55271. /**
  55272. * The scene the component belongs to.
  55273. */
  55274. scene: Scene;
  55275. private _engine;
  55276. private _renderEffects;
  55277. private _needStencil;
  55278. private _previousStencilState;
  55279. /**
  55280. * Creates a new instance of the component for the given scene
  55281. * @param scene Defines the scene to register the component in
  55282. */
  55283. constructor(scene: Scene);
  55284. /**
  55285. * Registers the component in a given scene
  55286. */
  55287. register(): void;
  55288. /**
  55289. * Rebuilds the elements related to this component in case of
  55290. * context lost for instance.
  55291. */
  55292. rebuild(): void;
  55293. /**
  55294. * Serializes the component data to the specified json object
  55295. * @param serializationObject The object to serialize to
  55296. */
  55297. serialize(serializationObject: any): void;
  55298. /**
  55299. * Adds all the elements from the container to the scene
  55300. * @param container the container holding the elements
  55301. */
  55302. addFromContainer(container: AbstractScene): void;
  55303. /**
  55304. * Removes all the elements in the container from the scene
  55305. * @param container contains the elements to remove
  55306. * @param dispose if the removed element should be disposed (default: false)
  55307. */
  55308. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55309. /**
  55310. * Disposes the component and the associated ressources.
  55311. */
  55312. dispose(): void;
  55313. private _isReadyForMesh;
  55314. private _renderMainTexture;
  55315. private _setStencil;
  55316. private _setStencilBack;
  55317. private _draw;
  55318. private _drawCamera;
  55319. private _drawRenderingGroup;
  55320. }
  55321. }
  55322. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55323. /** @hidden */
  55324. export var glowMapMergePixelShader: {
  55325. name: string;
  55326. shader: string;
  55327. };
  55328. }
  55329. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55330. /** @hidden */
  55331. export var glowMapMergeVertexShader: {
  55332. name: string;
  55333. shader: string;
  55334. };
  55335. }
  55336. declare module "babylonjs/Layers/glowLayer" {
  55337. import { Nullable } from "babylonjs/types";
  55338. import { Camera } from "babylonjs/Cameras/camera";
  55339. import { Scene } from "babylonjs/scene";
  55340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55342. import { Mesh } from "babylonjs/Meshes/mesh";
  55343. import { Texture } from "babylonjs/Materials/Textures/texture";
  55344. import { Effect } from "babylonjs/Materials/effect";
  55345. import { Material } from "babylonjs/Materials/material";
  55346. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55347. import { Color4 } from "babylonjs/Maths/math.color";
  55348. import "babylonjs/Shaders/glowMapMerge.fragment";
  55349. import "babylonjs/Shaders/glowMapMerge.vertex";
  55350. import "babylonjs/Layers/effectLayerSceneComponent";
  55351. module "babylonjs/abstractScene" {
  55352. interface AbstractScene {
  55353. /**
  55354. * Return a the first highlight layer of the scene with a given name.
  55355. * @param name The name of the highlight layer to look for.
  55356. * @return The highlight layer if found otherwise null.
  55357. */
  55358. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55359. }
  55360. }
  55361. /**
  55362. * Glow layer options. This helps customizing the behaviour
  55363. * of the glow layer.
  55364. */
  55365. export interface IGlowLayerOptions {
  55366. /**
  55367. * Multiplication factor apply to the canvas size to compute the render target size
  55368. * used to generated the glowing objects (the smaller the faster).
  55369. */
  55370. mainTextureRatio: number;
  55371. /**
  55372. * Enforces a fixed size texture to ensure resize independant blur.
  55373. */
  55374. mainTextureFixedSize?: number;
  55375. /**
  55376. * How big is the kernel of the blur texture.
  55377. */
  55378. blurKernelSize: number;
  55379. /**
  55380. * The camera attached to the layer.
  55381. */
  55382. camera: Nullable<Camera>;
  55383. /**
  55384. * Enable MSAA by chosing the number of samples.
  55385. */
  55386. mainTextureSamples?: number;
  55387. /**
  55388. * The rendering group to draw the layer in.
  55389. */
  55390. renderingGroupId: number;
  55391. }
  55392. /**
  55393. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55394. *
  55395. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55396. *
  55397. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55398. */
  55399. export class GlowLayer extends EffectLayer {
  55400. /**
  55401. * Effect Name of the layer.
  55402. */
  55403. static readonly EffectName: string;
  55404. /**
  55405. * The default blur kernel size used for the glow.
  55406. */
  55407. static DefaultBlurKernelSize: number;
  55408. /**
  55409. * The default texture size ratio used for the glow.
  55410. */
  55411. static DefaultTextureRatio: number;
  55412. /**
  55413. * Sets the kernel size of the blur.
  55414. */
  55415. set blurKernelSize(value: number);
  55416. /**
  55417. * Gets the kernel size of the blur.
  55418. */
  55419. get blurKernelSize(): number;
  55420. /**
  55421. * Sets the glow intensity.
  55422. */
  55423. set intensity(value: number);
  55424. /**
  55425. * Gets the glow intensity.
  55426. */
  55427. get intensity(): number;
  55428. private _options;
  55429. private _intensity;
  55430. private _horizontalBlurPostprocess1;
  55431. private _verticalBlurPostprocess1;
  55432. private _horizontalBlurPostprocess2;
  55433. private _verticalBlurPostprocess2;
  55434. private _blurTexture1;
  55435. private _blurTexture2;
  55436. private _postProcesses1;
  55437. private _postProcesses2;
  55438. private _includedOnlyMeshes;
  55439. private _excludedMeshes;
  55440. private _meshesUsingTheirOwnMaterials;
  55441. /**
  55442. * Callback used to let the user override the color selection on a per mesh basis
  55443. */
  55444. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55445. /**
  55446. * Callback used to let the user override the texture selection on a per mesh basis
  55447. */
  55448. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55449. /**
  55450. * Instantiates a new glow Layer and references it to the scene.
  55451. * @param name The name of the layer
  55452. * @param scene The scene to use the layer in
  55453. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55454. */
  55455. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55456. /**
  55457. * Get the effect name of the layer.
  55458. * @return The effect name
  55459. */
  55460. getEffectName(): string;
  55461. /**
  55462. * Create the merge effect. This is the shader use to blit the information back
  55463. * to the main canvas at the end of the scene rendering.
  55464. */
  55465. protected _createMergeEffect(): Effect;
  55466. /**
  55467. * Creates the render target textures and post processes used in the glow layer.
  55468. */
  55469. protected _createTextureAndPostProcesses(): void;
  55470. /**
  55471. * Checks for the readiness of the element composing the layer.
  55472. * @param subMesh the mesh to check for
  55473. * @param useInstances specify wether or not to use instances to render the mesh
  55474. * @param emissiveTexture the associated emissive texture used to generate the glow
  55475. * @return true if ready otherwise, false
  55476. */
  55477. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55478. /**
  55479. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55480. */
  55481. needStencil(): boolean;
  55482. /**
  55483. * Returns true if the mesh can be rendered, otherwise false.
  55484. * @param mesh The mesh to render
  55485. * @param material The material used on the mesh
  55486. * @returns true if it can be rendered otherwise false
  55487. */
  55488. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55489. /**
  55490. * Implementation specific of rendering the generating effect on the main canvas.
  55491. * @param effect The effect used to render through
  55492. */
  55493. protected _internalRender(effect: Effect): void;
  55494. /**
  55495. * Sets the required values for both the emissive texture and and the main color.
  55496. */
  55497. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55498. /**
  55499. * Returns true if the mesh should render, otherwise false.
  55500. * @param mesh The mesh to render
  55501. * @returns true if it should render otherwise false
  55502. */
  55503. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55504. /**
  55505. * Adds specific effects defines.
  55506. * @param defines The defines to add specifics to.
  55507. */
  55508. protected _addCustomEffectDefines(defines: string[]): void;
  55509. /**
  55510. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55511. * @param mesh The mesh to exclude from the glow layer
  55512. */
  55513. addExcludedMesh(mesh: Mesh): void;
  55514. /**
  55515. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55516. * @param mesh The mesh to remove
  55517. */
  55518. removeExcludedMesh(mesh: Mesh): void;
  55519. /**
  55520. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55521. * @param mesh The mesh to include in the glow layer
  55522. */
  55523. addIncludedOnlyMesh(mesh: Mesh): void;
  55524. /**
  55525. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55526. * @param mesh The mesh to remove
  55527. */
  55528. removeIncludedOnlyMesh(mesh: Mesh): void;
  55529. /**
  55530. * Determine if a given mesh will be used in the glow layer
  55531. * @param mesh The mesh to test
  55532. * @returns true if the mesh will be highlighted by the current glow layer
  55533. */
  55534. hasMesh(mesh: AbstractMesh): boolean;
  55535. /**
  55536. * Defines whether the current material of the mesh should be use to render the effect.
  55537. * @param mesh defines the current mesh to render
  55538. */
  55539. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55540. /**
  55541. * Add a mesh to be rendered through its own material and not with emissive only.
  55542. * @param mesh The mesh for which we need to use its material
  55543. */
  55544. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55545. /**
  55546. * Remove a mesh from being rendered through its own material and not with emissive only.
  55547. * @param mesh The mesh for which we need to not use its material
  55548. */
  55549. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55550. /**
  55551. * Free any resources and references associated to a mesh.
  55552. * Internal use
  55553. * @param mesh The mesh to free.
  55554. * @hidden
  55555. */
  55556. _disposeMesh(mesh: Mesh): void;
  55557. /**
  55558. * Gets the class name of the effect layer
  55559. * @returns the string with the class name of the effect layer
  55560. */
  55561. getClassName(): string;
  55562. /**
  55563. * Serializes this glow layer
  55564. * @returns a serialized glow layer object
  55565. */
  55566. serialize(): any;
  55567. /**
  55568. * Creates a Glow Layer from parsed glow layer data
  55569. * @param parsedGlowLayer defines glow layer data
  55570. * @param scene defines the current scene
  55571. * @param rootUrl defines the root URL containing the glow layer information
  55572. * @returns a parsed Glow Layer
  55573. */
  55574. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55575. }
  55576. }
  55577. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55578. /** @hidden */
  55579. export var glowBlurPostProcessPixelShader: {
  55580. name: string;
  55581. shader: string;
  55582. };
  55583. }
  55584. declare module "babylonjs/Layers/highlightLayer" {
  55585. import { Observable } from "babylonjs/Misc/observable";
  55586. import { Nullable } from "babylonjs/types";
  55587. import { Camera } from "babylonjs/Cameras/camera";
  55588. import { Scene } from "babylonjs/scene";
  55589. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55591. import { Mesh } from "babylonjs/Meshes/mesh";
  55592. import { Effect } from "babylonjs/Materials/effect";
  55593. import { Material } from "babylonjs/Materials/material";
  55594. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55595. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55596. import "babylonjs/Shaders/glowMapMerge.fragment";
  55597. import "babylonjs/Shaders/glowMapMerge.vertex";
  55598. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55599. module "babylonjs/abstractScene" {
  55600. interface AbstractScene {
  55601. /**
  55602. * Return a the first highlight layer of the scene with a given name.
  55603. * @param name The name of the highlight layer to look for.
  55604. * @return The highlight layer if found otherwise null.
  55605. */
  55606. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55607. }
  55608. }
  55609. /**
  55610. * Highlight layer options. This helps customizing the behaviour
  55611. * of the highlight layer.
  55612. */
  55613. export interface IHighlightLayerOptions {
  55614. /**
  55615. * Multiplication factor apply to the canvas size to compute the render target size
  55616. * used to generated the glowing objects (the smaller the faster).
  55617. */
  55618. mainTextureRatio: number;
  55619. /**
  55620. * Enforces a fixed size texture to ensure resize independant blur.
  55621. */
  55622. mainTextureFixedSize?: number;
  55623. /**
  55624. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55625. * of the picture to blur (the smaller the faster).
  55626. */
  55627. blurTextureSizeRatio: number;
  55628. /**
  55629. * How big in texel of the blur texture is the vertical blur.
  55630. */
  55631. blurVerticalSize: number;
  55632. /**
  55633. * How big in texel of the blur texture is the horizontal blur.
  55634. */
  55635. blurHorizontalSize: number;
  55636. /**
  55637. * Alpha blending mode used to apply the blur. Default is combine.
  55638. */
  55639. alphaBlendingMode: number;
  55640. /**
  55641. * The camera attached to the layer.
  55642. */
  55643. camera: Nullable<Camera>;
  55644. /**
  55645. * Should we display highlight as a solid stroke?
  55646. */
  55647. isStroke?: boolean;
  55648. /**
  55649. * The rendering group to draw the layer in.
  55650. */
  55651. renderingGroupId: number;
  55652. }
  55653. /**
  55654. * The highlight layer Helps adding a glow effect around a mesh.
  55655. *
  55656. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55657. * glowy meshes to your scene.
  55658. *
  55659. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55660. */
  55661. export class HighlightLayer extends EffectLayer {
  55662. name: string;
  55663. /**
  55664. * Effect Name of the highlight layer.
  55665. */
  55666. static readonly EffectName: string;
  55667. /**
  55668. * The neutral color used during the preparation of the glow effect.
  55669. * This is black by default as the blend operation is a blend operation.
  55670. */
  55671. static NeutralColor: Color4;
  55672. /**
  55673. * Stencil value used for glowing meshes.
  55674. */
  55675. static GlowingMeshStencilReference: number;
  55676. /**
  55677. * Stencil value used for the other meshes in the scene.
  55678. */
  55679. static NormalMeshStencilReference: number;
  55680. /**
  55681. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55682. */
  55683. innerGlow: boolean;
  55684. /**
  55685. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55686. */
  55687. outerGlow: boolean;
  55688. /**
  55689. * Specifies the horizontal size of the blur.
  55690. */
  55691. set blurHorizontalSize(value: number);
  55692. /**
  55693. * Specifies the vertical size of the blur.
  55694. */
  55695. set blurVerticalSize(value: number);
  55696. /**
  55697. * Gets the horizontal size of the blur.
  55698. */
  55699. get blurHorizontalSize(): number;
  55700. /**
  55701. * Gets the vertical size of the blur.
  55702. */
  55703. get blurVerticalSize(): number;
  55704. /**
  55705. * An event triggered when the highlight layer is being blurred.
  55706. */
  55707. onBeforeBlurObservable: Observable<HighlightLayer>;
  55708. /**
  55709. * An event triggered when the highlight layer has been blurred.
  55710. */
  55711. onAfterBlurObservable: Observable<HighlightLayer>;
  55712. private _instanceGlowingMeshStencilReference;
  55713. private _options;
  55714. private _downSamplePostprocess;
  55715. private _horizontalBlurPostprocess;
  55716. private _verticalBlurPostprocess;
  55717. private _blurTexture;
  55718. private _meshes;
  55719. private _excludedMeshes;
  55720. /**
  55721. * Instantiates a new highlight Layer and references it to the scene..
  55722. * @param name The name of the layer
  55723. * @param scene The scene to use the layer in
  55724. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55725. */
  55726. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55727. /**
  55728. * Get the effect name of the layer.
  55729. * @return The effect name
  55730. */
  55731. getEffectName(): string;
  55732. /**
  55733. * Create the merge effect. This is the shader use to blit the information back
  55734. * to the main canvas at the end of the scene rendering.
  55735. */
  55736. protected _createMergeEffect(): Effect;
  55737. /**
  55738. * Creates the render target textures and post processes used in the highlight layer.
  55739. */
  55740. protected _createTextureAndPostProcesses(): void;
  55741. /**
  55742. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55743. */
  55744. needStencil(): boolean;
  55745. /**
  55746. * Checks for the readiness of the element composing the layer.
  55747. * @param subMesh the mesh to check for
  55748. * @param useInstances specify wether or not to use instances to render the mesh
  55749. * @param emissiveTexture the associated emissive texture used to generate the glow
  55750. * @return true if ready otherwise, false
  55751. */
  55752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55753. /**
  55754. * Implementation specific of rendering the generating effect on the main canvas.
  55755. * @param effect The effect used to render through
  55756. */
  55757. protected _internalRender(effect: Effect): void;
  55758. /**
  55759. * Returns true if the layer contains information to display, otherwise false.
  55760. */
  55761. shouldRender(): boolean;
  55762. /**
  55763. * Returns true if the mesh should render, otherwise false.
  55764. * @param mesh The mesh to render
  55765. * @returns true if it should render otherwise false
  55766. */
  55767. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55768. /**
  55769. * Sets the required values for both the emissive texture and and the main color.
  55770. */
  55771. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55772. /**
  55773. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55774. * @param mesh The mesh to exclude from the highlight layer
  55775. */
  55776. addExcludedMesh(mesh: Mesh): void;
  55777. /**
  55778. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55779. * @param mesh The mesh to highlight
  55780. */
  55781. removeExcludedMesh(mesh: Mesh): void;
  55782. /**
  55783. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55784. * @param mesh mesh to test
  55785. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55786. */
  55787. hasMesh(mesh: AbstractMesh): boolean;
  55788. /**
  55789. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55790. * @param mesh The mesh to highlight
  55791. * @param color The color of the highlight
  55792. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55793. */
  55794. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55795. /**
  55796. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55797. * @param mesh The mesh to highlight
  55798. */
  55799. removeMesh(mesh: Mesh): void;
  55800. /**
  55801. * Remove all the meshes currently referenced in the highlight layer
  55802. */
  55803. removeAllMeshes(): void;
  55804. /**
  55805. * Force the stencil to the normal expected value for none glowing parts
  55806. */
  55807. private _defaultStencilReference;
  55808. /**
  55809. * Free any resources and references associated to a mesh.
  55810. * Internal use
  55811. * @param mesh The mesh to free.
  55812. * @hidden
  55813. */
  55814. _disposeMesh(mesh: Mesh): void;
  55815. /**
  55816. * Dispose the highlight layer and free resources.
  55817. */
  55818. dispose(): void;
  55819. /**
  55820. * Gets the class name of the effect layer
  55821. * @returns the string with the class name of the effect layer
  55822. */
  55823. getClassName(): string;
  55824. /**
  55825. * Serializes this Highlight layer
  55826. * @returns a serialized Highlight layer object
  55827. */
  55828. serialize(): any;
  55829. /**
  55830. * Creates a Highlight layer from parsed Highlight layer data
  55831. * @param parsedHightlightLayer defines the Highlight layer data
  55832. * @param scene defines the current scene
  55833. * @param rootUrl defines the root URL containing the Highlight layer information
  55834. * @returns a parsed Highlight layer
  55835. */
  55836. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55837. }
  55838. }
  55839. declare module "babylonjs/Layers/layerSceneComponent" {
  55840. import { Scene } from "babylonjs/scene";
  55841. import { ISceneComponent } from "babylonjs/sceneComponent";
  55842. import { Layer } from "babylonjs/Layers/layer";
  55843. import { AbstractScene } from "babylonjs/abstractScene";
  55844. module "babylonjs/abstractScene" {
  55845. interface AbstractScene {
  55846. /**
  55847. * The list of layers (background and foreground) of the scene
  55848. */
  55849. layers: Array<Layer>;
  55850. }
  55851. }
  55852. /**
  55853. * Defines the layer scene component responsible to manage any layers
  55854. * in a given scene.
  55855. */
  55856. export class LayerSceneComponent implements ISceneComponent {
  55857. /**
  55858. * The component name helpfull to identify the component in the list of scene components.
  55859. */
  55860. readonly name: string;
  55861. /**
  55862. * The scene the component belongs to.
  55863. */
  55864. scene: Scene;
  55865. private _engine;
  55866. /**
  55867. * Creates a new instance of the component for the given scene
  55868. * @param scene Defines the scene to register the component in
  55869. */
  55870. constructor(scene: Scene);
  55871. /**
  55872. * Registers the component in a given scene
  55873. */
  55874. register(): void;
  55875. /**
  55876. * Rebuilds the elements related to this component in case of
  55877. * context lost for instance.
  55878. */
  55879. rebuild(): void;
  55880. /**
  55881. * Disposes the component and the associated ressources.
  55882. */
  55883. dispose(): void;
  55884. private _draw;
  55885. private _drawCameraPredicate;
  55886. private _drawCameraBackground;
  55887. private _drawCameraForeground;
  55888. private _drawRenderTargetPredicate;
  55889. private _drawRenderTargetBackground;
  55890. private _drawRenderTargetForeground;
  55891. /**
  55892. * Adds all the elements from the container to the scene
  55893. * @param container the container holding the elements
  55894. */
  55895. addFromContainer(container: AbstractScene): void;
  55896. /**
  55897. * Removes all the elements in the container from the scene
  55898. * @param container contains the elements to remove
  55899. * @param dispose if the removed element should be disposed (default: false)
  55900. */
  55901. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55902. }
  55903. }
  55904. declare module "babylonjs/Shaders/layer.fragment" {
  55905. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55906. /** @hidden */
  55907. export var layerPixelShader: {
  55908. name: string;
  55909. shader: string;
  55910. };
  55911. }
  55912. declare module "babylonjs/Shaders/layer.vertex" {
  55913. /** @hidden */
  55914. export var layerVertexShader: {
  55915. name: string;
  55916. shader: string;
  55917. };
  55918. }
  55919. declare module "babylonjs/Layers/layer" {
  55920. import { Observable } from "babylonjs/Misc/observable";
  55921. import { Nullable } from "babylonjs/types";
  55922. import { Scene } from "babylonjs/scene";
  55923. import { Vector2 } from "babylonjs/Maths/math.vector";
  55924. import { Color4 } from "babylonjs/Maths/math.color";
  55925. import { Texture } from "babylonjs/Materials/Textures/texture";
  55926. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55927. import "babylonjs/Shaders/layer.fragment";
  55928. import "babylonjs/Shaders/layer.vertex";
  55929. /**
  55930. * This represents a full screen 2d layer.
  55931. * This can be useful to display a picture in the background of your scene for instance.
  55932. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55933. */
  55934. export class Layer {
  55935. /**
  55936. * Define the name of the layer.
  55937. */
  55938. name: string;
  55939. /**
  55940. * Define the texture the layer should display.
  55941. */
  55942. texture: Nullable<Texture>;
  55943. /**
  55944. * Is the layer in background or foreground.
  55945. */
  55946. isBackground: boolean;
  55947. /**
  55948. * Define the color of the layer (instead of texture).
  55949. */
  55950. color: Color4;
  55951. /**
  55952. * Define the scale of the layer in order to zoom in out of the texture.
  55953. */
  55954. scale: Vector2;
  55955. /**
  55956. * Define an offset for the layer in order to shift the texture.
  55957. */
  55958. offset: Vector2;
  55959. /**
  55960. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55961. */
  55962. alphaBlendingMode: number;
  55963. /**
  55964. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55965. * Alpha test will not mix with the background color in case of transparency.
  55966. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55967. */
  55968. alphaTest: boolean;
  55969. /**
  55970. * Define a mask to restrict the layer to only some of the scene cameras.
  55971. */
  55972. layerMask: number;
  55973. /**
  55974. * Define the list of render target the layer is visible into.
  55975. */
  55976. renderTargetTextures: RenderTargetTexture[];
  55977. /**
  55978. * Define if the layer is only used in renderTarget or if it also
  55979. * renders in the main frame buffer of the canvas.
  55980. */
  55981. renderOnlyInRenderTargetTextures: boolean;
  55982. private _scene;
  55983. private _vertexBuffers;
  55984. private _indexBuffer;
  55985. private _effect;
  55986. private _previousDefines;
  55987. /**
  55988. * An event triggered when the layer is disposed.
  55989. */
  55990. onDisposeObservable: Observable<Layer>;
  55991. private _onDisposeObserver;
  55992. /**
  55993. * Back compatibility with callback before the onDisposeObservable existed.
  55994. * The set callback will be triggered when the layer has been disposed.
  55995. */
  55996. set onDispose(callback: () => void);
  55997. /**
  55998. * An event triggered before rendering the scene
  55999. */
  56000. onBeforeRenderObservable: Observable<Layer>;
  56001. private _onBeforeRenderObserver;
  56002. /**
  56003. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56004. * The set callback will be triggered just before rendering the layer.
  56005. */
  56006. set onBeforeRender(callback: () => void);
  56007. /**
  56008. * An event triggered after rendering the scene
  56009. */
  56010. onAfterRenderObservable: Observable<Layer>;
  56011. private _onAfterRenderObserver;
  56012. /**
  56013. * Back compatibility with callback before the onAfterRenderObservable existed.
  56014. * The set callback will be triggered just after rendering the layer.
  56015. */
  56016. set onAfterRender(callback: () => void);
  56017. /**
  56018. * Instantiates a new layer.
  56019. * This represents a full screen 2d layer.
  56020. * This can be useful to display a picture in the background of your scene for instance.
  56021. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56022. * @param name Define the name of the layer in the scene
  56023. * @param imgUrl Define the url of the texture to display in the layer
  56024. * @param scene Define the scene the layer belongs to
  56025. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56026. * @param color Defines a color for the layer
  56027. */
  56028. constructor(
  56029. /**
  56030. * Define the name of the layer.
  56031. */
  56032. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56033. private _createIndexBuffer;
  56034. /** @hidden */
  56035. _rebuild(): void;
  56036. /**
  56037. * Renders the layer in the scene.
  56038. */
  56039. render(): void;
  56040. /**
  56041. * Disposes and releases the associated ressources.
  56042. */
  56043. dispose(): void;
  56044. }
  56045. }
  56046. declare module "babylonjs/Layers/index" {
  56047. export * from "babylonjs/Layers/effectLayer";
  56048. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56049. export * from "babylonjs/Layers/glowLayer";
  56050. export * from "babylonjs/Layers/highlightLayer";
  56051. export * from "babylonjs/Layers/layer";
  56052. export * from "babylonjs/Layers/layerSceneComponent";
  56053. }
  56054. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56055. /** @hidden */
  56056. export var lensFlarePixelShader: {
  56057. name: string;
  56058. shader: string;
  56059. };
  56060. }
  56061. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56062. /** @hidden */
  56063. export var lensFlareVertexShader: {
  56064. name: string;
  56065. shader: string;
  56066. };
  56067. }
  56068. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56069. import { Scene } from "babylonjs/scene";
  56070. import { Vector3 } from "babylonjs/Maths/math.vector";
  56071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56072. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56073. import "babylonjs/Shaders/lensFlare.fragment";
  56074. import "babylonjs/Shaders/lensFlare.vertex";
  56075. import { Viewport } from "babylonjs/Maths/math.viewport";
  56076. /**
  56077. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56078. * It is usually composed of several `lensFlare`.
  56079. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56080. */
  56081. export class LensFlareSystem {
  56082. /**
  56083. * Define the name of the lens flare system
  56084. */
  56085. name: string;
  56086. /**
  56087. * List of lens flares used in this system.
  56088. */
  56089. lensFlares: LensFlare[];
  56090. /**
  56091. * Define a limit from the border the lens flare can be visible.
  56092. */
  56093. borderLimit: number;
  56094. /**
  56095. * Define a viewport border we do not want to see the lens flare in.
  56096. */
  56097. viewportBorder: number;
  56098. /**
  56099. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56100. */
  56101. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56102. /**
  56103. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56104. */
  56105. layerMask: number;
  56106. /**
  56107. * Define the id of the lens flare system in the scene.
  56108. * (equal to name by default)
  56109. */
  56110. id: string;
  56111. private _scene;
  56112. private _emitter;
  56113. private _vertexBuffers;
  56114. private _indexBuffer;
  56115. private _effect;
  56116. private _positionX;
  56117. private _positionY;
  56118. private _isEnabled;
  56119. /** @hidden */
  56120. static _SceneComponentInitialization: (scene: Scene) => void;
  56121. /**
  56122. * Instantiates a lens flare system.
  56123. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56124. * It is usually composed of several `lensFlare`.
  56125. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56126. * @param name Define the name of the lens flare system in the scene
  56127. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56128. * @param scene Define the scene the lens flare system belongs to
  56129. */
  56130. constructor(
  56131. /**
  56132. * Define the name of the lens flare system
  56133. */
  56134. name: string, emitter: any, scene: Scene);
  56135. /**
  56136. * Define if the lens flare system is enabled.
  56137. */
  56138. get isEnabled(): boolean;
  56139. set isEnabled(value: boolean);
  56140. /**
  56141. * Get the scene the effects belongs to.
  56142. * @returns the scene holding the lens flare system
  56143. */
  56144. getScene(): Scene;
  56145. /**
  56146. * Get the emitter of the lens flare system.
  56147. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56148. * @returns the emitter of the lens flare system
  56149. */
  56150. getEmitter(): any;
  56151. /**
  56152. * Set the emitter of the lens flare system.
  56153. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56154. * @param newEmitter Define the new emitter of the system
  56155. */
  56156. setEmitter(newEmitter: any): void;
  56157. /**
  56158. * Get the lens flare system emitter position.
  56159. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56160. * @returns the position
  56161. */
  56162. getEmitterPosition(): Vector3;
  56163. /**
  56164. * @hidden
  56165. */
  56166. computeEffectivePosition(globalViewport: Viewport): boolean;
  56167. /** @hidden */
  56168. _isVisible(): boolean;
  56169. /**
  56170. * @hidden
  56171. */
  56172. render(): boolean;
  56173. /**
  56174. * Dispose and release the lens flare with its associated resources.
  56175. */
  56176. dispose(): void;
  56177. /**
  56178. * Parse a lens flare system from a JSON repressentation
  56179. * @param parsedLensFlareSystem Define the JSON to parse
  56180. * @param scene Define the scene the parsed system should be instantiated in
  56181. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56182. * @returns the parsed system
  56183. */
  56184. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56185. /**
  56186. * Serialize the current Lens Flare System into a JSON representation.
  56187. * @returns the serialized JSON
  56188. */
  56189. serialize(): any;
  56190. }
  56191. }
  56192. declare module "babylonjs/LensFlares/lensFlare" {
  56193. import { Nullable } from "babylonjs/types";
  56194. import { Color3 } from "babylonjs/Maths/math.color";
  56195. import { Texture } from "babylonjs/Materials/Textures/texture";
  56196. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56197. /**
  56198. * This represents one of the lens effect in a `lensFlareSystem`.
  56199. * It controls one of the indiviual texture used in the effect.
  56200. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56201. */
  56202. export class LensFlare {
  56203. /**
  56204. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56205. */
  56206. size: number;
  56207. /**
  56208. * 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.
  56209. */
  56210. position: number;
  56211. /**
  56212. * Define the lens color.
  56213. */
  56214. color: Color3;
  56215. /**
  56216. * Define the lens texture.
  56217. */
  56218. texture: Nullable<Texture>;
  56219. /**
  56220. * Define the alpha mode to render this particular lens.
  56221. */
  56222. alphaMode: number;
  56223. private _system;
  56224. /**
  56225. * Creates a new Lens Flare.
  56226. * This represents one of the lens effect in a `lensFlareSystem`.
  56227. * It controls one of the indiviual texture used in the effect.
  56228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56229. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56230. * @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.
  56231. * @param color Define the lens color
  56232. * @param imgUrl Define the lens texture url
  56233. * @param system Define the `lensFlareSystem` this flare is part of
  56234. * @returns The newly created Lens Flare
  56235. */
  56236. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56237. /**
  56238. * Instantiates a new Lens Flare.
  56239. * This represents one of the lens effect in a `lensFlareSystem`.
  56240. * It controls one of the indiviual texture used in the effect.
  56241. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56242. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56243. * @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.
  56244. * @param color Define the lens color
  56245. * @param imgUrl Define the lens texture url
  56246. * @param system Define the `lensFlareSystem` this flare is part of
  56247. */
  56248. constructor(
  56249. /**
  56250. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56251. */
  56252. size: number,
  56253. /**
  56254. * 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.
  56255. */
  56256. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56257. /**
  56258. * Dispose and release the lens flare with its associated resources.
  56259. */
  56260. dispose(): void;
  56261. }
  56262. }
  56263. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56264. import { Nullable } from "babylonjs/types";
  56265. import { Scene } from "babylonjs/scene";
  56266. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56267. import { AbstractScene } from "babylonjs/abstractScene";
  56268. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56269. module "babylonjs/abstractScene" {
  56270. interface AbstractScene {
  56271. /**
  56272. * The list of lens flare system added to the scene
  56273. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56274. */
  56275. lensFlareSystems: Array<LensFlareSystem>;
  56276. /**
  56277. * Removes the given lens flare system from this scene.
  56278. * @param toRemove The lens flare system to remove
  56279. * @returns The index of the removed lens flare system
  56280. */
  56281. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56282. /**
  56283. * Adds the given lens flare system to this scene
  56284. * @param newLensFlareSystem The lens flare system to add
  56285. */
  56286. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56287. /**
  56288. * Gets a lens flare system using its name
  56289. * @param name defines the name to look for
  56290. * @returns the lens flare system or null if not found
  56291. */
  56292. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56293. /**
  56294. * Gets a lens flare system using its id
  56295. * @param id defines the id to look for
  56296. * @returns the lens flare system or null if not found
  56297. */
  56298. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56299. }
  56300. }
  56301. /**
  56302. * Defines the lens flare scene component responsible to manage any lens flares
  56303. * in a given scene.
  56304. */
  56305. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56306. /**
  56307. * The component name helpfull to identify the component in the list of scene components.
  56308. */
  56309. readonly name: string;
  56310. /**
  56311. * The scene the component belongs to.
  56312. */
  56313. scene: Scene;
  56314. /**
  56315. * Creates a new instance of the component for the given scene
  56316. * @param scene Defines the scene to register the component in
  56317. */
  56318. constructor(scene: Scene);
  56319. /**
  56320. * Registers the component in a given scene
  56321. */
  56322. register(): void;
  56323. /**
  56324. * Rebuilds the elements related to this component in case of
  56325. * context lost for instance.
  56326. */
  56327. rebuild(): void;
  56328. /**
  56329. * Adds all the elements from the container to the scene
  56330. * @param container the container holding the elements
  56331. */
  56332. addFromContainer(container: AbstractScene): void;
  56333. /**
  56334. * Removes all the elements in the container from the scene
  56335. * @param container contains the elements to remove
  56336. * @param dispose if the removed element should be disposed (default: false)
  56337. */
  56338. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56339. /**
  56340. * Serializes the component data to the specified json object
  56341. * @param serializationObject The object to serialize to
  56342. */
  56343. serialize(serializationObject: any): void;
  56344. /**
  56345. * Disposes the component and the associated ressources.
  56346. */
  56347. dispose(): void;
  56348. private _draw;
  56349. }
  56350. }
  56351. declare module "babylonjs/LensFlares/index" {
  56352. export * from "babylonjs/LensFlares/lensFlare";
  56353. export * from "babylonjs/LensFlares/lensFlareSystem";
  56354. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56355. }
  56356. declare module "babylonjs/Shaders/depth.fragment" {
  56357. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56358. /** @hidden */
  56359. export var depthPixelShader: {
  56360. name: string;
  56361. shader: string;
  56362. };
  56363. }
  56364. declare module "babylonjs/Shaders/depth.vertex" {
  56365. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56370. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56371. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56372. /** @hidden */
  56373. export var depthVertexShader: {
  56374. name: string;
  56375. shader: string;
  56376. };
  56377. }
  56378. declare module "babylonjs/Rendering/depthRenderer" {
  56379. import { Nullable } from "babylonjs/types";
  56380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56381. import { Scene } from "babylonjs/scene";
  56382. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56383. import { Camera } from "babylonjs/Cameras/camera";
  56384. import "babylonjs/Shaders/depth.fragment";
  56385. import "babylonjs/Shaders/depth.vertex";
  56386. /**
  56387. * This represents a depth renderer in Babylon.
  56388. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56389. */
  56390. export class DepthRenderer {
  56391. private _scene;
  56392. private _depthMap;
  56393. private _effect;
  56394. private readonly _storeNonLinearDepth;
  56395. private readonly _clearColor;
  56396. /** Get if the depth renderer is using packed depth or not */
  56397. readonly isPacked: boolean;
  56398. private _cachedDefines;
  56399. private _camera;
  56400. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56401. enabled: boolean;
  56402. /**
  56403. * Specifiess that the depth renderer will only be used within
  56404. * the camera it is created for.
  56405. * This can help forcing its rendering during the camera processing.
  56406. */
  56407. useOnlyInActiveCamera: boolean;
  56408. /** @hidden */
  56409. static _SceneComponentInitialization: (scene: Scene) => void;
  56410. /**
  56411. * Instantiates a depth renderer
  56412. * @param scene The scene the renderer belongs to
  56413. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56414. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56415. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56416. */
  56417. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56418. /**
  56419. * Creates the depth rendering effect and checks if the effect is ready.
  56420. * @param subMesh The submesh to be used to render the depth map of
  56421. * @param useInstances If multiple world instances should be used
  56422. * @returns if the depth renderer is ready to render the depth map
  56423. */
  56424. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56425. /**
  56426. * Gets the texture which the depth map will be written to.
  56427. * @returns The depth map texture
  56428. */
  56429. getDepthMap(): RenderTargetTexture;
  56430. /**
  56431. * Disposes of the depth renderer.
  56432. */
  56433. dispose(): void;
  56434. }
  56435. }
  56436. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56437. /** @hidden */
  56438. export var minmaxReduxPixelShader: {
  56439. name: string;
  56440. shader: string;
  56441. };
  56442. }
  56443. declare module "babylonjs/Misc/minMaxReducer" {
  56444. import { Nullable } from "babylonjs/types";
  56445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56446. import { Camera } from "babylonjs/Cameras/camera";
  56447. import { Observer } from "babylonjs/Misc/observable";
  56448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56449. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56450. import { Observable } from "babylonjs/Misc/observable";
  56451. import "babylonjs/Shaders/minmaxRedux.fragment";
  56452. /**
  56453. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56454. * and maximum values from all values of the texture.
  56455. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56456. * The source values are read from the red channel of the texture.
  56457. */
  56458. export class MinMaxReducer {
  56459. /**
  56460. * Observable triggered when the computation has been performed
  56461. */
  56462. onAfterReductionPerformed: Observable<{
  56463. min: number;
  56464. max: number;
  56465. }>;
  56466. protected _camera: Camera;
  56467. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56468. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56469. protected _postProcessManager: PostProcessManager;
  56470. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56471. protected _forceFullscreenViewport: boolean;
  56472. /**
  56473. * Creates a min/max reducer
  56474. * @param camera The camera to use for the post processes
  56475. */
  56476. constructor(camera: Camera);
  56477. /**
  56478. * Gets the texture used to read the values from.
  56479. */
  56480. get sourceTexture(): Nullable<RenderTargetTexture>;
  56481. /**
  56482. * Sets the source texture to read the values from.
  56483. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56484. * because in such textures '1' value must not be taken into account to compute the maximum
  56485. * as this value is used to clear the texture.
  56486. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56487. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56488. * @param depthRedux Indicates if the texture is a depth texture or not
  56489. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56490. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56491. */
  56492. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56493. /**
  56494. * Defines the refresh rate of the computation.
  56495. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56496. */
  56497. get refreshRate(): number;
  56498. set refreshRate(value: number);
  56499. protected _activated: boolean;
  56500. /**
  56501. * Gets the activation status of the reducer
  56502. */
  56503. get activated(): boolean;
  56504. /**
  56505. * Activates the reduction computation.
  56506. * When activated, the observers registered in onAfterReductionPerformed are
  56507. * called after the compuation is performed
  56508. */
  56509. activate(): void;
  56510. /**
  56511. * Deactivates the reduction computation.
  56512. */
  56513. deactivate(): void;
  56514. /**
  56515. * Disposes the min/max reducer
  56516. * @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.
  56517. */
  56518. dispose(disposeAll?: boolean): void;
  56519. }
  56520. }
  56521. declare module "babylonjs/Misc/depthReducer" {
  56522. import { Nullable } from "babylonjs/types";
  56523. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56524. import { Camera } from "babylonjs/Cameras/camera";
  56525. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56526. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56527. /**
  56528. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56529. */
  56530. export class DepthReducer extends MinMaxReducer {
  56531. private _depthRenderer;
  56532. private _depthRendererId;
  56533. /**
  56534. * Gets the depth renderer used for the computation.
  56535. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56536. */
  56537. get depthRenderer(): Nullable<DepthRenderer>;
  56538. /**
  56539. * Creates a depth reducer
  56540. * @param camera The camera used to render the depth texture
  56541. */
  56542. constructor(camera: Camera);
  56543. /**
  56544. * Sets the depth renderer to use to generate the depth map
  56545. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56546. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56547. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56548. */
  56549. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56550. /** @hidden */
  56551. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56552. /**
  56553. * Activates the reduction computation.
  56554. * When activated, the observers registered in onAfterReductionPerformed are
  56555. * called after the compuation is performed
  56556. */
  56557. activate(): void;
  56558. /**
  56559. * Deactivates the reduction computation.
  56560. */
  56561. deactivate(): void;
  56562. /**
  56563. * Disposes the depth reducer
  56564. * @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.
  56565. */
  56566. dispose(disposeAll?: boolean): void;
  56567. }
  56568. }
  56569. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56570. import { Nullable } from "babylonjs/types";
  56571. import { Scene } from "babylonjs/scene";
  56572. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56574. import { Effect } from "babylonjs/Materials/effect";
  56575. import "babylonjs/Shaders/shadowMap.fragment";
  56576. import "babylonjs/Shaders/shadowMap.vertex";
  56577. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56578. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56579. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56580. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56581. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56582. /**
  56583. * A CSM implementation allowing casting shadows on large scenes.
  56584. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56585. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56586. */
  56587. export class CascadedShadowGenerator extends ShadowGenerator {
  56588. private static readonly frustumCornersNDCSpace;
  56589. /**
  56590. * Name of the CSM class
  56591. */
  56592. static CLASSNAME: string;
  56593. /**
  56594. * Defines the default number of cascades used by the CSM.
  56595. */
  56596. static readonly DEFAULT_CASCADES_COUNT: number;
  56597. /**
  56598. * Defines the minimum number of cascades used by the CSM.
  56599. */
  56600. static readonly MIN_CASCADES_COUNT: number;
  56601. /**
  56602. * Defines the maximum number of cascades used by the CSM.
  56603. */
  56604. static readonly MAX_CASCADES_COUNT: number;
  56605. protected _validateFilter(filter: number): number;
  56606. /**
  56607. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56608. */
  56609. penumbraDarkness: number;
  56610. private _numCascades;
  56611. /**
  56612. * Gets or set the number of cascades used by the CSM.
  56613. */
  56614. get numCascades(): number;
  56615. set numCascades(value: number);
  56616. /**
  56617. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56618. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56619. */
  56620. stabilizeCascades: boolean;
  56621. private _freezeShadowCastersBoundingInfo;
  56622. private _freezeShadowCastersBoundingInfoObservable;
  56623. /**
  56624. * Enables or disables the shadow casters bounding info computation.
  56625. * If your shadow casters don't move, you can disable this feature.
  56626. * If it is enabled, the bounding box computation is done every frame.
  56627. */
  56628. get freezeShadowCastersBoundingInfo(): boolean;
  56629. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56630. private _scbiMin;
  56631. private _scbiMax;
  56632. protected _computeShadowCastersBoundingInfo(): void;
  56633. protected _shadowCastersBoundingInfo: BoundingInfo;
  56634. /**
  56635. * Gets or sets the shadow casters bounding info.
  56636. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56637. * so that the system won't overwrite the bounds you provide
  56638. */
  56639. get shadowCastersBoundingInfo(): BoundingInfo;
  56640. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56641. protected _breaksAreDirty: boolean;
  56642. protected _minDistance: number;
  56643. protected _maxDistance: number;
  56644. /**
  56645. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56646. *
  56647. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56648. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56649. * @param min minimal distance for the breaks (default to 0.)
  56650. * @param max maximal distance for the breaks (default to 1.)
  56651. */
  56652. setMinMaxDistance(min: number, max: number): void;
  56653. /** Gets the minimal distance used in the cascade break computation */
  56654. get minDistance(): number;
  56655. /** Gets the maximal distance used in the cascade break computation */
  56656. get maxDistance(): number;
  56657. /**
  56658. * Gets the class name of that object
  56659. * @returns "CascadedShadowGenerator"
  56660. */
  56661. getClassName(): string;
  56662. private _cascadeMinExtents;
  56663. private _cascadeMaxExtents;
  56664. /**
  56665. * Gets a cascade minimum extents
  56666. * @param cascadeIndex index of the cascade
  56667. * @returns the minimum cascade extents
  56668. */
  56669. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56670. /**
  56671. * Gets a cascade maximum extents
  56672. * @param cascadeIndex index of the cascade
  56673. * @returns the maximum cascade extents
  56674. */
  56675. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56676. private _cascades;
  56677. private _currentLayer;
  56678. private _viewSpaceFrustumsZ;
  56679. private _viewMatrices;
  56680. private _projectionMatrices;
  56681. private _transformMatrices;
  56682. private _transformMatricesAsArray;
  56683. private _frustumLengths;
  56684. private _lightSizeUVCorrection;
  56685. private _depthCorrection;
  56686. private _frustumCornersWorldSpace;
  56687. private _frustumCenter;
  56688. private _shadowCameraPos;
  56689. private _shadowMaxZ;
  56690. /**
  56691. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56692. * It defaults to camera.maxZ
  56693. */
  56694. get shadowMaxZ(): number;
  56695. /**
  56696. * Sets the shadow max z distance.
  56697. */
  56698. set shadowMaxZ(value: number);
  56699. protected _debug: boolean;
  56700. /**
  56701. * Gets or sets the debug flag.
  56702. * When enabled, the cascades are materialized by different colors on the screen.
  56703. */
  56704. get debug(): boolean;
  56705. set debug(dbg: boolean);
  56706. private _depthClamp;
  56707. /**
  56708. * Gets or sets the depth clamping value.
  56709. *
  56710. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56711. * to account for the shadow casters far away.
  56712. *
  56713. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56714. */
  56715. get depthClamp(): boolean;
  56716. set depthClamp(value: boolean);
  56717. private _cascadeBlendPercentage;
  56718. /**
  56719. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56720. * It defaults to 0.1 (10% blending).
  56721. */
  56722. get cascadeBlendPercentage(): number;
  56723. set cascadeBlendPercentage(value: number);
  56724. private _lambda;
  56725. /**
  56726. * Gets or set the lambda parameter.
  56727. * This parameter is used to split the camera frustum and create the cascades.
  56728. * 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.
  56729. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56730. */
  56731. get lambda(): number;
  56732. set lambda(value: number);
  56733. /**
  56734. * Gets the view matrix corresponding to a given cascade
  56735. * @param cascadeNum cascade to retrieve the view matrix from
  56736. * @returns the cascade view matrix
  56737. */
  56738. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56739. /**
  56740. * Gets the projection matrix corresponding to a given cascade
  56741. * @param cascadeNum cascade to retrieve the projection matrix from
  56742. * @returns the cascade projection matrix
  56743. */
  56744. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56745. /**
  56746. * Gets the transformation matrix corresponding to a given cascade
  56747. * @param cascadeNum cascade to retrieve the transformation matrix from
  56748. * @returns the cascade transformation matrix
  56749. */
  56750. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56751. private _depthRenderer;
  56752. /**
  56753. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56754. *
  56755. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56756. *
  56757. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56758. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56759. * @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
  56760. */
  56761. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56762. private _depthReducer;
  56763. private _autoCalcDepthBounds;
  56764. /**
  56765. * Gets or sets the autoCalcDepthBounds property.
  56766. *
  56767. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56768. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56769. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56770. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56771. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56772. */
  56773. get autoCalcDepthBounds(): boolean;
  56774. set autoCalcDepthBounds(value: boolean);
  56775. /**
  56776. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56777. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56778. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56779. * for setting the refresh rate on the renderer yourself!
  56780. */
  56781. get autoCalcDepthBoundsRefreshRate(): number;
  56782. set autoCalcDepthBoundsRefreshRate(value: number);
  56783. /**
  56784. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56785. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56786. * you change the camera near/far planes!
  56787. */
  56788. splitFrustum(): void;
  56789. private _splitFrustum;
  56790. private _computeMatrices;
  56791. private _computeFrustumInWorldSpace;
  56792. private _computeCascadeFrustum;
  56793. /** @hidden */
  56794. static _SceneComponentInitialization: (scene: Scene) => void;
  56795. /**
  56796. * Creates a Cascaded Shadow Generator object.
  56797. * A ShadowGenerator is the required tool to use the shadows.
  56798. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56799. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56800. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56801. * @param light The directional light object generating the shadows.
  56802. * @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.
  56803. */
  56804. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56805. protected _initializeGenerator(): void;
  56806. protected _createTargetRenderTexture(): void;
  56807. protected _initializeShadowMap(): void;
  56808. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56809. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56810. /**
  56811. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56812. * @param defines Defines of the material we want to update
  56813. * @param lightIndex Index of the light in the enabled light list of the material
  56814. */
  56815. prepareDefines(defines: any, lightIndex: number): void;
  56816. /**
  56817. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56818. * defined in the generator but impacting the effect).
  56819. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56820. * @param effect The effect we are binfing the information for
  56821. */
  56822. bindShadowLight(lightIndex: string, effect: Effect): void;
  56823. /**
  56824. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56825. * (eq to view projection * shadow projection matrices)
  56826. * @returns The transform matrix used to create the shadow map
  56827. */
  56828. getTransformMatrix(): Matrix;
  56829. /**
  56830. * Disposes the ShadowGenerator.
  56831. * Returns nothing.
  56832. */
  56833. dispose(): void;
  56834. /**
  56835. * Serializes the shadow generator setup to a json object.
  56836. * @returns The serialized JSON object
  56837. */
  56838. serialize(): any;
  56839. /**
  56840. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56841. * @param parsedShadowGenerator The JSON object to parse
  56842. * @param scene The scene to create the shadow map for
  56843. * @returns The parsed shadow generator
  56844. */
  56845. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56846. }
  56847. }
  56848. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56849. import { Scene } from "babylonjs/scene";
  56850. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56851. import { AbstractScene } from "babylonjs/abstractScene";
  56852. /**
  56853. * Defines the shadow generator component responsible to manage any shadow generators
  56854. * in a given scene.
  56855. */
  56856. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56857. /**
  56858. * The component name helpfull to identify the component in the list of scene components.
  56859. */
  56860. readonly name: string;
  56861. /**
  56862. * The scene the component belongs to.
  56863. */
  56864. scene: Scene;
  56865. /**
  56866. * Creates a new instance of the component for the given scene
  56867. * @param scene Defines the scene to register the component in
  56868. */
  56869. constructor(scene: Scene);
  56870. /**
  56871. * Registers the component in a given scene
  56872. */
  56873. register(): void;
  56874. /**
  56875. * Rebuilds the elements related to this component in case of
  56876. * context lost for instance.
  56877. */
  56878. rebuild(): void;
  56879. /**
  56880. * Serializes the component data to the specified json object
  56881. * @param serializationObject The object to serialize to
  56882. */
  56883. serialize(serializationObject: any): void;
  56884. /**
  56885. * Adds all the elements from the container to the scene
  56886. * @param container the container holding the elements
  56887. */
  56888. addFromContainer(container: AbstractScene): void;
  56889. /**
  56890. * Removes all the elements in the container from the scene
  56891. * @param container contains the elements to remove
  56892. * @param dispose if the removed element should be disposed (default: false)
  56893. */
  56894. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56895. /**
  56896. * Rebuilds the elements related to this component in case of
  56897. * context lost for instance.
  56898. */
  56899. dispose(): void;
  56900. private _gatherRenderTargets;
  56901. }
  56902. }
  56903. declare module "babylonjs/Lights/Shadows/index" {
  56904. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56905. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56906. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56907. }
  56908. declare module "babylonjs/Lights/pointLight" {
  56909. import { Scene } from "babylonjs/scene";
  56910. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56912. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56913. import { Effect } from "babylonjs/Materials/effect";
  56914. /**
  56915. * A point light is a light defined by an unique point in world space.
  56916. * The light is emitted in every direction from this point.
  56917. * A good example of a point light is a standard light bulb.
  56918. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56919. */
  56920. export class PointLight extends ShadowLight {
  56921. private _shadowAngle;
  56922. /**
  56923. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56924. * This specifies what angle the shadow will use to be created.
  56925. *
  56926. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56927. */
  56928. get shadowAngle(): number;
  56929. /**
  56930. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56931. * This specifies what angle the shadow will use to be created.
  56932. *
  56933. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56934. */
  56935. set shadowAngle(value: number);
  56936. /**
  56937. * Gets the direction if it has been set.
  56938. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56939. */
  56940. get direction(): Vector3;
  56941. /**
  56942. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56943. */
  56944. set direction(value: Vector3);
  56945. /**
  56946. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56947. * A PointLight emits the light in every direction.
  56948. * It can cast shadows.
  56949. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56950. * ```javascript
  56951. * var pointLight = new PointLight("pl", camera.position, scene);
  56952. * ```
  56953. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56954. * @param name The light friendly name
  56955. * @param position The position of the point light in the scene
  56956. * @param scene The scene the lights belongs to
  56957. */
  56958. constructor(name: string, position: Vector3, scene: Scene);
  56959. /**
  56960. * Returns the string "PointLight"
  56961. * @returns the class name
  56962. */
  56963. getClassName(): string;
  56964. /**
  56965. * Returns the integer 0.
  56966. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56967. */
  56968. getTypeID(): number;
  56969. /**
  56970. * Specifies wether or not the shadowmap should be a cube texture.
  56971. * @returns true if the shadowmap needs to be a cube texture.
  56972. */
  56973. needCube(): boolean;
  56974. /**
  56975. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56978. */
  56979. getShadowDirection(faceIndex?: number): Vector3;
  56980. /**
  56981. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56982. * - fov = PI / 2
  56983. * - aspect ratio : 1.0
  56984. * - z-near and far equal to the active camera minZ and maxZ.
  56985. * Returns the PointLight.
  56986. */
  56987. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56988. protected _buildUniformLayout(): void;
  56989. /**
  56990. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56991. * @param effect The effect to update
  56992. * @param lightIndex The index of the light in the effect to update
  56993. * @returns The point light
  56994. */
  56995. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56997. /**
  56998. * Prepares the list of defines specific to the light type.
  56999. * @param defines the list of defines
  57000. * @param lightIndex defines the index of the light for the effect
  57001. */
  57002. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57003. }
  57004. }
  57005. declare module "babylonjs/Lights/index" {
  57006. export * from "babylonjs/Lights/light";
  57007. export * from "babylonjs/Lights/shadowLight";
  57008. export * from "babylonjs/Lights/Shadows/index";
  57009. export * from "babylonjs/Lights/directionalLight";
  57010. export * from "babylonjs/Lights/hemisphericLight";
  57011. export * from "babylonjs/Lights/pointLight";
  57012. export * from "babylonjs/Lights/spotLight";
  57013. }
  57014. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57015. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57016. /**
  57017. * Header information of HDR texture files.
  57018. */
  57019. export interface HDRInfo {
  57020. /**
  57021. * The height of the texture in pixels.
  57022. */
  57023. height: number;
  57024. /**
  57025. * The width of the texture in pixels.
  57026. */
  57027. width: number;
  57028. /**
  57029. * The index of the beginning of the data in the binary file.
  57030. */
  57031. dataPosition: number;
  57032. }
  57033. /**
  57034. * This groups tools to convert HDR texture to native colors array.
  57035. */
  57036. export class HDRTools {
  57037. private static Ldexp;
  57038. private static Rgbe2float;
  57039. private static readStringLine;
  57040. /**
  57041. * Reads header information from an RGBE texture stored in a native array.
  57042. * More information on this format are available here:
  57043. * https://en.wikipedia.org/wiki/RGBE_image_format
  57044. *
  57045. * @param uint8array The binary file stored in native array.
  57046. * @return The header information.
  57047. */
  57048. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57049. /**
  57050. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57051. * This RGBE texture needs to store the information as a panorama.
  57052. *
  57053. * More information on this format are available here:
  57054. * https://en.wikipedia.org/wiki/RGBE_image_format
  57055. *
  57056. * @param buffer The binary file stored in an array buffer.
  57057. * @param size The expected size of the extracted cubemap.
  57058. * @return The Cube Map information.
  57059. */
  57060. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57061. /**
  57062. * Returns the pixels data extracted from an RGBE texture.
  57063. * This pixels will be stored left to right up to down in the R G B order in one array.
  57064. *
  57065. * More information on this format are available here:
  57066. * https://en.wikipedia.org/wiki/RGBE_image_format
  57067. *
  57068. * @param uint8array The binary file stored in an array buffer.
  57069. * @param hdrInfo The header information of the file.
  57070. * @return The pixels data in RGB right to left up to down order.
  57071. */
  57072. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57073. private static RGBE_ReadPixels_RLE;
  57074. }
  57075. }
  57076. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57077. import { Nullable } from "babylonjs/types";
  57078. import { Scene } from "babylonjs/scene";
  57079. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57081. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57082. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57083. /**
  57084. * This represents a texture coming from an HDR input.
  57085. *
  57086. * The only supported format is currently panorama picture stored in RGBE format.
  57087. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57088. */
  57089. export class HDRCubeTexture extends BaseTexture {
  57090. private static _facesMapping;
  57091. private _generateHarmonics;
  57092. private _noMipmap;
  57093. private _textureMatrix;
  57094. private _size;
  57095. private _onLoad;
  57096. private _onError;
  57097. /**
  57098. * The texture URL.
  57099. */
  57100. url: string;
  57101. /**
  57102. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57103. */
  57104. coordinatesMode: number;
  57105. protected _isBlocking: boolean;
  57106. /**
  57107. * Sets wether or not the texture is blocking during loading.
  57108. */
  57109. set isBlocking(value: boolean);
  57110. /**
  57111. * Gets wether or not the texture is blocking during loading.
  57112. */
  57113. get isBlocking(): boolean;
  57114. protected _rotationY: number;
  57115. /**
  57116. * Sets texture matrix rotation angle around Y axis in radians.
  57117. */
  57118. set rotationY(value: number);
  57119. /**
  57120. * Gets texture matrix rotation angle around Y axis radians.
  57121. */
  57122. get rotationY(): number;
  57123. /**
  57124. * Gets or sets the center of the bounding box associated with the cube texture
  57125. * It must define where the camera used to render the texture was set
  57126. */
  57127. boundingBoxPosition: Vector3;
  57128. private _boundingBoxSize;
  57129. /**
  57130. * Gets or sets the size of the bounding box associated with the cube texture
  57131. * When defined, the cubemap will switch to local mode
  57132. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57133. * @example https://www.babylonjs-playground.com/#RNASML
  57134. */
  57135. set boundingBoxSize(value: Vector3);
  57136. get boundingBoxSize(): Vector3;
  57137. /**
  57138. * Instantiates an HDRTexture from the following parameters.
  57139. *
  57140. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57141. * @param scene The scene the texture will be used in
  57142. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57143. * @param noMipmap Forces to not generate the mipmap if true
  57144. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57145. * @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)
  57146. * @param reserved Reserved flag for internal use.
  57147. */
  57148. 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>);
  57149. /**
  57150. * Get the current class name of the texture useful for serialization or dynamic coding.
  57151. * @returns "HDRCubeTexture"
  57152. */
  57153. getClassName(): string;
  57154. /**
  57155. * Occurs when the file is raw .hdr file.
  57156. */
  57157. private loadTexture;
  57158. clone(): HDRCubeTexture;
  57159. delayLoad(): void;
  57160. /**
  57161. * Get the texture reflection matrix used to rotate/transform the reflection.
  57162. * @returns the reflection matrix
  57163. */
  57164. getReflectionTextureMatrix(): Matrix;
  57165. /**
  57166. * Set the texture reflection matrix used to rotate/transform the reflection.
  57167. * @param value Define the reflection matrix to set
  57168. */
  57169. setReflectionTextureMatrix(value: Matrix): void;
  57170. /**
  57171. * Parses a JSON representation of an HDR Texture in order to create the texture
  57172. * @param parsedTexture Define the JSON representation
  57173. * @param scene Define the scene the texture should be created in
  57174. * @param rootUrl Define the root url in case we need to load relative dependencies
  57175. * @returns the newly created texture after parsing
  57176. */
  57177. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57178. serialize(): any;
  57179. }
  57180. }
  57181. declare module "babylonjs/Physics/physicsEngine" {
  57182. import { Nullable } from "babylonjs/types";
  57183. import { Vector3 } from "babylonjs/Maths/math.vector";
  57184. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57185. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57186. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57187. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57188. /**
  57189. * Class used to control physics engine
  57190. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57191. */
  57192. export class PhysicsEngine implements IPhysicsEngine {
  57193. private _physicsPlugin;
  57194. /**
  57195. * Global value used to control the smallest number supported by the simulation
  57196. */
  57197. static Epsilon: number;
  57198. private _impostors;
  57199. private _joints;
  57200. private _subTimeStep;
  57201. /**
  57202. * Gets the gravity vector used by the simulation
  57203. */
  57204. gravity: Vector3;
  57205. /**
  57206. * Factory used to create the default physics plugin.
  57207. * @returns The default physics plugin
  57208. */
  57209. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57210. /**
  57211. * Creates a new Physics Engine
  57212. * @param gravity defines the gravity vector used by the simulation
  57213. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57214. */
  57215. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57216. /**
  57217. * Sets the gravity vector used by the simulation
  57218. * @param gravity defines the gravity vector to use
  57219. */
  57220. setGravity(gravity: Vector3): void;
  57221. /**
  57222. * Set the time step of the physics engine.
  57223. * Default is 1/60.
  57224. * To slow it down, enter 1/600 for example.
  57225. * To speed it up, 1/30
  57226. * @param newTimeStep defines the new timestep to apply to this world.
  57227. */
  57228. setTimeStep(newTimeStep?: number): void;
  57229. /**
  57230. * Get the time step of the physics engine.
  57231. * @returns the current time step
  57232. */
  57233. getTimeStep(): number;
  57234. /**
  57235. * Set the sub time step of the physics engine.
  57236. * Default is 0 meaning there is no sub steps
  57237. * To increase physics resolution precision, set a small value (like 1 ms)
  57238. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57239. */
  57240. setSubTimeStep(subTimeStep?: number): void;
  57241. /**
  57242. * Get the sub time step of the physics engine.
  57243. * @returns the current sub time step
  57244. */
  57245. getSubTimeStep(): number;
  57246. /**
  57247. * Release all resources
  57248. */
  57249. dispose(): void;
  57250. /**
  57251. * Gets the name of the current physics plugin
  57252. * @returns the name of the plugin
  57253. */
  57254. getPhysicsPluginName(): string;
  57255. /**
  57256. * Adding a new impostor for the impostor tracking.
  57257. * This will be done by the impostor itself.
  57258. * @param impostor the impostor to add
  57259. */
  57260. addImpostor(impostor: PhysicsImpostor): void;
  57261. /**
  57262. * Remove an impostor from the engine.
  57263. * This impostor and its mesh will not longer be updated by the physics engine.
  57264. * @param impostor the impostor to remove
  57265. */
  57266. removeImpostor(impostor: PhysicsImpostor): void;
  57267. /**
  57268. * Add a joint to the physics engine
  57269. * @param mainImpostor defines the main impostor to which the joint is added.
  57270. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57271. * @param joint defines the joint that will connect both impostors.
  57272. */
  57273. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57274. /**
  57275. * Removes a joint from the simulation
  57276. * @param mainImpostor defines the impostor used with the joint
  57277. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57278. * @param joint defines the joint to remove
  57279. */
  57280. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57281. /**
  57282. * Called by the scene. No need to call it.
  57283. * @param delta defines the timespam between frames
  57284. */
  57285. _step(delta: number): void;
  57286. /**
  57287. * Gets the current plugin used to run the simulation
  57288. * @returns current plugin
  57289. */
  57290. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57291. /**
  57292. * Gets the list of physic impostors
  57293. * @returns an array of PhysicsImpostor
  57294. */
  57295. getImpostors(): Array<PhysicsImpostor>;
  57296. /**
  57297. * Gets the impostor for a physics enabled object
  57298. * @param object defines the object impersonated by the impostor
  57299. * @returns the PhysicsImpostor or null if not found
  57300. */
  57301. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57302. /**
  57303. * Gets the impostor for a physics body object
  57304. * @param body defines physics body used by the impostor
  57305. * @returns the PhysicsImpostor or null if not found
  57306. */
  57307. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57308. /**
  57309. * Does a raycast in the physics world
  57310. * @param from when should the ray start?
  57311. * @param to when should the ray end?
  57312. * @returns PhysicsRaycastResult
  57313. */
  57314. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57315. }
  57316. }
  57317. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57318. import { Nullable } from "babylonjs/types";
  57319. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57321. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57322. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57323. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57324. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57325. /** @hidden */
  57326. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57327. private _useDeltaForWorldStep;
  57328. world: any;
  57329. name: string;
  57330. private _physicsMaterials;
  57331. private _fixedTimeStep;
  57332. private _cannonRaycastResult;
  57333. private _raycastResult;
  57334. private _physicsBodysToRemoveAfterStep;
  57335. BJSCANNON: any;
  57336. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57337. setGravity(gravity: Vector3): void;
  57338. setTimeStep(timeStep: number): void;
  57339. getTimeStep(): number;
  57340. executeStep(delta: number): void;
  57341. private _removeMarkedPhysicsBodiesFromWorld;
  57342. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57343. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57344. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57345. private _processChildMeshes;
  57346. removePhysicsBody(impostor: PhysicsImpostor): void;
  57347. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57348. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57349. private _addMaterial;
  57350. private _checkWithEpsilon;
  57351. private _createShape;
  57352. private _createHeightmap;
  57353. private _minus90X;
  57354. private _plus90X;
  57355. private _tmpPosition;
  57356. private _tmpDeltaPosition;
  57357. private _tmpUnityRotation;
  57358. private _updatePhysicsBodyTransformation;
  57359. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57360. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57361. isSupported(): boolean;
  57362. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57363. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57364. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57365. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57366. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57367. getBodyMass(impostor: PhysicsImpostor): number;
  57368. getBodyFriction(impostor: PhysicsImpostor): number;
  57369. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57370. getBodyRestitution(impostor: PhysicsImpostor): number;
  57371. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57372. sleepBody(impostor: PhysicsImpostor): void;
  57373. wakeUpBody(impostor: PhysicsImpostor): void;
  57374. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57375. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57376. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57377. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57378. getRadius(impostor: PhysicsImpostor): number;
  57379. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57380. dispose(): void;
  57381. private _extendNamespace;
  57382. /**
  57383. * Does a raycast in the physics world
  57384. * @param from when should the ray start?
  57385. * @param to when should the ray end?
  57386. * @returns PhysicsRaycastResult
  57387. */
  57388. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57389. }
  57390. }
  57391. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57392. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57393. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57394. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57396. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57397. import { Nullable } from "babylonjs/types";
  57398. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57399. /** @hidden */
  57400. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57401. world: any;
  57402. name: string;
  57403. BJSOIMO: any;
  57404. private _raycastResult;
  57405. constructor(iterations?: number, oimoInjection?: any);
  57406. setGravity(gravity: Vector3): void;
  57407. setTimeStep(timeStep: number): void;
  57408. getTimeStep(): number;
  57409. private _tmpImpostorsArray;
  57410. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57411. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57412. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57413. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57414. private _tmpPositionVector;
  57415. removePhysicsBody(impostor: PhysicsImpostor): void;
  57416. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57417. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57418. isSupported(): boolean;
  57419. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57420. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57421. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57422. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57423. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57424. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57425. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57426. getBodyMass(impostor: PhysicsImpostor): number;
  57427. getBodyFriction(impostor: PhysicsImpostor): number;
  57428. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57429. getBodyRestitution(impostor: PhysicsImpostor): number;
  57430. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57431. sleepBody(impostor: PhysicsImpostor): void;
  57432. wakeUpBody(impostor: PhysicsImpostor): void;
  57433. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57434. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57435. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57436. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57437. getRadius(impostor: PhysicsImpostor): number;
  57438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57439. dispose(): void;
  57440. /**
  57441. * Does a raycast in the physics world
  57442. * @param from when should the ray start?
  57443. * @param to when should the ray end?
  57444. * @returns PhysicsRaycastResult
  57445. */
  57446. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57447. }
  57448. }
  57449. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57450. import { Nullable } from "babylonjs/types";
  57451. import { Scene } from "babylonjs/scene";
  57452. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57453. import { Color4 } from "babylonjs/Maths/math.color";
  57454. import { Mesh } from "babylonjs/Meshes/mesh";
  57455. /**
  57456. * Class containing static functions to help procedurally build meshes
  57457. */
  57458. export class RibbonBuilder {
  57459. /**
  57460. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57461. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57462. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57463. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57464. * * 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
  57465. * * 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
  57466. * * 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
  57467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57470. * * 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
  57471. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57472. * * 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
  57473. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57475. * @param name defines the name of the mesh
  57476. * @param options defines the options used to create the mesh
  57477. * @param scene defines the hosting scene
  57478. * @returns the ribbon mesh
  57479. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57481. */
  57482. static CreateRibbon(name: string, options: {
  57483. pathArray: Vector3[][];
  57484. closeArray?: boolean;
  57485. closePath?: boolean;
  57486. offset?: number;
  57487. updatable?: boolean;
  57488. sideOrientation?: number;
  57489. frontUVs?: Vector4;
  57490. backUVs?: Vector4;
  57491. instance?: Mesh;
  57492. invertUV?: boolean;
  57493. uvs?: Vector2[];
  57494. colors?: Color4[];
  57495. }, scene?: Nullable<Scene>): Mesh;
  57496. }
  57497. }
  57498. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57499. import { Nullable } from "babylonjs/types";
  57500. import { Scene } from "babylonjs/scene";
  57501. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57502. import { Mesh } from "babylonjs/Meshes/mesh";
  57503. /**
  57504. * Class containing static functions to help procedurally build meshes
  57505. */
  57506. export class ShapeBuilder {
  57507. /**
  57508. * 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.
  57509. * * 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.
  57510. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57511. * * 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.
  57512. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57513. * * 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
  57514. * * 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
  57515. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57520. * @param name defines the name of the mesh
  57521. * @param options defines the options used to create the mesh
  57522. * @param scene defines the hosting scene
  57523. * @returns the extruded shape mesh
  57524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57526. */
  57527. static ExtrudeShape(name: string, options: {
  57528. shape: Vector3[];
  57529. path: Vector3[];
  57530. scale?: number;
  57531. rotation?: number;
  57532. cap?: number;
  57533. updatable?: boolean;
  57534. sideOrientation?: number;
  57535. frontUVs?: Vector4;
  57536. backUVs?: Vector4;
  57537. instance?: Mesh;
  57538. invertUV?: boolean;
  57539. }, scene?: Nullable<Scene>): Mesh;
  57540. /**
  57541. * Creates an custom extruded shape mesh.
  57542. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57543. * * 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.
  57544. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57545. * * 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
  57546. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57547. * * 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
  57548. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57549. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57550. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57551. * * 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
  57552. * * 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
  57553. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57558. * @param name defines the name of the mesh
  57559. * @param options defines the options used to create the mesh
  57560. * @param scene defines the hosting scene
  57561. * @returns the custom extruded shape mesh
  57562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57565. */
  57566. static ExtrudeShapeCustom(name: string, options: {
  57567. shape: Vector3[];
  57568. path: Vector3[];
  57569. scaleFunction?: any;
  57570. rotationFunction?: any;
  57571. ribbonCloseArray?: boolean;
  57572. ribbonClosePath?: boolean;
  57573. cap?: number;
  57574. updatable?: boolean;
  57575. sideOrientation?: number;
  57576. frontUVs?: Vector4;
  57577. backUVs?: Vector4;
  57578. instance?: Mesh;
  57579. invertUV?: boolean;
  57580. }, scene?: Nullable<Scene>): Mesh;
  57581. private static _ExtrudeShapeGeneric;
  57582. }
  57583. }
  57584. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57585. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57586. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57587. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57588. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57589. import { Nullable } from "babylonjs/types";
  57590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57591. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57592. /**
  57593. * AmmoJS Physics plugin
  57594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57595. * @see https://github.com/kripken/ammo.js/
  57596. */
  57597. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57598. private _useDeltaForWorldStep;
  57599. /**
  57600. * Reference to the Ammo library
  57601. */
  57602. bjsAMMO: any;
  57603. /**
  57604. * Created ammoJS world which physics bodies are added to
  57605. */
  57606. world: any;
  57607. /**
  57608. * Name of the plugin
  57609. */
  57610. name: string;
  57611. private _timeStep;
  57612. private _fixedTimeStep;
  57613. private _maxSteps;
  57614. private _tmpQuaternion;
  57615. private _tmpAmmoTransform;
  57616. private _tmpAmmoQuaternion;
  57617. private _tmpAmmoConcreteContactResultCallback;
  57618. private _collisionConfiguration;
  57619. private _dispatcher;
  57620. private _overlappingPairCache;
  57621. private _solver;
  57622. private _softBodySolver;
  57623. private _tmpAmmoVectorA;
  57624. private _tmpAmmoVectorB;
  57625. private _tmpAmmoVectorC;
  57626. private _tmpAmmoVectorD;
  57627. private _tmpContactCallbackResult;
  57628. private _tmpAmmoVectorRCA;
  57629. private _tmpAmmoVectorRCB;
  57630. private _raycastResult;
  57631. private static readonly DISABLE_COLLISION_FLAG;
  57632. private static readonly KINEMATIC_FLAG;
  57633. private static readonly DISABLE_DEACTIVATION_FLAG;
  57634. /**
  57635. * Initializes the ammoJS plugin
  57636. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57637. * @param ammoInjection can be used to inject your own ammo reference
  57638. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57639. */
  57640. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57641. /**
  57642. * Sets the gravity of the physics world (m/(s^2))
  57643. * @param gravity Gravity to set
  57644. */
  57645. setGravity(gravity: Vector3): void;
  57646. /**
  57647. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57648. * @param timeStep timestep to use in seconds
  57649. */
  57650. setTimeStep(timeStep: number): void;
  57651. /**
  57652. * 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)
  57653. * @param fixedTimeStep fixedTimeStep to use in seconds
  57654. */
  57655. setFixedTimeStep(fixedTimeStep: number): void;
  57656. /**
  57657. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57658. * @param maxSteps the maximum number of steps by the physics engine per frame
  57659. */
  57660. setMaxSteps(maxSteps: number): void;
  57661. /**
  57662. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57663. * @returns the current timestep in seconds
  57664. */
  57665. getTimeStep(): number;
  57666. /**
  57667. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57668. */
  57669. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57670. private _isImpostorInContact;
  57671. private _isImpostorPairInContact;
  57672. private _stepSimulation;
  57673. /**
  57674. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57675. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57676. * After the step the babylon meshes are set to the position of the physics imposters
  57677. * @param delta amount of time to step forward
  57678. * @param impostors array of imposters to update before/after the step
  57679. */
  57680. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57681. /**
  57682. * Update babylon mesh to match physics world object
  57683. * @param impostor imposter to match
  57684. */
  57685. private _afterSoftStep;
  57686. /**
  57687. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57688. * @param impostor imposter to match
  57689. */
  57690. private _ropeStep;
  57691. /**
  57692. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57693. * @param impostor imposter to match
  57694. */
  57695. private _softbodyOrClothStep;
  57696. private _tmpVector;
  57697. private _tmpMatrix;
  57698. /**
  57699. * Applies an impulse on the imposter
  57700. * @param impostor imposter to apply impulse to
  57701. * @param force amount of force to be applied to the imposter
  57702. * @param contactPoint the location to apply the impulse on the imposter
  57703. */
  57704. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57705. /**
  57706. * Applies a force on the imposter
  57707. * @param impostor imposter to apply force
  57708. * @param force amount of force to be applied to the imposter
  57709. * @param contactPoint the location to apply the force on the imposter
  57710. */
  57711. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57712. /**
  57713. * Creates a physics body using the plugin
  57714. * @param impostor the imposter to create the physics body on
  57715. */
  57716. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57717. /**
  57718. * Removes the physics body from the imposter and disposes of the body's memory
  57719. * @param impostor imposter to remove the physics body from
  57720. */
  57721. removePhysicsBody(impostor: PhysicsImpostor): void;
  57722. /**
  57723. * Generates a joint
  57724. * @param impostorJoint the imposter joint to create the joint with
  57725. */
  57726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57727. /**
  57728. * Removes a joint
  57729. * @param impostorJoint the imposter joint to remove the joint from
  57730. */
  57731. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57732. private _addMeshVerts;
  57733. /**
  57734. * Initialise the soft body vertices to match its object's (mesh) vertices
  57735. * Softbody vertices (nodes) are in world space and to match this
  57736. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57737. * @param impostor to create the softbody for
  57738. */
  57739. private _softVertexData;
  57740. /**
  57741. * Create an impostor's soft body
  57742. * @param impostor to create the softbody for
  57743. */
  57744. private _createSoftbody;
  57745. /**
  57746. * Create cloth for an impostor
  57747. * @param impostor to create the softbody for
  57748. */
  57749. private _createCloth;
  57750. /**
  57751. * Create rope for an impostor
  57752. * @param impostor to create the softbody for
  57753. */
  57754. private _createRope;
  57755. /**
  57756. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57757. * @param impostor to create the custom physics shape for
  57758. */
  57759. private _createCustom;
  57760. private _addHullVerts;
  57761. private _createShape;
  57762. /**
  57763. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57764. * @param impostor imposter containing the physics body and babylon object
  57765. */
  57766. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57767. /**
  57768. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57769. * @param impostor imposter containing the physics body and babylon object
  57770. * @param newPosition new position
  57771. * @param newRotation new rotation
  57772. */
  57773. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57774. /**
  57775. * If this plugin is supported
  57776. * @returns true if its supported
  57777. */
  57778. isSupported(): boolean;
  57779. /**
  57780. * Sets the linear velocity of the physics body
  57781. * @param impostor imposter to set the velocity on
  57782. * @param velocity velocity to set
  57783. */
  57784. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57785. /**
  57786. * Sets the angular velocity of the physics body
  57787. * @param impostor imposter to set the velocity on
  57788. * @param velocity velocity to set
  57789. */
  57790. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57791. /**
  57792. * gets the linear velocity
  57793. * @param impostor imposter to get linear velocity from
  57794. * @returns linear velocity
  57795. */
  57796. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57797. /**
  57798. * gets the angular velocity
  57799. * @param impostor imposter to get angular velocity from
  57800. * @returns angular velocity
  57801. */
  57802. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57803. /**
  57804. * Sets the mass of physics body
  57805. * @param impostor imposter to set the mass on
  57806. * @param mass mass to set
  57807. */
  57808. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57809. /**
  57810. * Gets the mass of the physics body
  57811. * @param impostor imposter to get the mass from
  57812. * @returns mass
  57813. */
  57814. getBodyMass(impostor: PhysicsImpostor): number;
  57815. /**
  57816. * Gets friction of the impostor
  57817. * @param impostor impostor to get friction from
  57818. * @returns friction value
  57819. */
  57820. getBodyFriction(impostor: PhysicsImpostor): number;
  57821. /**
  57822. * Sets friction of the impostor
  57823. * @param impostor impostor to set friction on
  57824. * @param friction friction value
  57825. */
  57826. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57827. /**
  57828. * Gets restitution of the impostor
  57829. * @param impostor impostor to get restitution from
  57830. * @returns restitution value
  57831. */
  57832. getBodyRestitution(impostor: PhysicsImpostor): number;
  57833. /**
  57834. * Sets resitution of the impostor
  57835. * @param impostor impostor to set resitution on
  57836. * @param restitution resitution value
  57837. */
  57838. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57839. /**
  57840. * Gets pressure inside the impostor
  57841. * @param impostor impostor to get pressure from
  57842. * @returns pressure value
  57843. */
  57844. getBodyPressure(impostor: PhysicsImpostor): number;
  57845. /**
  57846. * Sets pressure inside a soft body impostor
  57847. * Cloth and rope must remain 0 pressure
  57848. * @param impostor impostor to set pressure on
  57849. * @param pressure pressure value
  57850. */
  57851. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57852. /**
  57853. * Gets stiffness of the impostor
  57854. * @param impostor impostor to get stiffness from
  57855. * @returns pressure value
  57856. */
  57857. getBodyStiffness(impostor: PhysicsImpostor): number;
  57858. /**
  57859. * Sets stiffness of the impostor
  57860. * @param impostor impostor to set stiffness on
  57861. * @param stiffness stiffness value from 0 to 1
  57862. */
  57863. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57864. /**
  57865. * Gets velocityIterations of the impostor
  57866. * @param impostor impostor to get velocity iterations from
  57867. * @returns velocityIterations value
  57868. */
  57869. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57870. /**
  57871. * Sets velocityIterations of the impostor
  57872. * @param impostor impostor to set velocity iterations on
  57873. * @param velocityIterations velocityIterations value
  57874. */
  57875. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57876. /**
  57877. * Gets positionIterations of the impostor
  57878. * @param impostor impostor to get position iterations from
  57879. * @returns positionIterations value
  57880. */
  57881. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57882. /**
  57883. * Sets positionIterations of the impostor
  57884. * @param impostor impostor to set position on
  57885. * @param positionIterations positionIterations value
  57886. */
  57887. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57888. /**
  57889. * Append an anchor to a cloth object
  57890. * @param impostor is the cloth impostor to add anchor to
  57891. * @param otherImpostor is the rigid impostor to anchor to
  57892. * @param width ratio across width from 0 to 1
  57893. * @param height ratio up height from 0 to 1
  57894. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57895. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57896. */
  57897. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57898. /**
  57899. * Append an hook to a rope object
  57900. * @param impostor is the rope impostor to add hook to
  57901. * @param otherImpostor is the rigid impostor to hook to
  57902. * @param length ratio along the rope from 0 to 1
  57903. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57904. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57905. */
  57906. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57907. /**
  57908. * Sleeps the physics body and stops it from being active
  57909. * @param impostor impostor to sleep
  57910. */
  57911. sleepBody(impostor: PhysicsImpostor): void;
  57912. /**
  57913. * Activates the physics body
  57914. * @param impostor impostor to activate
  57915. */
  57916. wakeUpBody(impostor: PhysicsImpostor): void;
  57917. /**
  57918. * Updates the distance parameters of the joint
  57919. * @param joint joint to update
  57920. * @param maxDistance maximum distance of the joint
  57921. * @param minDistance minimum distance of the joint
  57922. */
  57923. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57924. /**
  57925. * Sets a motor on the joint
  57926. * @param joint joint to set motor on
  57927. * @param speed speed of the motor
  57928. * @param maxForce maximum force of the motor
  57929. * @param motorIndex index of the motor
  57930. */
  57931. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57932. /**
  57933. * Sets the motors limit
  57934. * @param joint joint to set limit on
  57935. * @param upperLimit upper limit
  57936. * @param lowerLimit lower limit
  57937. */
  57938. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57939. /**
  57940. * Syncs the position and rotation of a mesh with the impostor
  57941. * @param mesh mesh to sync
  57942. * @param impostor impostor to update the mesh with
  57943. */
  57944. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57945. /**
  57946. * Gets the radius of the impostor
  57947. * @param impostor impostor to get radius from
  57948. * @returns the radius
  57949. */
  57950. getRadius(impostor: PhysicsImpostor): number;
  57951. /**
  57952. * Gets the box size of the impostor
  57953. * @param impostor impostor to get box size from
  57954. * @param result the resulting box size
  57955. */
  57956. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57957. /**
  57958. * Disposes of the impostor
  57959. */
  57960. dispose(): void;
  57961. /**
  57962. * Does a raycast in the physics world
  57963. * @param from when should the ray start?
  57964. * @param to when should the ray end?
  57965. * @returns PhysicsRaycastResult
  57966. */
  57967. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57968. }
  57969. }
  57970. declare module "babylonjs/Probes/reflectionProbe" {
  57971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57972. import { Vector3 } from "babylonjs/Maths/math.vector";
  57973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57974. import { Nullable } from "babylonjs/types";
  57975. import { Scene } from "babylonjs/scene";
  57976. module "babylonjs/abstractScene" {
  57977. interface AbstractScene {
  57978. /**
  57979. * The list of reflection probes added to the scene
  57980. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57981. */
  57982. reflectionProbes: Array<ReflectionProbe>;
  57983. /**
  57984. * Removes the given reflection probe from this scene.
  57985. * @param toRemove The reflection probe to remove
  57986. * @returns The index of the removed reflection probe
  57987. */
  57988. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57989. /**
  57990. * Adds the given reflection probe to this scene.
  57991. * @param newReflectionProbe The reflection probe to add
  57992. */
  57993. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57994. }
  57995. }
  57996. /**
  57997. * Class used to generate realtime reflection / refraction cube textures
  57998. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57999. */
  58000. export class ReflectionProbe {
  58001. /** defines the name of the probe */
  58002. name: string;
  58003. private _scene;
  58004. private _renderTargetTexture;
  58005. private _projectionMatrix;
  58006. private _viewMatrix;
  58007. private _target;
  58008. private _add;
  58009. private _attachedMesh;
  58010. private _invertYAxis;
  58011. /** Gets or sets probe position (center of the cube map) */
  58012. position: Vector3;
  58013. /**
  58014. * Creates a new reflection probe
  58015. * @param name defines the name of the probe
  58016. * @param size defines the texture resolution (for each face)
  58017. * @param scene defines the hosting scene
  58018. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58019. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58020. */
  58021. constructor(
  58022. /** defines the name of the probe */
  58023. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58024. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58025. get samples(): number;
  58026. set samples(value: number);
  58027. /** Gets or sets the refresh rate to use (on every frame by default) */
  58028. get refreshRate(): number;
  58029. set refreshRate(value: number);
  58030. /**
  58031. * Gets the hosting scene
  58032. * @returns a Scene
  58033. */
  58034. getScene(): Scene;
  58035. /** Gets the internal CubeTexture used to render to */
  58036. get cubeTexture(): RenderTargetTexture;
  58037. /** Gets the list of meshes to render */
  58038. get renderList(): Nullable<AbstractMesh[]>;
  58039. /**
  58040. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58041. * @param mesh defines the mesh to attach to
  58042. */
  58043. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58044. /**
  58045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58046. * @param renderingGroupId The rendering group id corresponding to its index
  58047. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58048. */
  58049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58050. /**
  58051. * Clean all associated resources
  58052. */
  58053. dispose(): void;
  58054. /**
  58055. * Converts the reflection probe information to a readable string for debug purpose.
  58056. * @param fullDetails Supports for multiple levels of logging within scene loading
  58057. * @returns the human readable reflection probe info
  58058. */
  58059. toString(fullDetails?: boolean): string;
  58060. /**
  58061. * Get the class name of the relfection probe.
  58062. * @returns "ReflectionProbe"
  58063. */
  58064. getClassName(): string;
  58065. /**
  58066. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58067. * @returns The JSON representation of the texture
  58068. */
  58069. serialize(): any;
  58070. /**
  58071. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58072. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58073. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58075. * @returns The parsed reflection probe if successful
  58076. */
  58077. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58078. }
  58079. }
  58080. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58081. /** @hidden */
  58082. export var _BabylonLoaderRegistered: boolean;
  58083. /**
  58084. * Helps setting up some configuration for the babylon file loader.
  58085. */
  58086. export class BabylonFileLoaderConfiguration {
  58087. /**
  58088. * The loader does not allow injecting custom physix engine into the plugins.
  58089. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58090. * So you could set this variable to your engine import to make it work.
  58091. */
  58092. static LoaderInjectedPhysicsEngine: any;
  58093. }
  58094. }
  58095. declare module "babylonjs/Loading/Plugins/index" {
  58096. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58097. }
  58098. declare module "babylonjs/Loading/index" {
  58099. export * from "babylonjs/Loading/loadingScreen";
  58100. export * from "babylonjs/Loading/Plugins/index";
  58101. export * from "babylonjs/Loading/sceneLoader";
  58102. export * from "babylonjs/Loading/sceneLoaderFlags";
  58103. }
  58104. declare module "babylonjs/Materials/Background/index" {
  58105. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58106. }
  58107. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58108. import { Scene } from "babylonjs/scene";
  58109. import { Color3 } from "babylonjs/Maths/math.color";
  58110. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58112. /**
  58113. * The Physically based simple base material of BJS.
  58114. *
  58115. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58116. * It is used as the base class for both the specGloss and metalRough conventions.
  58117. */
  58118. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58119. /**
  58120. * Number of Simultaneous lights allowed on the material.
  58121. */
  58122. maxSimultaneousLights: number;
  58123. /**
  58124. * If sets to true, disables all the lights affecting the material.
  58125. */
  58126. disableLighting: boolean;
  58127. /**
  58128. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58129. */
  58130. environmentTexture: BaseTexture;
  58131. /**
  58132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58133. */
  58134. invertNormalMapX: boolean;
  58135. /**
  58136. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58137. */
  58138. invertNormalMapY: boolean;
  58139. /**
  58140. * Normal map used in the model.
  58141. */
  58142. normalTexture: BaseTexture;
  58143. /**
  58144. * Emissivie color used to self-illuminate the model.
  58145. */
  58146. emissiveColor: Color3;
  58147. /**
  58148. * Emissivie texture used to self-illuminate the model.
  58149. */
  58150. emissiveTexture: BaseTexture;
  58151. /**
  58152. * Occlusion Channel Strenght.
  58153. */
  58154. occlusionStrength: number;
  58155. /**
  58156. * Occlusion Texture of the material (adding extra occlusion effects).
  58157. */
  58158. occlusionTexture: BaseTexture;
  58159. /**
  58160. * Defines the alpha limits in alpha test mode.
  58161. */
  58162. alphaCutOff: number;
  58163. /**
  58164. * Gets the current double sided mode.
  58165. */
  58166. get doubleSided(): boolean;
  58167. /**
  58168. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58169. */
  58170. set doubleSided(value: boolean);
  58171. /**
  58172. * Stores the pre-calculated light information of a mesh in a texture.
  58173. */
  58174. lightmapTexture: BaseTexture;
  58175. /**
  58176. * If true, the light map contains occlusion information instead of lighting info.
  58177. */
  58178. useLightmapAsShadowmap: boolean;
  58179. /**
  58180. * Instantiates a new PBRMaterial instance.
  58181. *
  58182. * @param name The material name
  58183. * @param scene The scene the material will be use in.
  58184. */
  58185. constructor(name: string, scene: Scene);
  58186. getClassName(): string;
  58187. }
  58188. }
  58189. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58190. import { Scene } from "babylonjs/scene";
  58191. import { Color3 } from "babylonjs/Maths/math.color";
  58192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58193. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58194. /**
  58195. * The PBR material of BJS following the metal roughness convention.
  58196. *
  58197. * This fits to the PBR convention in the GLTF definition:
  58198. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58199. */
  58200. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58201. /**
  58202. * The base color has two different interpretations depending on the value of metalness.
  58203. * When the material is a metal, the base color is the specific measured reflectance value
  58204. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58205. * of the material.
  58206. */
  58207. baseColor: Color3;
  58208. /**
  58209. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58210. * well as opacity information in the alpha channel.
  58211. */
  58212. baseTexture: BaseTexture;
  58213. /**
  58214. * Specifies the metallic scalar value of the material.
  58215. * Can also be used to scale the metalness values of the metallic texture.
  58216. */
  58217. metallic: number;
  58218. /**
  58219. * Specifies the roughness scalar value of the material.
  58220. * Can also be used to scale the roughness values of the metallic texture.
  58221. */
  58222. roughness: number;
  58223. /**
  58224. * Texture containing both the metallic value in the B channel and the
  58225. * roughness value in the G channel to keep better precision.
  58226. */
  58227. metallicRoughnessTexture: BaseTexture;
  58228. /**
  58229. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58230. *
  58231. * @param name The material name
  58232. * @param scene The scene the material will be use in.
  58233. */
  58234. constructor(name: string, scene: Scene);
  58235. /**
  58236. * Return the currrent class name of the material.
  58237. */
  58238. getClassName(): string;
  58239. /**
  58240. * Makes a duplicate of the current material.
  58241. * @param name - name to use for the new material.
  58242. */
  58243. clone(name: string): PBRMetallicRoughnessMaterial;
  58244. /**
  58245. * Serialize the material to a parsable JSON object.
  58246. */
  58247. serialize(): any;
  58248. /**
  58249. * Parses a JSON object correponding to the serialize function.
  58250. */
  58251. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58252. }
  58253. }
  58254. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58255. import { Scene } from "babylonjs/scene";
  58256. import { Color3 } from "babylonjs/Maths/math.color";
  58257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58258. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58259. /**
  58260. * The PBR material of BJS following the specular glossiness convention.
  58261. *
  58262. * This fits to the PBR convention in the GLTF definition:
  58263. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58264. */
  58265. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58266. /**
  58267. * Specifies the diffuse color of the material.
  58268. */
  58269. diffuseColor: Color3;
  58270. /**
  58271. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58272. * channel.
  58273. */
  58274. diffuseTexture: BaseTexture;
  58275. /**
  58276. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58277. */
  58278. specularColor: Color3;
  58279. /**
  58280. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58281. */
  58282. glossiness: number;
  58283. /**
  58284. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58285. */
  58286. specularGlossinessTexture: BaseTexture;
  58287. /**
  58288. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58289. *
  58290. * @param name The material name
  58291. * @param scene The scene the material will be use in.
  58292. */
  58293. constructor(name: string, scene: Scene);
  58294. /**
  58295. * Return the currrent class name of the material.
  58296. */
  58297. getClassName(): string;
  58298. /**
  58299. * Makes a duplicate of the current material.
  58300. * @param name - name to use for the new material.
  58301. */
  58302. clone(name: string): PBRSpecularGlossinessMaterial;
  58303. /**
  58304. * Serialize the material to a parsable JSON object.
  58305. */
  58306. serialize(): any;
  58307. /**
  58308. * Parses a JSON object correponding to the serialize function.
  58309. */
  58310. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58311. }
  58312. }
  58313. declare module "babylonjs/Materials/PBR/index" {
  58314. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58315. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58316. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58317. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58318. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58319. }
  58320. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58321. import { Nullable } from "babylonjs/types";
  58322. import { Scene } from "babylonjs/scene";
  58323. import { Matrix } from "babylonjs/Maths/math.vector";
  58324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58325. /**
  58326. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58327. * It can help converting any input color in a desired output one. This can then be used to create effects
  58328. * from sepia, black and white to sixties or futuristic rendering...
  58329. *
  58330. * The only supported format is currently 3dl.
  58331. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58332. */
  58333. export class ColorGradingTexture extends BaseTexture {
  58334. /**
  58335. * The current texture matrix. (will always be identity in color grading texture)
  58336. */
  58337. private _textureMatrix;
  58338. /**
  58339. * The texture URL.
  58340. */
  58341. url: string;
  58342. /**
  58343. * Empty line regex stored for GC.
  58344. */
  58345. private static _noneEmptyLineRegex;
  58346. private _engine;
  58347. /**
  58348. * Instantiates a ColorGradingTexture from the following parameters.
  58349. *
  58350. * @param url The location of the color gradind data (currently only supporting 3dl)
  58351. * @param scene The scene the texture will be used in
  58352. */
  58353. constructor(url: string, scene: Scene);
  58354. /**
  58355. * Returns the texture matrix used in most of the material.
  58356. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58357. */
  58358. getTextureMatrix(): Matrix;
  58359. /**
  58360. * Occurs when the file being loaded is a .3dl LUT file.
  58361. */
  58362. private load3dlTexture;
  58363. /**
  58364. * Starts the loading process of the texture.
  58365. */
  58366. private loadTexture;
  58367. /**
  58368. * Clones the color gradind texture.
  58369. */
  58370. clone(): ColorGradingTexture;
  58371. /**
  58372. * Called during delayed load for textures.
  58373. */
  58374. delayLoad(): void;
  58375. /**
  58376. * Parses a color grading texture serialized by Babylon.
  58377. * @param parsedTexture The texture information being parsedTexture
  58378. * @param scene The scene to load the texture in
  58379. * @param rootUrl The root url of the data assets to load
  58380. * @return A color gradind texture
  58381. */
  58382. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58383. /**
  58384. * Serializes the LUT texture to json format.
  58385. */
  58386. serialize(): any;
  58387. }
  58388. }
  58389. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58391. import { Scene } from "babylonjs/scene";
  58392. import { Nullable } from "babylonjs/types";
  58393. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58394. /**
  58395. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58396. */
  58397. export class EquiRectangularCubeTexture extends BaseTexture {
  58398. /** The six faces of the cube. */
  58399. private static _FacesMapping;
  58400. private _noMipmap;
  58401. private _onLoad;
  58402. private _onError;
  58403. /** The size of the cubemap. */
  58404. private _size;
  58405. /** The buffer of the image. */
  58406. private _buffer;
  58407. /** The width of the input image. */
  58408. private _width;
  58409. /** The height of the input image. */
  58410. private _height;
  58411. /** The URL to the image. */
  58412. url: string;
  58413. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58414. coordinatesMode: number;
  58415. /**
  58416. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58417. * @param url The location of the image
  58418. * @param scene The scene the texture will be used in
  58419. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58420. * @param noMipmap Forces to not generate the mipmap if true
  58421. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58422. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58423. * @param onLoad — defines a callback called when texture is loaded
  58424. * @param onError — defines a callback called if there is an error
  58425. */
  58426. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58427. /**
  58428. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58429. */
  58430. private loadImage;
  58431. /**
  58432. * Convert the image buffer into a cubemap and create a CubeTexture.
  58433. */
  58434. private loadTexture;
  58435. /**
  58436. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58437. * @param buffer The ArrayBuffer that should be converted.
  58438. * @returns The buffer as Float32Array.
  58439. */
  58440. private getFloat32ArrayFromArrayBuffer;
  58441. /**
  58442. * Get the current class name of the texture useful for serialization or dynamic coding.
  58443. * @returns "EquiRectangularCubeTexture"
  58444. */
  58445. getClassName(): string;
  58446. /**
  58447. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58448. * @returns A clone of the current EquiRectangularCubeTexture.
  58449. */
  58450. clone(): EquiRectangularCubeTexture;
  58451. }
  58452. }
  58453. declare module "babylonjs/Misc/tga" {
  58454. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58455. /**
  58456. * Based on jsTGALoader - Javascript loader for TGA file
  58457. * By Vincent Thibault
  58458. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58459. */
  58460. export class TGATools {
  58461. private static _TYPE_INDEXED;
  58462. private static _TYPE_RGB;
  58463. private static _TYPE_GREY;
  58464. private static _TYPE_RLE_INDEXED;
  58465. private static _TYPE_RLE_RGB;
  58466. private static _TYPE_RLE_GREY;
  58467. private static _ORIGIN_MASK;
  58468. private static _ORIGIN_SHIFT;
  58469. private static _ORIGIN_BL;
  58470. private static _ORIGIN_BR;
  58471. private static _ORIGIN_UL;
  58472. private static _ORIGIN_UR;
  58473. /**
  58474. * Gets the header of a TGA file
  58475. * @param data defines the TGA data
  58476. * @returns the header
  58477. */
  58478. static GetTGAHeader(data: Uint8Array): any;
  58479. /**
  58480. * Uploads TGA content to a Babylon Texture
  58481. * @hidden
  58482. */
  58483. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58484. /** @hidden */
  58485. 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;
  58486. /** @hidden */
  58487. 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;
  58488. /** @hidden */
  58489. 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;
  58490. /** @hidden */
  58491. 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;
  58492. /** @hidden */
  58493. 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;
  58494. /** @hidden */
  58495. 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;
  58496. }
  58497. }
  58498. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58499. import { Nullable } from "babylonjs/types";
  58500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58501. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58502. /**
  58503. * Implementation of the TGA Texture Loader.
  58504. * @hidden
  58505. */
  58506. export class _TGATextureLoader implements IInternalTextureLoader {
  58507. /**
  58508. * Defines wether the loader supports cascade loading the different faces.
  58509. */
  58510. readonly supportCascades: boolean;
  58511. /**
  58512. * This returns if the loader support the current file information.
  58513. * @param extension defines the file extension of the file being loaded
  58514. * @returns true if the loader can load the specified file
  58515. */
  58516. canLoad(extension: string): boolean;
  58517. /**
  58518. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58519. * @param data contains the texture data
  58520. * @param texture defines the BabylonJS internal texture
  58521. * @param createPolynomials will be true if polynomials have been requested
  58522. * @param onLoad defines the callback to trigger once the texture is ready
  58523. * @param onError defines the callback to trigger in case of error
  58524. */
  58525. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58526. /**
  58527. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58528. * @param data contains the texture data
  58529. * @param texture defines the BabylonJS internal texture
  58530. * @param callback defines the method to call once ready to upload
  58531. */
  58532. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58533. }
  58534. }
  58535. declare module "babylonjs/Misc/basis" {
  58536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58537. /**
  58538. * Info about the .basis files
  58539. */
  58540. class BasisFileInfo {
  58541. /**
  58542. * If the file has alpha
  58543. */
  58544. hasAlpha: boolean;
  58545. /**
  58546. * Info about each image of the basis file
  58547. */
  58548. images: Array<{
  58549. levels: Array<{
  58550. width: number;
  58551. height: number;
  58552. transcodedPixels: ArrayBufferView;
  58553. }>;
  58554. }>;
  58555. }
  58556. /**
  58557. * Result of transcoding a basis file
  58558. */
  58559. class TranscodeResult {
  58560. /**
  58561. * Info about the .basis file
  58562. */
  58563. fileInfo: BasisFileInfo;
  58564. /**
  58565. * Format to use when loading the file
  58566. */
  58567. format: number;
  58568. }
  58569. /**
  58570. * Configuration options for the Basis transcoder
  58571. */
  58572. export class BasisTranscodeConfiguration {
  58573. /**
  58574. * Supported compression formats used to determine the supported output format of the transcoder
  58575. */
  58576. supportedCompressionFormats?: {
  58577. /**
  58578. * etc1 compression format
  58579. */
  58580. etc1?: boolean;
  58581. /**
  58582. * s3tc compression format
  58583. */
  58584. s3tc?: boolean;
  58585. /**
  58586. * pvrtc compression format
  58587. */
  58588. pvrtc?: boolean;
  58589. /**
  58590. * etc2 compression format
  58591. */
  58592. etc2?: boolean;
  58593. };
  58594. /**
  58595. * If mipmap levels should be loaded for transcoded images (Default: true)
  58596. */
  58597. loadMipmapLevels?: boolean;
  58598. /**
  58599. * Index of a single image to load (Default: all images)
  58600. */
  58601. loadSingleImage?: number;
  58602. }
  58603. /**
  58604. * Used to load .Basis files
  58605. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58606. */
  58607. export class BasisTools {
  58608. private static _IgnoreSupportedFormats;
  58609. /**
  58610. * URL to use when loading the basis transcoder
  58611. */
  58612. static JSModuleURL: string;
  58613. /**
  58614. * URL to use when loading the wasm module for the transcoder
  58615. */
  58616. static WasmModuleURL: string;
  58617. /**
  58618. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58619. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58620. * @returns internal format corresponding to the Basis format
  58621. */
  58622. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58623. private static _WorkerPromise;
  58624. private static _Worker;
  58625. private static _actionId;
  58626. private static _CreateWorkerAsync;
  58627. /**
  58628. * Transcodes a loaded image file to compressed pixel data
  58629. * @param data image data to transcode
  58630. * @param config configuration options for the transcoding
  58631. * @returns a promise resulting in the transcoded image
  58632. */
  58633. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58634. /**
  58635. * Loads a texture from the transcode result
  58636. * @param texture texture load to
  58637. * @param transcodeResult the result of transcoding the basis file to load from
  58638. */
  58639. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58640. }
  58641. }
  58642. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58643. import { Nullable } from "babylonjs/types";
  58644. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58645. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58646. /**
  58647. * Loader for .basis file format
  58648. */
  58649. export class _BasisTextureLoader implements IInternalTextureLoader {
  58650. /**
  58651. * Defines whether the loader supports cascade loading the different faces.
  58652. */
  58653. readonly supportCascades: boolean;
  58654. /**
  58655. * This returns if the loader support the current file information.
  58656. * @param extension defines the file extension of the file being loaded
  58657. * @returns true if the loader can load the specified file
  58658. */
  58659. canLoad(extension: string): boolean;
  58660. /**
  58661. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58662. * @param data contains the texture data
  58663. * @param texture defines the BabylonJS internal texture
  58664. * @param createPolynomials will be true if polynomials have been requested
  58665. * @param onLoad defines the callback to trigger once the texture is ready
  58666. * @param onError defines the callback to trigger in case of error
  58667. */
  58668. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58669. /**
  58670. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58671. * @param data contains the texture data
  58672. * @param texture defines the BabylonJS internal texture
  58673. * @param callback defines the method to call once ready to upload
  58674. */
  58675. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58676. }
  58677. }
  58678. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58679. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58680. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58681. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58682. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58683. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58684. }
  58685. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58686. import { Scene } from "babylonjs/scene";
  58687. import { Texture } from "babylonjs/Materials/Textures/texture";
  58688. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58689. /**
  58690. * 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.
  58691. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58692. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58693. */
  58694. export class CustomProceduralTexture extends ProceduralTexture {
  58695. private _animate;
  58696. private _time;
  58697. private _config;
  58698. private _texturePath;
  58699. /**
  58700. * Instantiates a new Custom Procedural Texture.
  58701. * 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.
  58702. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58704. * @param name Define the name of the texture
  58705. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58706. * @param size Define the size of the texture to create
  58707. * @param scene Define the scene the texture belongs to
  58708. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58709. * @param generateMipMaps Define if the texture should creates mip maps or not
  58710. */
  58711. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58712. private _loadJson;
  58713. /**
  58714. * Is the texture ready to be used ? (rendered at least once)
  58715. * @returns true if ready, otherwise, false.
  58716. */
  58717. isReady(): boolean;
  58718. /**
  58719. * Render the texture to its associated render target.
  58720. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58721. */
  58722. render(useCameraPostProcess?: boolean): void;
  58723. /**
  58724. * Update the list of dependant textures samplers in the shader.
  58725. */
  58726. updateTextures(): void;
  58727. /**
  58728. * Update the uniform values of the procedural texture in the shader.
  58729. */
  58730. updateShaderUniforms(): void;
  58731. /**
  58732. * Define if the texture animates or not.
  58733. */
  58734. get animate(): boolean;
  58735. set animate(value: boolean);
  58736. }
  58737. }
  58738. declare module "babylonjs/Shaders/noise.fragment" {
  58739. /** @hidden */
  58740. export var noisePixelShader: {
  58741. name: string;
  58742. shader: string;
  58743. };
  58744. }
  58745. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58746. import { Nullable } from "babylonjs/types";
  58747. import { Scene } from "babylonjs/scene";
  58748. import { Texture } from "babylonjs/Materials/Textures/texture";
  58749. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58750. import "babylonjs/Shaders/noise.fragment";
  58751. /**
  58752. * Class used to generate noise procedural textures
  58753. */
  58754. export class NoiseProceduralTexture extends ProceduralTexture {
  58755. private _time;
  58756. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58757. brightness: number;
  58758. /** Defines the number of octaves to process */
  58759. octaves: number;
  58760. /** Defines the level of persistence (0.8 by default) */
  58761. persistence: number;
  58762. /** Gets or sets animation speed factor (default is 1) */
  58763. animationSpeedFactor: number;
  58764. /**
  58765. * Creates a new NoiseProceduralTexture
  58766. * @param name defines the name fo the texture
  58767. * @param size defines the size of the texture (default is 256)
  58768. * @param scene defines the hosting scene
  58769. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58770. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58771. */
  58772. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58773. private _updateShaderUniforms;
  58774. protected _getDefines(): string;
  58775. /** Generate the current state of the procedural texture */
  58776. render(useCameraPostProcess?: boolean): void;
  58777. /**
  58778. * Serializes this noise procedural texture
  58779. * @returns a serialized noise procedural texture object
  58780. */
  58781. serialize(): any;
  58782. /**
  58783. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58784. * @param parsedTexture defines parsed texture data
  58785. * @param scene defines the current scene
  58786. * @param rootUrl defines the root URL containing noise procedural texture information
  58787. * @returns a parsed NoiseProceduralTexture
  58788. */
  58789. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58790. }
  58791. }
  58792. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58793. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58794. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58795. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58796. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58797. }
  58798. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58799. import { Nullable } from "babylonjs/types";
  58800. import { Scene } from "babylonjs/scene";
  58801. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58802. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58803. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58804. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58805. /**
  58806. * Raw cube texture where the raw buffers are passed in
  58807. */
  58808. export class RawCubeTexture extends CubeTexture {
  58809. /**
  58810. * Creates a cube texture where the raw buffers are passed in.
  58811. * @param scene defines the scene the texture is attached to
  58812. * @param data defines the array of data to use to create each face
  58813. * @param size defines the size of the textures
  58814. * @param format defines the format of the data
  58815. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58816. * @param generateMipMaps defines if the engine should generate the mip levels
  58817. * @param invertY defines if data must be stored with Y axis inverted
  58818. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58819. * @param compression defines the compression used (null by default)
  58820. */
  58821. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58822. /**
  58823. * Updates the raw cube texture.
  58824. * @param data defines the data to store
  58825. * @param format defines the data format
  58826. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58827. * @param invertY defines if data must be stored with Y axis inverted
  58828. * @param compression defines the compression used (null by default)
  58829. * @param level defines which level of the texture to update
  58830. */
  58831. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58832. /**
  58833. * Updates a raw cube texture with RGBD encoded data.
  58834. * @param data defines the array of data [mipmap][face] to use to create each face
  58835. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58838. * @returns a promsie that resolves when the operation is complete
  58839. */
  58840. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58841. /**
  58842. * Clones the raw cube texture.
  58843. * @return a new cube texture
  58844. */
  58845. clone(): CubeTexture;
  58846. /** @hidden */
  58847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58848. }
  58849. }
  58850. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58851. import { Scene } from "babylonjs/scene";
  58852. import { Texture } from "babylonjs/Materials/Textures/texture";
  58853. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58854. /**
  58855. * Class used to store 3D textures containing user data
  58856. */
  58857. export class RawTexture3D extends Texture {
  58858. /** Gets or sets the texture format to use */
  58859. format: number;
  58860. private _engine;
  58861. /**
  58862. * Create a new RawTexture3D
  58863. * @param data defines the data of the texture
  58864. * @param width defines the width of the texture
  58865. * @param height defines the height of the texture
  58866. * @param depth defines the depth of the texture
  58867. * @param format defines the texture format to use
  58868. * @param scene defines the hosting scene
  58869. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58870. * @param invertY defines if texture must be stored with Y axis inverted
  58871. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58872. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58873. */
  58874. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58875. /** Gets or sets the texture format to use */
  58876. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58877. /**
  58878. * Update the texture with new data
  58879. * @param data defines the data to store in the texture
  58880. */
  58881. update(data: ArrayBufferView): void;
  58882. }
  58883. }
  58884. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58885. import { Scene } from "babylonjs/scene";
  58886. import { Texture } from "babylonjs/Materials/Textures/texture";
  58887. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58888. /**
  58889. * Class used to store 2D array textures containing user data
  58890. */
  58891. export class RawTexture2DArray extends Texture {
  58892. /** Gets or sets the texture format to use */
  58893. format: number;
  58894. private _engine;
  58895. /**
  58896. * Create a new RawTexture2DArray
  58897. * @param data defines the data of the texture
  58898. * @param width defines the width of the texture
  58899. * @param height defines the height of the texture
  58900. * @param depth defines the number of layers of the texture
  58901. * @param format defines the texture format to use
  58902. * @param scene defines the hosting scene
  58903. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58904. * @param invertY defines if texture must be stored with Y axis inverted
  58905. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58906. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58907. */
  58908. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58909. /** Gets or sets the texture format to use */
  58910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58911. /**
  58912. * Update the texture with new data
  58913. * @param data defines the data to store in the texture
  58914. */
  58915. update(data: ArrayBufferView): void;
  58916. }
  58917. }
  58918. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58919. import { Scene } from "babylonjs/scene";
  58920. import { Plane } from "babylonjs/Maths/math.plane";
  58921. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58922. /**
  58923. * Creates a refraction texture used by refraction channel of the standard material.
  58924. * It is like a mirror but to see through a material.
  58925. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58926. */
  58927. export class RefractionTexture extends RenderTargetTexture {
  58928. /**
  58929. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58930. * 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.
  58931. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58932. */
  58933. refractionPlane: Plane;
  58934. /**
  58935. * Define how deep under the surface we should see.
  58936. */
  58937. depth: number;
  58938. /**
  58939. * Creates a refraction texture used by refraction channel of the standard material.
  58940. * It is like a mirror but to see through a material.
  58941. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58942. * @param name Define the texture name
  58943. * @param size Define the size of the underlying texture
  58944. * @param scene Define the scene the refraction belongs to
  58945. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58946. */
  58947. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58948. /**
  58949. * Clone the refraction texture.
  58950. * @returns the cloned texture
  58951. */
  58952. clone(): RefractionTexture;
  58953. /**
  58954. * Serialize the texture to a JSON representation you could use in Parse later on
  58955. * @returns the serialized JSON representation
  58956. */
  58957. serialize(): any;
  58958. }
  58959. }
  58960. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58961. import { Nullable } from "babylonjs/types";
  58962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58963. import { Matrix } from "babylonjs/Maths/math.vector";
  58964. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58965. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58966. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58967. import { Scene } from "babylonjs/scene";
  58968. /**
  58969. * Defines the options related to the creation of an HtmlElementTexture
  58970. */
  58971. export interface IHtmlElementTextureOptions {
  58972. /**
  58973. * Defines wether mip maps should be created or not.
  58974. */
  58975. generateMipMaps?: boolean;
  58976. /**
  58977. * Defines the sampling mode of the texture.
  58978. */
  58979. samplingMode?: number;
  58980. /**
  58981. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58982. */
  58983. engine: Nullable<ThinEngine>;
  58984. /**
  58985. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58986. */
  58987. scene: Nullable<Scene>;
  58988. }
  58989. /**
  58990. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58991. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58992. * is automatically managed.
  58993. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58994. * in your application.
  58995. *
  58996. * As the update is not automatic, you need to call them manually.
  58997. */
  58998. export class HtmlElementTexture extends BaseTexture {
  58999. /**
  59000. * The texture URL.
  59001. */
  59002. element: HTMLVideoElement | HTMLCanvasElement;
  59003. private static readonly DefaultOptions;
  59004. private _textureMatrix;
  59005. private _engine;
  59006. private _isVideo;
  59007. private _generateMipMaps;
  59008. private _samplingMode;
  59009. /**
  59010. * Instantiates a HtmlElementTexture from the following parameters.
  59011. *
  59012. * @param name Defines the name of the texture
  59013. * @param element Defines the video or canvas the texture is filled with
  59014. * @param options Defines the other none mandatory texture creation options
  59015. */
  59016. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59017. private _createInternalTexture;
  59018. /**
  59019. * Returns the texture matrix used in most of the material.
  59020. */
  59021. getTextureMatrix(): Matrix;
  59022. /**
  59023. * Updates the content of the texture.
  59024. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59025. */
  59026. update(invertY?: Nullable<boolean>): void;
  59027. }
  59028. }
  59029. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59030. import { Vector2 } from "babylonjs/Maths/math.vector";
  59031. /**
  59032. * Defines the basic options interface of a TexturePacker Frame
  59033. */
  59034. export interface ITexturePackerFrame {
  59035. /**
  59036. * The frame ID
  59037. */
  59038. id: number;
  59039. /**
  59040. * The frames Scale
  59041. */
  59042. scale: Vector2;
  59043. /**
  59044. * The Frames offset
  59045. */
  59046. offset: Vector2;
  59047. }
  59048. /**
  59049. * This is a support class for frame Data on texture packer sets.
  59050. */
  59051. export class TexturePackerFrame implements ITexturePackerFrame {
  59052. /**
  59053. * The frame ID
  59054. */
  59055. id: number;
  59056. /**
  59057. * The frames Scale
  59058. */
  59059. scale: Vector2;
  59060. /**
  59061. * The Frames offset
  59062. */
  59063. offset: Vector2;
  59064. /**
  59065. * Initializes a texture package frame.
  59066. * @param id The numerical frame identifier
  59067. * @param scale Scalar Vector2 for UV frame
  59068. * @param offset Vector2 for the frame position in UV units.
  59069. * @returns TexturePackerFrame
  59070. */
  59071. constructor(id: number, scale: Vector2, offset: Vector2);
  59072. }
  59073. }
  59074. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59076. import { Scene } from "babylonjs/scene";
  59077. import { Nullable } from "babylonjs/types";
  59078. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59079. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59080. /**
  59081. * Defines the basic options interface of a TexturePacker
  59082. */
  59083. export interface ITexturePackerOptions {
  59084. /**
  59085. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59086. */
  59087. map?: string[];
  59088. /**
  59089. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59090. */
  59091. uvsIn?: string;
  59092. /**
  59093. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59094. */
  59095. uvsOut?: string;
  59096. /**
  59097. * number representing the layout style. Defaults to LAYOUT_STRIP
  59098. */
  59099. layout?: number;
  59100. /**
  59101. * number of columns if using custom column count layout(2). This defaults to 4.
  59102. */
  59103. colnum?: number;
  59104. /**
  59105. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59106. */
  59107. updateInputMeshes?: boolean;
  59108. /**
  59109. * boolean flag to dispose all the source textures. Defaults to true.
  59110. */
  59111. disposeSources?: boolean;
  59112. /**
  59113. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59114. */
  59115. fillBlanks?: boolean;
  59116. /**
  59117. * string value representing the context fill style color. Defaults to 'black'.
  59118. */
  59119. customFillColor?: string;
  59120. /**
  59121. * Width and Height Value of each Frame in the TexturePacker Sets
  59122. */
  59123. frameSize?: number;
  59124. /**
  59125. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59126. */
  59127. paddingRatio?: number;
  59128. /**
  59129. * Number that declares the fill method for the padding gutter.
  59130. */
  59131. paddingMode?: number;
  59132. /**
  59133. * If in SUBUV_COLOR padding mode what color to use.
  59134. */
  59135. paddingColor?: Color3 | Color4;
  59136. }
  59137. /**
  59138. * Defines the basic interface of a TexturePacker JSON File
  59139. */
  59140. export interface ITexturePackerJSON {
  59141. /**
  59142. * The frame ID
  59143. */
  59144. name: string;
  59145. /**
  59146. * The base64 channel data
  59147. */
  59148. sets: any;
  59149. /**
  59150. * The options of the Packer
  59151. */
  59152. options: ITexturePackerOptions;
  59153. /**
  59154. * The frame data of the Packer
  59155. */
  59156. frames: Array<number>;
  59157. }
  59158. /**
  59159. * This is a support class that generates a series of packed texture sets.
  59160. * @see https://doc.babylonjs.com/babylon101/materials
  59161. */
  59162. export class TexturePacker {
  59163. /** Packer Layout Constant 0 */
  59164. static readonly LAYOUT_STRIP: number;
  59165. /** Packer Layout Constant 1 */
  59166. static readonly LAYOUT_POWER2: number;
  59167. /** Packer Layout Constant 2 */
  59168. static readonly LAYOUT_COLNUM: number;
  59169. /** Packer Layout Constant 0 */
  59170. static readonly SUBUV_WRAP: number;
  59171. /** Packer Layout Constant 1 */
  59172. static readonly SUBUV_EXTEND: number;
  59173. /** Packer Layout Constant 2 */
  59174. static readonly SUBUV_COLOR: number;
  59175. /** The Name of the Texture Package */
  59176. name: string;
  59177. /** The scene scope of the TexturePacker */
  59178. scene: Scene;
  59179. /** The Meshes to target */
  59180. meshes: AbstractMesh[];
  59181. /** Arguments passed with the Constructor */
  59182. options: ITexturePackerOptions;
  59183. /** The promise that is started upon initialization */
  59184. promise: Nullable<Promise<TexturePacker | string>>;
  59185. /** The Container object for the channel sets that are generated */
  59186. sets: object;
  59187. /** The Container array for the frames that are generated */
  59188. frames: TexturePackerFrame[];
  59189. /** The expected number of textures the system is parsing. */
  59190. private _expecting;
  59191. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59192. private _paddingValue;
  59193. /**
  59194. * Initializes a texture package series from an array of meshes or a single mesh.
  59195. * @param name The name of the package
  59196. * @param meshes The target meshes to compose the package from
  59197. * @param options The arguments that texture packer should follow while building.
  59198. * @param scene The scene which the textures are scoped to.
  59199. * @returns TexturePacker
  59200. */
  59201. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59202. /**
  59203. * Starts the package process
  59204. * @param resolve The promises resolution function
  59205. * @returns TexturePacker
  59206. */
  59207. private _createFrames;
  59208. /**
  59209. * Calculates the Size of the Channel Sets
  59210. * @returns Vector2
  59211. */
  59212. private _calculateSize;
  59213. /**
  59214. * Calculates the UV data for the frames.
  59215. * @param baseSize the base frameSize
  59216. * @param padding the base frame padding
  59217. * @param dtSize size of the Dynamic Texture for that channel
  59218. * @param dtUnits is 1/dtSize
  59219. * @param update flag to update the input meshes
  59220. */
  59221. private _calculateMeshUVFrames;
  59222. /**
  59223. * Calculates the frames Offset.
  59224. * @param index of the frame
  59225. * @returns Vector2
  59226. */
  59227. private _getFrameOffset;
  59228. /**
  59229. * Updates a Mesh to the frame data
  59230. * @param mesh that is the target
  59231. * @param frameID or the frame index
  59232. */
  59233. private _updateMeshUV;
  59234. /**
  59235. * Updates a Meshes materials to use the texture packer channels
  59236. * @param m is the mesh to target
  59237. * @param force all channels on the packer to be set.
  59238. */
  59239. private _updateTextureReferences;
  59240. /**
  59241. * Public method to set a Mesh to a frame
  59242. * @param m that is the target
  59243. * @param frameID or the frame index
  59244. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59245. */
  59246. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59247. /**
  59248. * Starts the async promise to compile the texture packer.
  59249. * @returns Promise<void>
  59250. */
  59251. processAsync(): Promise<void>;
  59252. /**
  59253. * Disposes all textures associated with this packer
  59254. */
  59255. dispose(): void;
  59256. /**
  59257. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59258. * @param imageType is the image type to use.
  59259. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59260. */
  59261. download(imageType?: string, quality?: number): void;
  59262. /**
  59263. * Public method to load a texturePacker JSON file.
  59264. * @param data of the JSON file in string format.
  59265. */
  59266. updateFromJSON(data: string): void;
  59267. }
  59268. }
  59269. declare module "babylonjs/Materials/Textures/Packer/index" {
  59270. export * from "babylonjs/Materials/Textures/Packer/packer";
  59271. export * from "babylonjs/Materials/Textures/Packer/frame";
  59272. }
  59273. declare module "babylonjs/Materials/Textures/index" {
  59274. export * from "babylonjs/Materials/Textures/baseTexture";
  59275. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59276. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59277. export * from "babylonjs/Materials/Textures/cubeTexture";
  59278. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59279. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59280. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59281. export * from "babylonjs/Materials/Textures/internalTexture";
  59282. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59283. export * from "babylonjs/Materials/Textures/Loaders/index";
  59284. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59285. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59286. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59287. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59288. export * from "babylonjs/Materials/Textures/rawTexture";
  59289. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59290. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59291. export * from "babylonjs/Materials/Textures/refractionTexture";
  59292. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59293. export * from "babylonjs/Materials/Textures/texture";
  59294. export * from "babylonjs/Materials/Textures/videoTexture";
  59295. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59296. export * from "babylonjs/Materials/Textures/Packer/index";
  59297. }
  59298. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59299. /**
  59300. * Enum used to define the target of a block
  59301. */
  59302. export enum NodeMaterialBlockTargets {
  59303. /** Vertex shader */
  59304. Vertex = 1,
  59305. /** Fragment shader */
  59306. Fragment = 2,
  59307. /** Neutral */
  59308. Neutral = 4,
  59309. /** Vertex and Fragment */
  59310. VertexAndFragment = 3
  59311. }
  59312. }
  59313. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59314. /**
  59315. * Defines the kind of connection point for node based material
  59316. */
  59317. export enum NodeMaterialBlockConnectionPointTypes {
  59318. /** Float */
  59319. Float = 1,
  59320. /** Int */
  59321. Int = 2,
  59322. /** Vector2 */
  59323. Vector2 = 4,
  59324. /** Vector3 */
  59325. Vector3 = 8,
  59326. /** Vector4 */
  59327. Vector4 = 16,
  59328. /** Color3 */
  59329. Color3 = 32,
  59330. /** Color4 */
  59331. Color4 = 64,
  59332. /** Matrix */
  59333. Matrix = 128,
  59334. /** Detect type based on connection */
  59335. AutoDetect = 1024,
  59336. /** Output type that will be defined by input type */
  59337. BasedOnInput = 2048
  59338. }
  59339. }
  59340. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59341. /**
  59342. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59343. */
  59344. export enum NodeMaterialBlockConnectionPointMode {
  59345. /** Value is an uniform */
  59346. Uniform = 0,
  59347. /** Value is a mesh attribute */
  59348. Attribute = 1,
  59349. /** Value is a varying between vertex and fragment shaders */
  59350. Varying = 2,
  59351. /** Mode is undefined */
  59352. Undefined = 3
  59353. }
  59354. }
  59355. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59356. /**
  59357. * Enum used to define system values e.g. values automatically provided by the system
  59358. */
  59359. export enum NodeMaterialSystemValues {
  59360. /** World */
  59361. World = 1,
  59362. /** View */
  59363. View = 2,
  59364. /** Projection */
  59365. Projection = 3,
  59366. /** ViewProjection */
  59367. ViewProjection = 4,
  59368. /** WorldView */
  59369. WorldView = 5,
  59370. /** WorldViewProjection */
  59371. WorldViewProjection = 6,
  59372. /** CameraPosition */
  59373. CameraPosition = 7,
  59374. /** Fog Color */
  59375. FogColor = 8,
  59376. /** Delta time */
  59377. DeltaTime = 9
  59378. }
  59379. }
  59380. declare module "babylonjs/Materials/Node/Enums/index" {
  59381. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59382. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59383. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59384. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59385. }
  59386. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59388. /**
  59389. * Root class for all node material optimizers
  59390. */
  59391. export class NodeMaterialOptimizer {
  59392. /**
  59393. * Function used to optimize a NodeMaterial graph
  59394. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59395. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59396. */
  59397. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59398. }
  59399. }
  59400. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  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. import { Scene } from "babylonjs/scene";
  59405. /**
  59406. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59407. */
  59408. export class TransformBlock extends NodeMaterialBlock {
  59409. /**
  59410. * Defines the value to use to complement W value to transform it to a Vector4
  59411. */
  59412. complementW: number;
  59413. /**
  59414. * Defines the value to use to complement z value to transform it to a Vector4
  59415. */
  59416. complementZ: number;
  59417. /**
  59418. * Creates a new TransformBlock
  59419. * @param name defines the block name
  59420. */
  59421. constructor(name: string);
  59422. /**
  59423. * Gets the current class name
  59424. * @returns the class name
  59425. */
  59426. getClassName(): string;
  59427. /**
  59428. * Gets the vector input
  59429. */
  59430. get vector(): NodeMaterialConnectionPoint;
  59431. /**
  59432. * Gets the output component
  59433. */
  59434. get output(): NodeMaterialConnectionPoint;
  59435. /**
  59436. * Gets the xyz output component
  59437. */
  59438. get xyz(): NodeMaterialConnectionPoint;
  59439. /**
  59440. * Gets the matrix transform input
  59441. */
  59442. get transform(): NodeMaterialConnectionPoint;
  59443. protected _buildBlock(state: NodeMaterialBuildState): this;
  59444. serialize(): any;
  59445. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59446. protected _dumpPropertiesCode(): string;
  59447. }
  59448. }
  59449. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59453. /**
  59454. * Block used to output the vertex position
  59455. */
  59456. export class VertexOutputBlock extends NodeMaterialBlock {
  59457. /**
  59458. * Creates a new VertexOutputBlock
  59459. * @param name defines the block name
  59460. */
  59461. constructor(name: string);
  59462. /**
  59463. * Gets the current class name
  59464. * @returns the class name
  59465. */
  59466. getClassName(): string;
  59467. /**
  59468. * Gets the vector input component
  59469. */
  59470. get vector(): NodeMaterialConnectionPoint;
  59471. protected _buildBlock(state: NodeMaterialBuildState): this;
  59472. }
  59473. }
  59474. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59478. /**
  59479. * Block used to output the final color
  59480. */
  59481. export class FragmentOutputBlock extends NodeMaterialBlock {
  59482. /**
  59483. * Create a new FragmentOutputBlock
  59484. * @param name defines the block name
  59485. */
  59486. constructor(name: string);
  59487. /**
  59488. * Gets the current class name
  59489. * @returns the class name
  59490. */
  59491. getClassName(): string;
  59492. /**
  59493. * Gets the rgba input component
  59494. */
  59495. get rgba(): NodeMaterialConnectionPoint;
  59496. /**
  59497. * Gets the rgb input component
  59498. */
  59499. get rgb(): NodeMaterialConnectionPoint;
  59500. /**
  59501. * Gets the a input component
  59502. */
  59503. get a(): NodeMaterialConnectionPoint;
  59504. protected _buildBlock(state: NodeMaterialBuildState): this;
  59505. }
  59506. }
  59507. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59511. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59513. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59514. import { Effect } from "babylonjs/Materials/effect";
  59515. import { Mesh } from "babylonjs/Meshes/mesh";
  59516. import { Nullable } from "babylonjs/types";
  59517. import { Scene } from "babylonjs/scene";
  59518. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59519. /**
  59520. * Block used to read a reflection texture from a sampler
  59521. */
  59522. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59523. private _define3DName;
  59524. private _defineCubicName;
  59525. private _defineExplicitName;
  59526. private _defineProjectionName;
  59527. private _defineLocalCubicName;
  59528. private _defineSphericalName;
  59529. private _definePlanarName;
  59530. private _defineEquirectangularName;
  59531. private _defineMirroredEquirectangularFixedName;
  59532. private _defineEquirectangularFixedName;
  59533. private _defineSkyboxName;
  59534. private _cubeSamplerName;
  59535. private _2DSamplerName;
  59536. private _positionUVWName;
  59537. private _directionWName;
  59538. private _reflectionCoordsName;
  59539. private _reflection2DCoordsName;
  59540. private _reflectionColorName;
  59541. private _reflectionMatrixName;
  59542. /**
  59543. * Gets or sets the texture associated with the node
  59544. */
  59545. texture: Nullable<BaseTexture>;
  59546. /**
  59547. * Create a new TextureBlock
  59548. * @param name defines the block name
  59549. */
  59550. constructor(name: string);
  59551. /**
  59552. * Gets the current class name
  59553. * @returns the class name
  59554. */
  59555. getClassName(): string;
  59556. /**
  59557. * Gets the world position input component
  59558. */
  59559. get position(): NodeMaterialConnectionPoint;
  59560. /**
  59561. * Gets the world position input component
  59562. */
  59563. get worldPosition(): NodeMaterialConnectionPoint;
  59564. /**
  59565. * Gets the world normal input component
  59566. */
  59567. get worldNormal(): NodeMaterialConnectionPoint;
  59568. /**
  59569. * Gets the world input component
  59570. */
  59571. get world(): NodeMaterialConnectionPoint;
  59572. /**
  59573. * Gets the camera (or eye) position component
  59574. */
  59575. get cameraPosition(): NodeMaterialConnectionPoint;
  59576. /**
  59577. * Gets the view input component
  59578. */
  59579. get view(): NodeMaterialConnectionPoint;
  59580. /**
  59581. * Gets the rgb output component
  59582. */
  59583. get rgb(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the r output component
  59586. */
  59587. get r(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the g output component
  59590. */
  59591. get g(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the b output component
  59594. */
  59595. get b(): NodeMaterialConnectionPoint;
  59596. autoConfigure(material: NodeMaterial): void;
  59597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59598. isReady(): boolean;
  59599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59600. private _injectVertexCode;
  59601. private _writeOutput;
  59602. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59603. protected _dumpPropertiesCode(): string;
  59604. serialize(): any;
  59605. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59606. }
  59607. }
  59608. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59610. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59611. import { Scene } from "babylonjs/scene";
  59612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59613. import { Matrix } from "babylonjs/Maths/math.vector";
  59614. import { Mesh } from "babylonjs/Meshes/mesh";
  59615. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59616. import { Observable } from "babylonjs/Misc/observable";
  59617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59618. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59619. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59620. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59621. import { Nullable } from "babylonjs/types";
  59622. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59623. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59624. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59625. /**
  59626. * Interface used to configure the node material editor
  59627. */
  59628. export interface INodeMaterialEditorOptions {
  59629. /** Define the URl to load node editor script */
  59630. editorURL?: string;
  59631. }
  59632. /** @hidden */
  59633. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59634. NORMAL: boolean;
  59635. TANGENT: boolean;
  59636. UV1: boolean;
  59637. /** BONES */
  59638. NUM_BONE_INFLUENCERS: number;
  59639. BonesPerMesh: number;
  59640. BONETEXTURE: boolean;
  59641. /** MORPH TARGETS */
  59642. MORPHTARGETS: boolean;
  59643. MORPHTARGETS_NORMAL: boolean;
  59644. MORPHTARGETS_TANGENT: boolean;
  59645. MORPHTARGETS_UV: boolean;
  59646. NUM_MORPH_INFLUENCERS: number;
  59647. /** IMAGE PROCESSING */
  59648. IMAGEPROCESSING: boolean;
  59649. VIGNETTE: boolean;
  59650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59651. VIGNETTEBLENDMODEOPAQUE: boolean;
  59652. TONEMAPPING: boolean;
  59653. TONEMAPPING_ACES: boolean;
  59654. CONTRAST: boolean;
  59655. EXPOSURE: boolean;
  59656. COLORCURVES: boolean;
  59657. COLORGRADING: boolean;
  59658. COLORGRADING3D: boolean;
  59659. SAMPLER3DGREENDEPTH: boolean;
  59660. SAMPLER3DBGRMAP: boolean;
  59661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59662. /** MISC. */
  59663. BUMPDIRECTUV: number;
  59664. constructor();
  59665. setValue(name: string, value: boolean): void;
  59666. }
  59667. /**
  59668. * Class used to configure NodeMaterial
  59669. */
  59670. export interface INodeMaterialOptions {
  59671. /**
  59672. * Defines if blocks should emit comments
  59673. */
  59674. emitComments: boolean;
  59675. }
  59676. /**
  59677. * Class used to create a node based material built by assembling shader blocks
  59678. */
  59679. export class NodeMaterial extends PushMaterial {
  59680. private static _BuildIdGenerator;
  59681. private _options;
  59682. private _vertexCompilationState;
  59683. private _fragmentCompilationState;
  59684. private _sharedData;
  59685. private _buildId;
  59686. private _buildWasSuccessful;
  59687. private _cachedWorldViewMatrix;
  59688. private _cachedWorldViewProjectionMatrix;
  59689. private _optimizers;
  59690. private _animationFrame;
  59691. /** Define the Url to load node editor script */
  59692. static EditorURL: string;
  59693. /** Define the Url to load snippets */
  59694. static SnippetUrl: string;
  59695. private BJSNODEMATERIALEDITOR;
  59696. /** Get the inspector from bundle or global */
  59697. private _getGlobalNodeMaterialEditor;
  59698. /**
  59699. * Gets or sets data used by visual editor
  59700. * @see https://nme.babylonjs.com
  59701. */
  59702. editorData: any;
  59703. /**
  59704. * 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)
  59705. */
  59706. ignoreAlpha: boolean;
  59707. /**
  59708. * Defines the maximum number of lights that can be used in the material
  59709. */
  59710. maxSimultaneousLights: number;
  59711. /**
  59712. * Observable raised when the material is built
  59713. */
  59714. onBuildObservable: Observable<NodeMaterial>;
  59715. /**
  59716. * Gets or sets the root nodes of the material vertex shader
  59717. */
  59718. _vertexOutputNodes: NodeMaterialBlock[];
  59719. /**
  59720. * Gets or sets the root nodes of the material fragment (pixel) shader
  59721. */
  59722. _fragmentOutputNodes: NodeMaterialBlock[];
  59723. /** Gets or sets options to control the node material overall behavior */
  59724. get options(): INodeMaterialOptions;
  59725. set options(options: INodeMaterialOptions);
  59726. /**
  59727. * Default configuration related to image processing available in the standard Material.
  59728. */
  59729. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59730. /**
  59731. * Gets the image processing configuration used either in this material.
  59732. */
  59733. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59734. /**
  59735. * Sets the Default image processing configuration used either in the this material.
  59736. *
  59737. * If sets to null, the scene one is in use.
  59738. */
  59739. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59740. /**
  59741. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59742. */
  59743. attachedBlocks: NodeMaterialBlock[];
  59744. /**
  59745. * Create a new node based material
  59746. * @param name defines the material name
  59747. * @param scene defines the hosting scene
  59748. * @param options defines creation option
  59749. */
  59750. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59751. /**
  59752. * Gets the current class name of the material e.g. "NodeMaterial"
  59753. * @returns the class name
  59754. */
  59755. getClassName(): string;
  59756. /**
  59757. * Keep track of the image processing observer to allow dispose and replace.
  59758. */
  59759. private _imageProcessingObserver;
  59760. /**
  59761. * Attaches a new image processing configuration to the Standard Material.
  59762. * @param configuration
  59763. */
  59764. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59765. /**
  59766. * Get a block by its name
  59767. * @param name defines the name of the block to retrieve
  59768. * @returns the required block or null if not found
  59769. */
  59770. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59771. /**
  59772. * Get a block by its name
  59773. * @param predicate defines the predicate used to find the good candidate
  59774. * @returns the required block or null if not found
  59775. */
  59776. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59777. /**
  59778. * Get an input block by its name
  59779. * @param predicate defines the predicate used to find the good candidate
  59780. * @returns the required input block or null if not found
  59781. */
  59782. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59783. /**
  59784. * Gets the list of input blocks attached to this material
  59785. * @returns an array of InputBlocks
  59786. */
  59787. getInputBlocks(): InputBlock[];
  59788. /**
  59789. * Adds a new optimizer to the list of optimizers
  59790. * @param optimizer defines the optimizers to add
  59791. * @returns the current material
  59792. */
  59793. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59794. /**
  59795. * Remove an optimizer from the list of optimizers
  59796. * @param optimizer defines the optimizers to remove
  59797. * @returns the current material
  59798. */
  59799. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59800. /**
  59801. * Add a new block to the list of output nodes
  59802. * @param node defines the node to add
  59803. * @returns the current material
  59804. */
  59805. addOutputNode(node: NodeMaterialBlock): this;
  59806. /**
  59807. * Remove a block from the list of root nodes
  59808. * @param node defines the node to remove
  59809. * @returns the current material
  59810. */
  59811. removeOutputNode(node: NodeMaterialBlock): this;
  59812. private _addVertexOutputNode;
  59813. private _removeVertexOutputNode;
  59814. private _addFragmentOutputNode;
  59815. private _removeFragmentOutputNode;
  59816. /**
  59817. * Specifies if the material will require alpha blending
  59818. * @returns a boolean specifying if alpha blending is needed
  59819. */
  59820. needAlphaBlending(): boolean;
  59821. /**
  59822. * Specifies if this material should be rendered in alpha test mode
  59823. * @returns a boolean specifying if an alpha test is needed.
  59824. */
  59825. needAlphaTesting(): boolean;
  59826. private _initializeBlock;
  59827. private _resetDualBlocks;
  59828. /**
  59829. * Remove a block from the current node material
  59830. * @param block defines the block to remove
  59831. */
  59832. removeBlock(block: NodeMaterialBlock): void;
  59833. /**
  59834. * Build the material and generates the inner effect
  59835. * @param verbose defines if the build should log activity
  59836. */
  59837. build(verbose?: boolean): void;
  59838. /**
  59839. * Runs an otpimization phase to try to improve the shader code
  59840. */
  59841. optimize(): void;
  59842. private _prepareDefinesForAttributes;
  59843. /**
  59844. * Get if the submesh is ready to be used and all its information available.
  59845. * Child classes can use it to update shaders
  59846. * @param mesh defines the mesh to check
  59847. * @param subMesh defines which submesh to check
  59848. * @param useInstances specifies that instances should be used
  59849. * @returns a boolean indicating that the submesh is ready or not
  59850. */
  59851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59852. /**
  59853. * Get a string representing the shaders built by the current node graph
  59854. */
  59855. get compiledShaders(): string;
  59856. /**
  59857. * Binds the world matrix to the material
  59858. * @param world defines the world transformation matrix
  59859. */
  59860. bindOnlyWorldMatrix(world: Matrix): void;
  59861. /**
  59862. * Binds the submesh to this material by preparing the effect and shader to draw
  59863. * @param world defines the world transformation matrix
  59864. * @param mesh defines the mesh containing the submesh
  59865. * @param subMesh defines the submesh to bind the material to
  59866. */
  59867. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59868. /**
  59869. * Gets the active textures from the material
  59870. * @returns an array of textures
  59871. */
  59872. getActiveTextures(): BaseTexture[];
  59873. /**
  59874. * Gets the list of texture blocks
  59875. * @returns an array of texture blocks
  59876. */
  59877. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59878. /**
  59879. * Specifies if the material uses a texture
  59880. * @param texture defines the texture to check against the material
  59881. * @returns a boolean specifying if the material uses the texture
  59882. */
  59883. hasTexture(texture: BaseTexture): boolean;
  59884. /**
  59885. * Disposes the material
  59886. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59887. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59888. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59889. */
  59890. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59891. /** Creates the node editor window. */
  59892. private _createNodeEditor;
  59893. /**
  59894. * Launch the node material editor
  59895. * @param config Define the configuration of the editor
  59896. * @return a promise fulfilled when the node editor is visible
  59897. */
  59898. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59899. /**
  59900. * Clear the current material
  59901. */
  59902. clear(): void;
  59903. /**
  59904. * Clear the current material and set it to a default state
  59905. */
  59906. setToDefault(): void;
  59907. /**
  59908. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59909. * @param url defines the url to load from
  59910. * @returns a promise that will fullfil when the material is fully loaded
  59911. */
  59912. loadAsync(url: string): Promise<void>;
  59913. private _gatherBlocks;
  59914. /**
  59915. * Generate a string containing the code declaration required to create an equivalent of this material
  59916. * @returns a string
  59917. */
  59918. generateCode(): string;
  59919. /**
  59920. * Serializes this material in a JSON representation
  59921. * @returns the serialized material object
  59922. */
  59923. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59924. private _restoreConnections;
  59925. /**
  59926. * Clear the current graph and load a new one from a serialization object
  59927. * @param source defines the JSON representation of the material
  59928. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59929. */
  59930. loadFromSerialization(source: any, rootUrl?: string): void;
  59931. /**
  59932. * Creates a node material from parsed material data
  59933. * @param source defines the JSON representation of the material
  59934. * @param scene defines the hosting scene
  59935. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59936. * @returns a new node material
  59937. */
  59938. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59939. /**
  59940. * Creates a node material from a snippet saved in a remote file
  59941. * @param name defines the name of the material to create
  59942. * @param url defines the url to load from
  59943. * @param scene defines the hosting scene
  59944. * @returns a promise that will resolve to the new node material
  59945. */
  59946. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59947. /**
  59948. * Creates a node material from a snippet saved by the node material editor
  59949. * @param snippetId defines the snippet to load
  59950. * @param scene defines the hosting scene
  59951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59952. * @returns a promise that will resolve to the new node material
  59953. */
  59954. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59955. /**
  59956. * Creates a new node material set to default basic configuration
  59957. * @param name defines the name of the material
  59958. * @param scene defines the hosting scene
  59959. * @returns a new NodeMaterial
  59960. */
  59961. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59962. }
  59963. }
  59964. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59967. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59970. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59971. import { Effect } from "babylonjs/Materials/effect";
  59972. import { Mesh } from "babylonjs/Meshes/mesh";
  59973. import { Nullable } from "babylonjs/types";
  59974. import { Texture } from "babylonjs/Materials/Textures/texture";
  59975. import { Scene } from "babylonjs/scene";
  59976. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59977. /**
  59978. * Block used to read a texture from a sampler
  59979. */
  59980. export class TextureBlock extends NodeMaterialBlock {
  59981. private _defineName;
  59982. private _linearDefineName;
  59983. private _tempTextureRead;
  59984. private _samplerName;
  59985. private _transformedUVName;
  59986. private _textureTransformName;
  59987. private _textureInfoName;
  59988. private _mainUVName;
  59989. private _mainUVDefineName;
  59990. /**
  59991. * Gets or sets the texture associated with the node
  59992. */
  59993. texture: Nullable<Texture>;
  59994. /**
  59995. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59996. */
  59997. convertToGammaSpace: boolean;
  59998. /**
  59999. * Create a new TextureBlock
  60000. * @param name defines the block name
  60001. */
  60002. constructor(name: string);
  60003. /**
  60004. * Gets the current class name
  60005. * @returns the class name
  60006. */
  60007. getClassName(): string;
  60008. /**
  60009. * Gets the uv input component
  60010. */
  60011. get uv(): NodeMaterialConnectionPoint;
  60012. /**
  60013. * Gets the rgba output component
  60014. */
  60015. get rgba(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the rgb output component
  60018. */
  60019. get rgb(): NodeMaterialConnectionPoint;
  60020. /**
  60021. * Gets the r output component
  60022. */
  60023. get r(): NodeMaterialConnectionPoint;
  60024. /**
  60025. * Gets the g output component
  60026. */
  60027. get g(): NodeMaterialConnectionPoint;
  60028. /**
  60029. * Gets the b output component
  60030. */
  60031. get b(): NodeMaterialConnectionPoint;
  60032. /**
  60033. * Gets the a output component
  60034. */
  60035. get a(): NodeMaterialConnectionPoint;
  60036. get target(): NodeMaterialBlockTargets;
  60037. autoConfigure(material: NodeMaterial): void;
  60038. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60039. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60040. isReady(): boolean;
  60041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60042. private get _isMixed();
  60043. private _injectVertexCode;
  60044. private _writeTextureRead;
  60045. private _writeOutput;
  60046. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60047. protected _dumpPropertiesCode(): string;
  60048. serialize(): any;
  60049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60050. }
  60051. }
  60052. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60055. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60056. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60057. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60058. import { Scene } from "babylonjs/scene";
  60059. /**
  60060. * Class used to store shared data between 2 NodeMaterialBuildState
  60061. */
  60062. export class NodeMaterialBuildStateSharedData {
  60063. /**
  60064. * Gets the list of emitted varyings
  60065. */
  60066. temps: string[];
  60067. /**
  60068. * Gets the list of emitted varyings
  60069. */
  60070. varyings: string[];
  60071. /**
  60072. * Gets the varying declaration string
  60073. */
  60074. varyingDeclaration: string;
  60075. /**
  60076. * Input blocks
  60077. */
  60078. inputBlocks: InputBlock[];
  60079. /**
  60080. * Input blocks
  60081. */
  60082. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60083. /**
  60084. * Bindable blocks (Blocks that need to set data to the effect)
  60085. */
  60086. bindableBlocks: NodeMaterialBlock[];
  60087. /**
  60088. * List of blocks that can provide a compilation fallback
  60089. */
  60090. blocksWithFallbacks: NodeMaterialBlock[];
  60091. /**
  60092. * List of blocks that can provide a define update
  60093. */
  60094. blocksWithDefines: NodeMaterialBlock[];
  60095. /**
  60096. * List of blocks that can provide a repeatable content
  60097. */
  60098. repeatableContentBlocks: NodeMaterialBlock[];
  60099. /**
  60100. * List of blocks that can provide a dynamic list of uniforms
  60101. */
  60102. dynamicUniformBlocks: NodeMaterialBlock[];
  60103. /**
  60104. * List of blocks that can block the isReady function for the material
  60105. */
  60106. blockingBlocks: NodeMaterialBlock[];
  60107. /**
  60108. * Gets the list of animated inputs
  60109. */
  60110. animatedInputs: InputBlock[];
  60111. /**
  60112. * Build Id used to avoid multiple recompilations
  60113. */
  60114. buildId: number;
  60115. /** List of emitted variables */
  60116. variableNames: {
  60117. [key: string]: number;
  60118. };
  60119. /** List of emitted defines */
  60120. defineNames: {
  60121. [key: string]: number;
  60122. };
  60123. /** Should emit comments? */
  60124. emitComments: boolean;
  60125. /** Emit build activity */
  60126. verbose: boolean;
  60127. /** Gets or sets the hosting scene */
  60128. scene: Scene;
  60129. /**
  60130. * Gets the compilation hints emitted at compilation time
  60131. */
  60132. hints: {
  60133. needWorldViewMatrix: boolean;
  60134. needWorldViewProjectionMatrix: boolean;
  60135. needAlphaBlending: boolean;
  60136. needAlphaTesting: boolean;
  60137. };
  60138. /**
  60139. * List of compilation checks
  60140. */
  60141. checks: {
  60142. emitVertex: boolean;
  60143. emitFragment: boolean;
  60144. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60145. };
  60146. /** Creates a new shared data */
  60147. constructor();
  60148. /**
  60149. * Emits console errors and exceptions if there is a failing check
  60150. */
  60151. emitErrors(): void;
  60152. }
  60153. }
  60154. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60155. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60156. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60157. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60158. /**
  60159. * Class used to store node based material build state
  60160. */
  60161. export class NodeMaterialBuildState {
  60162. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60163. supportUniformBuffers: boolean;
  60164. /**
  60165. * Gets the list of emitted attributes
  60166. */
  60167. attributes: string[];
  60168. /**
  60169. * Gets the list of emitted uniforms
  60170. */
  60171. uniforms: string[];
  60172. /**
  60173. * Gets the list of emitted constants
  60174. */
  60175. constants: string[];
  60176. /**
  60177. * Gets the list of emitted samplers
  60178. */
  60179. samplers: string[];
  60180. /**
  60181. * Gets the list of emitted functions
  60182. */
  60183. functions: {
  60184. [key: string]: string;
  60185. };
  60186. /**
  60187. * Gets the list of emitted extensions
  60188. */
  60189. extensions: {
  60190. [key: string]: string;
  60191. };
  60192. /**
  60193. * Gets the target of the compilation state
  60194. */
  60195. target: NodeMaterialBlockTargets;
  60196. /**
  60197. * Gets the list of emitted counters
  60198. */
  60199. counters: {
  60200. [key: string]: number;
  60201. };
  60202. /**
  60203. * Shared data between multiple NodeMaterialBuildState instances
  60204. */
  60205. sharedData: NodeMaterialBuildStateSharedData;
  60206. /** @hidden */
  60207. _vertexState: NodeMaterialBuildState;
  60208. /** @hidden */
  60209. _attributeDeclaration: string;
  60210. /** @hidden */
  60211. _uniformDeclaration: string;
  60212. /** @hidden */
  60213. _constantDeclaration: string;
  60214. /** @hidden */
  60215. _samplerDeclaration: string;
  60216. /** @hidden */
  60217. _varyingTransfer: string;
  60218. private _repeatableContentAnchorIndex;
  60219. /** @hidden */
  60220. _builtCompilationString: string;
  60221. /**
  60222. * Gets the emitted compilation strings
  60223. */
  60224. compilationString: string;
  60225. /**
  60226. * Finalize the compilation strings
  60227. * @param state defines the current compilation state
  60228. */
  60229. finalize(state: NodeMaterialBuildState): void;
  60230. /** @hidden */
  60231. get _repeatableContentAnchor(): string;
  60232. /** @hidden */
  60233. _getFreeVariableName(prefix: string): string;
  60234. /** @hidden */
  60235. _getFreeDefineName(prefix: string): string;
  60236. /** @hidden */
  60237. _excludeVariableName(name: string): void;
  60238. /** @hidden */
  60239. _emit2DSampler(name: string): void;
  60240. /** @hidden */
  60241. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60242. /** @hidden */
  60243. _emitExtension(name: string, extension: string): void;
  60244. /** @hidden */
  60245. _emitFunction(name: string, code: string, comments: string): void;
  60246. /** @hidden */
  60247. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60248. replaceStrings?: {
  60249. search: RegExp;
  60250. replace: string;
  60251. }[];
  60252. repeatKey?: string;
  60253. }): string;
  60254. /** @hidden */
  60255. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60256. repeatKey?: string;
  60257. removeAttributes?: boolean;
  60258. removeUniforms?: boolean;
  60259. removeVaryings?: boolean;
  60260. removeIfDef?: boolean;
  60261. replaceStrings?: {
  60262. search: RegExp;
  60263. replace: string;
  60264. }[];
  60265. }, storeKey?: string): void;
  60266. /** @hidden */
  60267. _registerTempVariable(name: string): boolean;
  60268. /** @hidden */
  60269. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60270. /** @hidden */
  60271. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60272. /** @hidden */
  60273. _emitFloat(value: number): string;
  60274. }
  60275. }
  60276. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60277. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60279. import { Nullable } from "babylonjs/types";
  60280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60281. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60282. import { Effect } from "babylonjs/Materials/effect";
  60283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60284. import { Mesh } from "babylonjs/Meshes/mesh";
  60285. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60286. import { Scene } from "babylonjs/scene";
  60287. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60288. /**
  60289. * Defines a block that can be used inside a node based material
  60290. */
  60291. export class NodeMaterialBlock {
  60292. private _buildId;
  60293. private _buildTarget;
  60294. private _target;
  60295. private _isFinalMerger;
  60296. private _isInput;
  60297. protected _isUnique: boolean;
  60298. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60299. inputsAreExclusive: boolean;
  60300. /** @hidden */
  60301. _codeVariableName: string;
  60302. /** @hidden */
  60303. _inputs: NodeMaterialConnectionPoint[];
  60304. /** @hidden */
  60305. _outputs: NodeMaterialConnectionPoint[];
  60306. /** @hidden */
  60307. _preparationId: number;
  60308. /**
  60309. * Gets or sets the name of the block
  60310. */
  60311. name: string;
  60312. /**
  60313. * Gets or sets the unique id of the node
  60314. */
  60315. uniqueId: number;
  60316. /**
  60317. * Gets or sets the comments associated with this block
  60318. */
  60319. comments: string;
  60320. /**
  60321. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60322. */
  60323. get isUnique(): boolean;
  60324. /**
  60325. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60326. */
  60327. get isFinalMerger(): boolean;
  60328. /**
  60329. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60330. */
  60331. get isInput(): boolean;
  60332. /**
  60333. * Gets or sets the build Id
  60334. */
  60335. get buildId(): number;
  60336. set buildId(value: number);
  60337. /**
  60338. * Gets or sets the target of the block
  60339. */
  60340. get target(): NodeMaterialBlockTargets;
  60341. set target(value: NodeMaterialBlockTargets);
  60342. /**
  60343. * Gets the list of input points
  60344. */
  60345. get inputs(): NodeMaterialConnectionPoint[];
  60346. /** Gets the list of output points */
  60347. get outputs(): NodeMaterialConnectionPoint[];
  60348. /**
  60349. * Find an input by its name
  60350. * @param name defines the name of the input to look for
  60351. * @returns the input or null if not found
  60352. */
  60353. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60354. /**
  60355. * Find an output by its name
  60356. * @param name defines the name of the outputto look for
  60357. * @returns the output or null if not found
  60358. */
  60359. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60360. /**
  60361. * Creates a new NodeMaterialBlock
  60362. * @param name defines the block name
  60363. * @param target defines the target of that block (Vertex by default)
  60364. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60365. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60366. */
  60367. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60368. /**
  60369. * Initialize the block and prepare the context for build
  60370. * @param state defines the state that will be used for the build
  60371. */
  60372. initialize(state: NodeMaterialBuildState): void;
  60373. /**
  60374. * Bind data to effect. Will only be called for blocks with isBindable === true
  60375. * @param effect defines the effect to bind data to
  60376. * @param nodeMaterial defines the hosting NodeMaterial
  60377. * @param mesh defines the mesh that will be rendered
  60378. */
  60379. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60380. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60381. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60382. protected _writeFloat(value: number): string;
  60383. /**
  60384. * Gets the current class name e.g. "NodeMaterialBlock"
  60385. * @returns the class name
  60386. */
  60387. getClassName(): string;
  60388. /**
  60389. * Register a new input. Must be called inside a block constructor
  60390. * @param name defines the connection point name
  60391. * @param type defines the connection point type
  60392. * @param isOptional defines a boolean indicating that this input can be omitted
  60393. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60394. * @returns the current block
  60395. */
  60396. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60397. /**
  60398. * Register a new output. Must be called inside a block constructor
  60399. * @param name defines the connection point name
  60400. * @param type defines the connection point type
  60401. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60402. * @returns the current block
  60403. */
  60404. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60405. /**
  60406. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60407. * @param forOutput defines an optional connection point to check compatibility with
  60408. * @returns the first available input or null
  60409. */
  60410. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60411. /**
  60412. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60413. * @param forBlock defines an optional block to check compatibility with
  60414. * @returns the first available input or null
  60415. */
  60416. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60417. /**
  60418. * Gets the sibling of the given output
  60419. * @param current defines the current output
  60420. * @returns the next output in the list or null
  60421. */
  60422. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60423. /**
  60424. * Connect current block with another block
  60425. * @param other defines the block to connect with
  60426. * @param options define the various options to help pick the right connections
  60427. * @returns the current block
  60428. */
  60429. connectTo(other: NodeMaterialBlock, options?: {
  60430. input?: string;
  60431. output?: string;
  60432. outputSwizzle?: string;
  60433. }): this | undefined;
  60434. protected _buildBlock(state: NodeMaterialBuildState): void;
  60435. /**
  60436. * Add uniforms, samplers and uniform buffers at compilation time
  60437. * @param state defines the state to update
  60438. * @param nodeMaterial defines the node material requesting the update
  60439. * @param defines defines the material defines to update
  60440. * @param uniformBuffers defines the list of uniform buffer names
  60441. */
  60442. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60443. /**
  60444. * Add potential fallbacks if shader compilation fails
  60445. * @param mesh defines the mesh to be rendered
  60446. * @param fallbacks defines the current prioritized list of fallbacks
  60447. */
  60448. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60449. /**
  60450. * Initialize defines for shader compilation
  60451. * @param mesh defines the mesh to be rendered
  60452. * @param nodeMaterial defines the node material requesting the update
  60453. * @param defines defines the material defines to update
  60454. * @param useInstances specifies that instances should be used
  60455. */
  60456. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60457. /**
  60458. * Update defines for shader compilation
  60459. * @param mesh defines the mesh to be rendered
  60460. * @param nodeMaterial defines the node material requesting the update
  60461. * @param defines defines the material defines to update
  60462. * @param useInstances specifies that instances should be used
  60463. */
  60464. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60465. /**
  60466. * Lets the block try to connect some inputs automatically
  60467. * @param material defines the hosting NodeMaterial
  60468. */
  60469. autoConfigure(material: NodeMaterial): void;
  60470. /**
  60471. * Function called when a block is declared as repeatable content generator
  60472. * @param vertexShaderState defines the current compilation state for the vertex shader
  60473. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60474. * @param mesh defines the mesh to be rendered
  60475. * @param defines defines the material defines to update
  60476. */
  60477. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60478. /**
  60479. * Checks if the block is ready
  60480. * @param mesh defines the mesh to be rendered
  60481. * @param nodeMaterial defines the node material requesting the update
  60482. * @param defines defines the material defines to update
  60483. * @param useInstances specifies that instances should be used
  60484. * @returns true if the block is ready
  60485. */
  60486. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60487. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60488. private _processBuild;
  60489. /**
  60490. * Compile the current node and generate the shader code
  60491. * @param state defines the current compilation state (uniforms, samplers, current string)
  60492. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60493. * @returns true if already built
  60494. */
  60495. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60496. protected _inputRename(name: string): string;
  60497. protected _outputRename(name: string): string;
  60498. protected _dumpPropertiesCode(): string;
  60499. /** @hidden */
  60500. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60501. /** @hidden */
  60502. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60503. /**
  60504. * Clone the current block to a new identical block
  60505. * @param scene defines the hosting scene
  60506. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60507. * @returns a copy of the current block
  60508. */
  60509. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60510. /**
  60511. * Serializes this block in a JSON representation
  60512. * @returns the serialized block object
  60513. */
  60514. serialize(): any;
  60515. /** @hidden */
  60516. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60517. /**
  60518. * Release resources
  60519. */
  60520. dispose(): void;
  60521. }
  60522. }
  60523. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60524. /**
  60525. * Enum defining the type of animations supported by InputBlock
  60526. */
  60527. export enum AnimatedInputBlockTypes {
  60528. /** No animation */
  60529. None = 0,
  60530. /** Time based animation. Will only work for floats */
  60531. Time = 1
  60532. }
  60533. }
  60534. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60536. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60537. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60538. import { Nullable } from "babylonjs/types";
  60539. import { Effect } from "babylonjs/Materials/effect";
  60540. import { Matrix } from "babylonjs/Maths/math.vector";
  60541. import { Scene } from "babylonjs/scene";
  60542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60544. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60545. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60546. import { Observable } from "babylonjs/Misc/observable";
  60547. /**
  60548. * Block used to expose an input value
  60549. */
  60550. export class InputBlock extends NodeMaterialBlock {
  60551. private _mode;
  60552. private _associatedVariableName;
  60553. private _storedValue;
  60554. private _valueCallback;
  60555. private _type;
  60556. private _animationType;
  60557. /** Gets or set a value used to limit the range of float values */
  60558. min: number;
  60559. /** Gets or set a value used to limit the range of float values */
  60560. max: number;
  60561. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60562. isBoolean: boolean;
  60563. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60564. matrixMode: number;
  60565. /** @hidden */
  60566. _systemValue: Nullable<NodeMaterialSystemValues>;
  60567. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60568. visibleInInspector: boolean;
  60569. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60570. isConstant: boolean;
  60571. /** Gets or sets the group to use to display this block in the Inspector */
  60572. groupInInspector: string;
  60573. /** Gets an observable raised when the value is changed */
  60574. onValueChangedObservable: Observable<InputBlock>;
  60575. /**
  60576. * Gets or sets the connection point type (default is float)
  60577. */
  60578. get type(): NodeMaterialBlockConnectionPointTypes;
  60579. /**
  60580. * Creates a new InputBlock
  60581. * @param name defines the block name
  60582. * @param target defines the target of that block (Vertex by default)
  60583. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60584. */
  60585. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60586. /**
  60587. * Gets the output component
  60588. */
  60589. get output(): NodeMaterialConnectionPoint;
  60590. /**
  60591. * Set the source of this connection point to a vertex attribute
  60592. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60593. * @returns the current connection point
  60594. */
  60595. setAsAttribute(attributeName?: string): InputBlock;
  60596. /**
  60597. * Set the source of this connection point to a system value
  60598. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60599. * @returns the current connection point
  60600. */
  60601. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60602. /**
  60603. * Gets or sets the value of that point.
  60604. * Please note that this value will be ignored if valueCallback is defined
  60605. */
  60606. get value(): any;
  60607. set value(value: any);
  60608. /**
  60609. * Gets or sets a callback used to get the value of that point.
  60610. * Please note that setting this value will force the connection point to ignore the value property
  60611. */
  60612. get valueCallback(): () => any;
  60613. set valueCallback(value: () => any);
  60614. /**
  60615. * Gets or sets the associated variable name in the shader
  60616. */
  60617. get associatedVariableName(): string;
  60618. set associatedVariableName(value: string);
  60619. /** Gets or sets the type of animation applied to the input */
  60620. get animationType(): AnimatedInputBlockTypes;
  60621. set animationType(value: AnimatedInputBlockTypes);
  60622. /**
  60623. * Gets a boolean indicating that this connection point not defined yet
  60624. */
  60625. get isUndefined(): boolean;
  60626. /**
  60627. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60628. * In this case the connection point name must be the name of the uniform to use.
  60629. * Can only be set on inputs
  60630. */
  60631. get isUniform(): boolean;
  60632. set isUniform(value: boolean);
  60633. /**
  60634. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60635. * In this case the connection point name must be the name of the attribute to use
  60636. * Can only be set on inputs
  60637. */
  60638. get isAttribute(): boolean;
  60639. set isAttribute(value: boolean);
  60640. /**
  60641. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60642. * Can only be set on exit points
  60643. */
  60644. get isVarying(): boolean;
  60645. set isVarying(value: boolean);
  60646. /**
  60647. * Gets a boolean indicating that the current connection point is a system value
  60648. */
  60649. get isSystemValue(): boolean;
  60650. /**
  60651. * Gets or sets the current well known value or null if not defined as a system value
  60652. */
  60653. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60654. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60655. /**
  60656. * Gets the current class name
  60657. * @returns the class name
  60658. */
  60659. getClassName(): string;
  60660. /**
  60661. * Animate the input if animationType !== None
  60662. * @param scene defines the rendering scene
  60663. */
  60664. animate(scene: Scene): void;
  60665. private _emitDefine;
  60666. initialize(state: NodeMaterialBuildState): void;
  60667. /**
  60668. * Set the input block to its default value (based on its type)
  60669. */
  60670. setDefaultValue(): void;
  60671. private _emitConstant;
  60672. private _emit;
  60673. /** @hidden */
  60674. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60675. /** @hidden */
  60676. _transmit(effect: Effect, scene: Scene): void;
  60677. protected _buildBlock(state: NodeMaterialBuildState): void;
  60678. protected _dumpPropertiesCode(): string;
  60679. dispose(): void;
  60680. serialize(): any;
  60681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60682. }
  60683. }
  60684. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60685. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60686. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60687. import { Nullable } from "babylonjs/types";
  60688. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60689. import { Observable } from "babylonjs/Misc/observable";
  60690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60691. /**
  60692. * Enum used to define the compatibility state between two connection points
  60693. */
  60694. export enum NodeMaterialConnectionPointCompatibilityStates {
  60695. /** Points are compatibles */
  60696. Compatible = 0,
  60697. /** Points are incompatible because of their types */
  60698. TypeIncompatible = 1,
  60699. /** Points are incompatible because of their targets (vertex vs fragment) */
  60700. TargetIncompatible = 2
  60701. }
  60702. /**
  60703. * Defines the direction of a connection point
  60704. */
  60705. export enum NodeMaterialConnectionPointDirection {
  60706. /** Input */
  60707. Input = 0,
  60708. /** Output */
  60709. Output = 1
  60710. }
  60711. /**
  60712. * Defines a connection point for a block
  60713. */
  60714. export class NodeMaterialConnectionPoint {
  60715. /** @hidden */
  60716. _ownerBlock: NodeMaterialBlock;
  60717. /** @hidden */
  60718. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60719. private _endpoints;
  60720. private _associatedVariableName;
  60721. private _direction;
  60722. /** @hidden */
  60723. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60724. /** @hidden */
  60725. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60726. private _type;
  60727. /** @hidden */
  60728. _enforceAssociatedVariableName: boolean;
  60729. /** Gets the direction of the point */
  60730. get direction(): NodeMaterialConnectionPointDirection;
  60731. /**
  60732. * Gets or sets the additional types supported by this connection point
  60733. */
  60734. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60735. /**
  60736. * Gets or sets the additional types excluded by this connection point
  60737. */
  60738. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60739. /**
  60740. * Observable triggered when this point is connected
  60741. */
  60742. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60743. /**
  60744. * Gets or sets the associated variable name in the shader
  60745. */
  60746. get associatedVariableName(): string;
  60747. set associatedVariableName(value: string);
  60748. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60749. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60750. /**
  60751. * Gets or sets the connection point type (default is float)
  60752. */
  60753. get type(): NodeMaterialBlockConnectionPointTypes;
  60754. set type(value: NodeMaterialBlockConnectionPointTypes);
  60755. /**
  60756. * Gets or sets the connection point name
  60757. */
  60758. name: string;
  60759. /**
  60760. * Gets or sets a boolean indicating that this connection point can be omitted
  60761. */
  60762. isOptional: boolean;
  60763. /**
  60764. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60765. */
  60766. define: string;
  60767. /** @hidden */
  60768. _prioritizeVertex: boolean;
  60769. private _target;
  60770. /** Gets or sets the target of that connection point */
  60771. get target(): NodeMaterialBlockTargets;
  60772. set target(value: NodeMaterialBlockTargets);
  60773. /**
  60774. * Gets a boolean indicating that the current point is connected
  60775. */
  60776. get isConnected(): boolean;
  60777. /**
  60778. * Gets a boolean indicating that the current point is connected to an input block
  60779. */
  60780. get isConnectedToInputBlock(): boolean;
  60781. /**
  60782. * Gets a the connected input block (if any)
  60783. */
  60784. get connectInputBlock(): Nullable<InputBlock>;
  60785. /** Get the other side of the connection (if any) */
  60786. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60787. /** Get the block that owns this connection point */
  60788. get ownerBlock(): NodeMaterialBlock;
  60789. /** Get the block connected on the other side of this connection (if any) */
  60790. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60791. /** Get the block connected on the endpoints of this connection (if any) */
  60792. get connectedBlocks(): Array<NodeMaterialBlock>;
  60793. /** Gets the list of connected endpoints */
  60794. get endpoints(): NodeMaterialConnectionPoint[];
  60795. /** Gets a boolean indicating if that output point is connected to at least one input */
  60796. get hasEndpoints(): boolean;
  60797. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60798. get isConnectedInVertexShader(): boolean;
  60799. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60800. get isConnectedInFragmentShader(): boolean;
  60801. /**
  60802. * Creates a new connection point
  60803. * @param name defines the connection point name
  60804. * @param ownerBlock defines the block hosting this connection point
  60805. * @param direction defines the direction of the connection point
  60806. */
  60807. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60808. /**
  60809. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60810. * @returns the class name
  60811. */
  60812. getClassName(): string;
  60813. /**
  60814. * Gets a boolean indicating if the current point can be connected to another point
  60815. * @param connectionPoint defines the other connection point
  60816. * @returns a boolean
  60817. */
  60818. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60819. /**
  60820. * Gets a number indicating if the current point can be connected to another point
  60821. * @param connectionPoint defines the other connection point
  60822. * @returns a number defining the compatibility state
  60823. */
  60824. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60825. /**
  60826. * Connect this point to another connection point
  60827. * @param connectionPoint defines the other connection point
  60828. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60829. * @returns the current connection point
  60830. */
  60831. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60832. /**
  60833. * Disconnect this point from one of his endpoint
  60834. * @param endpoint defines the other connection point
  60835. * @returns the current connection point
  60836. */
  60837. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60838. /**
  60839. * Serializes this point in a JSON representation
  60840. * @returns the serialized point object
  60841. */
  60842. serialize(): any;
  60843. /**
  60844. * Release resources
  60845. */
  60846. dispose(): void;
  60847. }
  60848. }
  60849. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60853. import { Mesh } from "babylonjs/Meshes/mesh";
  60854. import { Effect } from "babylonjs/Materials/effect";
  60855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60856. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60857. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60858. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60859. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60860. /**
  60861. * Block used to add support for vertex skinning (bones)
  60862. */
  60863. export class BonesBlock extends NodeMaterialBlock {
  60864. /**
  60865. * Creates a new BonesBlock
  60866. * @param name defines the block name
  60867. */
  60868. constructor(name: string);
  60869. /**
  60870. * Initialize the block and prepare the context for build
  60871. * @param state defines the state that will be used for the build
  60872. */
  60873. initialize(state: NodeMaterialBuildState): void;
  60874. /**
  60875. * Gets the current class name
  60876. * @returns the class name
  60877. */
  60878. getClassName(): string;
  60879. /**
  60880. * Gets the matrix indices input component
  60881. */
  60882. get matricesIndices(): NodeMaterialConnectionPoint;
  60883. /**
  60884. * Gets the matrix weights input component
  60885. */
  60886. get matricesWeights(): NodeMaterialConnectionPoint;
  60887. /**
  60888. * Gets the extra matrix indices input component
  60889. */
  60890. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60891. /**
  60892. * Gets the extra matrix weights input component
  60893. */
  60894. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60895. /**
  60896. * Gets the world input component
  60897. */
  60898. get world(): NodeMaterialConnectionPoint;
  60899. /**
  60900. * Gets the output component
  60901. */
  60902. get output(): NodeMaterialConnectionPoint;
  60903. autoConfigure(material: NodeMaterial): void;
  60904. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60907. protected _buildBlock(state: NodeMaterialBuildState): this;
  60908. }
  60909. }
  60910. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60915. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60916. /**
  60917. * Block used to add support for instances
  60918. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60919. */
  60920. export class InstancesBlock extends NodeMaterialBlock {
  60921. /**
  60922. * Creates a new InstancesBlock
  60923. * @param name defines the block name
  60924. */
  60925. constructor(name: string);
  60926. /**
  60927. * Gets the current class name
  60928. * @returns the class name
  60929. */
  60930. getClassName(): string;
  60931. /**
  60932. * Gets the first world row input component
  60933. */
  60934. get world0(): NodeMaterialConnectionPoint;
  60935. /**
  60936. * Gets the second world row input component
  60937. */
  60938. get world1(): NodeMaterialConnectionPoint;
  60939. /**
  60940. * Gets the third world row input component
  60941. */
  60942. get world2(): NodeMaterialConnectionPoint;
  60943. /**
  60944. * Gets the forth world row input component
  60945. */
  60946. get world3(): NodeMaterialConnectionPoint;
  60947. /**
  60948. * Gets the world input component
  60949. */
  60950. get world(): NodeMaterialConnectionPoint;
  60951. /**
  60952. * Gets the output component
  60953. */
  60954. get output(): NodeMaterialConnectionPoint;
  60955. /**
  60956. * Gets the isntanceID component
  60957. */
  60958. get instanceID(): NodeMaterialConnectionPoint;
  60959. autoConfigure(material: NodeMaterial): void;
  60960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60961. protected _buildBlock(state: NodeMaterialBuildState): this;
  60962. }
  60963. }
  60964. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60969. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60970. import { Effect } from "babylonjs/Materials/effect";
  60971. import { Mesh } from "babylonjs/Meshes/mesh";
  60972. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60973. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60974. /**
  60975. * Block used to add morph targets support to vertex shader
  60976. */
  60977. export class MorphTargetsBlock extends NodeMaterialBlock {
  60978. private _repeatableContentAnchor;
  60979. /**
  60980. * Create a new MorphTargetsBlock
  60981. * @param name defines the block name
  60982. */
  60983. constructor(name: string);
  60984. /**
  60985. * Gets the current class name
  60986. * @returns the class name
  60987. */
  60988. getClassName(): string;
  60989. /**
  60990. * Gets the position input component
  60991. */
  60992. get position(): NodeMaterialConnectionPoint;
  60993. /**
  60994. * Gets the normal input component
  60995. */
  60996. get normal(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the tangent input component
  60999. */
  61000. get tangent(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the tangent input component
  61003. */
  61004. get uv(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the position output component
  61007. */
  61008. get positionOutput(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the normal output component
  61011. */
  61012. get normalOutput(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the tangent output component
  61015. */
  61016. get tangentOutput(): NodeMaterialConnectionPoint;
  61017. /**
  61018. * Gets the tangent output component
  61019. */
  61020. get uvOutput(): NodeMaterialConnectionPoint;
  61021. initialize(state: NodeMaterialBuildState): void;
  61022. autoConfigure(material: NodeMaterial): void;
  61023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61025. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61026. protected _buildBlock(state: NodeMaterialBuildState): this;
  61027. }
  61028. }
  61029. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61033. import { Nullable } from "babylonjs/types";
  61034. import { Scene } from "babylonjs/scene";
  61035. import { Effect } from "babylonjs/Materials/effect";
  61036. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61037. import { Mesh } from "babylonjs/Meshes/mesh";
  61038. import { Light } from "babylonjs/Lights/light";
  61039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61040. /**
  61041. * Block used to get data information from a light
  61042. */
  61043. export class LightInformationBlock extends NodeMaterialBlock {
  61044. private _lightDataUniformName;
  61045. private _lightColorUniformName;
  61046. private _lightTypeDefineName;
  61047. /**
  61048. * Gets or sets the light associated with this block
  61049. */
  61050. light: Nullable<Light>;
  61051. /**
  61052. * Creates a new LightInformationBlock
  61053. * @param name defines the block name
  61054. */
  61055. constructor(name: string);
  61056. /**
  61057. * Gets the current class name
  61058. * @returns the class name
  61059. */
  61060. getClassName(): string;
  61061. /**
  61062. * Gets the world position input component
  61063. */
  61064. get worldPosition(): NodeMaterialConnectionPoint;
  61065. /**
  61066. * Gets the direction output component
  61067. */
  61068. get direction(): NodeMaterialConnectionPoint;
  61069. /**
  61070. * Gets the direction output component
  61071. */
  61072. get color(): NodeMaterialConnectionPoint;
  61073. /**
  61074. * Gets the direction output component
  61075. */
  61076. get intensity(): NodeMaterialConnectionPoint;
  61077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61079. protected _buildBlock(state: NodeMaterialBuildState): this;
  61080. serialize(): any;
  61081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61082. }
  61083. }
  61084. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61085. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61086. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61087. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61088. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61089. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61090. }
  61091. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61096. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61097. import { Effect } from "babylonjs/Materials/effect";
  61098. import { Mesh } from "babylonjs/Meshes/mesh";
  61099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61100. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61101. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61102. /**
  61103. * Block used to add image processing support to fragment shader
  61104. */
  61105. export class ImageProcessingBlock extends NodeMaterialBlock {
  61106. /**
  61107. * Create a new ImageProcessingBlock
  61108. * @param name defines the block name
  61109. */
  61110. constructor(name: string);
  61111. /**
  61112. * Gets the current class name
  61113. * @returns the class name
  61114. */
  61115. getClassName(): string;
  61116. /**
  61117. * Gets the color input component
  61118. */
  61119. get color(): NodeMaterialConnectionPoint;
  61120. /**
  61121. * Gets the output component
  61122. */
  61123. get output(): NodeMaterialConnectionPoint;
  61124. /**
  61125. * Initialize the block and prepare the context for build
  61126. * @param state defines the state that will be used for the build
  61127. */
  61128. initialize(state: NodeMaterialBuildState): void;
  61129. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61132. protected _buildBlock(state: NodeMaterialBuildState): this;
  61133. }
  61134. }
  61135. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61139. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61141. import { Effect } from "babylonjs/Materials/effect";
  61142. import { Mesh } from "babylonjs/Meshes/mesh";
  61143. import { Scene } from "babylonjs/scene";
  61144. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61145. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61146. /**
  61147. * Block used to pertub normals based on a normal map
  61148. */
  61149. export class PerturbNormalBlock extends NodeMaterialBlock {
  61150. private _tangentSpaceParameterName;
  61151. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61152. invertX: boolean;
  61153. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61154. invertY: boolean;
  61155. /**
  61156. * Create a new PerturbNormalBlock
  61157. * @param name defines the block name
  61158. */
  61159. constructor(name: string);
  61160. /**
  61161. * Gets the current class name
  61162. * @returns the class name
  61163. */
  61164. getClassName(): string;
  61165. /**
  61166. * Gets the world position input component
  61167. */
  61168. get worldPosition(): NodeMaterialConnectionPoint;
  61169. /**
  61170. * Gets the world normal input component
  61171. */
  61172. get worldNormal(): NodeMaterialConnectionPoint;
  61173. /**
  61174. * Gets the world tangent input component
  61175. */
  61176. get worldTangent(): NodeMaterialConnectionPoint;
  61177. /**
  61178. * Gets the uv input component
  61179. */
  61180. get uv(): NodeMaterialConnectionPoint;
  61181. /**
  61182. * Gets the normal map color input component
  61183. */
  61184. get normalMapColor(): NodeMaterialConnectionPoint;
  61185. /**
  61186. * Gets the strength input component
  61187. */
  61188. get strength(): NodeMaterialConnectionPoint;
  61189. /**
  61190. * Gets the output component
  61191. */
  61192. get output(): NodeMaterialConnectionPoint;
  61193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61194. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61195. autoConfigure(material: NodeMaterial): void;
  61196. protected _buildBlock(state: NodeMaterialBuildState): this;
  61197. protected _dumpPropertiesCode(): string;
  61198. serialize(): any;
  61199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61200. }
  61201. }
  61202. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61206. /**
  61207. * Block used to discard a pixel if a value is smaller than a cutoff
  61208. */
  61209. export class DiscardBlock extends NodeMaterialBlock {
  61210. /**
  61211. * Create a new DiscardBlock
  61212. * @param name defines the block name
  61213. */
  61214. constructor(name: string);
  61215. /**
  61216. * Gets the current class name
  61217. * @returns the class name
  61218. */
  61219. getClassName(): string;
  61220. /**
  61221. * Gets the color input component
  61222. */
  61223. get value(): NodeMaterialConnectionPoint;
  61224. /**
  61225. * Gets the cutoff input component
  61226. */
  61227. get cutoff(): NodeMaterialConnectionPoint;
  61228. protected _buildBlock(state: NodeMaterialBuildState): this;
  61229. }
  61230. }
  61231. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61235. /**
  61236. * Block used to test if the fragment shader is front facing
  61237. */
  61238. export class FrontFacingBlock extends NodeMaterialBlock {
  61239. /**
  61240. * Creates a new FrontFacingBlock
  61241. * @param name defines the block name
  61242. */
  61243. constructor(name: string);
  61244. /**
  61245. * Gets the current class name
  61246. * @returns the class name
  61247. */
  61248. getClassName(): string;
  61249. /**
  61250. * Gets the output component
  61251. */
  61252. get output(): NodeMaterialConnectionPoint;
  61253. protected _buildBlock(state: NodeMaterialBuildState): this;
  61254. }
  61255. }
  61256. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61260. /**
  61261. * Block used to get the derivative value on x and y of a given input
  61262. */
  61263. export class DerivativeBlock extends NodeMaterialBlock {
  61264. /**
  61265. * Create a new DerivativeBlock
  61266. * @param name defines the block name
  61267. */
  61268. constructor(name: string);
  61269. /**
  61270. * Gets the current class name
  61271. * @returns the class name
  61272. */
  61273. getClassName(): string;
  61274. /**
  61275. * Gets the input component
  61276. */
  61277. get input(): NodeMaterialConnectionPoint;
  61278. /**
  61279. * Gets the derivative output on x
  61280. */
  61281. get dx(): NodeMaterialConnectionPoint;
  61282. /**
  61283. * Gets the derivative output on y
  61284. */
  61285. get dy(): NodeMaterialConnectionPoint;
  61286. protected _buildBlock(state: NodeMaterialBuildState): this;
  61287. }
  61288. }
  61289. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61290. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61291. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61292. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61293. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61294. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61295. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61296. }
  61297. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61300. import { Mesh } from "babylonjs/Meshes/mesh";
  61301. import { Effect } from "babylonjs/Materials/effect";
  61302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61304. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61305. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61306. /**
  61307. * Block used to add support for scene fog
  61308. */
  61309. export class FogBlock extends NodeMaterialBlock {
  61310. private _fogDistanceName;
  61311. private _fogParameters;
  61312. /**
  61313. * Create a new FogBlock
  61314. * @param name defines the block name
  61315. */
  61316. constructor(name: string);
  61317. /**
  61318. * Gets the current class name
  61319. * @returns the class name
  61320. */
  61321. getClassName(): string;
  61322. /**
  61323. * Gets the world position input component
  61324. */
  61325. get worldPosition(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the view input component
  61328. */
  61329. get view(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the color input component
  61332. */
  61333. get input(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the fog color input component
  61336. */
  61337. get fogColor(): NodeMaterialConnectionPoint;
  61338. /**
  61339. * Gets the output component
  61340. */
  61341. get output(): NodeMaterialConnectionPoint;
  61342. autoConfigure(material: NodeMaterial): void;
  61343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61345. protected _buildBlock(state: NodeMaterialBuildState): this;
  61346. }
  61347. }
  61348. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61353. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61354. import { Effect } from "babylonjs/Materials/effect";
  61355. import { Mesh } from "babylonjs/Meshes/mesh";
  61356. import { Light } from "babylonjs/Lights/light";
  61357. import { Nullable } from "babylonjs/types";
  61358. import { Scene } from "babylonjs/scene";
  61359. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61360. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61361. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61362. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61363. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61364. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61365. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61366. /**
  61367. * Block used to add light in the fragment shader
  61368. */
  61369. export class LightBlock extends NodeMaterialBlock {
  61370. private _lightId;
  61371. /**
  61372. * Gets or sets the light associated with this block
  61373. */
  61374. light: Nullable<Light>;
  61375. /**
  61376. * Create a new LightBlock
  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 world position input component
  61387. */
  61388. get worldPosition(): NodeMaterialConnectionPoint;
  61389. /**
  61390. * Gets the world normal input component
  61391. */
  61392. get worldNormal(): NodeMaterialConnectionPoint;
  61393. /**
  61394. * Gets the camera (or eye) position component
  61395. */
  61396. get cameraPosition(): NodeMaterialConnectionPoint;
  61397. /**
  61398. * Gets the glossiness component
  61399. */
  61400. get glossiness(): NodeMaterialConnectionPoint;
  61401. /**
  61402. * Gets the glossinness power component
  61403. */
  61404. get glossPower(): NodeMaterialConnectionPoint;
  61405. /**
  61406. * Gets the diffuse color component
  61407. */
  61408. get diffuseColor(): NodeMaterialConnectionPoint;
  61409. /**
  61410. * Gets the specular color component
  61411. */
  61412. get specularColor(): NodeMaterialConnectionPoint;
  61413. /**
  61414. * Gets the diffuse output component
  61415. */
  61416. get diffuseOutput(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the specular output component
  61419. */
  61420. get specularOutput(): NodeMaterialConnectionPoint;
  61421. /**
  61422. * Gets the shadow output component
  61423. */
  61424. get shadow(): NodeMaterialConnectionPoint;
  61425. autoConfigure(material: NodeMaterial): void;
  61426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61427. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61429. private _injectVertexCode;
  61430. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61431. serialize(): any;
  61432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61433. }
  61434. }
  61435. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61436. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61437. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61438. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61439. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61440. }
  61441. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61442. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61443. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61444. }
  61445. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61449. /**
  61450. * Block used to multiply 2 values
  61451. */
  61452. export class MultiplyBlock extends NodeMaterialBlock {
  61453. /**
  61454. * Creates a new MultiplyBlock
  61455. * @param name defines the block name
  61456. */
  61457. constructor(name: string);
  61458. /**
  61459. * Gets the current class name
  61460. * @returns the class name
  61461. */
  61462. getClassName(): string;
  61463. /**
  61464. * Gets the left operand input component
  61465. */
  61466. get left(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the right operand input component
  61469. */
  61470. get right(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Gets the output component
  61473. */
  61474. get output(): NodeMaterialConnectionPoint;
  61475. protected _buildBlock(state: NodeMaterialBuildState): this;
  61476. }
  61477. }
  61478. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61482. /**
  61483. * Block used to add 2 vectors
  61484. */
  61485. export class AddBlock extends NodeMaterialBlock {
  61486. /**
  61487. * Creates a new AddBlock
  61488. * @param name defines the block name
  61489. */
  61490. constructor(name: string);
  61491. /**
  61492. * Gets the current class name
  61493. * @returns the class name
  61494. */
  61495. getClassName(): string;
  61496. /**
  61497. * Gets the left operand input component
  61498. */
  61499. get left(): NodeMaterialConnectionPoint;
  61500. /**
  61501. * Gets the right operand input component
  61502. */
  61503. get right(): NodeMaterialConnectionPoint;
  61504. /**
  61505. * Gets the output component
  61506. */
  61507. get output(): NodeMaterialConnectionPoint;
  61508. protected _buildBlock(state: NodeMaterialBuildState): this;
  61509. }
  61510. }
  61511. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61515. /**
  61516. * Block used to scale a vector by a float
  61517. */
  61518. export class ScaleBlock extends NodeMaterialBlock {
  61519. /**
  61520. * Creates a new ScaleBlock
  61521. * @param name defines the block name
  61522. */
  61523. constructor(name: string);
  61524. /**
  61525. * Gets the current class name
  61526. * @returns the class name
  61527. */
  61528. getClassName(): string;
  61529. /**
  61530. * Gets the input component
  61531. */
  61532. get input(): NodeMaterialConnectionPoint;
  61533. /**
  61534. * Gets the factor input component
  61535. */
  61536. get factor(): NodeMaterialConnectionPoint;
  61537. /**
  61538. * Gets the output component
  61539. */
  61540. get output(): NodeMaterialConnectionPoint;
  61541. protected _buildBlock(state: NodeMaterialBuildState): this;
  61542. }
  61543. }
  61544. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61548. import { Scene } from "babylonjs/scene";
  61549. /**
  61550. * Block used to clamp a float
  61551. */
  61552. export class ClampBlock extends NodeMaterialBlock {
  61553. /** Gets or sets the minimum range */
  61554. minimum: number;
  61555. /** Gets or sets the maximum range */
  61556. maximum: number;
  61557. /**
  61558. * Creates a new ClampBlock
  61559. * @param name defines the block name
  61560. */
  61561. constructor(name: string);
  61562. /**
  61563. * Gets the current class name
  61564. * @returns the class name
  61565. */
  61566. getClassName(): string;
  61567. /**
  61568. * Gets the value input component
  61569. */
  61570. get value(): NodeMaterialConnectionPoint;
  61571. /**
  61572. * Gets the output component
  61573. */
  61574. get output(): NodeMaterialConnectionPoint;
  61575. protected _buildBlock(state: NodeMaterialBuildState): this;
  61576. protected _dumpPropertiesCode(): string;
  61577. serialize(): any;
  61578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61579. }
  61580. }
  61581. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61585. /**
  61586. * Block used to apply a cross product between 2 vectors
  61587. */
  61588. export class CrossBlock extends NodeMaterialBlock {
  61589. /**
  61590. * Creates a new CrossBlock
  61591. * @param name defines the block name
  61592. */
  61593. constructor(name: string);
  61594. /**
  61595. * Gets the current class name
  61596. * @returns the class name
  61597. */
  61598. getClassName(): string;
  61599. /**
  61600. * Gets the left operand input component
  61601. */
  61602. get left(): NodeMaterialConnectionPoint;
  61603. /**
  61604. * Gets the right operand input component
  61605. */
  61606. get right(): NodeMaterialConnectionPoint;
  61607. /**
  61608. * Gets the output component
  61609. */
  61610. get output(): NodeMaterialConnectionPoint;
  61611. protected _buildBlock(state: NodeMaterialBuildState): this;
  61612. }
  61613. }
  61614. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61616. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61617. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61618. /**
  61619. * Block used to apply a dot product between 2 vectors
  61620. */
  61621. export class DotBlock extends NodeMaterialBlock {
  61622. /**
  61623. * Creates a new DotBlock
  61624. * @param name defines the block name
  61625. */
  61626. constructor(name: string);
  61627. /**
  61628. * Gets the current class name
  61629. * @returns the class name
  61630. */
  61631. getClassName(): string;
  61632. /**
  61633. * Gets the left operand input component
  61634. */
  61635. get left(): NodeMaterialConnectionPoint;
  61636. /**
  61637. * Gets the right operand input component
  61638. */
  61639. get right(): NodeMaterialConnectionPoint;
  61640. /**
  61641. * Gets the output component
  61642. */
  61643. get output(): NodeMaterialConnectionPoint;
  61644. protected _buildBlock(state: NodeMaterialBuildState): this;
  61645. }
  61646. }
  61647. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61651. import { Vector2 } from "babylonjs/Maths/math.vector";
  61652. import { Scene } from "babylonjs/scene";
  61653. /**
  61654. * Block used to remap a float from a range to a new one
  61655. */
  61656. export class RemapBlock extends NodeMaterialBlock {
  61657. /**
  61658. * Gets or sets the source range
  61659. */
  61660. sourceRange: Vector2;
  61661. /**
  61662. * Gets or sets the target range
  61663. */
  61664. targetRange: Vector2;
  61665. /**
  61666. * Creates a new RemapBlock
  61667. * @param name defines the block name
  61668. */
  61669. constructor(name: string);
  61670. /**
  61671. * Gets the current class name
  61672. * @returns the class name
  61673. */
  61674. getClassName(): string;
  61675. /**
  61676. * Gets the input component
  61677. */
  61678. get input(): NodeMaterialConnectionPoint;
  61679. /**
  61680. * Gets the source min input component
  61681. */
  61682. get sourceMin(): NodeMaterialConnectionPoint;
  61683. /**
  61684. * Gets the source max input component
  61685. */
  61686. get sourceMax(): NodeMaterialConnectionPoint;
  61687. /**
  61688. * Gets the target min input component
  61689. */
  61690. get targetMin(): NodeMaterialConnectionPoint;
  61691. /**
  61692. * Gets the target max input component
  61693. */
  61694. get targetMax(): NodeMaterialConnectionPoint;
  61695. /**
  61696. * Gets the output component
  61697. */
  61698. get output(): NodeMaterialConnectionPoint;
  61699. protected _buildBlock(state: NodeMaterialBuildState): this;
  61700. protected _dumpPropertiesCode(): string;
  61701. serialize(): any;
  61702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61703. }
  61704. }
  61705. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61709. /**
  61710. * Block used to normalize a vector
  61711. */
  61712. export class NormalizeBlock extends NodeMaterialBlock {
  61713. /**
  61714. * Creates a new NormalizeBlock
  61715. * @param name defines the block name
  61716. */
  61717. constructor(name: string);
  61718. /**
  61719. * Gets the current class name
  61720. * @returns the class name
  61721. */
  61722. getClassName(): string;
  61723. /**
  61724. * Gets the input component
  61725. */
  61726. get input(): NodeMaterialConnectionPoint;
  61727. /**
  61728. * Gets the output component
  61729. */
  61730. get output(): NodeMaterialConnectionPoint;
  61731. protected _buildBlock(state: NodeMaterialBuildState): this;
  61732. }
  61733. }
  61734. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  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. import { Scene } from "babylonjs/scene";
  61739. /**
  61740. * Operations supported by the Trigonometry block
  61741. */
  61742. export enum TrigonometryBlockOperations {
  61743. /** Cos */
  61744. Cos = 0,
  61745. /** Sin */
  61746. Sin = 1,
  61747. /** Abs */
  61748. Abs = 2,
  61749. /** Exp */
  61750. Exp = 3,
  61751. /** Exp2 */
  61752. Exp2 = 4,
  61753. /** Round */
  61754. Round = 5,
  61755. /** Floor */
  61756. Floor = 6,
  61757. /** Ceiling */
  61758. Ceiling = 7,
  61759. /** Square root */
  61760. Sqrt = 8,
  61761. /** Log */
  61762. Log = 9,
  61763. /** Tangent */
  61764. Tan = 10,
  61765. /** Arc tangent */
  61766. ArcTan = 11,
  61767. /** Arc cosinus */
  61768. ArcCos = 12,
  61769. /** Arc sinus */
  61770. ArcSin = 13,
  61771. /** Fraction */
  61772. Fract = 14,
  61773. /** Sign */
  61774. Sign = 15,
  61775. /** To radians (from degrees) */
  61776. Radians = 16,
  61777. /** To degrees (from radians) */
  61778. Degrees = 17
  61779. }
  61780. /**
  61781. * Block used to apply trigonometry operation to floats
  61782. */
  61783. export class TrigonometryBlock extends NodeMaterialBlock {
  61784. /**
  61785. * Gets or sets the operation applied by the block
  61786. */
  61787. operation: TrigonometryBlockOperations;
  61788. /**
  61789. * Creates a new TrigonometryBlock
  61790. * @param name defines the block name
  61791. */
  61792. constructor(name: string);
  61793. /**
  61794. * Gets the current class name
  61795. * @returns the class name
  61796. */
  61797. getClassName(): string;
  61798. /**
  61799. * Gets the input component
  61800. */
  61801. get input(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the output component
  61804. */
  61805. get output(): NodeMaterialConnectionPoint;
  61806. protected _buildBlock(state: NodeMaterialBuildState): this;
  61807. serialize(): any;
  61808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61809. protected _dumpPropertiesCode(): string;
  61810. }
  61811. }
  61812. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61813. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61816. /**
  61817. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61818. */
  61819. export class ColorMergerBlock extends NodeMaterialBlock {
  61820. /**
  61821. * Create a new ColorMergerBlock
  61822. * @param name defines the block name
  61823. */
  61824. constructor(name: string);
  61825. /**
  61826. * Gets the current class name
  61827. * @returns the class name
  61828. */
  61829. getClassName(): string;
  61830. /**
  61831. * Gets the rgb component (input)
  61832. */
  61833. get rgbIn(): NodeMaterialConnectionPoint;
  61834. /**
  61835. * Gets the r component (input)
  61836. */
  61837. get r(): NodeMaterialConnectionPoint;
  61838. /**
  61839. * Gets the g component (input)
  61840. */
  61841. get g(): NodeMaterialConnectionPoint;
  61842. /**
  61843. * Gets the b component (input)
  61844. */
  61845. get b(): NodeMaterialConnectionPoint;
  61846. /**
  61847. * Gets the a component (input)
  61848. */
  61849. get a(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the rgba component (output)
  61852. */
  61853. get rgba(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the rgb component (output)
  61856. */
  61857. get rgbOut(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the rgb component (output)
  61860. * @deprecated Please use rgbOut instead.
  61861. */
  61862. get rgb(): NodeMaterialConnectionPoint;
  61863. protected _buildBlock(state: NodeMaterialBuildState): this;
  61864. }
  61865. }
  61866. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61870. /**
  61871. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61872. */
  61873. export class VectorMergerBlock extends NodeMaterialBlock {
  61874. /**
  61875. * Create a new VectorMergerBlock
  61876. * @param name defines the block name
  61877. */
  61878. constructor(name: string);
  61879. /**
  61880. * Gets the current class name
  61881. * @returns the class name
  61882. */
  61883. getClassName(): string;
  61884. /**
  61885. * Gets the xyz component (input)
  61886. */
  61887. get xyzIn(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the xy component (input)
  61890. */
  61891. get xyIn(): NodeMaterialConnectionPoint;
  61892. /**
  61893. * Gets the x component (input)
  61894. */
  61895. get x(): NodeMaterialConnectionPoint;
  61896. /**
  61897. * Gets the y component (input)
  61898. */
  61899. get y(): NodeMaterialConnectionPoint;
  61900. /**
  61901. * Gets the z component (input)
  61902. */
  61903. get z(): NodeMaterialConnectionPoint;
  61904. /**
  61905. * Gets the w component (input)
  61906. */
  61907. get w(): NodeMaterialConnectionPoint;
  61908. /**
  61909. * Gets the xyzw component (output)
  61910. */
  61911. get xyzw(): NodeMaterialConnectionPoint;
  61912. /**
  61913. * Gets the xyz component (output)
  61914. */
  61915. get xyzOut(): NodeMaterialConnectionPoint;
  61916. /**
  61917. * Gets the xy component (output)
  61918. */
  61919. get xyOut(): NodeMaterialConnectionPoint;
  61920. /**
  61921. * Gets the xy component (output)
  61922. * @deprecated Please use xyOut instead.
  61923. */
  61924. get xy(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the xyz component (output)
  61927. * @deprecated Please use xyzOut instead.
  61928. */
  61929. get xyz(): NodeMaterialConnectionPoint;
  61930. protected _buildBlock(state: NodeMaterialBuildState): this;
  61931. }
  61932. }
  61933. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61937. /**
  61938. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61939. */
  61940. export class ColorSplitterBlock extends NodeMaterialBlock {
  61941. /**
  61942. * Create a new ColorSplitterBlock
  61943. * @param name defines the block name
  61944. */
  61945. constructor(name: string);
  61946. /**
  61947. * Gets the current class name
  61948. * @returns the class name
  61949. */
  61950. getClassName(): string;
  61951. /**
  61952. * Gets the rgba component (input)
  61953. */
  61954. get rgba(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the rgb component (input)
  61957. */
  61958. get rgbIn(): NodeMaterialConnectionPoint;
  61959. /**
  61960. * Gets the rgb component (output)
  61961. */
  61962. get rgbOut(): NodeMaterialConnectionPoint;
  61963. /**
  61964. * Gets the r component (output)
  61965. */
  61966. get r(): NodeMaterialConnectionPoint;
  61967. /**
  61968. * Gets the g component (output)
  61969. */
  61970. get g(): NodeMaterialConnectionPoint;
  61971. /**
  61972. * Gets the b component (output)
  61973. */
  61974. get b(): NodeMaterialConnectionPoint;
  61975. /**
  61976. * Gets the a component (output)
  61977. */
  61978. get a(): NodeMaterialConnectionPoint;
  61979. protected _inputRename(name: string): string;
  61980. protected _outputRename(name: string): string;
  61981. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61982. }
  61983. }
  61984. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61988. /**
  61989. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61990. */
  61991. export class VectorSplitterBlock extends NodeMaterialBlock {
  61992. /**
  61993. * Create a new VectorSplitterBlock
  61994. * @param name defines the block name
  61995. */
  61996. constructor(name: string);
  61997. /**
  61998. * Gets the current class name
  61999. * @returns the class name
  62000. */
  62001. getClassName(): string;
  62002. /**
  62003. * Gets the xyzw component (input)
  62004. */
  62005. get xyzw(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the xyz component (input)
  62008. */
  62009. get xyzIn(): NodeMaterialConnectionPoint;
  62010. /**
  62011. * Gets the xy component (input)
  62012. */
  62013. get xyIn(): NodeMaterialConnectionPoint;
  62014. /**
  62015. * Gets the xyz component (output)
  62016. */
  62017. get xyzOut(): NodeMaterialConnectionPoint;
  62018. /**
  62019. * Gets the xy component (output)
  62020. */
  62021. get xyOut(): NodeMaterialConnectionPoint;
  62022. /**
  62023. * Gets the x component (output)
  62024. */
  62025. get x(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the y component (output)
  62028. */
  62029. get y(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the z component (output)
  62032. */
  62033. get z(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the w component (output)
  62036. */
  62037. get w(): NodeMaterialConnectionPoint;
  62038. protected _inputRename(name: string): string;
  62039. protected _outputRename(name: string): string;
  62040. protected _buildBlock(state: NodeMaterialBuildState): this;
  62041. }
  62042. }
  62043. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62047. /**
  62048. * Block used to lerp between 2 values
  62049. */
  62050. export class LerpBlock extends NodeMaterialBlock {
  62051. /**
  62052. * Creates a new LerpBlock
  62053. * @param name defines the block name
  62054. */
  62055. constructor(name: string);
  62056. /**
  62057. * Gets the current class name
  62058. * @returns the class name
  62059. */
  62060. getClassName(): string;
  62061. /**
  62062. * Gets the left operand input component
  62063. */
  62064. get left(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the right operand input component
  62067. */
  62068. get right(): NodeMaterialConnectionPoint;
  62069. /**
  62070. * Gets the gradient operand input component
  62071. */
  62072. get gradient(): NodeMaterialConnectionPoint;
  62073. /**
  62074. * Gets the output component
  62075. */
  62076. get output(): NodeMaterialConnectionPoint;
  62077. protected _buildBlock(state: NodeMaterialBuildState): this;
  62078. }
  62079. }
  62080. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62084. /**
  62085. * Block used to divide 2 vectors
  62086. */
  62087. export class DivideBlock extends NodeMaterialBlock {
  62088. /**
  62089. * Creates a new DivideBlock
  62090. * @param name defines the block name
  62091. */
  62092. constructor(name: string);
  62093. /**
  62094. * Gets the current class name
  62095. * @returns the class name
  62096. */
  62097. getClassName(): string;
  62098. /**
  62099. * Gets the left operand input component
  62100. */
  62101. get left(): NodeMaterialConnectionPoint;
  62102. /**
  62103. * Gets the right operand input component
  62104. */
  62105. get right(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the output component
  62108. */
  62109. get output(): NodeMaterialConnectionPoint;
  62110. protected _buildBlock(state: NodeMaterialBuildState): this;
  62111. }
  62112. }
  62113. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62117. /**
  62118. * Block used to subtract 2 vectors
  62119. */
  62120. export class SubtractBlock extends NodeMaterialBlock {
  62121. /**
  62122. * Creates a new SubtractBlock
  62123. * @param name defines the block name
  62124. */
  62125. constructor(name: string);
  62126. /**
  62127. * Gets the current class name
  62128. * @returns the class name
  62129. */
  62130. getClassName(): string;
  62131. /**
  62132. * Gets the left operand input component
  62133. */
  62134. get left(): NodeMaterialConnectionPoint;
  62135. /**
  62136. * Gets the right operand input component
  62137. */
  62138. get right(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the output component
  62141. */
  62142. get output(): NodeMaterialConnectionPoint;
  62143. protected _buildBlock(state: NodeMaterialBuildState): this;
  62144. }
  62145. }
  62146. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62150. /**
  62151. * Block used to step a value
  62152. */
  62153. export class StepBlock extends NodeMaterialBlock {
  62154. /**
  62155. * Creates a new StepBlock
  62156. * @param name defines the block name
  62157. */
  62158. constructor(name: string);
  62159. /**
  62160. * Gets the current class name
  62161. * @returns the class name
  62162. */
  62163. getClassName(): string;
  62164. /**
  62165. * Gets the value operand input component
  62166. */
  62167. get value(): NodeMaterialConnectionPoint;
  62168. /**
  62169. * Gets the edge operand input component
  62170. */
  62171. get edge(): NodeMaterialConnectionPoint;
  62172. /**
  62173. * Gets the output component
  62174. */
  62175. get output(): NodeMaterialConnectionPoint;
  62176. protected _buildBlock(state: NodeMaterialBuildState): this;
  62177. }
  62178. }
  62179. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62183. /**
  62184. * Block used to get the opposite (1 - x) of a value
  62185. */
  62186. export class OneMinusBlock extends NodeMaterialBlock {
  62187. /**
  62188. * Creates a new OneMinusBlock
  62189. * @param name defines the block name
  62190. */
  62191. constructor(name: string);
  62192. /**
  62193. * Gets the current class name
  62194. * @returns the class name
  62195. */
  62196. getClassName(): string;
  62197. /**
  62198. * Gets the input component
  62199. */
  62200. get input(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the output component
  62203. */
  62204. get output(): NodeMaterialConnectionPoint;
  62205. protected _buildBlock(state: NodeMaterialBuildState): this;
  62206. }
  62207. }
  62208. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62212. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62213. /**
  62214. * Block used to get the view direction
  62215. */
  62216. export class ViewDirectionBlock extends NodeMaterialBlock {
  62217. /**
  62218. * Creates a new ViewDirectionBlock
  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 world position component
  62229. */
  62230. get worldPosition(): NodeMaterialConnectionPoint;
  62231. /**
  62232. * Gets the camera position component
  62233. */
  62234. get cameraPosition(): NodeMaterialConnectionPoint;
  62235. /**
  62236. * Gets the output component
  62237. */
  62238. get output(): NodeMaterialConnectionPoint;
  62239. autoConfigure(material: NodeMaterial): void;
  62240. protected _buildBlock(state: NodeMaterialBuildState): this;
  62241. }
  62242. }
  62243. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62247. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62248. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62249. /**
  62250. * Block used to compute fresnel value
  62251. */
  62252. export class FresnelBlock extends NodeMaterialBlock {
  62253. /**
  62254. * Create a new FresnelBlock
  62255. * @param name defines the block name
  62256. */
  62257. constructor(name: string);
  62258. /**
  62259. * Gets the current class name
  62260. * @returns the class name
  62261. */
  62262. getClassName(): string;
  62263. /**
  62264. * Gets the world normal input component
  62265. */
  62266. get worldNormal(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the view direction input component
  62269. */
  62270. get viewDirection(): NodeMaterialConnectionPoint;
  62271. /**
  62272. * Gets the bias input component
  62273. */
  62274. get bias(): NodeMaterialConnectionPoint;
  62275. /**
  62276. * Gets the camera (or eye) position component
  62277. */
  62278. get power(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the fresnel output component
  62281. */
  62282. get fresnel(): NodeMaterialConnectionPoint;
  62283. autoConfigure(material: NodeMaterial): void;
  62284. protected _buildBlock(state: NodeMaterialBuildState): this;
  62285. }
  62286. }
  62287. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62289. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62291. /**
  62292. * Block used to get the max of 2 values
  62293. */
  62294. export class MaxBlock extends NodeMaterialBlock {
  62295. /**
  62296. * Creates a new MaxBlock
  62297. * @param name defines the block name
  62298. */
  62299. constructor(name: string);
  62300. /**
  62301. * Gets the current class name
  62302. * @returns the class name
  62303. */
  62304. getClassName(): string;
  62305. /**
  62306. * Gets the left operand input component
  62307. */
  62308. get left(): NodeMaterialConnectionPoint;
  62309. /**
  62310. * Gets the right operand input component
  62311. */
  62312. get right(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the output component
  62315. */
  62316. get output(): NodeMaterialConnectionPoint;
  62317. protected _buildBlock(state: NodeMaterialBuildState): this;
  62318. }
  62319. }
  62320. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62324. /**
  62325. * Block used to get the min of 2 values
  62326. */
  62327. export class MinBlock extends NodeMaterialBlock {
  62328. /**
  62329. * Creates a new MinBlock
  62330. * @param name defines the block name
  62331. */
  62332. constructor(name: string);
  62333. /**
  62334. * Gets the current class name
  62335. * @returns the class name
  62336. */
  62337. getClassName(): string;
  62338. /**
  62339. * Gets the left operand input component
  62340. */
  62341. get left(): NodeMaterialConnectionPoint;
  62342. /**
  62343. * Gets the right operand input component
  62344. */
  62345. get right(): NodeMaterialConnectionPoint;
  62346. /**
  62347. * Gets the output component
  62348. */
  62349. get output(): NodeMaterialConnectionPoint;
  62350. protected _buildBlock(state: NodeMaterialBuildState): this;
  62351. }
  62352. }
  62353. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62357. /**
  62358. * Block used to get the distance between 2 values
  62359. */
  62360. export class DistanceBlock extends NodeMaterialBlock {
  62361. /**
  62362. * Creates a new DistanceBlock
  62363. * @param name defines the block name
  62364. */
  62365. constructor(name: string);
  62366. /**
  62367. * Gets the current class name
  62368. * @returns the class name
  62369. */
  62370. getClassName(): string;
  62371. /**
  62372. * Gets the left operand input component
  62373. */
  62374. get left(): NodeMaterialConnectionPoint;
  62375. /**
  62376. * Gets the right operand input component
  62377. */
  62378. get right(): NodeMaterialConnectionPoint;
  62379. /**
  62380. * Gets the output component
  62381. */
  62382. get output(): NodeMaterialConnectionPoint;
  62383. protected _buildBlock(state: NodeMaterialBuildState): this;
  62384. }
  62385. }
  62386. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62390. /**
  62391. * Block used to get the length of a vector
  62392. */
  62393. export class LengthBlock extends NodeMaterialBlock {
  62394. /**
  62395. * Creates a new LengthBlock
  62396. * @param name defines the block name
  62397. */
  62398. constructor(name: string);
  62399. /**
  62400. * Gets the current class name
  62401. * @returns the class name
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the value input component
  62406. */
  62407. get value(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the output component
  62410. */
  62411. get output(): NodeMaterialConnectionPoint;
  62412. protected _buildBlock(state: NodeMaterialBuildState): this;
  62413. }
  62414. }
  62415. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62419. /**
  62420. * Block used to get negative version of a value (i.e. x * -1)
  62421. */
  62422. export class NegateBlock extends NodeMaterialBlock {
  62423. /**
  62424. * Creates a new NegateBlock
  62425. * @param name defines the block name
  62426. */
  62427. constructor(name: string);
  62428. /**
  62429. * Gets the current class name
  62430. * @returns the class name
  62431. */
  62432. getClassName(): string;
  62433. /**
  62434. * Gets the value input component
  62435. */
  62436. get value(): NodeMaterialConnectionPoint;
  62437. /**
  62438. * Gets the output component
  62439. */
  62440. get output(): NodeMaterialConnectionPoint;
  62441. protected _buildBlock(state: NodeMaterialBuildState): this;
  62442. }
  62443. }
  62444. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62448. /**
  62449. * Block used to get the value of the first parameter raised to the power of the second
  62450. */
  62451. export class PowBlock extends NodeMaterialBlock {
  62452. /**
  62453. * Creates a new PowBlock
  62454. * @param name defines the block name
  62455. */
  62456. constructor(name: string);
  62457. /**
  62458. * Gets the current class name
  62459. * @returns the class name
  62460. */
  62461. getClassName(): string;
  62462. /**
  62463. * Gets the value operand input component
  62464. */
  62465. get value(): NodeMaterialConnectionPoint;
  62466. /**
  62467. * Gets the power operand input component
  62468. */
  62469. get power(): NodeMaterialConnectionPoint;
  62470. /**
  62471. * Gets the output component
  62472. */
  62473. get output(): NodeMaterialConnectionPoint;
  62474. protected _buildBlock(state: NodeMaterialBuildState): this;
  62475. }
  62476. }
  62477. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62482. /**
  62483. * Block used to get a random number
  62484. */
  62485. export class RandomNumberBlock extends NodeMaterialBlock {
  62486. /**
  62487. * Creates a new RandomNumberBlock
  62488. * @param name defines the block name
  62489. */
  62490. constructor(name: string);
  62491. /**
  62492. * Gets the current class name
  62493. * @returns the class name
  62494. */
  62495. getClassName(): string;
  62496. /**
  62497. * Gets the seed input component
  62498. */
  62499. get seed(): NodeMaterialConnectionPoint;
  62500. /**
  62501. * Gets the output component
  62502. */
  62503. get output(): NodeMaterialConnectionPoint;
  62504. protected _buildBlock(state: NodeMaterialBuildState): this;
  62505. }
  62506. }
  62507. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62511. /**
  62512. * Block used to compute arc tangent of 2 values
  62513. */
  62514. export class ArcTan2Block extends NodeMaterialBlock {
  62515. /**
  62516. * Creates a new ArcTan2Block
  62517. * @param name defines the block name
  62518. */
  62519. constructor(name: string);
  62520. /**
  62521. * Gets the current class name
  62522. * @returns the class name
  62523. */
  62524. getClassName(): string;
  62525. /**
  62526. * Gets the x operand input component
  62527. */
  62528. get x(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the y operand input component
  62531. */
  62532. get y(): NodeMaterialConnectionPoint;
  62533. /**
  62534. * Gets the output component
  62535. */
  62536. get output(): NodeMaterialConnectionPoint;
  62537. protected _buildBlock(state: NodeMaterialBuildState): this;
  62538. }
  62539. }
  62540. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62544. /**
  62545. * Block used to smooth step a value
  62546. */
  62547. export class SmoothStepBlock extends NodeMaterialBlock {
  62548. /**
  62549. * Creates a new SmoothStepBlock
  62550. * @param name defines the block name
  62551. */
  62552. constructor(name: string);
  62553. /**
  62554. * Gets the current class name
  62555. * @returns the class name
  62556. */
  62557. getClassName(): string;
  62558. /**
  62559. * Gets the value operand input component
  62560. */
  62561. get value(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the first edge operand input component
  62564. */
  62565. get edge0(): NodeMaterialConnectionPoint;
  62566. /**
  62567. * Gets the second edge operand input component
  62568. */
  62569. get edge1(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the output component
  62572. */
  62573. get output(): NodeMaterialConnectionPoint;
  62574. protected _buildBlock(state: NodeMaterialBuildState): this;
  62575. }
  62576. }
  62577. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62581. /**
  62582. * Block used to get the reciprocal (1 / x) of a value
  62583. */
  62584. export class ReciprocalBlock extends NodeMaterialBlock {
  62585. /**
  62586. * Creates a new ReciprocalBlock
  62587. * @param name defines the block name
  62588. */
  62589. constructor(name: string);
  62590. /**
  62591. * Gets the current class name
  62592. * @returns the class name
  62593. */
  62594. getClassName(): string;
  62595. /**
  62596. * Gets the input component
  62597. */
  62598. get input(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Gets the output component
  62601. */
  62602. get output(): NodeMaterialConnectionPoint;
  62603. protected _buildBlock(state: NodeMaterialBuildState): this;
  62604. }
  62605. }
  62606. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62610. /**
  62611. * Block used to replace a color by another one
  62612. */
  62613. export class ReplaceColorBlock extends NodeMaterialBlock {
  62614. /**
  62615. * Creates a new ReplaceColorBlock
  62616. * @param name defines the block name
  62617. */
  62618. constructor(name: string);
  62619. /**
  62620. * Gets the current class name
  62621. * @returns the class name
  62622. */
  62623. getClassName(): string;
  62624. /**
  62625. * Gets the value input component
  62626. */
  62627. get value(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the reference input component
  62630. */
  62631. get reference(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the distance input component
  62634. */
  62635. get distance(): NodeMaterialConnectionPoint;
  62636. /**
  62637. * Gets the replacement input component
  62638. */
  62639. get replacement(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the output component
  62642. */
  62643. get output(): NodeMaterialConnectionPoint;
  62644. protected _buildBlock(state: NodeMaterialBuildState): this;
  62645. }
  62646. }
  62647. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62651. /**
  62652. * Block used to posterize a value
  62653. * @see https://en.wikipedia.org/wiki/Posterization
  62654. */
  62655. export class PosterizeBlock extends NodeMaterialBlock {
  62656. /**
  62657. * Creates a new PosterizeBlock
  62658. * @param name defines the block name
  62659. */
  62660. constructor(name: string);
  62661. /**
  62662. * Gets the current class name
  62663. * @returns the class name
  62664. */
  62665. getClassName(): string;
  62666. /**
  62667. * Gets the value input component
  62668. */
  62669. get value(): NodeMaterialConnectionPoint;
  62670. /**
  62671. * Gets the steps input component
  62672. */
  62673. get steps(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the output component
  62676. */
  62677. get output(): NodeMaterialConnectionPoint;
  62678. protected _buildBlock(state: NodeMaterialBuildState): this;
  62679. }
  62680. }
  62681. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62682. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62685. import { Scene } from "babylonjs/scene";
  62686. /**
  62687. * Operations supported by the Wave block
  62688. */
  62689. export enum WaveBlockKind {
  62690. /** SawTooth */
  62691. SawTooth = 0,
  62692. /** Square */
  62693. Square = 1,
  62694. /** Triangle */
  62695. Triangle = 2
  62696. }
  62697. /**
  62698. * Block used to apply wave operation to floats
  62699. */
  62700. export class WaveBlock extends NodeMaterialBlock {
  62701. /**
  62702. * Gets or sets the kibnd of wave to be applied by the block
  62703. */
  62704. kind: WaveBlockKind;
  62705. /**
  62706. * Creates a new WaveBlock
  62707. * @param name defines the block name
  62708. */
  62709. constructor(name: string);
  62710. /**
  62711. * Gets the current class name
  62712. * @returns the class name
  62713. */
  62714. getClassName(): string;
  62715. /**
  62716. * Gets the input component
  62717. */
  62718. get input(): NodeMaterialConnectionPoint;
  62719. /**
  62720. * Gets the output component
  62721. */
  62722. get output(): NodeMaterialConnectionPoint;
  62723. protected _buildBlock(state: NodeMaterialBuildState): this;
  62724. serialize(): any;
  62725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62726. }
  62727. }
  62728. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62732. import { Color3 } from "babylonjs/Maths/math.color";
  62733. import { Scene } from "babylonjs/scene";
  62734. /**
  62735. * Class used to store a color step for the GradientBlock
  62736. */
  62737. export class GradientBlockColorStep {
  62738. /**
  62739. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62740. */
  62741. step: number;
  62742. /**
  62743. * Gets or sets the color associated with this step
  62744. */
  62745. color: Color3;
  62746. /**
  62747. * Creates a new GradientBlockColorStep
  62748. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62749. * @param color defines the color associated with this step
  62750. */
  62751. constructor(
  62752. /**
  62753. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62754. */
  62755. step: number,
  62756. /**
  62757. * Gets or sets the color associated with this step
  62758. */
  62759. color: Color3);
  62760. }
  62761. /**
  62762. * Block used to return a color from a gradient based on an input value between 0 and 1
  62763. */
  62764. export class GradientBlock extends NodeMaterialBlock {
  62765. /**
  62766. * Gets or sets the list of color steps
  62767. */
  62768. colorSteps: GradientBlockColorStep[];
  62769. /**
  62770. * Creates a new GradientBlock
  62771. * @param name defines the block name
  62772. */
  62773. constructor(name: string);
  62774. /**
  62775. * Gets the current class name
  62776. * @returns the class name
  62777. */
  62778. getClassName(): string;
  62779. /**
  62780. * Gets the gradient input component
  62781. */
  62782. get gradient(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. private _writeColorConstant;
  62788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62789. serialize(): any;
  62790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62791. protected _dumpPropertiesCode(): string;
  62792. }
  62793. }
  62794. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62798. /**
  62799. * Block used to normalize lerp between 2 values
  62800. */
  62801. export class NLerpBlock extends NodeMaterialBlock {
  62802. /**
  62803. * Creates a new NLerpBlock
  62804. * @param name defines the block name
  62805. */
  62806. constructor(name: string);
  62807. /**
  62808. * Gets the current class name
  62809. * @returns the class name
  62810. */
  62811. getClassName(): string;
  62812. /**
  62813. * Gets the left operand input component
  62814. */
  62815. get left(): NodeMaterialConnectionPoint;
  62816. /**
  62817. * Gets the right operand input component
  62818. */
  62819. get right(): NodeMaterialConnectionPoint;
  62820. /**
  62821. * Gets the gradient operand input component
  62822. */
  62823. get gradient(): NodeMaterialConnectionPoint;
  62824. /**
  62825. * Gets the output component
  62826. */
  62827. get output(): NodeMaterialConnectionPoint;
  62828. protected _buildBlock(state: NodeMaterialBuildState): this;
  62829. }
  62830. }
  62831. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62835. import { Scene } from "babylonjs/scene";
  62836. /**
  62837. * block used to Generate a Worley Noise 3D Noise Pattern
  62838. */
  62839. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62840. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62841. manhattanDistance: boolean;
  62842. /**
  62843. * Creates a new WorleyNoise3DBlock
  62844. * @param name defines the block name
  62845. */
  62846. constructor(name: string);
  62847. /**
  62848. * Gets the current class name
  62849. * @returns the class name
  62850. */
  62851. getClassName(): string;
  62852. /**
  62853. * Gets the seed input component
  62854. */
  62855. get seed(): NodeMaterialConnectionPoint;
  62856. /**
  62857. * Gets the jitter input component
  62858. */
  62859. get jitter(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the output component
  62862. */
  62863. get output(): NodeMaterialConnectionPoint;
  62864. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62865. /**
  62866. * Exposes the properties to the UI?
  62867. */
  62868. protected _dumpPropertiesCode(): string;
  62869. /**
  62870. * Exposes the properties to the Seralize?
  62871. */
  62872. serialize(): any;
  62873. /**
  62874. * Exposes the properties to the deseralize?
  62875. */
  62876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62877. }
  62878. }
  62879. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62883. /**
  62884. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62885. */
  62886. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62887. /**
  62888. * Creates a new SimplexPerlin3DBlock
  62889. * @param name defines the block name
  62890. */
  62891. constructor(name: string);
  62892. /**
  62893. * Gets the current class name
  62894. * @returns the class name
  62895. */
  62896. getClassName(): string;
  62897. /**
  62898. * Gets the seed operand input component
  62899. */
  62900. get seed(): NodeMaterialConnectionPoint;
  62901. /**
  62902. * Gets the output component
  62903. */
  62904. get output(): NodeMaterialConnectionPoint;
  62905. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62906. }
  62907. }
  62908. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62912. /**
  62913. * Block used to blend normals
  62914. */
  62915. export class NormalBlendBlock extends NodeMaterialBlock {
  62916. /**
  62917. * Creates a new NormalBlendBlock
  62918. * @param name defines the block name
  62919. */
  62920. constructor(name: string);
  62921. /**
  62922. * Gets the current class name
  62923. * @returns the class name
  62924. */
  62925. getClassName(): string;
  62926. /**
  62927. * Gets the first input component
  62928. */
  62929. get normalMap0(): NodeMaterialConnectionPoint;
  62930. /**
  62931. * Gets the second input component
  62932. */
  62933. get normalMap1(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the output component
  62936. */
  62937. get output(): NodeMaterialConnectionPoint;
  62938. protected _buildBlock(state: NodeMaterialBuildState): this;
  62939. }
  62940. }
  62941. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62945. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62946. /**
  62947. * Block used to rotate a 2d vector by a given angle
  62948. */
  62949. export class Rotate2dBlock extends NodeMaterialBlock {
  62950. /**
  62951. * Creates a new Rotate2dBlock
  62952. * @param name defines the block name
  62953. */
  62954. constructor(name: string);
  62955. /**
  62956. * Gets the current class name
  62957. * @returns the class name
  62958. */
  62959. getClassName(): string;
  62960. /**
  62961. * Gets the input vector
  62962. */
  62963. get input(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the input angle
  62966. */
  62967. get angle(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the output component
  62970. */
  62971. get output(): NodeMaterialConnectionPoint;
  62972. autoConfigure(material: NodeMaterial): void;
  62973. protected _buildBlock(state: NodeMaterialBuildState): this;
  62974. }
  62975. }
  62976. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62980. /**
  62981. * Block used to get the reflected vector from a direction and a normal
  62982. */
  62983. export class ReflectBlock extends NodeMaterialBlock {
  62984. /**
  62985. * Creates a new ReflectBlock
  62986. * @param name defines the block name
  62987. */
  62988. constructor(name: string);
  62989. /**
  62990. * Gets the current class name
  62991. * @returns the class name
  62992. */
  62993. getClassName(): string;
  62994. /**
  62995. * Gets the incident component
  62996. */
  62997. get incident(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the normal component
  63000. */
  63001. get normal(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the output component
  63004. */
  63005. get output(): NodeMaterialConnectionPoint;
  63006. protected _buildBlock(state: NodeMaterialBuildState): this;
  63007. }
  63008. }
  63009. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63013. /**
  63014. * Block used to get the refracted vector from a direction and a normal
  63015. */
  63016. export class RefractBlock extends NodeMaterialBlock {
  63017. /**
  63018. * Creates a new RefractBlock
  63019. * @param name defines the block name
  63020. */
  63021. constructor(name: string);
  63022. /**
  63023. * Gets the current class name
  63024. * @returns the class name
  63025. */
  63026. getClassName(): string;
  63027. /**
  63028. * Gets the incident component
  63029. */
  63030. get incident(): NodeMaterialConnectionPoint;
  63031. /**
  63032. * Gets the normal component
  63033. */
  63034. get normal(): NodeMaterialConnectionPoint;
  63035. /**
  63036. * Gets the index of refraction component
  63037. */
  63038. get ior(): NodeMaterialConnectionPoint;
  63039. /**
  63040. * Gets the output component
  63041. */
  63042. get output(): NodeMaterialConnectionPoint;
  63043. protected _buildBlock(state: NodeMaterialBuildState): this;
  63044. }
  63045. }
  63046. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63050. /**
  63051. * Block used to desaturate a color
  63052. */
  63053. export class DesaturateBlock extends NodeMaterialBlock {
  63054. /**
  63055. * Creates a new DesaturateBlock
  63056. * @param name defines the block name
  63057. */
  63058. constructor(name: string);
  63059. /**
  63060. * Gets the current class name
  63061. * @returns the class name
  63062. */
  63063. getClassName(): string;
  63064. /**
  63065. * Gets the color operand input component
  63066. */
  63067. get color(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the level operand input component
  63070. */
  63071. get level(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the output component
  63074. */
  63075. get output(): NodeMaterialConnectionPoint;
  63076. protected _buildBlock(state: NodeMaterialBuildState): this;
  63077. }
  63078. }
  63079. declare module "babylonjs/Materials/Node/Blocks/index" {
  63080. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63081. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63082. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63083. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63084. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63086. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63087. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63096. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63097. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63098. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63099. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63100. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63101. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63102. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63103. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63104. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63105. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63106. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63107. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63108. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63109. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63110. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63111. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63112. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63113. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63114. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63115. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63116. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63117. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63118. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63119. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63120. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63121. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63122. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63123. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63124. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63125. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63126. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63127. }
  63128. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63129. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63130. }
  63131. declare module "babylonjs/Materials/Node/index" {
  63132. export * from "babylonjs/Materials/Node/Enums/index";
  63133. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63134. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63135. export * from "babylonjs/Materials/Node/nodeMaterial";
  63136. export * from "babylonjs/Materials/Node/Blocks/index";
  63137. export * from "babylonjs/Materials/Node/Optimizers/index";
  63138. }
  63139. declare module "babylonjs/Materials/effectRenderer" {
  63140. import { Nullable } from "babylonjs/types";
  63141. import { Texture } from "babylonjs/Materials/Textures/texture";
  63142. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63143. import { Viewport } from "babylonjs/Maths/math.viewport";
  63144. import { Observable } from "babylonjs/Misc/observable";
  63145. import { Effect } from "babylonjs/Materials/effect";
  63146. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63147. import "babylonjs/Shaders/postprocess.vertex";
  63148. /**
  63149. * Effect Render Options
  63150. */
  63151. export interface IEffectRendererOptions {
  63152. /**
  63153. * Defines the vertices positions.
  63154. */
  63155. positions?: number[];
  63156. /**
  63157. * Defines the indices.
  63158. */
  63159. indices?: number[];
  63160. }
  63161. /**
  63162. * Helper class to render one or more effects
  63163. */
  63164. export class EffectRenderer {
  63165. private engine;
  63166. private static _DefaultOptions;
  63167. private _vertexBuffers;
  63168. private _indexBuffer;
  63169. private _ringBufferIndex;
  63170. private _ringScreenBuffer;
  63171. private _fullscreenViewport;
  63172. private _getNextFrameBuffer;
  63173. /**
  63174. * Creates an effect renderer
  63175. * @param engine the engine to use for rendering
  63176. * @param options defines the options of the effect renderer
  63177. */
  63178. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63179. /**
  63180. * Sets the current viewport in normalized coordinates 0-1
  63181. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63182. */
  63183. setViewport(viewport?: Viewport): void;
  63184. /**
  63185. * Binds the embedded attributes buffer to the effect.
  63186. * @param effect Defines the effect to bind the attributes for
  63187. */
  63188. bindBuffers(effect: Effect): void;
  63189. /**
  63190. * Sets the current effect wrapper to use during draw.
  63191. * The effect needs to be ready before calling this api.
  63192. * This also sets the default full screen position attribute.
  63193. * @param effectWrapper Defines the effect to draw with
  63194. */
  63195. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63196. /**
  63197. * Draws a full screen quad.
  63198. */
  63199. draw(): void;
  63200. /**
  63201. * renders one or more effects to a specified texture
  63202. * @param effectWrappers list of effects to renderer
  63203. * @param outputTexture texture to draw to, if null it will render to the screen
  63204. */
  63205. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63206. /**
  63207. * Disposes of the effect renderer
  63208. */
  63209. dispose(): void;
  63210. }
  63211. /**
  63212. * Options to create an EffectWrapper
  63213. */
  63214. interface EffectWrapperCreationOptions {
  63215. /**
  63216. * Engine to use to create the effect
  63217. */
  63218. engine: ThinEngine;
  63219. /**
  63220. * Fragment shader for the effect
  63221. */
  63222. fragmentShader: string;
  63223. /**
  63224. * Vertex shader for the effect
  63225. */
  63226. vertexShader?: string;
  63227. /**
  63228. * Attributes to use in the shader
  63229. */
  63230. attributeNames?: Array<string>;
  63231. /**
  63232. * Uniforms to use in the shader
  63233. */
  63234. uniformNames?: Array<string>;
  63235. /**
  63236. * Texture sampler names to use in the shader
  63237. */
  63238. samplerNames?: Array<string>;
  63239. /**
  63240. * The friendly name of the effect displayed in Spector.
  63241. */
  63242. name?: string;
  63243. }
  63244. /**
  63245. * Wraps an effect to be used for rendering
  63246. */
  63247. export class EffectWrapper {
  63248. /**
  63249. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63250. */
  63251. onApplyObservable: Observable<{}>;
  63252. /**
  63253. * The underlying effect
  63254. */
  63255. effect: Effect;
  63256. /**
  63257. * Creates an effect to be renderer
  63258. * @param creationOptions options to create the effect
  63259. */
  63260. constructor(creationOptions: EffectWrapperCreationOptions);
  63261. /**
  63262. * Disposes of the effect wrapper
  63263. */
  63264. dispose(): void;
  63265. }
  63266. }
  63267. declare module "babylonjs/Materials/index" {
  63268. export * from "babylonjs/Materials/Background/index";
  63269. export * from "babylonjs/Materials/colorCurves";
  63270. export * from "babylonjs/Materials/iEffectFallbacks";
  63271. export * from "babylonjs/Materials/effectFallbacks";
  63272. export * from "babylonjs/Materials/effect";
  63273. export * from "babylonjs/Materials/fresnelParameters";
  63274. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63275. export * from "babylonjs/Materials/material";
  63276. export * from "babylonjs/Materials/materialDefines";
  63277. export * from "babylonjs/Materials/materialHelper";
  63278. export * from "babylonjs/Materials/multiMaterial";
  63279. export * from "babylonjs/Materials/PBR/index";
  63280. export * from "babylonjs/Materials/pushMaterial";
  63281. export * from "babylonjs/Materials/shaderMaterial";
  63282. export * from "babylonjs/Materials/standardMaterial";
  63283. export * from "babylonjs/Materials/Textures/index";
  63284. export * from "babylonjs/Materials/uniformBuffer";
  63285. export * from "babylonjs/Materials/materialFlags";
  63286. export * from "babylonjs/Materials/Node/index";
  63287. export * from "babylonjs/Materials/effectRenderer";
  63288. }
  63289. declare module "babylonjs/Maths/index" {
  63290. export * from "babylonjs/Maths/math.scalar";
  63291. export * from "babylonjs/Maths/math";
  63292. export * from "babylonjs/Maths/sphericalPolynomial";
  63293. }
  63294. declare module "babylonjs/Misc/workerPool" {
  63295. import { IDisposable } from "babylonjs/scene";
  63296. /**
  63297. * Helper class to push actions to a pool of workers.
  63298. */
  63299. export class WorkerPool implements IDisposable {
  63300. private _workerInfos;
  63301. private _pendingActions;
  63302. /**
  63303. * Constructor
  63304. * @param workers Array of workers to use for actions
  63305. */
  63306. constructor(workers: Array<Worker>);
  63307. /**
  63308. * Terminates all workers and clears any pending actions.
  63309. */
  63310. dispose(): void;
  63311. /**
  63312. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63313. * pended until a worker has completed its action.
  63314. * @param action The action to perform. Call onComplete when the action is complete.
  63315. */
  63316. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63317. private _execute;
  63318. }
  63319. }
  63320. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63321. import { IDisposable } from "babylonjs/scene";
  63322. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63323. /**
  63324. * Configuration for Draco compression
  63325. */
  63326. export interface IDracoCompressionConfiguration {
  63327. /**
  63328. * Configuration for the decoder.
  63329. */
  63330. decoder: {
  63331. /**
  63332. * The url to the WebAssembly module.
  63333. */
  63334. wasmUrl?: string;
  63335. /**
  63336. * The url to the WebAssembly binary.
  63337. */
  63338. wasmBinaryUrl?: string;
  63339. /**
  63340. * The url to the fallback JavaScript module.
  63341. */
  63342. fallbackUrl?: string;
  63343. };
  63344. }
  63345. /**
  63346. * Draco compression (https://google.github.io/draco/)
  63347. *
  63348. * This class wraps the Draco module.
  63349. *
  63350. * **Encoder**
  63351. *
  63352. * The encoder is not currently implemented.
  63353. *
  63354. * **Decoder**
  63355. *
  63356. * 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.
  63357. *
  63358. * To update the configuration, use the following code:
  63359. * ```javascript
  63360. * DracoCompression.Configuration = {
  63361. * decoder: {
  63362. * wasmUrl: "<url to the WebAssembly library>",
  63363. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63364. * fallbackUrl: "<url to the fallback JavaScript library>",
  63365. * }
  63366. * };
  63367. * ```
  63368. *
  63369. * 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.
  63370. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63371. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63372. *
  63373. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63374. * ```javascript
  63375. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63376. * ```
  63377. *
  63378. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63379. */
  63380. export class DracoCompression implements IDisposable {
  63381. private _workerPoolPromise?;
  63382. private _decoderModulePromise?;
  63383. /**
  63384. * The configuration. Defaults to the following urls:
  63385. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63386. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63387. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63388. */
  63389. static Configuration: IDracoCompressionConfiguration;
  63390. /**
  63391. * Returns true if the decoder configuration is available.
  63392. */
  63393. static get DecoderAvailable(): boolean;
  63394. /**
  63395. * Default number of workers to create when creating the draco compression object.
  63396. */
  63397. static DefaultNumWorkers: number;
  63398. private static GetDefaultNumWorkers;
  63399. private static _Default;
  63400. /**
  63401. * Default instance for the draco compression object.
  63402. */
  63403. static get Default(): DracoCompression;
  63404. /**
  63405. * Constructor
  63406. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63407. */
  63408. constructor(numWorkers?: number);
  63409. /**
  63410. * Stop all async operations and release resources.
  63411. */
  63412. dispose(): void;
  63413. /**
  63414. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63415. * @returns a promise that resolves when ready
  63416. */
  63417. whenReadyAsync(): Promise<void>;
  63418. /**
  63419. * Decode Draco compressed mesh data to vertex data.
  63420. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63421. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63422. * @returns A promise that resolves with the decoded vertex data
  63423. */
  63424. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63425. [kind: string]: number;
  63426. }): Promise<VertexData>;
  63427. }
  63428. }
  63429. declare module "babylonjs/Meshes/Compression/index" {
  63430. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63431. }
  63432. declare module "babylonjs/Meshes/csg" {
  63433. import { Nullable } from "babylonjs/types";
  63434. import { Scene } from "babylonjs/scene";
  63435. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63436. import { Mesh } from "babylonjs/Meshes/mesh";
  63437. import { Material } from "babylonjs/Materials/material";
  63438. /**
  63439. * Class for building Constructive Solid Geometry
  63440. */
  63441. export class CSG {
  63442. private polygons;
  63443. /**
  63444. * The world matrix
  63445. */
  63446. matrix: Matrix;
  63447. /**
  63448. * Stores the position
  63449. */
  63450. position: Vector3;
  63451. /**
  63452. * Stores the rotation
  63453. */
  63454. rotation: Vector3;
  63455. /**
  63456. * Stores the rotation quaternion
  63457. */
  63458. rotationQuaternion: Nullable<Quaternion>;
  63459. /**
  63460. * Stores the scaling vector
  63461. */
  63462. scaling: Vector3;
  63463. /**
  63464. * Convert the Mesh to CSG
  63465. * @param mesh The Mesh to convert to CSG
  63466. * @returns A new CSG from the Mesh
  63467. */
  63468. static FromMesh(mesh: Mesh): CSG;
  63469. /**
  63470. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63471. * @param polygons Polygons used to construct a CSG solid
  63472. */
  63473. private static FromPolygons;
  63474. /**
  63475. * Clones, or makes a deep copy, of the CSG
  63476. * @returns A new CSG
  63477. */
  63478. clone(): CSG;
  63479. /**
  63480. * Unions this CSG with another CSG
  63481. * @param csg The CSG to union against this CSG
  63482. * @returns The unioned CSG
  63483. */
  63484. union(csg: CSG): CSG;
  63485. /**
  63486. * Unions this CSG with another CSG in place
  63487. * @param csg The CSG to union against this CSG
  63488. */
  63489. unionInPlace(csg: CSG): void;
  63490. /**
  63491. * Subtracts this CSG with another CSG
  63492. * @param csg The CSG to subtract against this CSG
  63493. * @returns A new CSG
  63494. */
  63495. subtract(csg: CSG): CSG;
  63496. /**
  63497. * Subtracts this CSG with another CSG in place
  63498. * @param csg The CSG to subtact against this CSG
  63499. */
  63500. subtractInPlace(csg: CSG): void;
  63501. /**
  63502. * Intersect this CSG with another CSG
  63503. * @param csg The CSG to intersect against this CSG
  63504. * @returns A new CSG
  63505. */
  63506. intersect(csg: CSG): CSG;
  63507. /**
  63508. * Intersects this CSG with another CSG in place
  63509. * @param csg The CSG to intersect against this CSG
  63510. */
  63511. intersectInPlace(csg: CSG): void;
  63512. /**
  63513. * Return a new CSG solid with solid and empty space switched. This solid is
  63514. * not modified.
  63515. * @returns A new CSG solid with solid and empty space switched
  63516. */
  63517. inverse(): CSG;
  63518. /**
  63519. * Inverses the CSG in place
  63520. */
  63521. inverseInPlace(): void;
  63522. /**
  63523. * This is used to keep meshes transformations so they can be restored
  63524. * when we build back a Babylon Mesh
  63525. * NB : All CSG operations are performed in world coordinates
  63526. * @param csg The CSG to copy the transform attributes from
  63527. * @returns This CSG
  63528. */
  63529. copyTransformAttributes(csg: CSG): CSG;
  63530. /**
  63531. * Build Raw mesh from CSG
  63532. * Coordinates here are in world space
  63533. * @param name The name of the mesh geometry
  63534. * @param scene The Scene
  63535. * @param keepSubMeshes Specifies if the submeshes should be kept
  63536. * @returns A new Mesh
  63537. */
  63538. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63539. /**
  63540. * Build Mesh from CSG taking material and transforms into account
  63541. * @param name The name of the Mesh
  63542. * @param material The material of the Mesh
  63543. * @param scene The Scene
  63544. * @param keepSubMeshes Specifies if submeshes should be kept
  63545. * @returns The new Mesh
  63546. */
  63547. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63548. }
  63549. }
  63550. declare module "babylonjs/Meshes/trailMesh" {
  63551. import { Mesh } from "babylonjs/Meshes/mesh";
  63552. import { Scene } from "babylonjs/scene";
  63553. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63554. /**
  63555. * Class used to create a trail following a mesh
  63556. */
  63557. export class TrailMesh extends Mesh {
  63558. private _generator;
  63559. private _autoStart;
  63560. private _running;
  63561. private _diameter;
  63562. private _length;
  63563. private _sectionPolygonPointsCount;
  63564. private _sectionVectors;
  63565. private _sectionNormalVectors;
  63566. private _beforeRenderObserver;
  63567. /**
  63568. * @constructor
  63569. * @param name The value used by scene.getMeshByName() to do a lookup.
  63570. * @param generator The mesh or transform node to generate a trail.
  63571. * @param scene The scene to add this mesh to.
  63572. * @param diameter Diameter of trailing mesh. Default is 1.
  63573. * @param length Length of trailing mesh. Default is 60.
  63574. * @param autoStart Automatically start trailing mesh. Default true.
  63575. */
  63576. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63577. /**
  63578. * "TrailMesh"
  63579. * @returns "TrailMesh"
  63580. */
  63581. getClassName(): string;
  63582. private _createMesh;
  63583. /**
  63584. * Start trailing mesh.
  63585. */
  63586. start(): void;
  63587. /**
  63588. * Stop trailing mesh.
  63589. */
  63590. stop(): void;
  63591. /**
  63592. * Update trailing mesh geometry.
  63593. */
  63594. update(): void;
  63595. /**
  63596. * Returns a new TrailMesh object.
  63597. * @param name is a string, the name given to the new mesh
  63598. * @param newGenerator use new generator object for cloned trail mesh
  63599. * @returns a new mesh
  63600. */
  63601. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63602. /**
  63603. * Serializes this trail mesh
  63604. * @param serializationObject object to write serialization to
  63605. */
  63606. serialize(serializationObject: any): void;
  63607. /**
  63608. * Parses a serialized trail mesh
  63609. * @param parsedMesh the serialized mesh
  63610. * @param scene the scene to create the trail mesh in
  63611. * @returns the created trail mesh
  63612. */
  63613. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63614. }
  63615. }
  63616. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63617. import { Nullable } from "babylonjs/types";
  63618. import { Scene } from "babylonjs/scene";
  63619. import { Vector4 } from "babylonjs/Maths/math.vector";
  63620. import { Color4 } from "babylonjs/Maths/math.color";
  63621. import { Mesh } from "babylonjs/Meshes/mesh";
  63622. /**
  63623. * Class containing static functions to help procedurally build meshes
  63624. */
  63625. export class TiledBoxBuilder {
  63626. /**
  63627. * Creates a box mesh
  63628. * 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)
  63629. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63633. * @param name defines the name of the mesh
  63634. * @param options defines the options used to create the mesh
  63635. * @param scene defines the hosting scene
  63636. * @returns the box mesh
  63637. */
  63638. static CreateTiledBox(name: string, options: {
  63639. pattern?: number;
  63640. width?: number;
  63641. height?: number;
  63642. depth?: number;
  63643. tileSize?: number;
  63644. tileWidth?: number;
  63645. tileHeight?: number;
  63646. alignHorizontal?: number;
  63647. alignVertical?: number;
  63648. faceUV?: Vector4[];
  63649. faceColors?: Color4[];
  63650. sideOrientation?: number;
  63651. updatable?: boolean;
  63652. }, scene?: Nullable<Scene>): Mesh;
  63653. }
  63654. }
  63655. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63656. import { Vector4 } from "babylonjs/Maths/math.vector";
  63657. import { Mesh } from "babylonjs/Meshes/mesh";
  63658. /**
  63659. * Class containing static functions to help procedurally build meshes
  63660. */
  63661. export class TorusKnotBuilder {
  63662. /**
  63663. * Creates a torus knot mesh
  63664. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63665. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63666. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63667. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63671. * @param name defines the name of the mesh
  63672. * @param options defines the options used to create the mesh
  63673. * @param scene defines the hosting scene
  63674. * @returns the torus knot mesh
  63675. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63676. */
  63677. static CreateTorusKnot(name: string, options: {
  63678. radius?: number;
  63679. tube?: number;
  63680. radialSegments?: number;
  63681. tubularSegments?: number;
  63682. p?: number;
  63683. q?: number;
  63684. updatable?: boolean;
  63685. sideOrientation?: number;
  63686. frontUVs?: Vector4;
  63687. backUVs?: Vector4;
  63688. }, scene: any): Mesh;
  63689. }
  63690. }
  63691. declare module "babylonjs/Meshes/polygonMesh" {
  63692. import { Scene } from "babylonjs/scene";
  63693. import { Vector2 } from "babylonjs/Maths/math.vector";
  63694. import { Mesh } from "babylonjs/Meshes/mesh";
  63695. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63696. import { Path2 } from "babylonjs/Maths/math.path";
  63697. /**
  63698. * Polygon
  63699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63700. */
  63701. export class Polygon {
  63702. /**
  63703. * Creates a rectangle
  63704. * @param xmin bottom X coord
  63705. * @param ymin bottom Y coord
  63706. * @param xmax top X coord
  63707. * @param ymax top Y coord
  63708. * @returns points that make the resulting rectation
  63709. */
  63710. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63711. /**
  63712. * Creates a circle
  63713. * @param radius radius of circle
  63714. * @param cx scale in x
  63715. * @param cy scale in y
  63716. * @param numberOfSides number of sides that make up the circle
  63717. * @returns points that make the resulting circle
  63718. */
  63719. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63720. /**
  63721. * Creates a polygon from input string
  63722. * @param input Input polygon data
  63723. * @returns the parsed points
  63724. */
  63725. static Parse(input: string): Vector2[];
  63726. /**
  63727. * Starts building a polygon from x and y coordinates
  63728. * @param x x coordinate
  63729. * @param y y coordinate
  63730. * @returns the started path2
  63731. */
  63732. static StartingAt(x: number, y: number): Path2;
  63733. }
  63734. /**
  63735. * Builds a polygon
  63736. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63737. */
  63738. export class PolygonMeshBuilder {
  63739. private _points;
  63740. private _outlinepoints;
  63741. private _holes;
  63742. private _name;
  63743. private _scene;
  63744. private _epoints;
  63745. private _eholes;
  63746. private _addToepoint;
  63747. /**
  63748. * Babylon reference to the earcut plugin.
  63749. */
  63750. bjsEarcut: any;
  63751. /**
  63752. * Creates a PolygonMeshBuilder
  63753. * @param name name of the builder
  63754. * @param contours Path of the polygon
  63755. * @param scene scene to add to when creating the mesh
  63756. * @param earcutInjection can be used to inject your own earcut reference
  63757. */
  63758. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63759. /**
  63760. * Adds a whole within the polygon
  63761. * @param hole Array of points defining the hole
  63762. * @returns this
  63763. */
  63764. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63765. /**
  63766. * Creates the polygon
  63767. * @param updatable If the mesh should be updatable
  63768. * @param depth The depth of the mesh created
  63769. * @returns the created mesh
  63770. */
  63771. build(updatable?: boolean, depth?: number): Mesh;
  63772. /**
  63773. * Creates the polygon
  63774. * @param depth The depth of the mesh created
  63775. * @returns the created VertexData
  63776. */
  63777. buildVertexData(depth?: number): VertexData;
  63778. /**
  63779. * Adds a side to the polygon
  63780. * @param positions points that make the polygon
  63781. * @param normals normals of the polygon
  63782. * @param uvs uvs of the polygon
  63783. * @param indices indices of the polygon
  63784. * @param bounds bounds of the polygon
  63785. * @param points points of the polygon
  63786. * @param depth depth of the polygon
  63787. * @param flip flip of the polygon
  63788. */
  63789. private addSide;
  63790. }
  63791. }
  63792. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63793. import { Scene } from "babylonjs/scene";
  63794. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63795. import { Color4 } from "babylonjs/Maths/math.color";
  63796. import { Mesh } from "babylonjs/Meshes/mesh";
  63797. import { Nullable } from "babylonjs/types";
  63798. /**
  63799. * Class containing static functions to help procedurally build meshes
  63800. */
  63801. export class PolygonBuilder {
  63802. /**
  63803. * Creates a polygon mesh
  63804. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63805. * * 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
  63806. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63809. * * Remember you can only change the shape positions, not their number when updating a polygon
  63810. * @param name defines the name of the mesh
  63811. * @param options defines the options used to create the mesh
  63812. * @param scene defines the hosting scene
  63813. * @param earcutInjection can be used to inject your own earcut reference
  63814. * @returns the polygon mesh
  63815. */
  63816. static CreatePolygon(name: string, options: {
  63817. shape: Vector3[];
  63818. holes?: Vector3[][];
  63819. depth?: number;
  63820. faceUV?: Vector4[];
  63821. faceColors?: Color4[];
  63822. updatable?: boolean;
  63823. sideOrientation?: number;
  63824. frontUVs?: Vector4;
  63825. backUVs?: Vector4;
  63826. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63827. /**
  63828. * Creates an extruded polygon mesh, with depth in the Y direction.
  63829. * * 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)
  63830. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63831. * @param name defines the name of the mesh
  63832. * @param options defines the options used to create the mesh
  63833. * @param scene defines the hosting scene
  63834. * @param earcutInjection can be used to inject your own earcut reference
  63835. * @returns the polygon mesh
  63836. */
  63837. static ExtrudePolygon(name: string, options: {
  63838. shape: Vector3[];
  63839. holes?: Vector3[][];
  63840. depth?: number;
  63841. faceUV?: Vector4[];
  63842. faceColors?: Color4[];
  63843. updatable?: boolean;
  63844. sideOrientation?: number;
  63845. frontUVs?: Vector4;
  63846. backUVs?: Vector4;
  63847. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63848. }
  63849. }
  63850. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63851. import { Scene } from "babylonjs/scene";
  63852. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63853. import { Mesh } from "babylonjs/Meshes/mesh";
  63854. import { Nullable } from "babylonjs/types";
  63855. /**
  63856. * Class containing static functions to help procedurally build meshes
  63857. */
  63858. export class LatheBuilder {
  63859. /**
  63860. * Creates lathe mesh.
  63861. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63862. * * 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
  63863. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63864. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63865. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63866. * * 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
  63867. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63868. * * 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
  63869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63873. * @param name defines the name of the mesh
  63874. * @param options defines the options used to create the mesh
  63875. * @param scene defines the hosting scene
  63876. * @returns the lathe mesh
  63877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63878. */
  63879. static CreateLathe(name: string, options: {
  63880. shape: Vector3[];
  63881. radius?: number;
  63882. tessellation?: number;
  63883. clip?: number;
  63884. arc?: number;
  63885. closed?: boolean;
  63886. updatable?: boolean;
  63887. sideOrientation?: number;
  63888. frontUVs?: Vector4;
  63889. backUVs?: Vector4;
  63890. cap?: number;
  63891. invertUV?: boolean;
  63892. }, scene?: Nullable<Scene>): Mesh;
  63893. }
  63894. }
  63895. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63896. import { Nullable } from "babylonjs/types";
  63897. import { Scene } from "babylonjs/scene";
  63898. import { Vector4 } from "babylonjs/Maths/math.vector";
  63899. import { Mesh } from "babylonjs/Meshes/mesh";
  63900. /**
  63901. * Class containing static functions to help procedurally build meshes
  63902. */
  63903. export class TiledPlaneBuilder {
  63904. /**
  63905. * Creates a tiled plane mesh
  63906. * * The parameter `pattern` will, depending on value, do nothing or
  63907. * * * flip (reflect about central vertical) alternate tiles across and up
  63908. * * * flip every tile on alternate rows
  63909. * * * rotate (180 degs) alternate tiles across and up
  63910. * * * rotate every tile on alternate rows
  63911. * * * flip and rotate alternate tiles across and up
  63912. * * * flip and rotate every tile on alternate rows
  63913. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63914. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63917. * * 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)
  63918. * * 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)
  63919. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63920. * @param name defines the name of the mesh
  63921. * @param options defines the options used to create the mesh
  63922. * @param scene defines the hosting scene
  63923. * @returns the box mesh
  63924. */
  63925. static CreateTiledPlane(name: string, options: {
  63926. pattern?: number;
  63927. tileSize?: number;
  63928. tileWidth?: number;
  63929. tileHeight?: number;
  63930. size?: number;
  63931. width?: number;
  63932. height?: number;
  63933. alignHorizontal?: number;
  63934. alignVertical?: number;
  63935. sideOrientation?: number;
  63936. frontUVs?: Vector4;
  63937. backUVs?: Vector4;
  63938. updatable?: boolean;
  63939. }, scene?: Nullable<Scene>): Mesh;
  63940. }
  63941. }
  63942. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63943. import { Nullable } from "babylonjs/types";
  63944. import { Scene } from "babylonjs/scene";
  63945. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63946. import { Mesh } from "babylonjs/Meshes/mesh";
  63947. /**
  63948. * Class containing static functions to help procedurally build meshes
  63949. */
  63950. export class TubeBuilder {
  63951. /**
  63952. * Creates a tube mesh.
  63953. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63954. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63955. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63956. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63957. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63958. * * 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)
  63959. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63960. * * 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
  63961. * * 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
  63962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63964. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63966. * @param name defines the name of the mesh
  63967. * @param options defines the options used to create the mesh
  63968. * @param scene defines the hosting scene
  63969. * @returns the tube mesh
  63970. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63971. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63972. */
  63973. static CreateTube(name: string, options: {
  63974. path: Vector3[];
  63975. radius?: number;
  63976. tessellation?: number;
  63977. radiusFunction?: {
  63978. (i: number, distance: number): number;
  63979. };
  63980. cap?: number;
  63981. arc?: number;
  63982. updatable?: boolean;
  63983. sideOrientation?: number;
  63984. frontUVs?: Vector4;
  63985. backUVs?: Vector4;
  63986. instance?: Mesh;
  63987. invertUV?: boolean;
  63988. }, scene?: Nullable<Scene>): Mesh;
  63989. }
  63990. }
  63991. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63992. import { Scene } from "babylonjs/scene";
  63993. import { Vector4 } from "babylonjs/Maths/math.vector";
  63994. import { Mesh } from "babylonjs/Meshes/mesh";
  63995. import { Nullable } from "babylonjs/types";
  63996. /**
  63997. * Class containing static functions to help procedurally build meshes
  63998. */
  63999. export class IcoSphereBuilder {
  64000. /**
  64001. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64002. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64003. * * 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`)
  64004. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64005. * * 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
  64006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64009. * @param name defines the name of the mesh
  64010. * @param options defines the options used to create the mesh
  64011. * @param scene defines the hosting scene
  64012. * @returns the icosahedron mesh
  64013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64014. */
  64015. static CreateIcoSphere(name: string, options: {
  64016. radius?: number;
  64017. radiusX?: number;
  64018. radiusY?: number;
  64019. radiusZ?: number;
  64020. flat?: boolean;
  64021. subdivisions?: number;
  64022. sideOrientation?: number;
  64023. frontUVs?: Vector4;
  64024. backUVs?: Vector4;
  64025. updatable?: boolean;
  64026. }, scene?: Nullable<Scene>): Mesh;
  64027. }
  64028. }
  64029. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64030. import { Vector3 } from "babylonjs/Maths/math.vector";
  64031. import { Mesh } from "babylonjs/Meshes/mesh";
  64032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64033. /**
  64034. * Class containing static functions to help procedurally build meshes
  64035. */
  64036. export class DecalBuilder {
  64037. /**
  64038. * Creates a decal mesh.
  64039. * 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
  64040. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64041. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64042. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64043. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64044. * @param name defines the name of the mesh
  64045. * @param sourceMesh defines the mesh where the decal must be applied
  64046. * @param options defines the options used to create the mesh
  64047. * @param scene defines the hosting scene
  64048. * @returns the decal mesh
  64049. * @see https://doc.babylonjs.com/how_to/decals
  64050. */
  64051. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64052. position?: Vector3;
  64053. normal?: Vector3;
  64054. size?: Vector3;
  64055. angle?: number;
  64056. }): Mesh;
  64057. }
  64058. }
  64059. declare module "babylonjs/Meshes/meshBuilder" {
  64060. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64061. import { Nullable } from "babylonjs/types";
  64062. import { Scene } from "babylonjs/scene";
  64063. import { Mesh } from "babylonjs/Meshes/mesh";
  64064. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64065. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64067. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64068. import { Plane } from "babylonjs/Maths/math.plane";
  64069. /**
  64070. * Class containing static functions to help procedurally build meshes
  64071. */
  64072. export class MeshBuilder {
  64073. /**
  64074. * Creates a box mesh
  64075. * * The parameter `size` sets the size (float) of each box side (default 1)
  64076. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64077. * * 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)
  64078. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64082. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64083. * @param name defines the name of the mesh
  64084. * @param options defines the options used to create the mesh
  64085. * @param scene defines the hosting scene
  64086. * @returns the box mesh
  64087. */
  64088. static CreateBox(name: string, options: {
  64089. size?: number;
  64090. width?: number;
  64091. height?: number;
  64092. depth?: number;
  64093. faceUV?: Vector4[];
  64094. faceColors?: Color4[];
  64095. sideOrientation?: number;
  64096. frontUVs?: Vector4;
  64097. backUVs?: Vector4;
  64098. updatable?: boolean;
  64099. }, scene?: Nullable<Scene>): Mesh;
  64100. /**
  64101. * Creates a tiled box mesh
  64102. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64104. * @param name defines the name of the mesh
  64105. * @param options defines the options used to create the mesh
  64106. * @param scene defines the hosting scene
  64107. * @returns the tiled box mesh
  64108. */
  64109. static CreateTiledBox(name: string, options: {
  64110. pattern?: number;
  64111. size?: number;
  64112. width?: number;
  64113. height?: number;
  64114. depth: number;
  64115. tileSize?: number;
  64116. tileWidth?: number;
  64117. tileHeight?: number;
  64118. faceUV?: Vector4[];
  64119. faceColors?: Color4[];
  64120. alignHorizontal?: number;
  64121. alignVertical?: number;
  64122. sideOrientation?: number;
  64123. updatable?: boolean;
  64124. }, scene?: Nullable<Scene>): Mesh;
  64125. /**
  64126. * Creates a sphere mesh
  64127. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64128. * * 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`)
  64129. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64130. * * 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
  64131. * * 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)
  64132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64135. * @param name defines the name of the mesh
  64136. * @param options defines the options used to create the mesh
  64137. * @param scene defines the hosting scene
  64138. * @returns the sphere mesh
  64139. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64140. */
  64141. static CreateSphere(name: string, options: {
  64142. segments?: number;
  64143. diameter?: number;
  64144. diameterX?: number;
  64145. diameterY?: number;
  64146. diameterZ?: number;
  64147. arc?: number;
  64148. slice?: number;
  64149. sideOrientation?: number;
  64150. frontUVs?: Vector4;
  64151. backUVs?: Vector4;
  64152. updatable?: boolean;
  64153. }, scene?: Nullable<Scene>): Mesh;
  64154. /**
  64155. * Creates a plane polygonal mesh. By default, this is a disc
  64156. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64157. * * 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
  64158. * * 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
  64159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64162. * @param name defines the name of the mesh
  64163. * @param options defines the options used to create the mesh
  64164. * @param scene defines the hosting scene
  64165. * @returns the plane polygonal mesh
  64166. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64167. */
  64168. static CreateDisc(name: string, options: {
  64169. radius?: number;
  64170. tessellation?: number;
  64171. arc?: number;
  64172. updatable?: boolean;
  64173. sideOrientation?: number;
  64174. frontUVs?: Vector4;
  64175. backUVs?: Vector4;
  64176. }, scene?: Nullable<Scene>): Mesh;
  64177. /**
  64178. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64179. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64180. * * 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`)
  64181. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64182. * * 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
  64183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64186. * @param name defines the name of the mesh
  64187. * @param options defines the options used to create the mesh
  64188. * @param scene defines the hosting scene
  64189. * @returns the icosahedron mesh
  64190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64191. */
  64192. static CreateIcoSphere(name: string, options: {
  64193. radius?: number;
  64194. radiusX?: number;
  64195. radiusY?: number;
  64196. radiusZ?: number;
  64197. flat?: boolean;
  64198. subdivisions?: number;
  64199. sideOrientation?: number;
  64200. frontUVs?: Vector4;
  64201. backUVs?: Vector4;
  64202. updatable?: boolean;
  64203. }, scene?: Nullable<Scene>): Mesh;
  64204. /**
  64205. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64206. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64207. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64208. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64209. * * 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
  64210. * * 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
  64211. * * 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
  64212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64215. * * 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
  64216. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64217. * * 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
  64218. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64220. * @param name defines the name of the mesh
  64221. * @param options defines the options used to create the mesh
  64222. * @param scene defines the hosting scene
  64223. * @returns the ribbon mesh
  64224. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64225. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64226. */
  64227. static CreateRibbon(name: string, options: {
  64228. pathArray: Vector3[][];
  64229. closeArray?: boolean;
  64230. closePath?: boolean;
  64231. offset?: number;
  64232. updatable?: boolean;
  64233. sideOrientation?: number;
  64234. frontUVs?: Vector4;
  64235. backUVs?: Vector4;
  64236. instance?: Mesh;
  64237. invertUV?: boolean;
  64238. uvs?: Vector2[];
  64239. colors?: Color4[];
  64240. }, scene?: Nullable<Scene>): Mesh;
  64241. /**
  64242. * Creates a cylinder or a cone mesh
  64243. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64244. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64245. * * 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.
  64246. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64247. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64248. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64249. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64250. * * 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).
  64251. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64252. * * 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).
  64253. * * 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
  64254. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64255. * * 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
  64256. * * 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.
  64257. * * If `enclose` is false, a ring surface is one element.
  64258. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64259. * * 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
  64260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64263. * @param name defines the name of the mesh
  64264. * @param options defines the options used to create the mesh
  64265. * @param scene defines the hosting scene
  64266. * @returns the cylinder mesh
  64267. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64268. */
  64269. static CreateCylinder(name: string, options: {
  64270. height?: number;
  64271. diameterTop?: number;
  64272. diameterBottom?: number;
  64273. diameter?: number;
  64274. tessellation?: number;
  64275. subdivisions?: number;
  64276. arc?: number;
  64277. faceColors?: Color4[];
  64278. faceUV?: Vector4[];
  64279. updatable?: boolean;
  64280. hasRings?: boolean;
  64281. enclose?: boolean;
  64282. cap?: number;
  64283. sideOrientation?: number;
  64284. frontUVs?: Vector4;
  64285. backUVs?: Vector4;
  64286. }, scene?: Nullable<Scene>): Mesh;
  64287. /**
  64288. * Creates a torus mesh
  64289. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64290. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64291. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64295. * @param name defines the name of the mesh
  64296. * @param options defines the options used to create the mesh
  64297. * @param scene defines the hosting scene
  64298. * @returns the torus mesh
  64299. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64300. */
  64301. static CreateTorus(name: string, options: {
  64302. diameter?: number;
  64303. thickness?: number;
  64304. tessellation?: number;
  64305. updatable?: boolean;
  64306. sideOrientation?: number;
  64307. frontUVs?: Vector4;
  64308. backUVs?: Vector4;
  64309. }, scene?: Nullable<Scene>): Mesh;
  64310. /**
  64311. * Creates a torus knot mesh
  64312. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64313. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64314. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64315. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64319. * @param name defines the name of the mesh
  64320. * @param options defines the options used to create the mesh
  64321. * @param scene defines the hosting scene
  64322. * @returns the torus knot mesh
  64323. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64324. */
  64325. static CreateTorusKnot(name: string, options: {
  64326. radius?: number;
  64327. tube?: number;
  64328. radialSegments?: number;
  64329. tubularSegments?: number;
  64330. p?: number;
  64331. q?: number;
  64332. updatable?: boolean;
  64333. sideOrientation?: number;
  64334. frontUVs?: Vector4;
  64335. backUVs?: Vector4;
  64336. }, scene?: Nullable<Scene>): Mesh;
  64337. /**
  64338. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64339. * * 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
  64340. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64341. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64342. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64343. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64344. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64345. * * 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
  64346. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64349. * @param name defines the name of the new line system
  64350. * @param options defines the options used to create the line system
  64351. * @param scene defines the hosting scene
  64352. * @returns a new line system mesh
  64353. */
  64354. static CreateLineSystem(name: string, options: {
  64355. lines: Vector3[][];
  64356. updatable?: boolean;
  64357. instance?: Nullable<LinesMesh>;
  64358. colors?: Nullable<Color4[][]>;
  64359. useVertexAlpha?: boolean;
  64360. }, scene: Nullable<Scene>): LinesMesh;
  64361. /**
  64362. * Creates a line mesh
  64363. * 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
  64364. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64365. * * The parameter `points` is an array successive Vector3
  64366. * * 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
  64367. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64368. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64369. * * When updating an instance, remember that only point positions can change, not the number of points
  64370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64372. * @param name defines the name of the new line system
  64373. * @param options defines the options used to create the line system
  64374. * @param scene defines the hosting scene
  64375. * @returns a new line mesh
  64376. */
  64377. static CreateLines(name: string, options: {
  64378. points: Vector3[];
  64379. updatable?: boolean;
  64380. instance?: Nullable<LinesMesh>;
  64381. colors?: Color4[];
  64382. useVertexAlpha?: boolean;
  64383. }, scene?: Nullable<Scene>): LinesMesh;
  64384. /**
  64385. * Creates a dashed line mesh
  64386. * * 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
  64387. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64388. * * The parameter `points` is an array successive Vector3
  64389. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64390. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64391. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64392. * * 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
  64393. * * When updating an instance, remember that only point positions can change, not the number of points
  64394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64395. * @param name defines the name of the mesh
  64396. * @param options defines the options used to create the mesh
  64397. * @param scene defines the hosting scene
  64398. * @returns the dashed line mesh
  64399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64400. */
  64401. static CreateDashedLines(name: string, options: {
  64402. points: Vector3[];
  64403. dashSize?: number;
  64404. gapSize?: number;
  64405. dashNb?: number;
  64406. updatable?: boolean;
  64407. instance?: LinesMesh;
  64408. }, scene?: Nullable<Scene>): LinesMesh;
  64409. /**
  64410. * 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.
  64411. * * 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.
  64412. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64413. * * 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.
  64414. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64415. * * 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
  64416. * * 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
  64417. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64422. * @param name defines the name of the mesh
  64423. * @param options defines the options used to create the mesh
  64424. * @param scene defines the hosting scene
  64425. * @returns the extruded shape mesh
  64426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64428. */
  64429. static ExtrudeShape(name: string, options: {
  64430. shape: Vector3[];
  64431. path: Vector3[];
  64432. scale?: number;
  64433. rotation?: number;
  64434. cap?: number;
  64435. updatable?: boolean;
  64436. sideOrientation?: number;
  64437. frontUVs?: Vector4;
  64438. backUVs?: Vector4;
  64439. instance?: Mesh;
  64440. invertUV?: boolean;
  64441. }, scene?: Nullable<Scene>): Mesh;
  64442. /**
  64443. * Creates an custom extruded shape mesh.
  64444. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64445. * * 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.
  64446. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64447. * * 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
  64448. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64449. * * 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
  64450. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64451. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64452. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64453. * * 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
  64454. * * 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
  64455. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64460. * @param name defines the name of the mesh
  64461. * @param options defines the options used to create the mesh
  64462. * @param scene defines the hosting scene
  64463. * @returns the custom extruded shape mesh
  64464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64465. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64467. */
  64468. static ExtrudeShapeCustom(name: string, options: {
  64469. shape: Vector3[];
  64470. path: Vector3[];
  64471. scaleFunction?: any;
  64472. rotationFunction?: any;
  64473. ribbonCloseArray?: boolean;
  64474. ribbonClosePath?: boolean;
  64475. cap?: number;
  64476. updatable?: boolean;
  64477. sideOrientation?: number;
  64478. frontUVs?: Vector4;
  64479. backUVs?: Vector4;
  64480. instance?: Mesh;
  64481. invertUV?: boolean;
  64482. }, scene?: Nullable<Scene>): Mesh;
  64483. /**
  64484. * Creates lathe mesh.
  64485. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64486. * * 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
  64487. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64488. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64489. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64490. * * 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
  64491. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64492. * * 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
  64493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64497. * @param name defines the name of the mesh
  64498. * @param options defines the options used to create the mesh
  64499. * @param scene defines the hosting scene
  64500. * @returns the lathe mesh
  64501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64502. */
  64503. static CreateLathe(name: string, options: {
  64504. shape: Vector3[];
  64505. radius?: number;
  64506. tessellation?: number;
  64507. clip?: number;
  64508. arc?: number;
  64509. closed?: boolean;
  64510. updatable?: boolean;
  64511. sideOrientation?: number;
  64512. frontUVs?: Vector4;
  64513. backUVs?: Vector4;
  64514. cap?: number;
  64515. invertUV?: boolean;
  64516. }, scene?: Nullable<Scene>): Mesh;
  64517. /**
  64518. * Creates a tiled plane mesh
  64519. * * You can set a limited pattern arrangement with the tiles
  64520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64521. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64523. * @param name defines the name of the mesh
  64524. * @param options defines the options used to create the mesh
  64525. * @param scene defines the hosting scene
  64526. * @returns the plane mesh
  64527. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64528. */
  64529. static CreateTiledPlane(name: string, options: {
  64530. pattern?: number;
  64531. tileSize?: number;
  64532. tileWidth?: number;
  64533. tileHeight?: number;
  64534. size?: number;
  64535. width?: number;
  64536. height?: number;
  64537. alignHorizontal?: number;
  64538. alignVertical?: number;
  64539. sideOrientation?: number;
  64540. frontUVs?: Vector4;
  64541. backUVs?: Vector4;
  64542. updatable?: boolean;
  64543. }, scene?: Nullable<Scene>): Mesh;
  64544. /**
  64545. * Creates a plane mesh
  64546. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64547. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64548. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64552. * @param name defines the name of the mesh
  64553. * @param options defines the options used to create the mesh
  64554. * @param scene defines the hosting scene
  64555. * @returns the plane mesh
  64556. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64557. */
  64558. static CreatePlane(name: string, options: {
  64559. size?: number;
  64560. width?: number;
  64561. height?: number;
  64562. sideOrientation?: number;
  64563. frontUVs?: Vector4;
  64564. backUVs?: Vector4;
  64565. updatable?: boolean;
  64566. sourcePlane?: Plane;
  64567. }, scene?: Nullable<Scene>): Mesh;
  64568. /**
  64569. * Creates a ground mesh
  64570. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64571. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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. * @param name defines the name of the mesh
  64574. * @param options defines the options used to create the mesh
  64575. * @param scene defines the hosting scene
  64576. * @returns the ground mesh
  64577. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64578. */
  64579. static CreateGround(name: string, options: {
  64580. width?: number;
  64581. height?: number;
  64582. subdivisions?: number;
  64583. subdivisionsX?: number;
  64584. subdivisionsY?: number;
  64585. updatable?: boolean;
  64586. }, scene?: Nullable<Scene>): Mesh;
  64587. /**
  64588. * Creates a tiled ground mesh
  64589. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64590. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64591. * * 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
  64592. * * 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
  64593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64594. * @param name defines the name of the mesh
  64595. * @param options defines the options used to create the mesh
  64596. * @param scene defines the hosting scene
  64597. * @returns the tiled ground mesh
  64598. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64599. */
  64600. static CreateTiledGround(name: string, options: {
  64601. xmin: number;
  64602. zmin: number;
  64603. xmax: number;
  64604. zmax: number;
  64605. subdivisions?: {
  64606. w: number;
  64607. h: number;
  64608. };
  64609. precision?: {
  64610. w: number;
  64611. h: number;
  64612. };
  64613. updatable?: boolean;
  64614. }, scene?: Nullable<Scene>): Mesh;
  64615. /**
  64616. * Creates a ground mesh from a height map
  64617. * * The parameter `url` sets the URL of the height map image resource.
  64618. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64619. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64620. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64621. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64622. * * 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.
  64623. * * 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).
  64624. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64626. * @param name defines the name of the mesh
  64627. * @param url defines the url to the height map
  64628. * @param options defines the options used to create the mesh
  64629. * @param scene defines the hosting scene
  64630. * @returns the ground mesh
  64631. * @see https://doc.babylonjs.com/babylon101/height_map
  64632. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64633. */
  64634. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64635. width?: number;
  64636. height?: number;
  64637. subdivisions?: number;
  64638. minHeight?: number;
  64639. maxHeight?: number;
  64640. colorFilter?: Color3;
  64641. alphaFilter?: number;
  64642. updatable?: boolean;
  64643. onReady?: (mesh: GroundMesh) => void;
  64644. }, scene?: Nullable<Scene>): GroundMesh;
  64645. /**
  64646. * Creates a polygon mesh
  64647. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64648. * * 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
  64649. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64652. * * Remember you can only change the shape positions, not their number when updating a polygon
  64653. * @param name defines the name of the mesh
  64654. * @param options defines the options used to create the mesh
  64655. * @param scene defines the hosting scene
  64656. * @param earcutInjection can be used to inject your own earcut reference
  64657. * @returns the polygon mesh
  64658. */
  64659. static CreatePolygon(name: string, options: {
  64660. shape: Vector3[];
  64661. holes?: Vector3[][];
  64662. depth?: number;
  64663. faceUV?: Vector4[];
  64664. faceColors?: Color4[];
  64665. updatable?: boolean;
  64666. sideOrientation?: number;
  64667. frontUVs?: Vector4;
  64668. backUVs?: Vector4;
  64669. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64670. /**
  64671. * Creates an extruded polygon mesh, with depth in the Y direction.
  64672. * * 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)
  64673. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64674. * @param name defines the name of the mesh
  64675. * @param options defines the options used to create the mesh
  64676. * @param scene defines the hosting scene
  64677. * @param earcutInjection can be used to inject your own earcut reference
  64678. * @returns the polygon mesh
  64679. */
  64680. static ExtrudePolygon(name: string, options: {
  64681. shape: Vector3[];
  64682. holes?: Vector3[][];
  64683. depth?: number;
  64684. faceUV?: Vector4[];
  64685. faceColors?: Color4[];
  64686. updatable?: boolean;
  64687. sideOrientation?: number;
  64688. frontUVs?: Vector4;
  64689. backUVs?: Vector4;
  64690. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64691. /**
  64692. * Creates a tube mesh.
  64693. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64694. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64695. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64696. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64697. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64698. * * 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)
  64699. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64700. * * 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
  64701. * * 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
  64702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64704. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64706. * @param name defines the name of the mesh
  64707. * @param options defines the options used to create the mesh
  64708. * @param scene defines the hosting scene
  64709. * @returns the tube mesh
  64710. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64711. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64712. */
  64713. static CreateTube(name: string, options: {
  64714. path: Vector3[];
  64715. radius?: number;
  64716. tessellation?: number;
  64717. radiusFunction?: {
  64718. (i: number, distance: number): number;
  64719. };
  64720. cap?: number;
  64721. arc?: number;
  64722. updatable?: boolean;
  64723. sideOrientation?: number;
  64724. frontUVs?: Vector4;
  64725. backUVs?: Vector4;
  64726. instance?: Mesh;
  64727. invertUV?: boolean;
  64728. }, scene?: Nullable<Scene>): Mesh;
  64729. /**
  64730. * Creates a polyhedron mesh
  64731. * * 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
  64732. * * The parameter `size` (positive float, default 1) sets the polygon size
  64733. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64734. * * 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`
  64735. * * 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
  64736. * * 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)`)
  64737. * * 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
  64738. * * 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
  64739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64742. * @param name defines the name of the mesh
  64743. * @param options defines the options used to create the mesh
  64744. * @param scene defines the hosting scene
  64745. * @returns the polyhedron mesh
  64746. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64747. */
  64748. static CreatePolyhedron(name: string, options: {
  64749. type?: number;
  64750. size?: number;
  64751. sizeX?: number;
  64752. sizeY?: number;
  64753. sizeZ?: number;
  64754. custom?: any;
  64755. faceUV?: Vector4[];
  64756. faceColors?: Color4[];
  64757. flat?: boolean;
  64758. updatable?: boolean;
  64759. sideOrientation?: number;
  64760. frontUVs?: Vector4;
  64761. backUVs?: Vector4;
  64762. }, scene?: Nullable<Scene>): Mesh;
  64763. /**
  64764. * Creates a decal mesh.
  64765. * 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
  64766. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64767. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64768. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64769. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64770. * @param name defines the name of the mesh
  64771. * @param sourceMesh defines the mesh where the decal must be applied
  64772. * @param options defines the options used to create the mesh
  64773. * @param scene defines the hosting scene
  64774. * @returns the decal mesh
  64775. * @see https://doc.babylonjs.com/how_to/decals
  64776. */
  64777. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64778. position?: Vector3;
  64779. normal?: Vector3;
  64780. size?: Vector3;
  64781. angle?: number;
  64782. }): Mesh;
  64783. }
  64784. }
  64785. declare module "babylonjs/Meshes/meshSimplification" {
  64786. import { Mesh } from "babylonjs/Meshes/mesh";
  64787. /**
  64788. * A simplifier interface for future simplification implementations
  64789. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64790. */
  64791. export interface ISimplifier {
  64792. /**
  64793. * Simplification of a given mesh according to the given settings.
  64794. * Since this requires computation, it is assumed that the function runs async.
  64795. * @param settings The settings of the simplification, including quality and distance
  64796. * @param successCallback A callback that will be called after the mesh was simplified.
  64797. * @param errorCallback in case of an error, this callback will be called. optional.
  64798. */
  64799. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64800. }
  64801. /**
  64802. * Expected simplification settings.
  64803. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64804. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64805. */
  64806. export interface ISimplificationSettings {
  64807. /**
  64808. * Gets or sets the expected quality
  64809. */
  64810. quality: number;
  64811. /**
  64812. * Gets or sets the distance when this optimized version should be used
  64813. */
  64814. distance: number;
  64815. /**
  64816. * Gets an already optimized mesh
  64817. */
  64818. optimizeMesh?: boolean;
  64819. }
  64820. /**
  64821. * Class used to specify simplification options
  64822. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64823. */
  64824. export class SimplificationSettings implements ISimplificationSettings {
  64825. /** expected quality */
  64826. quality: number;
  64827. /** distance when this optimized version should be used */
  64828. distance: number;
  64829. /** already optimized mesh */
  64830. optimizeMesh?: boolean | undefined;
  64831. /**
  64832. * Creates a SimplificationSettings
  64833. * @param quality expected quality
  64834. * @param distance distance when this optimized version should be used
  64835. * @param optimizeMesh already optimized mesh
  64836. */
  64837. constructor(
  64838. /** expected quality */
  64839. quality: number,
  64840. /** distance when this optimized version should be used */
  64841. distance: number,
  64842. /** already optimized mesh */
  64843. optimizeMesh?: boolean | undefined);
  64844. }
  64845. /**
  64846. * Interface used to define a simplification task
  64847. */
  64848. export interface ISimplificationTask {
  64849. /**
  64850. * Array of settings
  64851. */
  64852. settings: Array<ISimplificationSettings>;
  64853. /**
  64854. * Simplification type
  64855. */
  64856. simplificationType: SimplificationType;
  64857. /**
  64858. * Mesh to simplify
  64859. */
  64860. mesh: Mesh;
  64861. /**
  64862. * Callback called on success
  64863. */
  64864. successCallback?: () => void;
  64865. /**
  64866. * Defines if parallel processing can be used
  64867. */
  64868. parallelProcessing: boolean;
  64869. }
  64870. /**
  64871. * Queue used to order the simplification tasks
  64872. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64873. */
  64874. export class SimplificationQueue {
  64875. private _simplificationArray;
  64876. /**
  64877. * Gets a boolean indicating that the process is still running
  64878. */
  64879. running: boolean;
  64880. /**
  64881. * Creates a new queue
  64882. */
  64883. constructor();
  64884. /**
  64885. * Adds a new simplification task
  64886. * @param task defines a task to add
  64887. */
  64888. addTask(task: ISimplificationTask): void;
  64889. /**
  64890. * Execute next task
  64891. */
  64892. executeNext(): void;
  64893. /**
  64894. * Execute a simplification task
  64895. * @param task defines the task to run
  64896. */
  64897. runSimplification(task: ISimplificationTask): void;
  64898. private getSimplifier;
  64899. }
  64900. /**
  64901. * The implemented types of simplification
  64902. * At the moment only Quadratic Error Decimation is implemented
  64903. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64904. */
  64905. export enum SimplificationType {
  64906. /** Quadratic error decimation */
  64907. QUADRATIC = 0
  64908. }
  64909. /**
  64910. * An implementation of the Quadratic Error simplification algorithm.
  64911. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64912. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64913. * @author RaananW
  64914. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64915. */
  64916. export class QuadraticErrorSimplification implements ISimplifier {
  64917. private _mesh;
  64918. private triangles;
  64919. private vertices;
  64920. private references;
  64921. private _reconstructedMesh;
  64922. /** Gets or sets the number pf sync interations */
  64923. syncIterations: number;
  64924. /** Gets or sets the aggressiveness of the simplifier */
  64925. aggressiveness: number;
  64926. /** Gets or sets the number of allowed iterations for decimation */
  64927. decimationIterations: number;
  64928. /** Gets or sets the espilon to use for bounding box computation */
  64929. boundingBoxEpsilon: number;
  64930. /**
  64931. * Creates a new QuadraticErrorSimplification
  64932. * @param _mesh defines the target mesh
  64933. */
  64934. constructor(_mesh: Mesh);
  64935. /**
  64936. * Simplification of a given mesh according to the given settings.
  64937. * Since this requires computation, it is assumed that the function runs async.
  64938. * @param settings The settings of the simplification, including quality and distance
  64939. * @param successCallback A callback that will be called after the mesh was simplified.
  64940. */
  64941. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64942. private runDecimation;
  64943. private initWithMesh;
  64944. private init;
  64945. private reconstructMesh;
  64946. private initDecimatedMesh;
  64947. private isFlipped;
  64948. private updateTriangles;
  64949. private identifyBorder;
  64950. private updateMesh;
  64951. private vertexError;
  64952. private calculateError;
  64953. }
  64954. }
  64955. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64956. import { Scene } from "babylonjs/scene";
  64957. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64958. import { ISceneComponent } from "babylonjs/sceneComponent";
  64959. module "babylonjs/scene" {
  64960. interface Scene {
  64961. /** @hidden (Backing field) */
  64962. _simplificationQueue: SimplificationQueue;
  64963. /**
  64964. * Gets or sets the simplification queue attached to the scene
  64965. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64966. */
  64967. simplificationQueue: SimplificationQueue;
  64968. }
  64969. }
  64970. module "babylonjs/Meshes/mesh" {
  64971. interface Mesh {
  64972. /**
  64973. * Simplify the mesh according to the given array of settings.
  64974. * Function will return immediately and will simplify async
  64975. * @param settings a collection of simplification settings
  64976. * @param parallelProcessing should all levels calculate parallel or one after the other
  64977. * @param simplificationType the type of simplification to run
  64978. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64979. * @returns the current mesh
  64980. */
  64981. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64982. }
  64983. }
  64984. /**
  64985. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64986. * created in a scene
  64987. */
  64988. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64989. /**
  64990. * The component name helpfull to identify the component in the list of scene components.
  64991. */
  64992. readonly name: string;
  64993. /**
  64994. * The scene the component belongs to.
  64995. */
  64996. scene: Scene;
  64997. /**
  64998. * Creates a new instance of the component for the given scene
  64999. * @param scene Defines the scene to register the component in
  65000. */
  65001. constructor(scene: Scene);
  65002. /**
  65003. * Registers the component in a given scene
  65004. */
  65005. register(): void;
  65006. /**
  65007. * Rebuilds the elements related to this component in case of
  65008. * context lost for instance.
  65009. */
  65010. rebuild(): void;
  65011. /**
  65012. * Disposes the component and the associated ressources
  65013. */
  65014. dispose(): void;
  65015. private _beforeCameraUpdate;
  65016. }
  65017. }
  65018. declare module "babylonjs/Meshes/Builders/index" {
  65019. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65020. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65021. export * from "babylonjs/Meshes/Builders/discBuilder";
  65022. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65023. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65024. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65025. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65026. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65027. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65028. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65029. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65030. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65031. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65032. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65033. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65034. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65035. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65036. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65037. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65038. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65039. }
  65040. declare module "babylonjs/Meshes/index" {
  65041. export * from "babylonjs/Meshes/abstractMesh";
  65042. export * from "babylonjs/Meshes/buffer";
  65043. export * from "babylonjs/Meshes/Compression/index";
  65044. export * from "babylonjs/Meshes/csg";
  65045. export * from "babylonjs/Meshes/geometry";
  65046. export * from "babylonjs/Meshes/groundMesh";
  65047. export * from "babylonjs/Meshes/trailMesh";
  65048. export * from "babylonjs/Meshes/instancedMesh";
  65049. export * from "babylonjs/Meshes/linesMesh";
  65050. export * from "babylonjs/Meshes/mesh";
  65051. export * from "babylonjs/Meshes/mesh.vertexData";
  65052. export * from "babylonjs/Meshes/meshBuilder";
  65053. export * from "babylonjs/Meshes/meshSimplification";
  65054. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65055. export * from "babylonjs/Meshes/polygonMesh";
  65056. export * from "babylonjs/Meshes/subMesh";
  65057. export * from "babylonjs/Meshes/meshLODLevel";
  65058. export * from "babylonjs/Meshes/transformNode";
  65059. export * from "babylonjs/Meshes/Builders/index";
  65060. export * from "babylonjs/Meshes/dataBuffer";
  65061. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65062. }
  65063. declare module "babylonjs/Morph/index" {
  65064. export * from "babylonjs/Morph/morphTarget";
  65065. export * from "babylonjs/Morph/morphTargetManager";
  65066. }
  65067. declare module "babylonjs/Navigation/INavigationEngine" {
  65068. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65069. import { Vector3 } from "babylonjs/Maths/math";
  65070. import { Mesh } from "babylonjs/Meshes/mesh";
  65071. import { Scene } from "babylonjs/scene";
  65072. /**
  65073. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65074. */
  65075. export interface INavigationEnginePlugin {
  65076. /**
  65077. * plugin name
  65078. */
  65079. name: string;
  65080. /**
  65081. * Creates a navigation mesh
  65082. * @param meshes array of all the geometry used to compute the navigatio mesh
  65083. * @param parameters bunch of parameters used to filter geometry
  65084. */
  65085. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65086. /**
  65087. * Create a navigation mesh debug mesh
  65088. * @param scene is where the mesh will be added
  65089. * @returns debug display mesh
  65090. */
  65091. createDebugNavMesh(scene: Scene): Mesh;
  65092. /**
  65093. * Get a navigation mesh constrained position, closest to the parameter position
  65094. * @param position world position
  65095. * @returns the closest point to position constrained by the navigation mesh
  65096. */
  65097. getClosestPoint(position: Vector3): Vector3;
  65098. /**
  65099. * Get a navigation mesh constrained position, within a particular radius
  65100. * @param position world position
  65101. * @param maxRadius the maximum distance to the constrained world position
  65102. * @returns the closest point to position constrained by the navigation mesh
  65103. */
  65104. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65105. /**
  65106. * Compute the final position from a segment made of destination-position
  65107. * @param position world position
  65108. * @param destination world position
  65109. * @returns the resulting point along the navmesh
  65110. */
  65111. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65112. /**
  65113. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65114. * @param start world position
  65115. * @param end world position
  65116. * @returns array containing world position composing the path
  65117. */
  65118. computePath(start: Vector3, end: Vector3): Vector3[];
  65119. /**
  65120. * If this plugin is supported
  65121. * @returns true if plugin is supported
  65122. */
  65123. isSupported(): boolean;
  65124. /**
  65125. * Create a new Crowd so you can add agents
  65126. * @param maxAgents the maximum agent count in the crowd
  65127. * @param maxAgentRadius the maximum radius an agent can have
  65128. * @param scene to attach the crowd to
  65129. * @returns the crowd you can add agents to
  65130. */
  65131. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65132. /**
  65133. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65134. * The queries will try to find a solution within those bounds
  65135. * default is (1,1,1)
  65136. * @param extent x,y,z value that define the extent around the queries point of reference
  65137. */
  65138. setDefaultQueryExtent(extent: Vector3): void;
  65139. /**
  65140. * Get the Bounding box extent specified by setDefaultQueryExtent
  65141. * @returns the box extent values
  65142. */
  65143. getDefaultQueryExtent(): Vector3;
  65144. /**
  65145. * Release all resources
  65146. */
  65147. dispose(): void;
  65148. }
  65149. /**
  65150. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65151. */
  65152. export interface ICrowd {
  65153. /**
  65154. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65155. * You can attach anything to that node. The node position is updated in the scene update tick.
  65156. * @param pos world position that will be constrained by the navigation mesh
  65157. * @param parameters agent parameters
  65158. * @param transform hooked to the agent that will be update by the scene
  65159. * @returns agent index
  65160. */
  65161. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65162. /**
  65163. * Returns the agent position in world space
  65164. * @param index agent index returned by addAgent
  65165. * @returns world space position
  65166. */
  65167. getAgentPosition(index: number): Vector3;
  65168. /**
  65169. * Gets the agent velocity in world space
  65170. * @param index agent index returned by addAgent
  65171. * @returns world space velocity
  65172. */
  65173. getAgentVelocity(index: number): Vector3;
  65174. /**
  65175. * remove a particular agent previously created
  65176. * @param index agent index returned by addAgent
  65177. */
  65178. removeAgent(index: number): void;
  65179. /**
  65180. * get the list of all agents attached to this crowd
  65181. * @returns list of agent indices
  65182. */
  65183. getAgents(): number[];
  65184. /**
  65185. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65186. * @param deltaTime in seconds
  65187. */
  65188. update(deltaTime: number): void;
  65189. /**
  65190. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65191. * @param index agent index returned by addAgent
  65192. * @param destination targeted world position
  65193. */
  65194. agentGoto(index: number, destination: Vector3): void;
  65195. /**
  65196. * Teleport the agent to a new position
  65197. * @param index agent index returned by addAgent
  65198. * @param destination targeted world position
  65199. */
  65200. agentTeleport(index: number, destination: Vector3): void;
  65201. /**
  65202. * Update agent parameters
  65203. * @param index agent index returned by addAgent
  65204. * @param parameters agent parameters
  65205. */
  65206. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65207. /**
  65208. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65209. * The queries will try to find a solution within those bounds
  65210. * default is (1,1,1)
  65211. * @param extent x,y,z value that define the extent around the queries point of reference
  65212. */
  65213. setDefaultQueryExtent(extent: Vector3): void;
  65214. /**
  65215. * Get the Bounding box extent specified by setDefaultQueryExtent
  65216. * @returns the box extent values
  65217. */
  65218. getDefaultQueryExtent(): Vector3;
  65219. /**
  65220. * Release all resources
  65221. */
  65222. dispose(): void;
  65223. }
  65224. /**
  65225. * Configures an agent
  65226. */
  65227. export interface IAgentParameters {
  65228. /**
  65229. * Agent radius. [Limit: >= 0]
  65230. */
  65231. radius: number;
  65232. /**
  65233. * Agent height. [Limit: > 0]
  65234. */
  65235. height: number;
  65236. /**
  65237. * Maximum allowed acceleration. [Limit: >= 0]
  65238. */
  65239. maxAcceleration: number;
  65240. /**
  65241. * Maximum allowed speed. [Limit: >= 0]
  65242. */
  65243. maxSpeed: number;
  65244. /**
  65245. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65246. */
  65247. collisionQueryRange: number;
  65248. /**
  65249. * The path visibility optimization range. [Limit: > 0]
  65250. */
  65251. pathOptimizationRange: number;
  65252. /**
  65253. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65254. */
  65255. separationWeight: number;
  65256. }
  65257. /**
  65258. * Configures the navigation mesh creation
  65259. */
  65260. export interface INavMeshParameters {
  65261. /**
  65262. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65263. */
  65264. cs: number;
  65265. /**
  65266. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65267. */
  65268. ch: number;
  65269. /**
  65270. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65271. */
  65272. walkableSlopeAngle: number;
  65273. /**
  65274. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65275. * be considered walkable. [Limit: >= 3] [Units: vx]
  65276. */
  65277. walkableHeight: number;
  65278. /**
  65279. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65280. */
  65281. walkableClimb: number;
  65282. /**
  65283. * The distance to erode/shrink the walkable area of the heightfield away from
  65284. * obstructions. [Limit: >=0] [Units: vx]
  65285. */
  65286. walkableRadius: number;
  65287. /**
  65288. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65289. */
  65290. maxEdgeLen: number;
  65291. /**
  65292. * The maximum distance a simplfied contour's border edges should deviate
  65293. * the original raw contour. [Limit: >=0] [Units: vx]
  65294. */
  65295. maxSimplificationError: number;
  65296. /**
  65297. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65298. */
  65299. minRegionArea: number;
  65300. /**
  65301. * Any regions with a span count smaller than this value will, if possible,
  65302. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65303. */
  65304. mergeRegionArea: number;
  65305. /**
  65306. * The maximum number of vertices allowed for polygons generated during the
  65307. * contour to polygon conversion process. [Limit: >= 3]
  65308. */
  65309. maxVertsPerPoly: number;
  65310. /**
  65311. * Sets the sampling distance to use when generating the detail mesh.
  65312. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65313. */
  65314. detailSampleDist: number;
  65315. /**
  65316. * The maximum distance the detail mesh surface should deviate from heightfield
  65317. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65318. */
  65319. detailSampleMaxError: number;
  65320. }
  65321. }
  65322. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65323. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65324. import { Mesh } from "babylonjs/Meshes/mesh";
  65325. import { Scene } from "babylonjs/scene";
  65326. import { Vector3 } from "babylonjs/Maths/math";
  65327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65328. /**
  65329. * RecastJS navigation plugin
  65330. */
  65331. export class RecastJSPlugin implements INavigationEnginePlugin {
  65332. /**
  65333. * Reference to the Recast library
  65334. */
  65335. bjsRECAST: any;
  65336. /**
  65337. * plugin name
  65338. */
  65339. name: string;
  65340. /**
  65341. * the first navmesh created. We might extend this to support multiple navmeshes
  65342. */
  65343. navMesh: any;
  65344. /**
  65345. * Initializes the recastJS plugin
  65346. * @param recastInjection can be used to inject your own recast reference
  65347. */
  65348. constructor(recastInjection?: any);
  65349. /**
  65350. * Creates a navigation mesh
  65351. * @param meshes array of all the geometry used to compute the navigatio mesh
  65352. * @param parameters bunch of parameters used to filter geometry
  65353. */
  65354. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65355. /**
  65356. * Create a navigation mesh debug mesh
  65357. * @param scene is where the mesh will be added
  65358. * @returns debug display mesh
  65359. */
  65360. createDebugNavMesh(scene: Scene): Mesh;
  65361. /**
  65362. * Get a navigation mesh constrained position, closest to the parameter position
  65363. * @param position world position
  65364. * @returns the closest point to position constrained by the navigation mesh
  65365. */
  65366. getClosestPoint(position: Vector3): Vector3;
  65367. /**
  65368. * Get a navigation mesh constrained position, within a particular radius
  65369. * @param position world position
  65370. * @param maxRadius the maximum distance to the constrained world position
  65371. * @returns the closest point to position constrained by the navigation mesh
  65372. */
  65373. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65374. /**
  65375. * Compute the final position from a segment made of destination-position
  65376. * @param position world position
  65377. * @param destination world position
  65378. * @returns the resulting point along the navmesh
  65379. */
  65380. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65381. /**
  65382. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65383. * @param start world position
  65384. * @param end world position
  65385. * @returns array containing world position composing the path
  65386. */
  65387. computePath(start: Vector3, end: Vector3): Vector3[];
  65388. /**
  65389. * Create a new Crowd so you can add agents
  65390. * @param maxAgents the maximum agent count in the crowd
  65391. * @param maxAgentRadius the maximum radius an agent can have
  65392. * @param scene to attach the crowd to
  65393. * @returns the crowd you can add agents to
  65394. */
  65395. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65396. /**
  65397. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65398. * The queries will try to find a solution within those bounds
  65399. * default is (1,1,1)
  65400. * @param extent x,y,z value that define the extent around the queries point of reference
  65401. */
  65402. setDefaultQueryExtent(extent: Vector3): void;
  65403. /**
  65404. * Get the Bounding box extent specified by setDefaultQueryExtent
  65405. * @returns the box extent values
  65406. */
  65407. getDefaultQueryExtent(): Vector3;
  65408. /**
  65409. * Disposes
  65410. */
  65411. dispose(): void;
  65412. /**
  65413. * If this plugin is supported
  65414. * @returns true if plugin is supported
  65415. */
  65416. isSupported(): boolean;
  65417. }
  65418. /**
  65419. * Recast detour crowd implementation
  65420. */
  65421. export class RecastJSCrowd implements ICrowd {
  65422. /**
  65423. * Recast/detour plugin
  65424. */
  65425. bjsRECASTPlugin: RecastJSPlugin;
  65426. /**
  65427. * Link to the detour crowd
  65428. */
  65429. recastCrowd: any;
  65430. /**
  65431. * One transform per agent
  65432. */
  65433. transforms: TransformNode[];
  65434. /**
  65435. * All agents created
  65436. */
  65437. agents: number[];
  65438. /**
  65439. * Link to the scene is kept to unregister the crowd from the scene
  65440. */
  65441. private _scene;
  65442. /**
  65443. * Observer for crowd updates
  65444. */
  65445. private _onBeforeAnimationsObserver;
  65446. /**
  65447. * Constructor
  65448. * @param plugin recastJS plugin
  65449. * @param maxAgents the maximum agent count in the crowd
  65450. * @param maxAgentRadius the maximum radius an agent can have
  65451. * @param scene to attach the crowd to
  65452. * @returns the crowd you can add agents to
  65453. */
  65454. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65455. /**
  65456. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65457. * You can attach anything to that node. The node position is updated in the scene update tick.
  65458. * @param pos world position that will be constrained by the navigation mesh
  65459. * @param parameters agent parameters
  65460. * @param transform hooked to the agent that will be update by the scene
  65461. * @returns agent index
  65462. */
  65463. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65464. /**
  65465. * Returns the agent position in world space
  65466. * @param index agent index returned by addAgent
  65467. * @returns world space position
  65468. */
  65469. getAgentPosition(index: number): Vector3;
  65470. /**
  65471. * Returns the agent velocity in world space
  65472. * @param index agent index returned by addAgent
  65473. * @returns world space velocity
  65474. */
  65475. getAgentVelocity(index: number): Vector3;
  65476. /**
  65477. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65478. * @param index agent index returned by addAgent
  65479. * @param destination targeted world position
  65480. */
  65481. agentGoto(index: number, destination: Vector3): void;
  65482. /**
  65483. * Teleport the agent to a new position
  65484. * @param index agent index returned by addAgent
  65485. * @param destination targeted world position
  65486. */
  65487. agentTeleport(index: number, destination: Vector3): void;
  65488. /**
  65489. * Update agent parameters
  65490. * @param index agent index returned by addAgent
  65491. * @param parameters agent parameters
  65492. */
  65493. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65494. /**
  65495. * remove a particular agent previously created
  65496. * @param index agent index returned by addAgent
  65497. */
  65498. removeAgent(index: number): void;
  65499. /**
  65500. * get the list of all agents attached to this crowd
  65501. * @returns list of agent indices
  65502. */
  65503. getAgents(): number[];
  65504. /**
  65505. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65506. * @param deltaTime in seconds
  65507. */
  65508. update(deltaTime: number): void;
  65509. /**
  65510. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65511. * The queries will try to find a solution within those bounds
  65512. * default is (1,1,1)
  65513. * @param extent x,y,z value that define the extent around the queries point of reference
  65514. */
  65515. setDefaultQueryExtent(extent: Vector3): void;
  65516. /**
  65517. * Get the Bounding box extent specified by setDefaultQueryExtent
  65518. * @returns the box extent values
  65519. */
  65520. getDefaultQueryExtent(): Vector3;
  65521. /**
  65522. * Release all resources
  65523. */
  65524. dispose(): void;
  65525. }
  65526. }
  65527. declare module "babylonjs/Navigation/Plugins/index" {
  65528. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65529. }
  65530. declare module "babylonjs/Navigation/index" {
  65531. export * from "babylonjs/Navigation/INavigationEngine";
  65532. export * from "babylonjs/Navigation/Plugins/index";
  65533. }
  65534. declare module "babylonjs/Offline/database" {
  65535. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65536. /**
  65537. * Class used to enable access to IndexedDB
  65538. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65539. */
  65540. export class Database implements IOfflineProvider {
  65541. private _callbackManifestChecked;
  65542. private _currentSceneUrl;
  65543. private _db;
  65544. private _enableSceneOffline;
  65545. private _enableTexturesOffline;
  65546. private _manifestVersionFound;
  65547. private _mustUpdateRessources;
  65548. private _hasReachedQuota;
  65549. private _isSupported;
  65550. private _idbFactory;
  65551. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65552. private static IsUASupportingBlobStorage;
  65553. /**
  65554. * Gets a boolean indicating if Database storate is enabled (off by default)
  65555. */
  65556. static IDBStorageEnabled: boolean;
  65557. /**
  65558. * Gets a boolean indicating if scene must be saved in the database
  65559. */
  65560. get enableSceneOffline(): boolean;
  65561. /**
  65562. * Gets a boolean indicating if textures must be saved in the database
  65563. */
  65564. get enableTexturesOffline(): boolean;
  65565. /**
  65566. * Creates a new Database
  65567. * @param urlToScene defines the url to load the scene
  65568. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65569. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65570. */
  65571. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65572. private static _ParseURL;
  65573. private static _ReturnFullUrlLocation;
  65574. private _checkManifestFile;
  65575. /**
  65576. * Open the database and make it available
  65577. * @param successCallback defines the callback to call on success
  65578. * @param errorCallback defines the callback to call on error
  65579. */
  65580. open(successCallback: () => void, errorCallback: () => void): void;
  65581. /**
  65582. * Loads an image from the database
  65583. * @param url defines the url to load from
  65584. * @param image defines the target DOM image
  65585. */
  65586. loadImage(url: string, image: HTMLImageElement): void;
  65587. private _loadImageFromDBAsync;
  65588. private _saveImageIntoDBAsync;
  65589. private _checkVersionFromDB;
  65590. private _loadVersionFromDBAsync;
  65591. private _saveVersionIntoDBAsync;
  65592. /**
  65593. * Loads a file from database
  65594. * @param url defines the URL to load from
  65595. * @param sceneLoaded defines a callback to call on success
  65596. * @param progressCallBack defines a callback to call when progress changed
  65597. * @param errorCallback defines a callback to call on error
  65598. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65599. */
  65600. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65601. private _loadFileAsync;
  65602. private _saveFileAsync;
  65603. /**
  65604. * Validates if xhr data is correct
  65605. * @param xhr defines the request to validate
  65606. * @param dataType defines the expected data type
  65607. * @returns true if data is correct
  65608. */
  65609. private static _ValidateXHRData;
  65610. }
  65611. }
  65612. declare module "babylonjs/Offline/index" {
  65613. export * from "babylonjs/Offline/database";
  65614. export * from "babylonjs/Offline/IOfflineProvider";
  65615. }
  65616. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65617. /** @hidden */
  65618. export var gpuUpdateParticlesPixelShader: {
  65619. name: string;
  65620. shader: string;
  65621. };
  65622. }
  65623. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65624. /** @hidden */
  65625. export var gpuUpdateParticlesVertexShader: {
  65626. name: string;
  65627. shader: string;
  65628. };
  65629. }
  65630. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65631. /** @hidden */
  65632. export var clipPlaneFragmentDeclaration2: {
  65633. name: string;
  65634. shader: string;
  65635. };
  65636. }
  65637. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65638. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65639. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65640. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65641. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65642. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65643. /** @hidden */
  65644. export var gpuRenderParticlesPixelShader: {
  65645. name: string;
  65646. shader: string;
  65647. };
  65648. }
  65649. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65650. /** @hidden */
  65651. export var clipPlaneVertexDeclaration2: {
  65652. name: string;
  65653. shader: string;
  65654. };
  65655. }
  65656. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65657. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65658. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65659. /** @hidden */
  65660. export var gpuRenderParticlesVertexShader: {
  65661. name: string;
  65662. shader: string;
  65663. };
  65664. }
  65665. declare module "babylonjs/Particles/gpuParticleSystem" {
  65666. import { Nullable } from "babylonjs/types";
  65667. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65668. import { Observable } from "babylonjs/Misc/observable";
  65669. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65670. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65671. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65672. import { Scene, IDisposable } from "babylonjs/scene";
  65673. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65674. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65675. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65676. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65677. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65678. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65679. /**
  65680. * This represents a GPU particle system in Babylon
  65681. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65682. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65683. */
  65684. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65685. /**
  65686. * The layer mask we are rendering the particles through.
  65687. */
  65688. layerMask: number;
  65689. private _capacity;
  65690. private _activeCount;
  65691. private _currentActiveCount;
  65692. private _accumulatedCount;
  65693. private _renderEffect;
  65694. private _updateEffect;
  65695. private _buffer0;
  65696. private _buffer1;
  65697. private _spriteBuffer;
  65698. private _updateVAO;
  65699. private _renderVAO;
  65700. private _targetIndex;
  65701. private _sourceBuffer;
  65702. private _targetBuffer;
  65703. private _engine;
  65704. private _currentRenderId;
  65705. private _started;
  65706. private _stopped;
  65707. private _timeDelta;
  65708. private _randomTexture;
  65709. private _randomTexture2;
  65710. private _attributesStrideSize;
  65711. private _updateEffectOptions;
  65712. private _randomTextureSize;
  65713. private _actualFrame;
  65714. private readonly _rawTextureWidth;
  65715. /**
  65716. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65717. */
  65718. static get IsSupported(): boolean;
  65719. /**
  65720. * An event triggered when the system is disposed.
  65721. */
  65722. onDisposeObservable: Observable<GPUParticleSystem>;
  65723. /**
  65724. * Gets the maximum number of particles active at the same time.
  65725. * @returns The max number of active particles.
  65726. */
  65727. getCapacity(): number;
  65728. /**
  65729. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65730. * to override the particles.
  65731. */
  65732. forceDepthWrite: boolean;
  65733. /**
  65734. * Gets or set the number of active particles
  65735. */
  65736. get activeParticleCount(): number;
  65737. set activeParticleCount(value: number);
  65738. private _preWarmDone;
  65739. /**
  65740. * Specifies if the particles are updated in emitter local space or world space.
  65741. * This is always false for GPU particles
  65742. */
  65743. get isLocal(): boolean;
  65744. set isLocal(value: boolean);
  65745. /**
  65746. * Is this system ready to be used/rendered
  65747. * @return true if the system is ready
  65748. */
  65749. isReady(): boolean;
  65750. /**
  65751. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65752. * @returns True if it has been started, otherwise false.
  65753. */
  65754. isStarted(): boolean;
  65755. /**
  65756. * Starts the particle system and begins to emit
  65757. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65758. */
  65759. start(delay?: number): void;
  65760. /**
  65761. * Stops the particle system.
  65762. */
  65763. stop(): void;
  65764. /**
  65765. * Remove all active particles
  65766. */
  65767. reset(): void;
  65768. /**
  65769. * Returns the string "GPUParticleSystem"
  65770. * @returns a string containing the class name
  65771. */
  65772. getClassName(): string;
  65773. private _colorGradientsTexture;
  65774. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65775. /**
  65776. * Adds a new color gradient
  65777. * @param gradient defines the gradient to use (between 0 and 1)
  65778. * @param color1 defines the color to affect to the specified gradient
  65779. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65780. * @returns the current particle system
  65781. */
  65782. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65783. /**
  65784. * Remove a specific color gradient
  65785. * @param gradient defines the gradient to remove
  65786. * @returns the current particle system
  65787. */
  65788. removeColorGradient(gradient: number): GPUParticleSystem;
  65789. private _angularSpeedGradientsTexture;
  65790. private _sizeGradientsTexture;
  65791. private _velocityGradientsTexture;
  65792. private _limitVelocityGradientsTexture;
  65793. private _dragGradientsTexture;
  65794. private _addFactorGradient;
  65795. /**
  65796. * Adds a new size gradient
  65797. * @param gradient defines the gradient to use (between 0 and 1)
  65798. * @param factor defines the size factor to affect to the specified gradient
  65799. * @returns the current particle system
  65800. */
  65801. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65802. /**
  65803. * Remove a specific size gradient
  65804. * @param gradient defines the gradient to remove
  65805. * @returns the current particle system
  65806. */
  65807. removeSizeGradient(gradient: number): GPUParticleSystem;
  65808. /**
  65809. * Adds a new angular speed gradient
  65810. * @param gradient defines the gradient to use (between 0 and 1)
  65811. * @param factor defines the angular speed to affect to the specified gradient
  65812. * @returns the current particle system
  65813. */
  65814. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65815. /**
  65816. * Remove a specific angular speed gradient
  65817. * @param gradient defines the gradient to remove
  65818. * @returns the current particle system
  65819. */
  65820. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65821. /**
  65822. * Adds a new velocity gradient
  65823. * @param gradient defines the gradient to use (between 0 and 1)
  65824. * @param factor defines the velocity to affect to the specified gradient
  65825. * @returns the current particle system
  65826. */
  65827. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65828. /**
  65829. * Remove a specific velocity gradient
  65830. * @param gradient defines the gradient to remove
  65831. * @returns the current particle system
  65832. */
  65833. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65834. /**
  65835. * Adds a new limit velocity gradient
  65836. * @param gradient defines the gradient to use (between 0 and 1)
  65837. * @param factor defines the limit velocity value to affect to the specified gradient
  65838. * @returns the current particle system
  65839. */
  65840. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65841. /**
  65842. * Remove a specific limit velocity gradient
  65843. * @param gradient defines the gradient to remove
  65844. * @returns the current particle system
  65845. */
  65846. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65847. /**
  65848. * Adds a new drag gradient
  65849. * @param gradient defines the gradient to use (between 0 and 1)
  65850. * @param factor defines the drag value to affect to the specified gradient
  65851. * @returns the current particle system
  65852. */
  65853. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65854. /**
  65855. * Remove a specific drag gradient
  65856. * @param gradient defines the gradient to remove
  65857. * @returns the current particle system
  65858. */
  65859. removeDragGradient(gradient: number): GPUParticleSystem;
  65860. /**
  65861. * Not supported by GPUParticleSystem
  65862. * @param gradient defines the gradient to use (between 0 and 1)
  65863. * @param factor defines the emit rate value to affect to the specified gradient
  65864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65865. * @returns the current particle system
  65866. */
  65867. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65868. /**
  65869. * Not supported by GPUParticleSystem
  65870. * @param gradient defines the gradient to remove
  65871. * @returns the current particle system
  65872. */
  65873. removeEmitRateGradient(gradient: number): IParticleSystem;
  65874. /**
  65875. * Not supported by GPUParticleSystem
  65876. * @param gradient defines the gradient to use (between 0 and 1)
  65877. * @param factor defines the start size value to affect to the specified gradient
  65878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65879. * @returns the current particle system
  65880. */
  65881. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65882. /**
  65883. * Not supported by GPUParticleSystem
  65884. * @param gradient defines the gradient to remove
  65885. * @returns the current particle system
  65886. */
  65887. removeStartSizeGradient(gradient: number): IParticleSystem;
  65888. /**
  65889. * Not supported by GPUParticleSystem
  65890. * @param gradient defines the gradient to use (between 0 and 1)
  65891. * @param min defines the color remap minimal range
  65892. * @param max defines the color remap maximal range
  65893. * @returns the current particle system
  65894. */
  65895. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65896. /**
  65897. * Not supported by GPUParticleSystem
  65898. * @param gradient defines the gradient to remove
  65899. * @returns the current particle system
  65900. */
  65901. removeColorRemapGradient(): IParticleSystem;
  65902. /**
  65903. * Not supported by GPUParticleSystem
  65904. * @param gradient defines the gradient to use (between 0 and 1)
  65905. * @param min defines the alpha remap minimal range
  65906. * @param max defines the alpha remap maximal range
  65907. * @returns the current particle system
  65908. */
  65909. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65910. /**
  65911. * Not supported by GPUParticleSystem
  65912. * @param gradient defines the gradient to remove
  65913. * @returns the current particle system
  65914. */
  65915. removeAlphaRemapGradient(): IParticleSystem;
  65916. /**
  65917. * Not supported by GPUParticleSystem
  65918. * @param gradient defines the gradient to use (between 0 and 1)
  65919. * @param color defines the color to affect to the specified gradient
  65920. * @returns the current particle system
  65921. */
  65922. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65923. /**
  65924. * Not supported by GPUParticleSystem
  65925. * @param gradient defines the gradient to remove
  65926. * @returns the current particle system
  65927. */
  65928. removeRampGradient(): IParticleSystem;
  65929. /**
  65930. * Not supported by GPUParticleSystem
  65931. * @returns the list of ramp gradients
  65932. */
  65933. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65934. /**
  65935. * Not supported by GPUParticleSystem
  65936. * Gets or sets a boolean indicating that ramp gradients must be used
  65937. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65938. */
  65939. get useRampGradients(): boolean;
  65940. set useRampGradients(value: boolean);
  65941. /**
  65942. * Not supported by GPUParticleSystem
  65943. * @param gradient defines the gradient to use (between 0 and 1)
  65944. * @param factor defines the life time factor to affect to the specified gradient
  65945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65946. * @returns the current particle system
  65947. */
  65948. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65949. /**
  65950. * Not supported by GPUParticleSystem
  65951. * @param gradient defines the gradient to remove
  65952. * @returns the current particle system
  65953. */
  65954. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65955. /**
  65956. * Instantiates a GPU particle system.
  65957. * 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.
  65958. * @param name The name of the particle system
  65959. * @param options The options used to create the system
  65960. * @param scene The scene the particle system belongs to
  65961. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65962. */
  65963. constructor(name: string, options: Partial<{
  65964. capacity: number;
  65965. randomTextureSize: number;
  65966. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65967. protected _reset(): void;
  65968. private _createUpdateVAO;
  65969. private _createRenderVAO;
  65970. private _initialize;
  65971. /** @hidden */
  65972. _recreateUpdateEffect(): void;
  65973. /** @hidden */
  65974. _recreateRenderEffect(): void;
  65975. /**
  65976. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65977. * @param preWarm defines if we are in the pre-warmimg phase
  65978. */
  65979. animate(preWarm?: boolean): void;
  65980. private _createFactorGradientTexture;
  65981. private _createSizeGradientTexture;
  65982. private _createAngularSpeedGradientTexture;
  65983. private _createVelocityGradientTexture;
  65984. private _createLimitVelocityGradientTexture;
  65985. private _createDragGradientTexture;
  65986. private _createColorGradientTexture;
  65987. /**
  65988. * Renders the particle system in its current state
  65989. * @param preWarm defines if the system should only update the particles but not render them
  65990. * @returns the current number of particles
  65991. */
  65992. render(preWarm?: boolean): number;
  65993. /**
  65994. * Rebuilds the particle system
  65995. */
  65996. rebuild(): void;
  65997. private _releaseBuffers;
  65998. private _releaseVAOs;
  65999. /**
  66000. * Disposes the particle system and free the associated resources
  66001. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66002. */
  66003. dispose(disposeTexture?: boolean): void;
  66004. /**
  66005. * Clones the particle system.
  66006. * @param name The name of the cloned object
  66007. * @param newEmitter The new emitter to use
  66008. * @returns the cloned particle system
  66009. */
  66010. clone(name: string, newEmitter: any): GPUParticleSystem;
  66011. /**
  66012. * Serializes the particle system to a JSON object.
  66013. * @returns the JSON object
  66014. */
  66015. serialize(): any;
  66016. /**
  66017. * Parses a JSON object to create a GPU particle system.
  66018. * @param parsedParticleSystem The JSON object to parse
  66019. * @param scene The scene to create the particle system in
  66020. * @param rootUrl The root url to use to load external dependencies like texture
  66021. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66022. * @returns the parsed GPU particle system
  66023. */
  66024. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66025. }
  66026. }
  66027. declare module "babylonjs/Particles/particleSystemSet" {
  66028. import { Nullable } from "babylonjs/types";
  66029. import { Color3 } from "babylonjs/Maths/math.color";
  66030. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66032. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66033. import { Scene, IDisposable } from "babylonjs/scene";
  66034. /**
  66035. * Represents a set of particle systems working together to create a specific effect
  66036. */
  66037. export class ParticleSystemSet implements IDisposable {
  66038. /**
  66039. * Gets or sets base Assets URL
  66040. */
  66041. static BaseAssetsUrl: string;
  66042. private _emitterCreationOptions;
  66043. private _emitterNode;
  66044. /**
  66045. * Gets the particle system list
  66046. */
  66047. systems: IParticleSystem[];
  66048. /**
  66049. * Gets the emitter node used with this set
  66050. */
  66051. get emitterNode(): Nullable<TransformNode>;
  66052. /**
  66053. * Creates a new emitter mesh as a sphere
  66054. * @param options defines the options used to create the sphere
  66055. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66056. * @param scene defines the hosting scene
  66057. */
  66058. setEmitterAsSphere(options: {
  66059. diameter: number;
  66060. segments: number;
  66061. color: Color3;
  66062. }, renderingGroupId: number, scene: Scene): void;
  66063. /**
  66064. * Starts all particle systems of the set
  66065. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66066. */
  66067. start(emitter?: AbstractMesh): void;
  66068. /**
  66069. * Release all associated resources
  66070. */
  66071. dispose(): void;
  66072. /**
  66073. * Serialize the set into a JSON compatible object
  66074. * @returns a JSON compatible representation of the set
  66075. */
  66076. serialize(): any;
  66077. /**
  66078. * Parse a new ParticleSystemSet from a serialized source
  66079. * @param data defines a JSON compatible representation of the set
  66080. * @param scene defines the hosting scene
  66081. * @param gpu defines if we want GPU particles or CPU particles
  66082. * @returns a new ParticleSystemSet
  66083. */
  66084. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66085. }
  66086. }
  66087. declare module "babylonjs/Particles/particleHelper" {
  66088. import { Nullable } from "babylonjs/types";
  66089. import { Scene } from "babylonjs/scene";
  66090. import { Vector3 } from "babylonjs/Maths/math.vector";
  66091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66092. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66093. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66094. /**
  66095. * This class is made for on one-liner static method to help creating particle system set.
  66096. */
  66097. export class ParticleHelper {
  66098. /**
  66099. * Gets or sets base Assets URL
  66100. */
  66101. static BaseAssetsUrl: string;
  66102. /**
  66103. * Create a default particle system that you can tweak
  66104. * @param emitter defines the emitter to use
  66105. * @param capacity defines the system capacity (default is 500 particles)
  66106. * @param scene defines the hosting scene
  66107. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66108. * @returns the new Particle system
  66109. */
  66110. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66111. /**
  66112. * This is the main static method (one-liner) of this helper to create different particle systems
  66113. * @param type This string represents the type to the particle system to create
  66114. * @param scene The scene where the particle system should live
  66115. * @param gpu If the system will use gpu
  66116. * @returns the ParticleSystemSet created
  66117. */
  66118. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66119. /**
  66120. * Static function used to export a particle system to a ParticleSystemSet variable.
  66121. * Please note that the emitter shape is not exported
  66122. * @param systems defines the particle systems to export
  66123. * @returns the created particle system set
  66124. */
  66125. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66126. }
  66127. }
  66128. declare module "babylonjs/Particles/particleSystemComponent" {
  66129. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66130. import { Effect } from "babylonjs/Materials/effect";
  66131. import "babylonjs/Shaders/particles.vertex";
  66132. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66133. module "babylonjs/Engines/engine" {
  66134. interface Engine {
  66135. /**
  66136. * Create an effect to use with particle systems.
  66137. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66138. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66139. * @param uniformsNames defines a list of attribute names
  66140. * @param samplers defines an array of string used to represent textures
  66141. * @param defines defines the string containing the defines to use to compile the shaders
  66142. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66143. * @param onCompiled defines a function to call when the effect creation is successful
  66144. * @param onError defines a function to call when the effect creation has failed
  66145. * @returns the new Effect
  66146. */
  66147. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66148. }
  66149. }
  66150. module "babylonjs/Meshes/mesh" {
  66151. interface Mesh {
  66152. /**
  66153. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66154. * @returns an array of IParticleSystem
  66155. */
  66156. getEmittedParticleSystems(): IParticleSystem[];
  66157. /**
  66158. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66159. * @returns an array of IParticleSystem
  66160. */
  66161. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66162. }
  66163. }
  66164. /**
  66165. * @hidden
  66166. */
  66167. export var _IDoNeedToBeInTheBuild: number;
  66168. }
  66169. declare module "babylonjs/Particles/pointsCloudSystem" {
  66170. import { Color4 } from "babylonjs/Maths/math";
  66171. import { Mesh } from "babylonjs/Meshes/mesh";
  66172. import { Scene, IDisposable } from "babylonjs/scene";
  66173. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66174. /** Defines the 4 color options */
  66175. export enum PointColor {
  66176. /** color value */
  66177. Color = 2,
  66178. /** uv value */
  66179. UV = 1,
  66180. /** random value */
  66181. Random = 0,
  66182. /** stated value */
  66183. Stated = 3
  66184. }
  66185. /**
  66186. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66187. * 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.
  66188. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66189. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66190. *
  66191. * Full documentation here : TO BE ENTERED
  66192. */
  66193. export class PointsCloudSystem implements IDisposable {
  66194. /**
  66195. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66196. * Example : var p = SPS.particles[i];
  66197. */
  66198. particles: CloudPoint[];
  66199. /**
  66200. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66201. */
  66202. nbParticles: number;
  66203. /**
  66204. * This a counter for your own usage. It's not set by any SPS functions.
  66205. */
  66206. counter: number;
  66207. /**
  66208. * The PCS name. This name is also given to the underlying mesh.
  66209. */
  66210. name: string;
  66211. /**
  66212. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66213. */
  66214. mesh: Mesh;
  66215. /**
  66216. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66217. * Please read :
  66218. */
  66219. vars: any;
  66220. /**
  66221. * @hidden
  66222. */
  66223. _size: number;
  66224. private _scene;
  66225. private _promises;
  66226. private _positions;
  66227. private _indices;
  66228. private _normals;
  66229. private _colors;
  66230. private _uvs;
  66231. private _indices32;
  66232. private _positions32;
  66233. private _colors32;
  66234. private _uvs32;
  66235. private _updatable;
  66236. private _isVisibilityBoxLocked;
  66237. private _alwaysVisible;
  66238. private _groups;
  66239. private _groupCounter;
  66240. private _computeParticleColor;
  66241. private _computeParticleTexture;
  66242. private _computeParticleRotation;
  66243. private _computeBoundingBox;
  66244. private _isReady;
  66245. /**
  66246. * Creates a PCS (Points Cloud System) object
  66247. * @param name (String) is the PCS name, this will be the underlying mesh name
  66248. * @param pointSize (number) is the size for each point
  66249. * @param scene (Scene) is the scene in which the PCS is added
  66250. * @param options defines the options of the PCS e.g.
  66251. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66252. */
  66253. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66254. updatable?: boolean;
  66255. });
  66256. /**
  66257. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66258. * If no points were added to the PCS, the returned mesh is just a single point.
  66259. * @returns a promise for the created mesh
  66260. */
  66261. buildMeshAsync(): Promise<Mesh>;
  66262. /**
  66263. * @hidden
  66264. */
  66265. private _buildMesh;
  66266. private _addParticle;
  66267. private _randomUnitVector;
  66268. private _getColorIndicesForCoord;
  66269. private _setPointsColorOrUV;
  66270. private _colorFromTexture;
  66271. private _calculateDensity;
  66272. /**
  66273. * Adds points to the PCS in random positions within a unit sphere
  66274. * @param nb (positive integer) the number of particles to be created from this model
  66275. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66276. * @returns the number of groups in the system
  66277. */
  66278. addPoints(nb: number, pointFunction?: any): number;
  66279. /**
  66280. * Adds points to the PCS from the surface of the model shape
  66281. * @param mesh is any Mesh object that will be used as a surface model for the points
  66282. * @param nb (positive integer) the number of particles to be created from this model
  66283. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66284. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66285. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66286. * @returns the number of groups in the system
  66287. */
  66288. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66289. /**
  66290. * Adds points to the PCS inside the model shape
  66291. * @param mesh is any Mesh object that will be used as a surface model for the points
  66292. * @param nb (positive integer) the number of particles to be created from this model
  66293. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66294. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66295. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66296. * @returns the number of groups in the system
  66297. */
  66298. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66299. /**
  66300. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66301. * This method calls `updateParticle()` for each particle of the SPS.
  66302. * For an animated SPS, it is usually called within the render loop.
  66303. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66304. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66305. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66306. * @returns the PCS.
  66307. */
  66308. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66309. /**
  66310. * Disposes the PCS.
  66311. */
  66312. dispose(): void;
  66313. /**
  66314. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66315. * doc :
  66316. * @returns the PCS.
  66317. */
  66318. refreshVisibleSize(): PointsCloudSystem;
  66319. /**
  66320. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66321. * @param size the size (float) of the visibility box
  66322. * note : this doesn't lock the PCS mesh bounding box.
  66323. * doc :
  66324. */
  66325. setVisibilityBox(size: number): void;
  66326. /**
  66327. * Gets whether the PCS is always visible or not
  66328. * doc :
  66329. */
  66330. get isAlwaysVisible(): boolean;
  66331. /**
  66332. * Sets the PCS as always visible or not
  66333. * doc :
  66334. */
  66335. set isAlwaysVisible(val: boolean);
  66336. /**
  66337. * Tells to `setParticles()` to compute the particle rotations or not
  66338. * Default value : false. The PCS is faster when it's set to false
  66339. * Note : particle rotations are only applied to parent particles
  66340. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66341. */
  66342. set computeParticleRotation(val: boolean);
  66343. /**
  66344. * Tells to `setParticles()` to compute the particle colors or not.
  66345. * Default value : true. The PCS is faster when it's set to false.
  66346. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66347. */
  66348. set computeParticleColor(val: boolean);
  66349. set computeParticleTexture(val: boolean);
  66350. /**
  66351. * Gets if `setParticles()` computes the particle colors or not.
  66352. * Default value : false. The PCS is faster when it's set to false.
  66353. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66354. */
  66355. get computeParticleColor(): boolean;
  66356. /**
  66357. * Gets if `setParticles()` computes the particle textures or not.
  66358. * Default value : false. The PCS is faster when it's set to false.
  66359. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66360. */
  66361. get computeParticleTexture(): boolean;
  66362. /**
  66363. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66364. */
  66365. set computeBoundingBox(val: boolean);
  66366. /**
  66367. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66368. */
  66369. get computeBoundingBox(): boolean;
  66370. /**
  66371. * This function does nothing. It may be overwritten to set all the particle first values.
  66372. * The PCS doesn't call this function, you may have to call it by your own.
  66373. * doc :
  66374. */
  66375. initParticles(): void;
  66376. /**
  66377. * This function does nothing. It may be overwritten to recycle a particle
  66378. * The PCS doesn't call this function, you can to call it
  66379. * doc :
  66380. * @param particle The particle to recycle
  66381. * @returns the recycled particle
  66382. */
  66383. recycleParticle(particle: CloudPoint): CloudPoint;
  66384. /**
  66385. * Updates a particle : this function should be overwritten by the user.
  66386. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66387. * doc :
  66388. * @example : just set a particle position or velocity and recycle conditions
  66389. * @param particle The particle to update
  66390. * @returns the updated particle
  66391. */
  66392. updateParticle(particle: CloudPoint): CloudPoint;
  66393. /**
  66394. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66395. * This does nothing and may be overwritten by the user.
  66396. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66397. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66398. * @param update the boolean update value actually passed to setParticles()
  66399. */
  66400. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66401. /**
  66402. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66403. * This will be passed three parameters.
  66404. * This does nothing and may be overwritten by the user.
  66405. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66406. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66407. * @param update the boolean update value actually passed to setParticles()
  66408. */
  66409. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66410. }
  66411. }
  66412. declare module "babylonjs/Particles/cloudPoint" {
  66413. import { Nullable } from "babylonjs/types";
  66414. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66415. import { Mesh } from "babylonjs/Meshes/mesh";
  66416. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66417. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66418. /**
  66419. * Represents one particle of a points cloud system.
  66420. */
  66421. export class CloudPoint {
  66422. /**
  66423. * particle global index
  66424. */
  66425. idx: number;
  66426. /**
  66427. * The color of the particle
  66428. */
  66429. color: Nullable<Color4>;
  66430. /**
  66431. * The world space position of the particle.
  66432. */
  66433. position: Vector3;
  66434. /**
  66435. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66436. */
  66437. rotation: Vector3;
  66438. /**
  66439. * The world space rotation quaternion of the particle.
  66440. */
  66441. rotationQuaternion: Nullable<Quaternion>;
  66442. /**
  66443. * The uv of the particle.
  66444. */
  66445. uv: Nullable<Vector2>;
  66446. /**
  66447. * The current speed of the particle.
  66448. */
  66449. velocity: Vector3;
  66450. /**
  66451. * The pivot point in the particle local space.
  66452. */
  66453. pivot: Vector3;
  66454. /**
  66455. * Must the particle be translated from its pivot point in its local space ?
  66456. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66457. * Default : false
  66458. */
  66459. translateFromPivot: boolean;
  66460. /**
  66461. * Index of this particle in the global "positions" array (Internal use)
  66462. * @hidden
  66463. */
  66464. _pos: number;
  66465. /**
  66466. * @hidden Index of this particle in the global "indices" array (Internal use)
  66467. */
  66468. _ind: number;
  66469. /**
  66470. * Group this particle belongs to
  66471. */
  66472. _group: PointsGroup;
  66473. /**
  66474. * Group id of this particle
  66475. */
  66476. groupId: number;
  66477. /**
  66478. * Index of the particle in its group id (Internal use)
  66479. */
  66480. idxInGroup: number;
  66481. /**
  66482. * @hidden Particle BoundingInfo object (Internal use)
  66483. */
  66484. _boundingInfo: BoundingInfo;
  66485. /**
  66486. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66487. */
  66488. _pcs: PointsCloudSystem;
  66489. /**
  66490. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66491. */
  66492. _stillInvisible: boolean;
  66493. /**
  66494. * @hidden Last computed particle rotation matrix
  66495. */
  66496. _rotationMatrix: number[];
  66497. /**
  66498. * Parent particle Id, if any.
  66499. * Default null.
  66500. */
  66501. parentId: Nullable<number>;
  66502. /**
  66503. * @hidden Internal global position in the PCS.
  66504. */
  66505. _globalPosition: Vector3;
  66506. /**
  66507. * Creates a Point Cloud object.
  66508. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66509. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66510. * @param group (PointsGroup) is the group the particle belongs to
  66511. * @param groupId (integer) is the group identifier in the PCS.
  66512. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66513. * @param pcs defines the PCS it is associated to
  66514. */
  66515. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66516. /**
  66517. * get point size
  66518. */
  66519. get size(): Vector3;
  66520. /**
  66521. * Set point size
  66522. */
  66523. set size(scale: Vector3);
  66524. /**
  66525. * Legacy support, changed quaternion to rotationQuaternion
  66526. */
  66527. get quaternion(): Nullable<Quaternion>;
  66528. /**
  66529. * Legacy support, changed quaternion to rotationQuaternion
  66530. */
  66531. set quaternion(q: Nullable<Quaternion>);
  66532. /**
  66533. * Returns a boolean. True if the particle intersects a mesh, else false
  66534. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66535. * @param target is the object (point or mesh) what the intersection is computed against
  66536. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66537. * @returns true if it intersects
  66538. */
  66539. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66540. /**
  66541. * get the rotation matrix of the particle
  66542. * @hidden
  66543. */
  66544. getRotationMatrix(m: Matrix): void;
  66545. }
  66546. /**
  66547. * Represents a group of points in a points cloud system
  66548. * * PCS internal tool, don't use it manually.
  66549. */
  66550. export class PointsGroup {
  66551. /**
  66552. * The group id
  66553. * @hidden
  66554. */
  66555. groupID: number;
  66556. /**
  66557. * image data for group (internal use)
  66558. * @hidden
  66559. */
  66560. _groupImageData: Nullable<ArrayBufferView>;
  66561. /**
  66562. * Image Width (internal use)
  66563. * @hidden
  66564. */
  66565. _groupImgWidth: number;
  66566. /**
  66567. * Image Height (internal use)
  66568. * @hidden
  66569. */
  66570. _groupImgHeight: number;
  66571. /**
  66572. * Custom position function (internal use)
  66573. * @hidden
  66574. */
  66575. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66576. /**
  66577. * density per facet for surface points
  66578. * @hidden
  66579. */
  66580. _groupDensity: number[];
  66581. /**
  66582. * Only when points are colored by texture carries pointer to texture list array
  66583. * @hidden
  66584. */
  66585. _textureNb: number;
  66586. /**
  66587. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66588. * PCS internal tool, don't use it manually.
  66589. * @hidden
  66590. */
  66591. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66592. }
  66593. }
  66594. declare module "babylonjs/Particles/index" {
  66595. export * from "babylonjs/Particles/baseParticleSystem";
  66596. export * from "babylonjs/Particles/EmitterTypes/index";
  66597. export * from "babylonjs/Particles/gpuParticleSystem";
  66598. export * from "babylonjs/Particles/IParticleSystem";
  66599. export * from "babylonjs/Particles/particle";
  66600. export * from "babylonjs/Particles/particleHelper";
  66601. export * from "babylonjs/Particles/particleSystem";
  66602. export * from "babylonjs/Particles/particleSystemComponent";
  66603. export * from "babylonjs/Particles/particleSystemSet";
  66604. export * from "babylonjs/Particles/solidParticle";
  66605. export * from "babylonjs/Particles/solidParticleSystem";
  66606. export * from "babylonjs/Particles/cloudPoint";
  66607. export * from "babylonjs/Particles/pointsCloudSystem";
  66608. export * from "babylonjs/Particles/subEmitter";
  66609. }
  66610. declare module "babylonjs/Physics/physicsEngineComponent" {
  66611. import { Nullable } from "babylonjs/types";
  66612. import { Observable, Observer } from "babylonjs/Misc/observable";
  66613. import { Vector3 } from "babylonjs/Maths/math.vector";
  66614. import { Mesh } from "babylonjs/Meshes/mesh";
  66615. import { ISceneComponent } from "babylonjs/sceneComponent";
  66616. import { Scene } from "babylonjs/scene";
  66617. import { Node } from "babylonjs/node";
  66618. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66619. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66620. module "babylonjs/scene" {
  66621. interface Scene {
  66622. /** @hidden (Backing field) */
  66623. _physicsEngine: Nullable<IPhysicsEngine>;
  66624. /** @hidden */
  66625. _physicsTimeAccumulator: number;
  66626. /**
  66627. * Gets the current physics engine
  66628. * @returns a IPhysicsEngine or null if none attached
  66629. */
  66630. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66631. /**
  66632. * Enables physics to the current scene
  66633. * @param gravity defines the scene's gravity for the physics engine
  66634. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66635. * @return a boolean indicating if the physics engine was initialized
  66636. */
  66637. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66638. /**
  66639. * Disables and disposes the physics engine associated with the scene
  66640. */
  66641. disablePhysicsEngine(): void;
  66642. /**
  66643. * Gets a boolean indicating if there is an active physics engine
  66644. * @returns a boolean indicating if there is an active physics engine
  66645. */
  66646. isPhysicsEnabled(): boolean;
  66647. /**
  66648. * Deletes a physics compound impostor
  66649. * @param compound defines the compound to delete
  66650. */
  66651. deleteCompoundImpostor(compound: any): void;
  66652. /**
  66653. * An event triggered when physic simulation is about to be run
  66654. */
  66655. onBeforePhysicsObservable: Observable<Scene>;
  66656. /**
  66657. * An event triggered when physic simulation has been done
  66658. */
  66659. onAfterPhysicsObservable: Observable<Scene>;
  66660. }
  66661. }
  66662. module "babylonjs/Meshes/abstractMesh" {
  66663. interface AbstractMesh {
  66664. /** @hidden */
  66665. _physicsImpostor: Nullable<PhysicsImpostor>;
  66666. /**
  66667. * Gets or sets impostor used for physic simulation
  66668. * @see http://doc.babylonjs.com/features/physics_engine
  66669. */
  66670. physicsImpostor: Nullable<PhysicsImpostor>;
  66671. /**
  66672. * Gets the current physics impostor
  66673. * @see http://doc.babylonjs.com/features/physics_engine
  66674. * @returns a physics impostor or null
  66675. */
  66676. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66677. /** Apply a physic impulse to the mesh
  66678. * @param force defines the force to apply
  66679. * @param contactPoint defines where to apply the force
  66680. * @returns the current mesh
  66681. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66682. */
  66683. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66684. /**
  66685. * Creates a physic joint between two meshes
  66686. * @param otherMesh defines the other mesh to use
  66687. * @param pivot1 defines the pivot to use on this mesh
  66688. * @param pivot2 defines the pivot to use on the other mesh
  66689. * @param options defines additional options (can be plugin dependent)
  66690. * @returns the current mesh
  66691. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66692. */
  66693. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66694. /** @hidden */
  66695. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66696. }
  66697. }
  66698. /**
  66699. * Defines the physics engine scene component responsible to manage a physics engine
  66700. */
  66701. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66702. /**
  66703. * The component name helpful to identify the component in the list of scene components.
  66704. */
  66705. readonly name: string;
  66706. /**
  66707. * The scene the component belongs to.
  66708. */
  66709. scene: Scene;
  66710. /**
  66711. * Creates a new instance of the component for the given scene
  66712. * @param scene Defines the scene to register the component in
  66713. */
  66714. constructor(scene: Scene);
  66715. /**
  66716. * Registers the component in a given scene
  66717. */
  66718. register(): void;
  66719. /**
  66720. * Rebuilds the elements related to this component in case of
  66721. * context lost for instance.
  66722. */
  66723. rebuild(): void;
  66724. /**
  66725. * Disposes the component and the associated ressources
  66726. */
  66727. dispose(): void;
  66728. }
  66729. }
  66730. declare module "babylonjs/Physics/physicsHelper" {
  66731. import { Nullable } from "babylonjs/types";
  66732. import { Vector3 } from "babylonjs/Maths/math.vector";
  66733. import { Mesh } from "babylonjs/Meshes/mesh";
  66734. import { Scene } from "babylonjs/scene";
  66735. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66736. /**
  66737. * A helper for physics simulations
  66738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66739. */
  66740. export class PhysicsHelper {
  66741. private _scene;
  66742. private _physicsEngine;
  66743. /**
  66744. * Initializes the Physics helper
  66745. * @param scene Babylon.js scene
  66746. */
  66747. constructor(scene: Scene);
  66748. /**
  66749. * Applies a radial explosion impulse
  66750. * @param origin the origin of the explosion
  66751. * @param radiusOrEventOptions the radius or the options of radial explosion
  66752. * @param strength the explosion strength
  66753. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66754. * @returns A physics radial explosion event, or null
  66755. */
  66756. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66757. /**
  66758. * Applies a radial explosion force
  66759. * @param origin the origin of the explosion
  66760. * @param radiusOrEventOptions the radius or the options of radial explosion
  66761. * @param strength the explosion strength
  66762. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66763. * @returns A physics radial explosion event, or null
  66764. */
  66765. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66766. /**
  66767. * Creates a gravitational field
  66768. * @param origin the origin of the explosion
  66769. * @param radiusOrEventOptions the radius or the options of radial explosion
  66770. * @param strength the explosion strength
  66771. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66772. * @returns A physics gravitational field event, or null
  66773. */
  66774. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66775. /**
  66776. * Creates a physics updraft event
  66777. * @param origin the origin of the updraft
  66778. * @param radiusOrEventOptions the radius or the options of the updraft
  66779. * @param strength the strength of the updraft
  66780. * @param height the height of the updraft
  66781. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66782. * @returns A physics updraft event, or null
  66783. */
  66784. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66785. /**
  66786. * Creates a physics vortex event
  66787. * @param origin the of the vortex
  66788. * @param radiusOrEventOptions the radius or the options of the vortex
  66789. * @param strength the strength of the vortex
  66790. * @param height the height of the vortex
  66791. * @returns a Physics vortex event, or null
  66792. * A physics vortex event or null
  66793. */
  66794. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66795. }
  66796. /**
  66797. * Represents a physics radial explosion event
  66798. */
  66799. class PhysicsRadialExplosionEvent {
  66800. private _scene;
  66801. private _options;
  66802. private _sphere;
  66803. private _dataFetched;
  66804. /**
  66805. * Initializes a radial explosioin event
  66806. * @param _scene BabylonJS scene
  66807. * @param _options The options for the vortex event
  66808. */
  66809. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66810. /**
  66811. * Returns the data related to the radial explosion event (sphere).
  66812. * @returns The radial explosion event data
  66813. */
  66814. getData(): PhysicsRadialExplosionEventData;
  66815. /**
  66816. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66817. * @param impostor A physics imposter
  66818. * @param origin the origin of the explosion
  66819. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66820. */
  66821. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66822. /**
  66823. * Triggers affecterd impostors callbacks
  66824. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66825. */
  66826. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66827. /**
  66828. * Disposes the sphere.
  66829. * @param force Specifies if the sphere should be disposed by force
  66830. */
  66831. dispose(force?: boolean): void;
  66832. /*** Helpers ***/
  66833. private _prepareSphere;
  66834. private _intersectsWithSphere;
  66835. }
  66836. /**
  66837. * Represents a gravitational field event
  66838. */
  66839. class PhysicsGravitationalFieldEvent {
  66840. private _physicsHelper;
  66841. private _scene;
  66842. private _origin;
  66843. private _options;
  66844. private _tickCallback;
  66845. private _sphere;
  66846. private _dataFetched;
  66847. /**
  66848. * Initializes the physics gravitational field event
  66849. * @param _physicsHelper A physics helper
  66850. * @param _scene BabylonJS scene
  66851. * @param _origin The origin position of the gravitational field event
  66852. * @param _options The options for the vortex event
  66853. */
  66854. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66855. /**
  66856. * Returns the data related to the gravitational field event (sphere).
  66857. * @returns A gravitational field event
  66858. */
  66859. getData(): PhysicsGravitationalFieldEventData;
  66860. /**
  66861. * Enables the gravitational field.
  66862. */
  66863. enable(): void;
  66864. /**
  66865. * Disables the gravitational field.
  66866. */
  66867. disable(): void;
  66868. /**
  66869. * Disposes the sphere.
  66870. * @param force The force to dispose from the gravitational field event
  66871. */
  66872. dispose(force?: boolean): void;
  66873. private _tick;
  66874. }
  66875. /**
  66876. * Represents a physics updraft event
  66877. */
  66878. class PhysicsUpdraftEvent {
  66879. private _scene;
  66880. private _origin;
  66881. private _options;
  66882. private _physicsEngine;
  66883. private _originTop;
  66884. private _originDirection;
  66885. private _tickCallback;
  66886. private _cylinder;
  66887. private _cylinderPosition;
  66888. private _dataFetched;
  66889. /**
  66890. * Initializes the physics updraft event
  66891. * @param _scene BabylonJS scene
  66892. * @param _origin The origin position of the updraft
  66893. * @param _options The options for the updraft event
  66894. */
  66895. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66896. /**
  66897. * Returns the data related to the updraft event (cylinder).
  66898. * @returns A physics updraft event
  66899. */
  66900. getData(): PhysicsUpdraftEventData;
  66901. /**
  66902. * Enables the updraft.
  66903. */
  66904. enable(): void;
  66905. /**
  66906. * Disables the updraft.
  66907. */
  66908. disable(): void;
  66909. /**
  66910. * Disposes the cylinder.
  66911. * @param force Specifies if the updraft should be disposed by force
  66912. */
  66913. dispose(force?: boolean): void;
  66914. private getImpostorHitData;
  66915. private _tick;
  66916. /*** Helpers ***/
  66917. private _prepareCylinder;
  66918. private _intersectsWithCylinder;
  66919. }
  66920. /**
  66921. * Represents a physics vortex event
  66922. */
  66923. class PhysicsVortexEvent {
  66924. private _scene;
  66925. private _origin;
  66926. private _options;
  66927. private _physicsEngine;
  66928. private _originTop;
  66929. private _tickCallback;
  66930. private _cylinder;
  66931. private _cylinderPosition;
  66932. private _dataFetched;
  66933. /**
  66934. * Initializes the physics vortex event
  66935. * @param _scene The BabylonJS scene
  66936. * @param _origin The origin position of the vortex
  66937. * @param _options The options for the vortex event
  66938. */
  66939. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66940. /**
  66941. * Returns the data related to the vortex event (cylinder).
  66942. * @returns The physics vortex event data
  66943. */
  66944. getData(): PhysicsVortexEventData;
  66945. /**
  66946. * Enables the vortex.
  66947. */
  66948. enable(): void;
  66949. /**
  66950. * Disables the cortex.
  66951. */
  66952. disable(): void;
  66953. /**
  66954. * Disposes the sphere.
  66955. * @param force
  66956. */
  66957. dispose(force?: boolean): void;
  66958. private getImpostorHitData;
  66959. private _tick;
  66960. /*** Helpers ***/
  66961. private _prepareCylinder;
  66962. private _intersectsWithCylinder;
  66963. }
  66964. /**
  66965. * Options fot the radial explosion event
  66966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66967. */
  66968. export class PhysicsRadialExplosionEventOptions {
  66969. /**
  66970. * The radius of the sphere for the radial explosion.
  66971. */
  66972. radius: number;
  66973. /**
  66974. * The strenth of the explosion.
  66975. */
  66976. strength: number;
  66977. /**
  66978. * The strenght of the force in correspondence to the distance of the affected object
  66979. */
  66980. falloff: PhysicsRadialImpulseFalloff;
  66981. /**
  66982. * Sphere options for the radial explosion.
  66983. */
  66984. sphere: {
  66985. segments: number;
  66986. diameter: number;
  66987. };
  66988. /**
  66989. * Sphere options for the radial explosion.
  66990. */
  66991. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66992. }
  66993. /**
  66994. * Options fot the updraft event
  66995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66996. */
  66997. export class PhysicsUpdraftEventOptions {
  66998. /**
  66999. * The radius of the cylinder for the vortex
  67000. */
  67001. radius: number;
  67002. /**
  67003. * The strenth of the updraft.
  67004. */
  67005. strength: number;
  67006. /**
  67007. * The height of the cylinder for the updraft.
  67008. */
  67009. height: number;
  67010. /**
  67011. * The mode for the the updraft.
  67012. */
  67013. updraftMode: PhysicsUpdraftMode;
  67014. }
  67015. /**
  67016. * Options fot the vortex event
  67017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67018. */
  67019. export class PhysicsVortexEventOptions {
  67020. /**
  67021. * The radius of the cylinder for the vortex
  67022. */
  67023. radius: number;
  67024. /**
  67025. * The strenth of the vortex.
  67026. */
  67027. strength: number;
  67028. /**
  67029. * The height of the cylinder for the vortex.
  67030. */
  67031. height: number;
  67032. /**
  67033. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67034. */
  67035. centripetalForceThreshold: number;
  67036. /**
  67037. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67038. */
  67039. centripetalForceMultiplier: number;
  67040. /**
  67041. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67042. */
  67043. centrifugalForceMultiplier: number;
  67044. /**
  67045. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67046. */
  67047. updraftForceMultiplier: number;
  67048. }
  67049. /**
  67050. * The strenght of the force in correspondence to the distance of the affected object
  67051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67052. */
  67053. export enum PhysicsRadialImpulseFalloff {
  67054. /** Defines that impulse is constant in strength across it's whole radius */
  67055. Constant = 0,
  67056. /** Defines that impulse gets weaker if it's further from the origin */
  67057. Linear = 1
  67058. }
  67059. /**
  67060. * The strength of the force in correspondence to the distance of the affected object
  67061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67062. */
  67063. export enum PhysicsUpdraftMode {
  67064. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67065. Center = 0,
  67066. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67067. Perpendicular = 1
  67068. }
  67069. /**
  67070. * Interface for a physics hit data
  67071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67072. */
  67073. export interface PhysicsHitData {
  67074. /**
  67075. * The force applied at the contact point
  67076. */
  67077. force: Vector3;
  67078. /**
  67079. * The contact point
  67080. */
  67081. contactPoint: Vector3;
  67082. /**
  67083. * The distance from the origin to the contact point
  67084. */
  67085. distanceFromOrigin: number;
  67086. }
  67087. /**
  67088. * Interface for radial explosion event data
  67089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67090. */
  67091. export interface PhysicsRadialExplosionEventData {
  67092. /**
  67093. * A sphere used for the radial explosion event
  67094. */
  67095. sphere: Mesh;
  67096. }
  67097. /**
  67098. * Interface for gravitational field event data
  67099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67100. */
  67101. export interface PhysicsGravitationalFieldEventData {
  67102. /**
  67103. * A sphere mesh used for the gravitational field event
  67104. */
  67105. sphere: Mesh;
  67106. }
  67107. /**
  67108. * Interface for updraft event data
  67109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67110. */
  67111. export interface PhysicsUpdraftEventData {
  67112. /**
  67113. * A cylinder used for the updraft event
  67114. */
  67115. cylinder: Mesh;
  67116. }
  67117. /**
  67118. * Interface for vortex event data
  67119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67120. */
  67121. export interface PhysicsVortexEventData {
  67122. /**
  67123. * A cylinder used for the vortex event
  67124. */
  67125. cylinder: Mesh;
  67126. }
  67127. /**
  67128. * Interface for an affected physics impostor
  67129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67130. */
  67131. export interface PhysicsAffectedImpostorWithData {
  67132. /**
  67133. * The impostor affected by the effect
  67134. */
  67135. impostor: PhysicsImpostor;
  67136. /**
  67137. * The data about the hit/horce from the explosion
  67138. */
  67139. hitData: PhysicsHitData;
  67140. }
  67141. }
  67142. declare module "babylonjs/Physics/Plugins/index" {
  67143. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67144. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67145. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67146. }
  67147. declare module "babylonjs/Physics/index" {
  67148. export * from "babylonjs/Physics/IPhysicsEngine";
  67149. export * from "babylonjs/Physics/physicsEngine";
  67150. export * from "babylonjs/Physics/physicsEngineComponent";
  67151. export * from "babylonjs/Physics/physicsHelper";
  67152. export * from "babylonjs/Physics/physicsImpostor";
  67153. export * from "babylonjs/Physics/physicsJoint";
  67154. export * from "babylonjs/Physics/Plugins/index";
  67155. }
  67156. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67157. /** @hidden */
  67158. export var blackAndWhitePixelShader: {
  67159. name: string;
  67160. shader: string;
  67161. };
  67162. }
  67163. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67164. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67165. import { Camera } from "babylonjs/Cameras/camera";
  67166. import { Engine } from "babylonjs/Engines/engine";
  67167. import "babylonjs/Shaders/blackAndWhite.fragment";
  67168. /**
  67169. * Post process used to render in black and white
  67170. */
  67171. export class BlackAndWhitePostProcess extends PostProcess {
  67172. /**
  67173. * Linear about to convert he result to black and white (default: 1)
  67174. */
  67175. degree: number;
  67176. /**
  67177. * Creates a black and white post process
  67178. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67179. * @param name The name of the effect.
  67180. * @param options The required width/height ratio to downsize to before computing the render pass.
  67181. * @param camera The camera to apply the render pass to.
  67182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67183. * @param engine The engine which the post process will be applied. (default: current engine)
  67184. * @param reusable If the post process can be reused on the same frame. (default: false)
  67185. */
  67186. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67187. }
  67188. }
  67189. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67190. import { Nullable } from "babylonjs/types";
  67191. import { Camera } from "babylonjs/Cameras/camera";
  67192. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67193. import { Engine } from "babylonjs/Engines/engine";
  67194. /**
  67195. * This represents a set of one or more post processes in Babylon.
  67196. * A post process can be used to apply a shader to a texture after it is rendered.
  67197. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67198. */
  67199. export class PostProcessRenderEffect {
  67200. private _postProcesses;
  67201. private _getPostProcesses;
  67202. private _singleInstance;
  67203. private _cameras;
  67204. private _indicesForCamera;
  67205. /**
  67206. * Name of the effect
  67207. * @hidden
  67208. */
  67209. _name: string;
  67210. /**
  67211. * Instantiates a post process render effect.
  67212. * A post process can be used to apply a shader to a texture after it is rendered.
  67213. * @param engine The engine the effect is tied to
  67214. * @param name The name of the effect
  67215. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67216. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67217. */
  67218. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67219. /**
  67220. * Checks if all the post processes in the effect are supported.
  67221. */
  67222. get isSupported(): boolean;
  67223. /**
  67224. * Updates the current state of the effect
  67225. * @hidden
  67226. */
  67227. _update(): void;
  67228. /**
  67229. * Attaches the effect on cameras
  67230. * @param cameras The camera to attach to.
  67231. * @hidden
  67232. */
  67233. _attachCameras(cameras: Camera): void;
  67234. /**
  67235. * Attaches the effect on cameras
  67236. * @param cameras The camera to attach to.
  67237. * @hidden
  67238. */
  67239. _attachCameras(cameras: Camera[]): void;
  67240. /**
  67241. * Detaches the effect on cameras
  67242. * @param cameras The camera to detatch from.
  67243. * @hidden
  67244. */
  67245. _detachCameras(cameras: Camera): void;
  67246. /**
  67247. * Detatches the effect on cameras
  67248. * @param cameras The camera to detatch from.
  67249. * @hidden
  67250. */
  67251. _detachCameras(cameras: Camera[]): void;
  67252. /**
  67253. * Enables the effect on given cameras
  67254. * @param cameras The camera to enable.
  67255. * @hidden
  67256. */
  67257. _enable(cameras: Camera): void;
  67258. /**
  67259. * Enables the effect on given cameras
  67260. * @param cameras The camera to enable.
  67261. * @hidden
  67262. */
  67263. _enable(cameras: Nullable<Camera[]>): void;
  67264. /**
  67265. * Disables the effect on the given cameras
  67266. * @param cameras The camera to disable.
  67267. * @hidden
  67268. */
  67269. _disable(cameras: Camera): void;
  67270. /**
  67271. * Disables the effect on the given cameras
  67272. * @param cameras The camera to disable.
  67273. * @hidden
  67274. */
  67275. _disable(cameras: Nullable<Camera[]>): void;
  67276. /**
  67277. * Gets a list of the post processes contained in the effect.
  67278. * @param camera The camera to get the post processes on.
  67279. * @returns The list of the post processes in the effect.
  67280. */
  67281. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67282. }
  67283. }
  67284. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67285. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67286. /** @hidden */
  67287. export var extractHighlightsPixelShader: {
  67288. name: string;
  67289. shader: string;
  67290. };
  67291. }
  67292. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67293. import { Nullable } from "babylonjs/types";
  67294. import { Camera } from "babylonjs/Cameras/camera";
  67295. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67296. import { Engine } from "babylonjs/Engines/engine";
  67297. import "babylonjs/Shaders/extractHighlights.fragment";
  67298. /**
  67299. * 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.
  67300. */
  67301. export class ExtractHighlightsPostProcess extends PostProcess {
  67302. /**
  67303. * The luminance threshold, pixels below this value will be set to black.
  67304. */
  67305. threshold: number;
  67306. /** @hidden */
  67307. _exposure: number;
  67308. /**
  67309. * Post process which has the input texture to be used when performing highlight extraction
  67310. * @hidden
  67311. */
  67312. _inputPostProcess: Nullable<PostProcess>;
  67313. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67314. }
  67315. }
  67316. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67317. /** @hidden */
  67318. export var bloomMergePixelShader: {
  67319. name: string;
  67320. shader: string;
  67321. };
  67322. }
  67323. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67324. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67325. import { Nullable } from "babylonjs/types";
  67326. import { Engine } from "babylonjs/Engines/engine";
  67327. import { Camera } from "babylonjs/Cameras/camera";
  67328. import "babylonjs/Shaders/bloomMerge.fragment";
  67329. /**
  67330. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67331. */
  67332. export class BloomMergePostProcess extends PostProcess {
  67333. /** Weight of the bloom to be added to the original input. */
  67334. weight: number;
  67335. /**
  67336. * Creates a new instance of @see BloomMergePostProcess
  67337. * @param name The name of the effect.
  67338. * @param originalFromInput Post process which's input will be used for the merge.
  67339. * @param blurred Blurred highlights post process which's output will be used.
  67340. * @param weight Weight of the bloom to be added to the original input.
  67341. * @param options The required width/height ratio to downsize to before computing the render pass.
  67342. * @param camera The camera to apply the render pass to.
  67343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67344. * @param engine The engine which the post process will be applied. (default: current engine)
  67345. * @param reusable If the post process can be reused on the same frame. (default: false)
  67346. * @param textureType Type of textures used when performing the post process. (default: 0)
  67347. * @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)
  67348. */
  67349. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67350. /** Weight of the bloom to be added to the original input. */
  67351. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67352. }
  67353. }
  67354. declare module "babylonjs/PostProcesses/bloomEffect" {
  67355. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67356. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67357. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67358. import { Camera } from "babylonjs/Cameras/camera";
  67359. import { Scene } from "babylonjs/scene";
  67360. /**
  67361. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67362. */
  67363. export class BloomEffect extends PostProcessRenderEffect {
  67364. private bloomScale;
  67365. /**
  67366. * @hidden Internal
  67367. */
  67368. _effects: Array<PostProcess>;
  67369. /**
  67370. * @hidden Internal
  67371. */
  67372. _downscale: ExtractHighlightsPostProcess;
  67373. private _blurX;
  67374. private _blurY;
  67375. private _merge;
  67376. /**
  67377. * The luminance threshold to find bright areas of the image to bloom.
  67378. */
  67379. get threshold(): number;
  67380. set threshold(value: number);
  67381. /**
  67382. * The strength of the bloom.
  67383. */
  67384. get weight(): number;
  67385. set weight(value: number);
  67386. /**
  67387. * Specifies the size of the bloom blur kernel, relative to the final output size
  67388. */
  67389. get kernel(): number;
  67390. set kernel(value: number);
  67391. /**
  67392. * Creates a new instance of @see BloomEffect
  67393. * @param scene The scene the effect belongs to.
  67394. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67395. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67396. * @param bloomWeight The the strength of bloom.
  67397. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67398. * @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)
  67399. */
  67400. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67401. /**
  67402. * Disposes each of the internal effects for a given camera.
  67403. * @param camera The camera to dispose the effect on.
  67404. */
  67405. disposeEffects(camera: Camera): void;
  67406. /**
  67407. * @hidden Internal
  67408. */
  67409. _updateEffects(): void;
  67410. /**
  67411. * Internal
  67412. * @returns if all the contained post processes are ready.
  67413. * @hidden
  67414. */
  67415. _isReady(): boolean;
  67416. }
  67417. }
  67418. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67419. /** @hidden */
  67420. export var chromaticAberrationPixelShader: {
  67421. name: string;
  67422. shader: string;
  67423. };
  67424. }
  67425. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67426. import { Vector2 } from "babylonjs/Maths/math.vector";
  67427. import { Nullable } from "babylonjs/types";
  67428. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67429. import { Camera } from "babylonjs/Cameras/camera";
  67430. import { Engine } from "babylonjs/Engines/engine";
  67431. import "babylonjs/Shaders/chromaticAberration.fragment";
  67432. /**
  67433. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67434. */
  67435. export class ChromaticAberrationPostProcess extends PostProcess {
  67436. /**
  67437. * The amount of seperation of rgb channels (default: 30)
  67438. */
  67439. aberrationAmount: number;
  67440. /**
  67441. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67442. */
  67443. radialIntensity: number;
  67444. /**
  67445. * 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))
  67446. */
  67447. direction: Vector2;
  67448. /**
  67449. * 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))
  67450. */
  67451. centerPosition: Vector2;
  67452. /**
  67453. * Creates a new instance ChromaticAberrationPostProcess
  67454. * @param name The name of the effect.
  67455. * @param screenWidth The width of the screen to apply the effect on.
  67456. * @param screenHeight The height of the screen to apply the effect on.
  67457. * @param options The required width/height ratio to downsize to before computing the render pass.
  67458. * @param camera The camera to apply the render pass to.
  67459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67460. * @param engine The engine which the post process will be applied. (default: current engine)
  67461. * @param reusable If the post process can be reused on the same frame. (default: false)
  67462. * @param textureType Type of textures used when performing the post process. (default: 0)
  67463. * @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)
  67464. */
  67465. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67466. }
  67467. }
  67468. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67469. /** @hidden */
  67470. export var circleOfConfusionPixelShader: {
  67471. name: string;
  67472. shader: string;
  67473. };
  67474. }
  67475. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67476. import { Nullable } from "babylonjs/types";
  67477. import { Engine } from "babylonjs/Engines/engine";
  67478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67480. import { Camera } from "babylonjs/Cameras/camera";
  67481. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67482. /**
  67483. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67484. */
  67485. export class CircleOfConfusionPostProcess extends PostProcess {
  67486. /**
  67487. * 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.
  67488. */
  67489. lensSize: number;
  67490. /**
  67491. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67492. */
  67493. fStop: number;
  67494. /**
  67495. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67496. */
  67497. focusDistance: number;
  67498. /**
  67499. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67500. */
  67501. focalLength: number;
  67502. private _depthTexture;
  67503. /**
  67504. * Creates a new instance CircleOfConfusionPostProcess
  67505. * @param name The name of the effect.
  67506. * @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.
  67507. * @param options The required width/height ratio to downsize to before computing the render pass.
  67508. * @param camera The camera to apply the render pass to.
  67509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67510. * @param engine The engine which the post process will be applied. (default: current engine)
  67511. * @param reusable If the post process can be reused on the same frame. (default: false)
  67512. * @param textureType Type of textures used when performing the post process. (default: 0)
  67513. * @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)
  67514. */
  67515. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67516. /**
  67517. * 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.
  67518. */
  67519. set depthTexture(value: RenderTargetTexture);
  67520. }
  67521. }
  67522. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67523. /** @hidden */
  67524. export var colorCorrectionPixelShader: {
  67525. name: string;
  67526. shader: string;
  67527. };
  67528. }
  67529. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67530. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67531. import { Engine } from "babylonjs/Engines/engine";
  67532. import { Camera } from "babylonjs/Cameras/camera";
  67533. import "babylonjs/Shaders/colorCorrection.fragment";
  67534. /**
  67535. *
  67536. * This post-process allows the modification of rendered colors by using
  67537. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67538. *
  67539. * The object needs to be provided an url to a texture containing the color
  67540. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67541. * Use an image editing software to tweak the LUT to match your needs.
  67542. *
  67543. * For an example of a color LUT, see here:
  67544. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67545. * For explanations on color grading, see here:
  67546. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67547. *
  67548. */
  67549. export class ColorCorrectionPostProcess extends PostProcess {
  67550. private _colorTableTexture;
  67551. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67552. }
  67553. }
  67554. declare module "babylonjs/Shaders/convolution.fragment" {
  67555. /** @hidden */
  67556. export var convolutionPixelShader: {
  67557. name: string;
  67558. shader: string;
  67559. };
  67560. }
  67561. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67562. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67563. import { Nullable } from "babylonjs/types";
  67564. import { Camera } from "babylonjs/Cameras/camera";
  67565. import { Engine } from "babylonjs/Engines/engine";
  67566. import "babylonjs/Shaders/convolution.fragment";
  67567. /**
  67568. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67569. * input texture to perform effects such as edge detection or sharpening
  67570. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67571. */
  67572. export class ConvolutionPostProcess extends PostProcess {
  67573. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67574. kernel: number[];
  67575. /**
  67576. * Creates a new instance ConvolutionPostProcess
  67577. * @param name The name of the effect.
  67578. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67579. * @param options The required width/height ratio to downsize to before computing the render pass.
  67580. * @param camera The camera to apply the render pass to.
  67581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67582. * @param engine The engine which the post process will be applied. (default: current engine)
  67583. * @param reusable If the post process can be reused on the same frame. (default: false)
  67584. * @param textureType Type of textures used when performing the post process. (default: 0)
  67585. */
  67586. constructor(name: string,
  67587. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67588. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67589. /**
  67590. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67591. */
  67592. static EdgeDetect0Kernel: number[];
  67593. /**
  67594. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67595. */
  67596. static EdgeDetect1Kernel: number[];
  67597. /**
  67598. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67599. */
  67600. static EdgeDetect2Kernel: number[];
  67601. /**
  67602. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67603. */
  67604. static SharpenKernel: number[];
  67605. /**
  67606. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67607. */
  67608. static EmbossKernel: number[];
  67609. /**
  67610. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67611. */
  67612. static GaussianKernel: number[];
  67613. }
  67614. }
  67615. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67616. import { Nullable } from "babylonjs/types";
  67617. import { Vector2 } from "babylonjs/Maths/math.vector";
  67618. import { Camera } from "babylonjs/Cameras/camera";
  67619. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67620. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67621. import { Engine } from "babylonjs/Engines/engine";
  67622. import { Scene } from "babylonjs/scene";
  67623. /**
  67624. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67625. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67626. * based on samples that have a large difference in distance than the center pixel.
  67627. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67628. */
  67629. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67630. direction: Vector2;
  67631. /**
  67632. * Creates a new instance CircleOfConfusionPostProcess
  67633. * @param name The name of the effect.
  67634. * @param scene The scene the effect belongs to.
  67635. * @param direction The direction the blur should be applied.
  67636. * @param kernel The size of the kernel used to blur.
  67637. * @param options The required width/height ratio to downsize to before computing the render pass.
  67638. * @param camera The camera to apply the render pass to.
  67639. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67640. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67642. * @param engine The engine which the post process will be applied. (default: current engine)
  67643. * @param reusable If the post process can be reused on the same frame. (default: false)
  67644. * @param textureType Type of textures used when performing the post process. (default: 0)
  67645. * @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)
  67646. */
  67647. 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);
  67648. }
  67649. }
  67650. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67651. /** @hidden */
  67652. export var depthOfFieldMergePixelShader: {
  67653. name: string;
  67654. shader: string;
  67655. };
  67656. }
  67657. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67658. import { Nullable } from "babylonjs/types";
  67659. import { Camera } from "babylonjs/Cameras/camera";
  67660. import { Effect } from "babylonjs/Materials/effect";
  67661. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67662. import { Engine } from "babylonjs/Engines/engine";
  67663. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67664. /**
  67665. * Options to be set when merging outputs from the default pipeline.
  67666. */
  67667. export class DepthOfFieldMergePostProcessOptions {
  67668. /**
  67669. * The original image to merge on top of
  67670. */
  67671. originalFromInput: PostProcess;
  67672. /**
  67673. * Parameters to perform the merge of the depth of field effect
  67674. */
  67675. depthOfField?: {
  67676. circleOfConfusion: PostProcess;
  67677. blurSteps: Array<PostProcess>;
  67678. };
  67679. /**
  67680. * Parameters to perform the merge of bloom effect
  67681. */
  67682. bloom?: {
  67683. blurred: PostProcess;
  67684. weight: number;
  67685. };
  67686. }
  67687. /**
  67688. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67689. */
  67690. export class DepthOfFieldMergePostProcess extends PostProcess {
  67691. private blurSteps;
  67692. /**
  67693. * Creates a new instance of DepthOfFieldMergePostProcess
  67694. * @param name The name of the effect.
  67695. * @param originalFromInput Post process which's input will be used for the merge.
  67696. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67697. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67698. * @param options The required width/height ratio to downsize to before computing the render pass.
  67699. * @param camera The camera to apply the render pass to.
  67700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67701. * @param engine The engine which the post process will be applied. (default: current engine)
  67702. * @param reusable If the post process can be reused on the same frame. (default: false)
  67703. * @param textureType Type of textures used when performing the post process. (default: 0)
  67704. * @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)
  67705. */
  67706. 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);
  67707. /**
  67708. * Updates the effect with the current post process compile time values and recompiles the shader.
  67709. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67710. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67711. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67712. * @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
  67713. * @param onCompiled Called when the shader has been compiled.
  67714. * @param onError Called if there is an error when compiling a shader.
  67715. */
  67716. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67717. }
  67718. }
  67719. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67720. import { Nullable } from "babylonjs/types";
  67721. import { Camera } from "babylonjs/Cameras/camera";
  67722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67724. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67725. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67726. import { Scene } from "babylonjs/scene";
  67727. /**
  67728. * Specifies the level of max blur that should be applied when using the depth of field effect
  67729. */
  67730. export enum DepthOfFieldEffectBlurLevel {
  67731. /**
  67732. * Subtle blur
  67733. */
  67734. Low = 0,
  67735. /**
  67736. * Medium blur
  67737. */
  67738. Medium = 1,
  67739. /**
  67740. * Large blur
  67741. */
  67742. High = 2
  67743. }
  67744. /**
  67745. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67746. */
  67747. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67748. private _circleOfConfusion;
  67749. /**
  67750. * @hidden Internal, blurs from high to low
  67751. */
  67752. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67753. private _depthOfFieldBlurY;
  67754. private _dofMerge;
  67755. /**
  67756. * @hidden Internal post processes in depth of field effect
  67757. */
  67758. _effects: Array<PostProcess>;
  67759. /**
  67760. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67761. */
  67762. set focalLength(value: number);
  67763. get focalLength(): number;
  67764. /**
  67765. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67766. */
  67767. set fStop(value: number);
  67768. get fStop(): number;
  67769. /**
  67770. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67771. */
  67772. set focusDistance(value: number);
  67773. get focusDistance(): number;
  67774. /**
  67775. * 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.
  67776. */
  67777. set lensSize(value: number);
  67778. get lensSize(): number;
  67779. /**
  67780. * Creates a new instance DepthOfFieldEffect
  67781. * @param scene The scene the effect belongs to.
  67782. * @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.
  67783. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67784. * @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)
  67785. */
  67786. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67787. /**
  67788. * Get the current class name of the current effet
  67789. * @returns "DepthOfFieldEffect"
  67790. */
  67791. getClassName(): string;
  67792. /**
  67793. * 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.
  67794. */
  67795. set depthTexture(value: RenderTargetTexture);
  67796. /**
  67797. * Disposes each of the internal effects for a given camera.
  67798. * @param camera The camera to dispose the effect on.
  67799. */
  67800. disposeEffects(camera: Camera): void;
  67801. /**
  67802. * @hidden Internal
  67803. */
  67804. _updateEffects(): void;
  67805. /**
  67806. * Internal
  67807. * @returns if all the contained post processes are ready.
  67808. * @hidden
  67809. */
  67810. _isReady(): boolean;
  67811. }
  67812. }
  67813. declare module "babylonjs/Shaders/displayPass.fragment" {
  67814. /** @hidden */
  67815. export var displayPassPixelShader: {
  67816. name: string;
  67817. shader: string;
  67818. };
  67819. }
  67820. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67821. import { Nullable } from "babylonjs/types";
  67822. import { Camera } from "babylonjs/Cameras/camera";
  67823. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67824. import { Engine } from "babylonjs/Engines/engine";
  67825. import "babylonjs/Shaders/displayPass.fragment";
  67826. /**
  67827. * DisplayPassPostProcess which produces an output the same as it's input
  67828. */
  67829. export class DisplayPassPostProcess extends PostProcess {
  67830. /**
  67831. * Creates the DisplayPassPostProcess
  67832. * @param name The name of the effect.
  67833. * @param options The required width/height ratio to downsize to before computing the render pass.
  67834. * @param camera The camera to apply the render pass to.
  67835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67836. * @param engine The engine which the post process will be applied. (default: current engine)
  67837. * @param reusable If the post process can be reused on the same frame. (default: false)
  67838. */
  67839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67840. }
  67841. }
  67842. declare module "babylonjs/Shaders/filter.fragment" {
  67843. /** @hidden */
  67844. export var filterPixelShader: {
  67845. name: string;
  67846. shader: string;
  67847. };
  67848. }
  67849. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67850. import { Nullable } from "babylonjs/types";
  67851. import { Matrix } from "babylonjs/Maths/math.vector";
  67852. import { Camera } from "babylonjs/Cameras/camera";
  67853. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67854. import { Engine } from "babylonjs/Engines/engine";
  67855. import "babylonjs/Shaders/filter.fragment";
  67856. /**
  67857. * Applies a kernel filter to the image
  67858. */
  67859. export class FilterPostProcess extends PostProcess {
  67860. /** The matrix to be applied to the image */
  67861. kernelMatrix: Matrix;
  67862. /**
  67863. *
  67864. * @param name The name of the effect.
  67865. * @param kernelMatrix The matrix to be applied to the image
  67866. * @param options The required width/height ratio to downsize to before computing the render pass.
  67867. * @param camera The camera to apply the render pass to.
  67868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67869. * @param engine The engine which the post process will be applied. (default: current engine)
  67870. * @param reusable If the post process can be reused on the same frame. (default: false)
  67871. */
  67872. constructor(name: string,
  67873. /** The matrix to be applied to the image */
  67874. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67875. }
  67876. }
  67877. declare module "babylonjs/Shaders/fxaa.fragment" {
  67878. /** @hidden */
  67879. export var fxaaPixelShader: {
  67880. name: string;
  67881. shader: string;
  67882. };
  67883. }
  67884. declare module "babylonjs/Shaders/fxaa.vertex" {
  67885. /** @hidden */
  67886. export var fxaaVertexShader: {
  67887. name: string;
  67888. shader: string;
  67889. };
  67890. }
  67891. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67892. import { Nullable } from "babylonjs/types";
  67893. import { Camera } from "babylonjs/Cameras/camera";
  67894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67895. import { Engine } from "babylonjs/Engines/engine";
  67896. import "babylonjs/Shaders/fxaa.fragment";
  67897. import "babylonjs/Shaders/fxaa.vertex";
  67898. /**
  67899. * Fxaa post process
  67900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67901. */
  67902. export class FxaaPostProcess extends PostProcess {
  67903. /** @hidden */
  67904. texelWidth: number;
  67905. /** @hidden */
  67906. texelHeight: number;
  67907. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67908. private _getDefines;
  67909. }
  67910. }
  67911. declare module "babylonjs/Shaders/grain.fragment" {
  67912. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67913. /** @hidden */
  67914. export var grainPixelShader: {
  67915. name: string;
  67916. shader: string;
  67917. };
  67918. }
  67919. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67920. import { Nullable } from "babylonjs/types";
  67921. import { Camera } from "babylonjs/Cameras/camera";
  67922. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67923. import { Engine } from "babylonjs/Engines/engine";
  67924. import "babylonjs/Shaders/grain.fragment";
  67925. /**
  67926. * The GrainPostProcess adds noise to the image at mid luminance levels
  67927. */
  67928. export class GrainPostProcess extends PostProcess {
  67929. /**
  67930. * The intensity of the grain added (default: 30)
  67931. */
  67932. intensity: number;
  67933. /**
  67934. * If the grain should be randomized on every frame
  67935. */
  67936. animated: boolean;
  67937. /**
  67938. * Creates a new instance of @see GrainPostProcess
  67939. * @param name The name of the effect.
  67940. * @param options The required width/height ratio to downsize to before computing the render pass.
  67941. * @param camera The camera to apply the render pass to.
  67942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67943. * @param engine The engine which the post process will be applied. (default: current engine)
  67944. * @param reusable If the post process can be reused on the same frame. (default: false)
  67945. * @param textureType Type of textures used when performing the post process. (default: 0)
  67946. * @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)
  67947. */
  67948. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67949. }
  67950. }
  67951. declare module "babylonjs/Shaders/highlights.fragment" {
  67952. /** @hidden */
  67953. export var highlightsPixelShader: {
  67954. name: string;
  67955. shader: string;
  67956. };
  67957. }
  67958. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67959. import { Nullable } from "babylonjs/types";
  67960. import { Camera } from "babylonjs/Cameras/camera";
  67961. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67962. import { Engine } from "babylonjs/Engines/engine";
  67963. import "babylonjs/Shaders/highlights.fragment";
  67964. /**
  67965. * Extracts highlights from the image
  67966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67967. */
  67968. export class HighlightsPostProcess extends PostProcess {
  67969. /**
  67970. * Extracts highlights from the image
  67971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67972. * @param name The name of the effect.
  67973. * @param options The required width/height ratio to downsize to before computing the render pass.
  67974. * @param camera The camera to apply the render pass to.
  67975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67976. * @param engine The engine which the post process will be applied. (default: current engine)
  67977. * @param reusable If the post process can be reused on the same frame. (default: false)
  67978. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67979. */
  67980. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67981. }
  67982. }
  67983. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67984. /** @hidden */
  67985. export var mrtFragmentDeclaration: {
  67986. name: string;
  67987. shader: string;
  67988. };
  67989. }
  67990. declare module "babylonjs/Shaders/geometry.fragment" {
  67991. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67992. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67993. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67994. /** @hidden */
  67995. export var geometryPixelShader: {
  67996. name: string;
  67997. shader: string;
  67998. };
  67999. }
  68000. declare module "babylonjs/Shaders/geometry.vertex" {
  68001. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68002. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68003. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68005. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68006. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68007. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68008. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68009. /** @hidden */
  68010. export var geometryVertexShader: {
  68011. name: string;
  68012. shader: string;
  68013. };
  68014. }
  68015. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68016. import { Matrix } from "babylonjs/Maths/math.vector";
  68017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68018. import { Mesh } from "babylonjs/Meshes/mesh";
  68019. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68020. import { Effect } from "babylonjs/Materials/effect";
  68021. import { Scene } from "babylonjs/scene";
  68022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68023. import "babylonjs/Shaders/geometry.fragment";
  68024. import "babylonjs/Shaders/geometry.vertex";
  68025. /** @hidden */
  68026. interface ISavedTransformationMatrix {
  68027. world: Matrix;
  68028. viewProjection: Matrix;
  68029. }
  68030. /**
  68031. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68032. */
  68033. export class GeometryBufferRenderer {
  68034. /**
  68035. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68036. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68037. */
  68038. static readonly POSITION_TEXTURE_TYPE: number;
  68039. /**
  68040. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68041. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68042. */
  68043. static readonly VELOCITY_TEXTURE_TYPE: number;
  68044. /**
  68045. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68046. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68047. */
  68048. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68049. /**
  68050. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68051. * in order to compute objects velocities when enableVelocity is set to "true"
  68052. * @hidden
  68053. */
  68054. _previousTransformationMatrices: {
  68055. [index: number]: ISavedTransformationMatrix;
  68056. };
  68057. /**
  68058. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68059. * in order to compute objects velocities when enableVelocity is set to "true"
  68060. * @hidden
  68061. */
  68062. _previousBonesTransformationMatrices: {
  68063. [index: number]: Float32Array;
  68064. };
  68065. /**
  68066. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68067. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68068. */
  68069. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68070. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68071. renderTransparentMeshes: boolean;
  68072. private _scene;
  68073. private _multiRenderTarget;
  68074. private _ratio;
  68075. private _enablePosition;
  68076. private _enableVelocity;
  68077. private _enableReflectivity;
  68078. private _positionIndex;
  68079. private _velocityIndex;
  68080. private _reflectivityIndex;
  68081. protected _effect: Effect;
  68082. protected _cachedDefines: string;
  68083. /**
  68084. * Set the render list (meshes to be rendered) used in the G buffer.
  68085. */
  68086. set renderList(meshes: Mesh[]);
  68087. /**
  68088. * Gets wether or not G buffer are supported by the running hardware.
  68089. * This requires draw buffer supports
  68090. */
  68091. get isSupported(): boolean;
  68092. /**
  68093. * Returns the index of the given texture type in the G-Buffer textures array
  68094. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68095. * @returns the index of the given texture type in the G-Buffer textures array
  68096. */
  68097. getTextureIndex(textureType: number): number;
  68098. /**
  68099. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68100. */
  68101. get enablePosition(): boolean;
  68102. /**
  68103. * Sets whether or not objects positions are enabled for the G buffer.
  68104. */
  68105. set enablePosition(enable: boolean);
  68106. /**
  68107. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68108. */
  68109. get enableVelocity(): boolean;
  68110. /**
  68111. * Sets wether or not objects velocities are enabled for the G buffer.
  68112. */
  68113. set enableVelocity(enable: boolean);
  68114. /**
  68115. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68116. */
  68117. get enableReflectivity(): boolean;
  68118. /**
  68119. * Sets wether or not objects roughness are enabled for the G buffer.
  68120. */
  68121. set enableReflectivity(enable: boolean);
  68122. /**
  68123. * Gets the scene associated with the buffer.
  68124. */
  68125. get scene(): Scene;
  68126. /**
  68127. * Gets the ratio used by the buffer during its creation.
  68128. * How big is the buffer related to the main canvas.
  68129. */
  68130. get ratio(): number;
  68131. /** @hidden */
  68132. static _SceneComponentInitialization: (scene: Scene) => void;
  68133. /**
  68134. * Creates a new G Buffer for the scene
  68135. * @param scene The scene the buffer belongs to
  68136. * @param ratio How big is the buffer related to the main canvas.
  68137. */
  68138. constructor(scene: Scene, ratio?: number);
  68139. /**
  68140. * Checks wether everything is ready to render a submesh to the G buffer.
  68141. * @param subMesh the submesh to check readiness for
  68142. * @param useInstances is the mesh drawn using instance or not
  68143. * @returns true if ready otherwise false
  68144. */
  68145. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68146. /**
  68147. * Gets the current underlying G Buffer.
  68148. * @returns the buffer
  68149. */
  68150. getGBuffer(): MultiRenderTarget;
  68151. /**
  68152. * Gets the number of samples used to render the buffer (anti aliasing).
  68153. */
  68154. get samples(): number;
  68155. /**
  68156. * Sets the number of samples used to render the buffer (anti aliasing).
  68157. */
  68158. set samples(value: number);
  68159. /**
  68160. * Disposes the renderer and frees up associated resources.
  68161. */
  68162. dispose(): void;
  68163. protected _createRenderTargets(): void;
  68164. private _copyBonesTransformationMatrices;
  68165. }
  68166. }
  68167. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68168. import { Nullable } from "babylonjs/types";
  68169. import { Scene } from "babylonjs/scene";
  68170. import { ISceneComponent } from "babylonjs/sceneComponent";
  68171. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68172. module "babylonjs/scene" {
  68173. interface Scene {
  68174. /** @hidden (Backing field) */
  68175. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68176. /**
  68177. * Gets or Sets the current geometry buffer associated to the scene.
  68178. */
  68179. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68180. /**
  68181. * Enables a GeometryBufferRender and associates it with the scene
  68182. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68183. * @returns the GeometryBufferRenderer
  68184. */
  68185. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68186. /**
  68187. * Disables the GeometryBufferRender associated with the scene
  68188. */
  68189. disableGeometryBufferRenderer(): void;
  68190. }
  68191. }
  68192. /**
  68193. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68194. * in several rendering techniques.
  68195. */
  68196. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68197. /**
  68198. * The component name helpful to identify the component in the list of scene components.
  68199. */
  68200. readonly name: string;
  68201. /**
  68202. * The scene the component belongs to.
  68203. */
  68204. scene: Scene;
  68205. /**
  68206. * Creates a new instance of the component for the given scene
  68207. * @param scene Defines the scene to register the component in
  68208. */
  68209. constructor(scene: Scene);
  68210. /**
  68211. * Registers the component in a given scene
  68212. */
  68213. register(): void;
  68214. /**
  68215. * Rebuilds the elements related to this component in case of
  68216. * context lost for instance.
  68217. */
  68218. rebuild(): void;
  68219. /**
  68220. * Disposes the component and the associated ressources
  68221. */
  68222. dispose(): void;
  68223. private _gatherRenderTargets;
  68224. }
  68225. }
  68226. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68227. /** @hidden */
  68228. export var motionBlurPixelShader: {
  68229. name: string;
  68230. shader: string;
  68231. };
  68232. }
  68233. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68234. import { Nullable } from "babylonjs/types";
  68235. import { Camera } from "babylonjs/Cameras/camera";
  68236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68237. import { Scene } from "babylonjs/scene";
  68238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68239. import "babylonjs/Animations/animatable";
  68240. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68241. import "babylonjs/Shaders/motionBlur.fragment";
  68242. import { Engine } from "babylonjs/Engines/engine";
  68243. /**
  68244. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68245. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68246. * As an example, all you have to do is to create the post-process:
  68247. * var mb = new BABYLON.MotionBlurPostProcess(
  68248. * 'mb', // The name of the effect.
  68249. * scene, // The scene containing the objects to blur according to their velocity.
  68250. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68251. * camera // The camera to apply the render pass to.
  68252. * );
  68253. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68254. */
  68255. export class MotionBlurPostProcess extends PostProcess {
  68256. /**
  68257. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68258. */
  68259. motionStrength: number;
  68260. /**
  68261. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68262. */
  68263. get motionBlurSamples(): number;
  68264. /**
  68265. * Sets the number of iterations to be used for motion blur quality
  68266. */
  68267. set motionBlurSamples(samples: number);
  68268. private _motionBlurSamples;
  68269. private _geometryBufferRenderer;
  68270. /**
  68271. * Creates a new instance MotionBlurPostProcess
  68272. * @param name The name of the effect.
  68273. * @param scene The scene containing the objects to blur according to their velocity.
  68274. * @param options The required width/height ratio to downsize to before computing the render pass.
  68275. * @param camera The camera to apply the render pass to.
  68276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68277. * @param engine The engine which the post process will be applied. (default: current engine)
  68278. * @param reusable If the post process can be reused on the same frame. (default: false)
  68279. * @param textureType Type of textures used when performing the post process. (default: 0)
  68280. * @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)
  68281. */
  68282. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68283. /**
  68284. * Excludes the given skinned mesh from computing bones velocities.
  68285. * 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.
  68286. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68287. */
  68288. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68289. /**
  68290. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68291. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68292. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68293. */
  68294. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68295. /**
  68296. * Disposes the post process.
  68297. * @param camera The camera to dispose the post process on.
  68298. */
  68299. dispose(camera?: Camera): void;
  68300. }
  68301. }
  68302. declare module "babylonjs/Shaders/refraction.fragment" {
  68303. /** @hidden */
  68304. export var refractionPixelShader: {
  68305. name: string;
  68306. shader: string;
  68307. };
  68308. }
  68309. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68310. import { Color3 } from "babylonjs/Maths/math.color";
  68311. import { Camera } from "babylonjs/Cameras/camera";
  68312. import { Texture } from "babylonjs/Materials/Textures/texture";
  68313. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68314. import { Engine } from "babylonjs/Engines/engine";
  68315. import "babylonjs/Shaders/refraction.fragment";
  68316. /**
  68317. * Post process which applies a refractin texture
  68318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68319. */
  68320. export class RefractionPostProcess extends PostProcess {
  68321. /** the base color of the refraction (used to taint the rendering) */
  68322. color: Color3;
  68323. /** simulated refraction depth */
  68324. depth: number;
  68325. /** the coefficient of the base color (0 to remove base color tainting) */
  68326. colorLevel: number;
  68327. private _refTexture;
  68328. private _ownRefractionTexture;
  68329. /**
  68330. * Gets or sets the refraction texture
  68331. * Please note that you are responsible for disposing the texture if you set it manually
  68332. */
  68333. get refractionTexture(): Texture;
  68334. set refractionTexture(value: Texture);
  68335. /**
  68336. * Initializes the RefractionPostProcess
  68337. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68338. * @param name The name of the effect.
  68339. * @param refractionTextureUrl Url of the refraction texture to use
  68340. * @param color the base color of the refraction (used to taint the rendering)
  68341. * @param depth simulated refraction depth
  68342. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68343. * @param camera The camera to apply the render pass to.
  68344. * @param options The required width/height ratio to downsize to before computing the render pass.
  68345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68346. * @param engine The engine which the post process will be applied. (default: current engine)
  68347. * @param reusable If the post process can be reused on the same frame. (default: false)
  68348. */
  68349. constructor(name: string, refractionTextureUrl: string,
  68350. /** the base color of the refraction (used to taint the rendering) */
  68351. color: Color3,
  68352. /** simulated refraction depth */
  68353. depth: number,
  68354. /** the coefficient of the base color (0 to remove base color tainting) */
  68355. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68356. /**
  68357. * Disposes of the post process
  68358. * @param camera Camera to dispose post process on
  68359. */
  68360. dispose(camera: Camera): void;
  68361. }
  68362. }
  68363. declare module "babylonjs/Shaders/sharpen.fragment" {
  68364. /** @hidden */
  68365. export var sharpenPixelShader: {
  68366. name: string;
  68367. shader: string;
  68368. };
  68369. }
  68370. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68371. import { Nullable } from "babylonjs/types";
  68372. import { Camera } from "babylonjs/Cameras/camera";
  68373. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68374. import "babylonjs/Shaders/sharpen.fragment";
  68375. import { Engine } from "babylonjs/Engines/engine";
  68376. /**
  68377. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68378. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68379. */
  68380. export class SharpenPostProcess extends PostProcess {
  68381. /**
  68382. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68383. */
  68384. colorAmount: number;
  68385. /**
  68386. * How much sharpness should be applied (default: 0.3)
  68387. */
  68388. edgeAmount: number;
  68389. /**
  68390. * Creates a new instance ConvolutionPostProcess
  68391. * @param name The name of the effect.
  68392. * @param options The required width/height ratio to downsize to before computing the render pass.
  68393. * @param camera The camera to apply the render pass to.
  68394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68395. * @param engine The engine which the post process will be applied. (default: current engine)
  68396. * @param reusable If the post process can be reused on the same frame. (default: false)
  68397. * @param textureType Type of textures used when performing the post process. (default: 0)
  68398. * @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)
  68399. */
  68400. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68401. }
  68402. }
  68403. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68404. import { Nullable } from "babylonjs/types";
  68405. import { Camera } from "babylonjs/Cameras/camera";
  68406. import { Engine } from "babylonjs/Engines/engine";
  68407. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68408. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68409. /**
  68410. * PostProcessRenderPipeline
  68411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68412. */
  68413. export class PostProcessRenderPipeline {
  68414. private engine;
  68415. private _renderEffects;
  68416. private _renderEffectsForIsolatedPass;
  68417. /**
  68418. * List of inspectable custom properties (used by the Inspector)
  68419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68420. */
  68421. inspectableCustomProperties: IInspectable[];
  68422. /**
  68423. * @hidden
  68424. */
  68425. protected _cameras: Camera[];
  68426. /** @hidden */
  68427. _name: string;
  68428. /**
  68429. * Gets pipeline name
  68430. */
  68431. get name(): string;
  68432. /** Gets the list of attached cameras */
  68433. get cameras(): Camera[];
  68434. /**
  68435. * Initializes a PostProcessRenderPipeline
  68436. * @param engine engine to add the pipeline to
  68437. * @param name name of the pipeline
  68438. */
  68439. constructor(engine: Engine, name: string);
  68440. /**
  68441. * Gets the class name
  68442. * @returns "PostProcessRenderPipeline"
  68443. */
  68444. getClassName(): string;
  68445. /**
  68446. * If all the render effects in the pipeline are supported
  68447. */
  68448. get isSupported(): boolean;
  68449. /**
  68450. * Adds an effect to the pipeline
  68451. * @param renderEffect the effect to add
  68452. */
  68453. addEffect(renderEffect: PostProcessRenderEffect): void;
  68454. /** @hidden */
  68455. _rebuild(): void;
  68456. /** @hidden */
  68457. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68458. /** @hidden */
  68459. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68460. /** @hidden */
  68461. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68462. /** @hidden */
  68463. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68464. /** @hidden */
  68465. _attachCameras(cameras: Camera, unique: boolean): void;
  68466. /** @hidden */
  68467. _attachCameras(cameras: Camera[], unique: boolean): void;
  68468. /** @hidden */
  68469. _detachCameras(cameras: Camera): void;
  68470. /** @hidden */
  68471. _detachCameras(cameras: Nullable<Camera[]>): void;
  68472. /** @hidden */
  68473. _update(): void;
  68474. /** @hidden */
  68475. _reset(): void;
  68476. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68477. /**
  68478. * Disposes of the pipeline
  68479. */
  68480. dispose(): void;
  68481. }
  68482. }
  68483. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68484. import { Camera } from "babylonjs/Cameras/camera";
  68485. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68486. /**
  68487. * PostProcessRenderPipelineManager class
  68488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68489. */
  68490. export class PostProcessRenderPipelineManager {
  68491. private _renderPipelines;
  68492. /**
  68493. * Initializes a PostProcessRenderPipelineManager
  68494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68495. */
  68496. constructor();
  68497. /**
  68498. * Gets the list of supported render pipelines
  68499. */
  68500. get supportedPipelines(): PostProcessRenderPipeline[];
  68501. /**
  68502. * Adds a pipeline to the manager
  68503. * @param renderPipeline The pipeline to add
  68504. */
  68505. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68506. /**
  68507. * Attaches a camera to the pipeline
  68508. * @param renderPipelineName The name of the pipeline to attach to
  68509. * @param cameras the camera to attach
  68510. * @param unique if the camera can be attached multiple times to the pipeline
  68511. */
  68512. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68513. /**
  68514. * Detaches a camera from the pipeline
  68515. * @param renderPipelineName The name of the pipeline to detach from
  68516. * @param cameras the camera to detach
  68517. */
  68518. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68519. /**
  68520. * Enables an effect by name on a pipeline
  68521. * @param renderPipelineName the name of the pipeline to enable the effect in
  68522. * @param renderEffectName the name of the effect to enable
  68523. * @param cameras the cameras that the effect should be enabled on
  68524. */
  68525. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68526. /**
  68527. * Disables an effect by name on a pipeline
  68528. * @param renderPipelineName the name of the pipeline to disable the effect in
  68529. * @param renderEffectName the name of the effect to disable
  68530. * @param cameras the cameras that the effect should be disabled on
  68531. */
  68532. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68533. /**
  68534. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68535. */
  68536. update(): void;
  68537. /** @hidden */
  68538. _rebuild(): void;
  68539. /**
  68540. * Disposes of the manager and pipelines
  68541. */
  68542. dispose(): void;
  68543. }
  68544. }
  68545. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68546. import { ISceneComponent } from "babylonjs/sceneComponent";
  68547. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68548. import { Scene } from "babylonjs/scene";
  68549. module "babylonjs/scene" {
  68550. interface Scene {
  68551. /** @hidden (Backing field) */
  68552. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68553. /**
  68554. * Gets the postprocess render pipeline manager
  68555. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68556. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68557. */
  68558. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68559. }
  68560. }
  68561. /**
  68562. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68563. */
  68564. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68565. /**
  68566. * The component name helpfull to identify the component in the list of scene components.
  68567. */
  68568. readonly name: string;
  68569. /**
  68570. * The scene the component belongs to.
  68571. */
  68572. scene: Scene;
  68573. /**
  68574. * Creates a new instance of the component for the given scene
  68575. * @param scene Defines the scene to register the component in
  68576. */
  68577. constructor(scene: Scene);
  68578. /**
  68579. * Registers the component in a given scene
  68580. */
  68581. register(): void;
  68582. /**
  68583. * Rebuilds the elements related to this component in case of
  68584. * context lost for instance.
  68585. */
  68586. rebuild(): void;
  68587. /**
  68588. * Disposes the component and the associated ressources
  68589. */
  68590. dispose(): void;
  68591. private _gatherRenderTargets;
  68592. }
  68593. }
  68594. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68595. import { Nullable } from "babylonjs/types";
  68596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68597. import { Camera } from "babylonjs/Cameras/camera";
  68598. import { IDisposable } from "babylonjs/scene";
  68599. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68600. import { Scene } from "babylonjs/scene";
  68601. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68602. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68603. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68604. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68605. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68606. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68607. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68608. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68609. import { Animation } from "babylonjs/Animations/animation";
  68610. /**
  68611. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68612. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68613. */
  68614. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68615. private _scene;
  68616. private _camerasToBeAttached;
  68617. /**
  68618. * ID of the sharpen post process,
  68619. */
  68620. private readonly SharpenPostProcessId;
  68621. /**
  68622. * @ignore
  68623. * ID of the image processing post process;
  68624. */
  68625. readonly ImageProcessingPostProcessId: string;
  68626. /**
  68627. * @ignore
  68628. * ID of the Fast Approximate Anti-Aliasing post process;
  68629. */
  68630. readonly FxaaPostProcessId: string;
  68631. /**
  68632. * ID of the chromatic aberration post process,
  68633. */
  68634. private readonly ChromaticAberrationPostProcessId;
  68635. /**
  68636. * ID of the grain post process
  68637. */
  68638. private readonly GrainPostProcessId;
  68639. /**
  68640. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68641. */
  68642. sharpen: SharpenPostProcess;
  68643. private _sharpenEffect;
  68644. private bloom;
  68645. /**
  68646. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68647. */
  68648. depthOfField: DepthOfFieldEffect;
  68649. /**
  68650. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68651. */
  68652. fxaa: FxaaPostProcess;
  68653. /**
  68654. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68655. */
  68656. imageProcessing: ImageProcessingPostProcess;
  68657. /**
  68658. * Chromatic aberration post process which will shift rgb colors in the image
  68659. */
  68660. chromaticAberration: ChromaticAberrationPostProcess;
  68661. private _chromaticAberrationEffect;
  68662. /**
  68663. * Grain post process which add noise to the image
  68664. */
  68665. grain: GrainPostProcess;
  68666. private _grainEffect;
  68667. /**
  68668. * Glow post process which adds a glow to emissive areas of the image
  68669. */
  68670. private _glowLayer;
  68671. /**
  68672. * Animations which can be used to tweak settings over a period of time
  68673. */
  68674. animations: Animation[];
  68675. private _imageProcessingConfigurationObserver;
  68676. private _sharpenEnabled;
  68677. private _bloomEnabled;
  68678. private _depthOfFieldEnabled;
  68679. private _depthOfFieldBlurLevel;
  68680. private _fxaaEnabled;
  68681. private _imageProcessingEnabled;
  68682. private _defaultPipelineTextureType;
  68683. private _bloomScale;
  68684. private _chromaticAberrationEnabled;
  68685. private _grainEnabled;
  68686. private _buildAllowed;
  68687. /**
  68688. * Gets active scene
  68689. */
  68690. get scene(): Scene;
  68691. /**
  68692. * Enable or disable the sharpen process from the pipeline
  68693. */
  68694. set sharpenEnabled(enabled: boolean);
  68695. get sharpenEnabled(): boolean;
  68696. private _resizeObserver;
  68697. private _hardwareScaleLevel;
  68698. private _bloomKernel;
  68699. /**
  68700. * Specifies the size of the bloom blur kernel, relative to the final output size
  68701. */
  68702. get bloomKernel(): number;
  68703. set bloomKernel(value: number);
  68704. /**
  68705. * Specifies the weight of the bloom in the final rendering
  68706. */
  68707. private _bloomWeight;
  68708. /**
  68709. * Specifies the luma threshold for the area that will be blurred by the bloom
  68710. */
  68711. private _bloomThreshold;
  68712. private _hdr;
  68713. /**
  68714. * The strength of the bloom.
  68715. */
  68716. set bloomWeight(value: number);
  68717. get bloomWeight(): number;
  68718. /**
  68719. * The strength of the bloom.
  68720. */
  68721. set bloomThreshold(value: number);
  68722. get bloomThreshold(): number;
  68723. /**
  68724. * The scale of the bloom, lower value will provide better performance.
  68725. */
  68726. set bloomScale(value: number);
  68727. get bloomScale(): number;
  68728. /**
  68729. * Enable or disable the bloom from the pipeline
  68730. */
  68731. set bloomEnabled(enabled: boolean);
  68732. get bloomEnabled(): boolean;
  68733. private _rebuildBloom;
  68734. /**
  68735. * If the depth of field is enabled.
  68736. */
  68737. get depthOfFieldEnabled(): boolean;
  68738. set depthOfFieldEnabled(enabled: boolean);
  68739. /**
  68740. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68741. */
  68742. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68743. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68744. /**
  68745. * If the anti aliasing is enabled.
  68746. */
  68747. set fxaaEnabled(enabled: boolean);
  68748. get fxaaEnabled(): boolean;
  68749. private _samples;
  68750. /**
  68751. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68752. */
  68753. set samples(sampleCount: number);
  68754. get samples(): number;
  68755. /**
  68756. * If image processing is enabled.
  68757. */
  68758. set imageProcessingEnabled(enabled: boolean);
  68759. get imageProcessingEnabled(): boolean;
  68760. /**
  68761. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68762. */
  68763. set glowLayerEnabled(enabled: boolean);
  68764. get glowLayerEnabled(): boolean;
  68765. /**
  68766. * Gets the glow layer (or null if not defined)
  68767. */
  68768. get glowLayer(): Nullable<GlowLayer>;
  68769. /**
  68770. * Enable or disable the chromaticAberration process from the pipeline
  68771. */
  68772. set chromaticAberrationEnabled(enabled: boolean);
  68773. get chromaticAberrationEnabled(): boolean;
  68774. /**
  68775. * Enable or disable the grain process from the pipeline
  68776. */
  68777. set grainEnabled(enabled: boolean);
  68778. get grainEnabled(): boolean;
  68779. /**
  68780. * @constructor
  68781. * @param name - The rendering pipeline name (default: "")
  68782. * @param hdr - If high dynamic range textures should be used (default: true)
  68783. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68784. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68785. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68786. */
  68787. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68788. /**
  68789. * Get the class name
  68790. * @returns "DefaultRenderingPipeline"
  68791. */
  68792. getClassName(): string;
  68793. /**
  68794. * Force the compilation of the entire pipeline.
  68795. */
  68796. prepare(): void;
  68797. private _hasCleared;
  68798. private _prevPostProcess;
  68799. private _prevPrevPostProcess;
  68800. private _setAutoClearAndTextureSharing;
  68801. private _depthOfFieldSceneObserver;
  68802. private _buildPipeline;
  68803. private _disposePostProcesses;
  68804. /**
  68805. * Adds a camera to the pipeline
  68806. * @param camera the camera to be added
  68807. */
  68808. addCamera(camera: Camera): void;
  68809. /**
  68810. * Removes a camera from the pipeline
  68811. * @param camera the camera to remove
  68812. */
  68813. removeCamera(camera: Camera): void;
  68814. /**
  68815. * Dispose of the pipeline and stop all post processes
  68816. */
  68817. dispose(): void;
  68818. /**
  68819. * Serialize the rendering pipeline (Used when exporting)
  68820. * @returns the serialized object
  68821. */
  68822. serialize(): any;
  68823. /**
  68824. * Parse the serialized pipeline
  68825. * @param source Source pipeline.
  68826. * @param scene The scene to load the pipeline to.
  68827. * @param rootUrl The URL of the serialized pipeline.
  68828. * @returns An instantiated pipeline from the serialized object.
  68829. */
  68830. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68831. }
  68832. }
  68833. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68834. /** @hidden */
  68835. export var lensHighlightsPixelShader: {
  68836. name: string;
  68837. shader: string;
  68838. };
  68839. }
  68840. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68841. /** @hidden */
  68842. export var depthOfFieldPixelShader: {
  68843. name: string;
  68844. shader: string;
  68845. };
  68846. }
  68847. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68848. import { Camera } from "babylonjs/Cameras/camera";
  68849. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68850. import { Scene } from "babylonjs/scene";
  68851. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68852. import "babylonjs/Shaders/chromaticAberration.fragment";
  68853. import "babylonjs/Shaders/lensHighlights.fragment";
  68854. import "babylonjs/Shaders/depthOfField.fragment";
  68855. /**
  68856. * BABYLON.JS Chromatic Aberration GLSL Shader
  68857. * Author: Olivier Guyot
  68858. * Separates very slightly R, G and B colors on the edges of the screen
  68859. * Inspired by Francois Tarlier & Martins Upitis
  68860. */
  68861. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68862. /**
  68863. * @ignore
  68864. * The chromatic aberration PostProcess id in the pipeline
  68865. */
  68866. LensChromaticAberrationEffect: string;
  68867. /**
  68868. * @ignore
  68869. * The highlights enhancing PostProcess id in the pipeline
  68870. */
  68871. HighlightsEnhancingEffect: string;
  68872. /**
  68873. * @ignore
  68874. * The depth-of-field PostProcess id in the pipeline
  68875. */
  68876. LensDepthOfFieldEffect: string;
  68877. private _scene;
  68878. private _depthTexture;
  68879. private _grainTexture;
  68880. private _chromaticAberrationPostProcess;
  68881. private _highlightsPostProcess;
  68882. private _depthOfFieldPostProcess;
  68883. private _edgeBlur;
  68884. private _grainAmount;
  68885. private _chromaticAberration;
  68886. private _distortion;
  68887. private _highlightsGain;
  68888. private _highlightsThreshold;
  68889. private _dofDistance;
  68890. private _dofAperture;
  68891. private _dofDarken;
  68892. private _dofPentagon;
  68893. private _blurNoise;
  68894. /**
  68895. * @constructor
  68896. *
  68897. * Effect parameters are as follow:
  68898. * {
  68899. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68900. * edge_blur: number; // from 0 to x (1 for realism)
  68901. * distortion: number; // from 0 to x (1 for realism)
  68902. * grain_amount: number; // from 0 to 1
  68903. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68904. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68905. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68906. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68907. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68908. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68909. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68910. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68911. * }
  68912. * Note: if an effect parameter is unset, effect is disabled
  68913. *
  68914. * @param name The rendering pipeline name
  68915. * @param parameters - An object containing all parameters (see above)
  68916. * @param scene The scene linked to this pipeline
  68917. * @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)
  68918. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68919. */
  68920. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68921. /**
  68922. * Get the class name
  68923. * @returns "LensRenderingPipeline"
  68924. */
  68925. getClassName(): string;
  68926. /**
  68927. * Gets associated scene
  68928. */
  68929. get scene(): Scene;
  68930. /**
  68931. * Gets or sets the edge blur
  68932. */
  68933. get edgeBlur(): number;
  68934. set edgeBlur(value: number);
  68935. /**
  68936. * Gets or sets the grain amount
  68937. */
  68938. get grainAmount(): number;
  68939. set grainAmount(value: number);
  68940. /**
  68941. * Gets or sets the chromatic aberration amount
  68942. */
  68943. get chromaticAberration(): number;
  68944. set chromaticAberration(value: number);
  68945. /**
  68946. * Gets or sets the depth of field aperture
  68947. */
  68948. get dofAperture(): number;
  68949. set dofAperture(value: number);
  68950. /**
  68951. * Gets or sets the edge distortion
  68952. */
  68953. get edgeDistortion(): number;
  68954. set edgeDistortion(value: number);
  68955. /**
  68956. * Gets or sets the depth of field distortion
  68957. */
  68958. get dofDistortion(): number;
  68959. set dofDistortion(value: number);
  68960. /**
  68961. * Gets or sets the darken out of focus amount
  68962. */
  68963. get darkenOutOfFocus(): number;
  68964. set darkenOutOfFocus(value: number);
  68965. /**
  68966. * Gets or sets a boolean indicating if blur noise is enabled
  68967. */
  68968. get blurNoise(): boolean;
  68969. set blurNoise(value: boolean);
  68970. /**
  68971. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68972. */
  68973. get pentagonBokeh(): boolean;
  68974. set pentagonBokeh(value: boolean);
  68975. /**
  68976. * Gets or sets the highlight grain amount
  68977. */
  68978. get highlightsGain(): number;
  68979. set highlightsGain(value: number);
  68980. /**
  68981. * Gets or sets the highlight threshold
  68982. */
  68983. get highlightsThreshold(): number;
  68984. set highlightsThreshold(value: number);
  68985. /**
  68986. * Sets the amount of blur at the edges
  68987. * @param amount blur amount
  68988. */
  68989. setEdgeBlur(amount: number): void;
  68990. /**
  68991. * Sets edge blur to 0
  68992. */
  68993. disableEdgeBlur(): void;
  68994. /**
  68995. * Sets the amout of grain
  68996. * @param amount Amount of grain
  68997. */
  68998. setGrainAmount(amount: number): void;
  68999. /**
  69000. * Set grain amount to 0
  69001. */
  69002. disableGrain(): void;
  69003. /**
  69004. * Sets the chromatic aberration amount
  69005. * @param amount amount of chromatic aberration
  69006. */
  69007. setChromaticAberration(amount: number): void;
  69008. /**
  69009. * Sets chromatic aberration amount to 0
  69010. */
  69011. disableChromaticAberration(): void;
  69012. /**
  69013. * Sets the EdgeDistortion amount
  69014. * @param amount amount of EdgeDistortion
  69015. */
  69016. setEdgeDistortion(amount: number): void;
  69017. /**
  69018. * Sets edge distortion to 0
  69019. */
  69020. disableEdgeDistortion(): void;
  69021. /**
  69022. * Sets the FocusDistance amount
  69023. * @param amount amount of FocusDistance
  69024. */
  69025. setFocusDistance(amount: number): void;
  69026. /**
  69027. * Disables depth of field
  69028. */
  69029. disableDepthOfField(): void;
  69030. /**
  69031. * Sets the Aperture amount
  69032. * @param amount amount of Aperture
  69033. */
  69034. setAperture(amount: number): void;
  69035. /**
  69036. * Sets the DarkenOutOfFocus amount
  69037. * @param amount amount of DarkenOutOfFocus
  69038. */
  69039. setDarkenOutOfFocus(amount: number): void;
  69040. private _pentagonBokehIsEnabled;
  69041. /**
  69042. * Creates a pentagon bokeh effect
  69043. */
  69044. enablePentagonBokeh(): void;
  69045. /**
  69046. * Disables the pentagon bokeh effect
  69047. */
  69048. disablePentagonBokeh(): void;
  69049. /**
  69050. * Enables noise blur
  69051. */
  69052. enableNoiseBlur(): void;
  69053. /**
  69054. * Disables noise blur
  69055. */
  69056. disableNoiseBlur(): void;
  69057. /**
  69058. * Sets the HighlightsGain amount
  69059. * @param amount amount of HighlightsGain
  69060. */
  69061. setHighlightsGain(amount: number): void;
  69062. /**
  69063. * Sets the HighlightsThreshold amount
  69064. * @param amount amount of HighlightsThreshold
  69065. */
  69066. setHighlightsThreshold(amount: number): void;
  69067. /**
  69068. * Disables highlights
  69069. */
  69070. disableHighlights(): void;
  69071. /**
  69072. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69073. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69074. */
  69075. dispose(disableDepthRender?: boolean): void;
  69076. private _createChromaticAberrationPostProcess;
  69077. private _createHighlightsPostProcess;
  69078. private _createDepthOfFieldPostProcess;
  69079. private _createGrainTexture;
  69080. }
  69081. }
  69082. declare module "babylonjs/Shaders/ssao2.fragment" {
  69083. /** @hidden */
  69084. export var ssao2PixelShader: {
  69085. name: string;
  69086. shader: string;
  69087. };
  69088. }
  69089. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69090. /** @hidden */
  69091. export var ssaoCombinePixelShader: {
  69092. name: string;
  69093. shader: string;
  69094. };
  69095. }
  69096. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69097. import { Camera } from "babylonjs/Cameras/camera";
  69098. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69099. import { Scene } from "babylonjs/scene";
  69100. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69101. import "babylonjs/Shaders/ssao2.fragment";
  69102. import "babylonjs/Shaders/ssaoCombine.fragment";
  69103. /**
  69104. * Render pipeline to produce ssao effect
  69105. */
  69106. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69107. /**
  69108. * @ignore
  69109. * The PassPostProcess id in the pipeline that contains the original scene color
  69110. */
  69111. SSAOOriginalSceneColorEffect: string;
  69112. /**
  69113. * @ignore
  69114. * The SSAO PostProcess id in the pipeline
  69115. */
  69116. SSAORenderEffect: string;
  69117. /**
  69118. * @ignore
  69119. * The horizontal blur PostProcess id in the pipeline
  69120. */
  69121. SSAOBlurHRenderEffect: string;
  69122. /**
  69123. * @ignore
  69124. * The vertical blur PostProcess id in the pipeline
  69125. */
  69126. SSAOBlurVRenderEffect: string;
  69127. /**
  69128. * @ignore
  69129. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69130. */
  69131. SSAOCombineRenderEffect: string;
  69132. /**
  69133. * The output strength of the SSAO post-process. Default value is 1.0.
  69134. */
  69135. totalStrength: number;
  69136. /**
  69137. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69138. */
  69139. maxZ: number;
  69140. /**
  69141. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69142. */
  69143. minZAspect: number;
  69144. private _samples;
  69145. /**
  69146. * Number of samples used for the SSAO calculations. Default value is 8
  69147. */
  69148. set samples(n: number);
  69149. get samples(): number;
  69150. private _textureSamples;
  69151. /**
  69152. * Number of samples to use for antialiasing
  69153. */
  69154. set textureSamples(n: number);
  69155. get textureSamples(): number;
  69156. /**
  69157. * Ratio object used for SSAO ratio and blur ratio
  69158. */
  69159. private _ratio;
  69160. /**
  69161. * Dynamically generated sphere sampler.
  69162. */
  69163. private _sampleSphere;
  69164. /**
  69165. * Blur filter offsets
  69166. */
  69167. private _samplerOffsets;
  69168. private _expensiveBlur;
  69169. /**
  69170. * If bilateral blur should be used
  69171. */
  69172. set expensiveBlur(b: boolean);
  69173. get expensiveBlur(): boolean;
  69174. /**
  69175. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69176. */
  69177. radius: number;
  69178. /**
  69179. * The base color of the SSAO post-process
  69180. * The final result is "base + ssao" between [0, 1]
  69181. */
  69182. base: number;
  69183. /**
  69184. * Support test.
  69185. */
  69186. static get IsSupported(): boolean;
  69187. private _scene;
  69188. private _depthTexture;
  69189. private _normalTexture;
  69190. private _randomTexture;
  69191. private _originalColorPostProcess;
  69192. private _ssaoPostProcess;
  69193. private _blurHPostProcess;
  69194. private _blurVPostProcess;
  69195. private _ssaoCombinePostProcess;
  69196. /**
  69197. * Gets active scene
  69198. */
  69199. get scene(): Scene;
  69200. /**
  69201. * @constructor
  69202. * @param name The rendering pipeline name
  69203. * @param scene The scene linked to this pipeline
  69204. * @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 }
  69205. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69206. */
  69207. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69208. /**
  69209. * Get the class name
  69210. * @returns "SSAO2RenderingPipeline"
  69211. */
  69212. getClassName(): string;
  69213. /**
  69214. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69215. */
  69216. dispose(disableGeometryBufferRenderer?: boolean): void;
  69217. private _createBlurPostProcess;
  69218. /** @hidden */
  69219. _rebuild(): void;
  69220. private _bits;
  69221. private _radicalInverse_VdC;
  69222. private _hammersley;
  69223. private _hemisphereSample_uniform;
  69224. private _generateHemisphere;
  69225. private _createSSAOPostProcess;
  69226. private _createSSAOCombinePostProcess;
  69227. private _createRandomTexture;
  69228. /**
  69229. * Serialize the rendering pipeline (Used when exporting)
  69230. * @returns the serialized object
  69231. */
  69232. serialize(): any;
  69233. /**
  69234. * Parse the serialized pipeline
  69235. * @param source Source pipeline.
  69236. * @param scene The scene to load the pipeline to.
  69237. * @param rootUrl The URL of the serialized pipeline.
  69238. * @returns An instantiated pipeline from the serialized object.
  69239. */
  69240. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69241. }
  69242. }
  69243. declare module "babylonjs/Shaders/ssao.fragment" {
  69244. /** @hidden */
  69245. export var ssaoPixelShader: {
  69246. name: string;
  69247. shader: string;
  69248. };
  69249. }
  69250. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69251. import { Camera } from "babylonjs/Cameras/camera";
  69252. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69253. import { Scene } from "babylonjs/scene";
  69254. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69255. import "babylonjs/Shaders/ssao.fragment";
  69256. import "babylonjs/Shaders/ssaoCombine.fragment";
  69257. /**
  69258. * Render pipeline to produce ssao effect
  69259. */
  69260. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69261. /**
  69262. * @ignore
  69263. * The PassPostProcess id in the pipeline that contains the original scene color
  69264. */
  69265. SSAOOriginalSceneColorEffect: string;
  69266. /**
  69267. * @ignore
  69268. * The SSAO PostProcess id in the pipeline
  69269. */
  69270. SSAORenderEffect: string;
  69271. /**
  69272. * @ignore
  69273. * The horizontal blur PostProcess id in the pipeline
  69274. */
  69275. SSAOBlurHRenderEffect: string;
  69276. /**
  69277. * @ignore
  69278. * The vertical blur PostProcess id in the pipeline
  69279. */
  69280. SSAOBlurVRenderEffect: string;
  69281. /**
  69282. * @ignore
  69283. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69284. */
  69285. SSAOCombineRenderEffect: string;
  69286. /**
  69287. * The output strength of the SSAO post-process. Default value is 1.0.
  69288. */
  69289. totalStrength: number;
  69290. /**
  69291. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69292. */
  69293. radius: number;
  69294. /**
  69295. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69296. * Must not be equal to fallOff and superior to fallOff.
  69297. * Default value is 0.0075
  69298. */
  69299. area: number;
  69300. /**
  69301. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69302. * Must not be equal to area and inferior to area.
  69303. * Default value is 0.000001
  69304. */
  69305. fallOff: number;
  69306. /**
  69307. * The base color of the SSAO post-process
  69308. * The final result is "base + ssao" between [0, 1]
  69309. */
  69310. base: number;
  69311. private _scene;
  69312. private _depthTexture;
  69313. private _randomTexture;
  69314. private _originalColorPostProcess;
  69315. private _ssaoPostProcess;
  69316. private _blurHPostProcess;
  69317. private _blurVPostProcess;
  69318. private _ssaoCombinePostProcess;
  69319. private _firstUpdate;
  69320. /**
  69321. * Gets active scene
  69322. */
  69323. get scene(): Scene;
  69324. /**
  69325. * @constructor
  69326. * @param name - The rendering pipeline name
  69327. * @param scene - The scene linked to this pipeline
  69328. * @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 }
  69329. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69330. */
  69331. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69332. /**
  69333. * Get the class name
  69334. * @returns "SSAORenderingPipeline"
  69335. */
  69336. getClassName(): string;
  69337. /**
  69338. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69339. */
  69340. dispose(disableDepthRender?: boolean): void;
  69341. private _createBlurPostProcess;
  69342. /** @hidden */
  69343. _rebuild(): void;
  69344. private _createSSAOPostProcess;
  69345. private _createSSAOCombinePostProcess;
  69346. private _createRandomTexture;
  69347. }
  69348. }
  69349. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69350. /** @hidden */
  69351. export var screenSpaceReflectionPixelShader: {
  69352. name: string;
  69353. shader: string;
  69354. };
  69355. }
  69356. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69357. import { Nullable } from "babylonjs/types";
  69358. import { Camera } from "babylonjs/Cameras/camera";
  69359. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69360. import { Scene } from "babylonjs/scene";
  69361. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69362. import { Engine } from "babylonjs/Engines/engine";
  69363. /**
  69364. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69365. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69366. */
  69367. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69368. /**
  69369. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69370. */
  69371. threshold: number;
  69372. /**
  69373. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69374. */
  69375. strength: number;
  69376. /**
  69377. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69378. */
  69379. reflectionSpecularFalloffExponent: number;
  69380. /**
  69381. * 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]
  69382. */
  69383. step: number;
  69384. /**
  69385. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69386. */
  69387. roughnessFactor: number;
  69388. private _geometryBufferRenderer;
  69389. private _enableSmoothReflections;
  69390. private _reflectionSamples;
  69391. private _smoothSteps;
  69392. /**
  69393. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69394. * @param name The name of the effect.
  69395. * @param scene The scene containing the objects to calculate reflections.
  69396. * @param options The required width/height ratio to downsize to before computing the render pass.
  69397. * @param camera The camera to apply the render pass to.
  69398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69399. * @param engine The engine which the post process will be applied. (default: current engine)
  69400. * @param reusable If the post process can be reused on the same frame. (default: false)
  69401. * @param textureType Type of textures used when performing the post process. (default: 0)
  69402. * @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)
  69403. */
  69404. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69405. /**
  69406. * Gets wether or not smoothing reflections is enabled.
  69407. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69408. */
  69409. get enableSmoothReflections(): boolean;
  69410. /**
  69411. * Sets wether or not smoothing reflections is enabled.
  69412. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69413. */
  69414. set enableSmoothReflections(enabled: boolean);
  69415. /**
  69416. * Gets the number of samples taken while computing reflections. More samples count is high,
  69417. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69418. */
  69419. get reflectionSamples(): number;
  69420. /**
  69421. * Sets the number of samples taken while computing reflections. More samples count is high,
  69422. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69423. */
  69424. set reflectionSamples(samples: number);
  69425. /**
  69426. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69427. * more the post-process will require GPU power and can generate a drop in FPS.
  69428. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69429. */
  69430. get smoothSteps(): number;
  69431. set smoothSteps(steps: number);
  69432. private _updateEffectDefines;
  69433. }
  69434. }
  69435. declare module "babylonjs/Shaders/standard.fragment" {
  69436. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69437. /** @hidden */
  69438. export var standardPixelShader: {
  69439. name: string;
  69440. shader: string;
  69441. };
  69442. }
  69443. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69444. import { Nullable } from "babylonjs/types";
  69445. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69446. import { Camera } from "babylonjs/Cameras/camera";
  69447. import { Texture } from "babylonjs/Materials/Textures/texture";
  69448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69449. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69450. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69451. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69452. import { IDisposable } from "babylonjs/scene";
  69453. import { SpotLight } from "babylonjs/Lights/spotLight";
  69454. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69455. import { Scene } from "babylonjs/scene";
  69456. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69457. import { Animation } from "babylonjs/Animations/animation";
  69458. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69459. import "babylonjs/Shaders/standard.fragment";
  69460. /**
  69461. * Standard rendering pipeline
  69462. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69463. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69464. */
  69465. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69466. /**
  69467. * Public members
  69468. */
  69469. /**
  69470. * Post-process which contains the original scene color before the pipeline applies all the effects
  69471. */
  69472. originalPostProcess: Nullable<PostProcess>;
  69473. /**
  69474. * Post-process used to down scale an image x4
  69475. */
  69476. downSampleX4PostProcess: Nullable<PostProcess>;
  69477. /**
  69478. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69479. */
  69480. brightPassPostProcess: Nullable<PostProcess>;
  69481. /**
  69482. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69483. */
  69484. blurHPostProcesses: PostProcess[];
  69485. /**
  69486. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69487. */
  69488. blurVPostProcesses: PostProcess[];
  69489. /**
  69490. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69491. */
  69492. textureAdderPostProcess: Nullable<PostProcess>;
  69493. /**
  69494. * Post-process used to create volumetric lighting effect
  69495. */
  69496. volumetricLightPostProcess: Nullable<PostProcess>;
  69497. /**
  69498. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69499. */
  69500. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69501. /**
  69502. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69503. */
  69504. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69505. /**
  69506. * Post-process used to merge the volumetric light effect and the real scene color
  69507. */
  69508. volumetricLightMergePostProces: Nullable<PostProcess>;
  69509. /**
  69510. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69511. */
  69512. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69513. /**
  69514. * Base post-process used to calculate the average luminance of the final image for HDR
  69515. */
  69516. luminancePostProcess: Nullable<PostProcess>;
  69517. /**
  69518. * Post-processes used to create down sample post-processes in order to get
  69519. * the average luminance of the final image for HDR
  69520. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69521. */
  69522. luminanceDownSamplePostProcesses: PostProcess[];
  69523. /**
  69524. * Post-process used to create a HDR effect (light adaptation)
  69525. */
  69526. hdrPostProcess: Nullable<PostProcess>;
  69527. /**
  69528. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69529. */
  69530. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69531. /**
  69532. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69533. */
  69534. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69535. /**
  69536. * Post-process used to merge the final HDR post-process and the real scene color
  69537. */
  69538. hdrFinalPostProcess: Nullable<PostProcess>;
  69539. /**
  69540. * Post-process used to create a lens flare effect
  69541. */
  69542. lensFlarePostProcess: Nullable<PostProcess>;
  69543. /**
  69544. * Post-process that merges the result of the lens flare post-process and the real scene color
  69545. */
  69546. lensFlareComposePostProcess: Nullable<PostProcess>;
  69547. /**
  69548. * Post-process used to create a motion blur effect
  69549. */
  69550. motionBlurPostProcess: Nullable<PostProcess>;
  69551. /**
  69552. * Post-process used to create a depth of field effect
  69553. */
  69554. depthOfFieldPostProcess: Nullable<PostProcess>;
  69555. /**
  69556. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69557. */
  69558. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69559. /**
  69560. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69561. */
  69562. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69563. /**
  69564. * Represents the brightness threshold in order to configure the illuminated surfaces
  69565. */
  69566. brightThreshold: number;
  69567. /**
  69568. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69569. */
  69570. blurWidth: number;
  69571. /**
  69572. * Sets if the blur for highlighted surfaces must be only horizontal
  69573. */
  69574. horizontalBlur: boolean;
  69575. /**
  69576. * Gets the overall exposure used by the pipeline
  69577. */
  69578. get exposure(): number;
  69579. /**
  69580. * Sets the overall exposure used by the pipeline
  69581. */
  69582. set exposure(value: number);
  69583. /**
  69584. * Texture used typically to simulate "dirty" on camera lens
  69585. */
  69586. lensTexture: Nullable<Texture>;
  69587. /**
  69588. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69589. */
  69590. volumetricLightCoefficient: number;
  69591. /**
  69592. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69593. */
  69594. volumetricLightPower: number;
  69595. /**
  69596. * Used the set the blur intensity to smooth the volumetric lights
  69597. */
  69598. volumetricLightBlurScale: number;
  69599. /**
  69600. * Light (spot or directional) used to generate the volumetric lights rays
  69601. * The source light must have a shadow generate so the pipeline can get its
  69602. * depth map
  69603. */
  69604. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69605. /**
  69606. * For eye adaptation, represents the minimum luminance the eye can see
  69607. */
  69608. hdrMinimumLuminance: number;
  69609. /**
  69610. * For eye adaptation, represents the decrease luminance speed
  69611. */
  69612. hdrDecreaseRate: number;
  69613. /**
  69614. * For eye adaptation, represents the increase luminance speed
  69615. */
  69616. hdrIncreaseRate: number;
  69617. /**
  69618. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69619. */
  69620. get hdrAutoExposure(): boolean;
  69621. /**
  69622. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69623. */
  69624. set hdrAutoExposure(value: boolean);
  69625. /**
  69626. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69627. */
  69628. lensColorTexture: Nullable<Texture>;
  69629. /**
  69630. * The overall strengh for the lens flare effect
  69631. */
  69632. lensFlareStrength: number;
  69633. /**
  69634. * Dispersion coefficient for lens flare ghosts
  69635. */
  69636. lensFlareGhostDispersal: number;
  69637. /**
  69638. * Main lens flare halo width
  69639. */
  69640. lensFlareHaloWidth: number;
  69641. /**
  69642. * Based on the lens distortion effect, defines how much the lens flare result
  69643. * is distorted
  69644. */
  69645. lensFlareDistortionStrength: number;
  69646. /**
  69647. * Configures the blur intensity used for for lens flare (halo)
  69648. */
  69649. lensFlareBlurWidth: number;
  69650. /**
  69651. * Lens star texture must be used to simulate rays on the flares and is available
  69652. * in the documentation
  69653. */
  69654. lensStarTexture: Nullable<Texture>;
  69655. /**
  69656. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69657. * flare effect by taking account of the dirt texture
  69658. */
  69659. lensFlareDirtTexture: Nullable<Texture>;
  69660. /**
  69661. * Represents the focal length for the depth of field effect
  69662. */
  69663. depthOfFieldDistance: number;
  69664. /**
  69665. * Represents the blur intensity for the blurred part of the depth of field effect
  69666. */
  69667. depthOfFieldBlurWidth: number;
  69668. /**
  69669. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69670. */
  69671. get motionStrength(): number;
  69672. /**
  69673. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69674. */
  69675. set motionStrength(strength: number);
  69676. /**
  69677. * Gets wether or not the motion blur post-process is object based or screen based.
  69678. */
  69679. get objectBasedMotionBlur(): boolean;
  69680. /**
  69681. * Sets wether or not the motion blur post-process should be object based or screen based
  69682. */
  69683. set objectBasedMotionBlur(value: boolean);
  69684. /**
  69685. * List of animations for the pipeline (IAnimatable implementation)
  69686. */
  69687. animations: Animation[];
  69688. /**
  69689. * Private members
  69690. */
  69691. private _scene;
  69692. private _currentDepthOfFieldSource;
  69693. private _basePostProcess;
  69694. private _fixedExposure;
  69695. private _currentExposure;
  69696. private _hdrAutoExposure;
  69697. private _hdrCurrentLuminance;
  69698. private _motionStrength;
  69699. private _isObjectBasedMotionBlur;
  69700. private _floatTextureType;
  69701. private _camerasToBeAttached;
  69702. private _ratio;
  69703. private _bloomEnabled;
  69704. private _depthOfFieldEnabled;
  69705. private _vlsEnabled;
  69706. private _lensFlareEnabled;
  69707. private _hdrEnabled;
  69708. private _motionBlurEnabled;
  69709. private _fxaaEnabled;
  69710. private _screenSpaceReflectionsEnabled;
  69711. private _motionBlurSamples;
  69712. private _volumetricLightStepsCount;
  69713. private _samples;
  69714. /**
  69715. * @ignore
  69716. * Specifies if the bloom pipeline is enabled
  69717. */
  69718. get BloomEnabled(): boolean;
  69719. set BloomEnabled(enabled: boolean);
  69720. /**
  69721. * @ignore
  69722. * Specifies if the depth of field pipeline is enabed
  69723. */
  69724. get DepthOfFieldEnabled(): boolean;
  69725. set DepthOfFieldEnabled(enabled: boolean);
  69726. /**
  69727. * @ignore
  69728. * Specifies if the lens flare pipeline is enabed
  69729. */
  69730. get LensFlareEnabled(): boolean;
  69731. set LensFlareEnabled(enabled: boolean);
  69732. /**
  69733. * @ignore
  69734. * Specifies if the HDR pipeline is enabled
  69735. */
  69736. get HDREnabled(): boolean;
  69737. set HDREnabled(enabled: boolean);
  69738. /**
  69739. * @ignore
  69740. * Specifies if the volumetric lights scattering effect is enabled
  69741. */
  69742. get VLSEnabled(): boolean;
  69743. set VLSEnabled(enabled: boolean);
  69744. /**
  69745. * @ignore
  69746. * Specifies if the motion blur effect is enabled
  69747. */
  69748. get MotionBlurEnabled(): boolean;
  69749. set MotionBlurEnabled(enabled: boolean);
  69750. /**
  69751. * Specifies if anti-aliasing is enabled
  69752. */
  69753. get fxaaEnabled(): boolean;
  69754. set fxaaEnabled(enabled: boolean);
  69755. /**
  69756. * Specifies if screen space reflections are enabled.
  69757. */
  69758. get screenSpaceReflectionsEnabled(): boolean;
  69759. set screenSpaceReflectionsEnabled(enabled: boolean);
  69760. /**
  69761. * Specifies the number of steps used to calculate the volumetric lights
  69762. * Typically in interval [50, 200]
  69763. */
  69764. get volumetricLightStepsCount(): number;
  69765. set volumetricLightStepsCount(count: number);
  69766. /**
  69767. * Specifies the number of samples used for the motion blur effect
  69768. * Typically in interval [16, 64]
  69769. */
  69770. get motionBlurSamples(): number;
  69771. set motionBlurSamples(samples: number);
  69772. /**
  69773. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69774. */
  69775. get samples(): number;
  69776. set samples(sampleCount: number);
  69777. /**
  69778. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69779. * @constructor
  69780. * @param name The rendering pipeline name
  69781. * @param scene The scene linked to this pipeline
  69782. * @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)
  69783. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69784. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69785. */
  69786. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69787. private _buildPipeline;
  69788. private _createDownSampleX4PostProcess;
  69789. private _createBrightPassPostProcess;
  69790. private _createBlurPostProcesses;
  69791. private _createTextureAdderPostProcess;
  69792. private _createVolumetricLightPostProcess;
  69793. private _createLuminancePostProcesses;
  69794. private _createHdrPostProcess;
  69795. private _createLensFlarePostProcess;
  69796. private _createDepthOfFieldPostProcess;
  69797. private _createMotionBlurPostProcess;
  69798. private _getDepthTexture;
  69799. private _disposePostProcesses;
  69800. /**
  69801. * Dispose of the pipeline and stop all post processes
  69802. */
  69803. dispose(): void;
  69804. /**
  69805. * Serialize the rendering pipeline (Used when exporting)
  69806. * @returns the serialized object
  69807. */
  69808. serialize(): any;
  69809. /**
  69810. * Parse the serialized pipeline
  69811. * @param source Source pipeline.
  69812. * @param scene The scene to load the pipeline to.
  69813. * @param rootUrl The URL of the serialized pipeline.
  69814. * @returns An instantiated pipeline from the serialized object.
  69815. */
  69816. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69817. /**
  69818. * Luminance steps
  69819. */
  69820. static LuminanceSteps: number;
  69821. }
  69822. }
  69823. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69824. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69825. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69826. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69827. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69828. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69829. }
  69830. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69831. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69832. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69833. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69834. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69835. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69836. }
  69837. declare module "babylonjs/Shaders/tonemap.fragment" {
  69838. /** @hidden */
  69839. export var tonemapPixelShader: {
  69840. name: string;
  69841. shader: string;
  69842. };
  69843. }
  69844. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69845. import { Camera } from "babylonjs/Cameras/camera";
  69846. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69847. import "babylonjs/Shaders/tonemap.fragment";
  69848. import { Engine } from "babylonjs/Engines/engine";
  69849. /** Defines operator used for tonemapping */
  69850. export enum TonemappingOperator {
  69851. /** Hable */
  69852. Hable = 0,
  69853. /** Reinhard */
  69854. Reinhard = 1,
  69855. /** HejiDawson */
  69856. HejiDawson = 2,
  69857. /** Photographic */
  69858. Photographic = 3
  69859. }
  69860. /**
  69861. * Defines a post process to apply tone mapping
  69862. */
  69863. export class TonemapPostProcess extends PostProcess {
  69864. private _operator;
  69865. /** Defines the required exposure adjustement */
  69866. exposureAdjustment: number;
  69867. /**
  69868. * Creates a new TonemapPostProcess
  69869. * @param name defines the name of the postprocess
  69870. * @param _operator defines the operator to use
  69871. * @param exposureAdjustment defines the required exposure adjustement
  69872. * @param camera defines the camera to use (can be null)
  69873. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69874. * @param engine defines the hosting engine (can be ignore if camera is set)
  69875. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69876. */
  69877. constructor(name: string, _operator: TonemappingOperator,
  69878. /** Defines the required exposure adjustement */
  69879. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69880. }
  69881. }
  69882. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69883. /** @hidden */
  69884. export var volumetricLightScatteringPixelShader: {
  69885. name: string;
  69886. shader: string;
  69887. };
  69888. }
  69889. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69890. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69892. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69893. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69895. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69896. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69897. /** @hidden */
  69898. export var volumetricLightScatteringPassVertexShader: {
  69899. name: string;
  69900. shader: string;
  69901. };
  69902. }
  69903. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69904. /** @hidden */
  69905. export var volumetricLightScatteringPassPixelShader: {
  69906. name: string;
  69907. shader: string;
  69908. };
  69909. }
  69910. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69911. import { Vector3 } from "babylonjs/Maths/math.vector";
  69912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69913. import { Mesh } from "babylonjs/Meshes/mesh";
  69914. import { Camera } from "babylonjs/Cameras/camera";
  69915. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69916. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69917. import { Scene } from "babylonjs/scene";
  69918. import "babylonjs/Meshes/Builders/planeBuilder";
  69919. import "babylonjs/Shaders/depth.vertex";
  69920. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69921. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69922. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69923. import { Engine } from "babylonjs/Engines/engine";
  69924. /**
  69925. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69926. */
  69927. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69928. private _volumetricLightScatteringPass;
  69929. private _volumetricLightScatteringRTT;
  69930. private _viewPort;
  69931. private _screenCoordinates;
  69932. private _cachedDefines;
  69933. /**
  69934. * If not undefined, the mesh position is computed from the attached node position
  69935. */
  69936. attachedNode: {
  69937. position: Vector3;
  69938. };
  69939. /**
  69940. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69941. */
  69942. customMeshPosition: Vector3;
  69943. /**
  69944. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69945. */
  69946. useCustomMeshPosition: boolean;
  69947. /**
  69948. * If the post-process should inverse the light scattering direction
  69949. */
  69950. invert: boolean;
  69951. /**
  69952. * The internal mesh used by the post-process
  69953. */
  69954. mesh: Mesh;
  69955. /**
  69956. * @hidden
  69957. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69958. */
  69959. get useDiffuseColor(): boolean;
  69960. set useDiffuseColor(useDiffuseColor: boolean);
  69961. /**
  69962. * Array containing the excluded meshes not rendered in the internal pass
  69963. */
  69964. excludedMeshes: AbstractMesh[];
  69965. /**
  69966. * Controls the overall intensity of the post-process
  69967. */
  69968. exposure: number;
  69969. /**
  69970. * Dissipates each sample's contribution in range [0, 1]
  69971. */
  69972. decay: number;
  69973. /**
  69974. * Controls the overall intensity of each sample
  69975. */
  69976. weight: number;
  69977. /**
  69978. * Controls the density of each sample
  69979. */
  69980. density: number;
  69981. /**
  69982. * @constructor
  69983. * @param name The post-process name
  69984. * @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)
  69985. * @param camera The camera that the post-process will be attached to
  69986. * @param mesh The mesh used to create the light scattering
  69987. * @param samples The post-process quality, default 100
  69988. * @param samplingModeThe post-process filtering mode
  69989. * @param engine The babylon engine
  69990. * @param reusable If the post-process is reusable
  69991. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69992. */
  69993. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69994. /**
  69995. * Returns the string "VolumetricLightScatteringPostProcess"
  69996. * @returns "VolumetricLightScatteringPostProcess"
  69997. */
  69998. getClassName(): string;
  69999. private _isReady;
  70000. /**
  70001. * Sets the new light position for light scattering effect
  70002. * @param position The new custom light position
  70003. */
  70004. setCustomMeshPosition(position: Vector3): void;
  70005. /**
  70006. * Returns the light position for light scattering effect
  70007. * @return Vector3 The custom light position
  70008. */
  70009. getCustomMeshPosition(): Vector3;
  70010. /**
  70011. * Disposes the internal assets and detaches the post-process from the camera
  70012. */
  70013. dispose(camera: Camera): void;
  70014. /**
  70015. * Returns the render target texture used by the post-process
  70016. * @return the render target texture used by the post-process
  70017. */
  70018. getPass(): RenderTargetTexture;
  70019. private _meshExcluded;
  70020. private _createPass;
  70021. private _updateMeshScreenCoordinates;
  70022. /**
  70023. * Creates a default mesh for the Volumeric Light Scattering post-process
  70024. * @param name The mesh name
  70025. * @param scene The scene where to create the mesh
  70026. * @return the default mesh
  70027. */
  70028. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70029. }
  70030. }
  70031. declare module "babylonjs/PostProcesses/index" {
  70032. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70033. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70034. export * from "babylonjs/PostProcesses/bloomEffect";
  70035. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70036. export * from "babylonjs/PostProcesses/blurPostProcess";
  70037. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70038. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70039. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70040. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70041. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70042. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70043. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70044. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70045. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70046. export * from "babylonjs/PostProcesses/filterPostProcess";
  70047. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70048. export * from "babylonjs/PostProcesses/grainPostProcess";
  70049. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70050. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70051. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70052. export * from "babylonjs/PostProcesses/passPostProcess";
  70053. export * from "babylonjs/PostProcesses/postProcess";
  70054. export * from "babylonjs/PostProcesses/postProcessManager";
  70055. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70056. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70057. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70058. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70059. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70060. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70061. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70062. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70063. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70064. }
  70065. declare module "babylonjs/Probes/index" {
  70066. export * from "babylonjs/Probes/reflectionProbe";
  70067. }
  70068. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70069. import { Scene } from "babylonjs/scene";
  70070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70071. import { SmartArray } from "babylonjs/Misc/smartArray";
  70072. import { ISceneComponent } from "babylonjs/sceneComponent";
  70073. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70074. import "babylonjs/Meshes/Builders/boxBuilder";
  70075. import "babylonjs/Shaders/color.fragment";
  70076. import "babylonjs/Shaders/color.vertex";
  70077. import { Color3 } from "babylonjs/Maths/math.color";
  70078. module "babylonjs/scene" {
  70079. interface Scene {
  70080. /** @hidden (Backing field) */
  70081. _boundingBoxRenderer: BoundingBoxRenderer;
  70082. /** @hidden (Backing field) */
  70083. _forceShowBoundingBoxes: boolean;
  70084. /**
  70085. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70086. */
  70087. forceShowBoundingBoxes: boolean;
  70088. /**
  70089. * Gets the bounding box renderer associated with the scene
  70090. * @returns a BoundingBoxRenderer
  70091. */
  70092. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70093. }
  70094. }
  70095. module "babylonjs/Meshes/abstractMesh" {
  70096. interface AbstractMesh {
  70097. /** @hidden (Backing field) */
  70098. _showBoundingBox: boolean;
  70099. /**
  70100. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70101. */
  70102. showBoundingBox: boolean;
  70103. }
  70104. }
  70105. /**
  70106. * Component responsible of rendering the bounding box of the meshes in a scene.
  70107. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70108. */
  70109. export class BoundingBoxRenderer implements ISceneComponent {
  70110. /**
  70111. * The component name helpfull to identify the component in the list of scene components.
  70112. */
  70113. readonly name: string;
  70114. /**
  70115. * The scene the component belongs to.
  70116. */
  70117. scene: Scene;
  70118. /**
  70119. * Color of the bounding box lines placed in front of an object
  70120. */
  70121. frontColor: Color3;
  70122. /**
  70123. * Color of the bounding box lines placed behind an object
  70124. */
  70125. backColor: Color3;
  70126. /**
  70127. * Defines if the renderer should show the back lines or not
  70128. */
  70129. showBackLines: boolean;
  70130. /**
  70131. * @hidden
  70132. */
  70133. renderList: SmartArray<BoundingBox>;
  70134. private _colorShader;
  70135. private _vertexBuffers;
  70136. private _indexBuffer;
  70137. private _fillIndexBuffer;
  70138. private _fillIndexData;
  70139. /**
  70140. * Instantiates a new bounding box renderer in a scene.
  70141. * @param scene the scene the renderer renders in
  70142. */
  70143. constructor(scene: Scene);
  70144. /**
  70145. * Registers the component in a given scene
  70146. */
  70147. register(): void;
  70148. private _evaluateSubMesh;
  70149. private _activeMesh;
  70150. private _prepareRessources;
  70151. private _createIndexBuffer;
  70152. /**
  70153. * Rebuilds the elements related to this component in case of
  70154. * context lost for instance.
  70155. */
  70156. rebuild(): void;
  70157. /**
  70158. * @hidden
  70159. */
  70160. reset(): void;
  70161. /**
  70162. * Render the bounding boxes of a specific rendering group
  70163. * @param renderingGroupId defines the rendering group to render
  70164. */
  70165. render(renderingGroupId: number): void;
  70166. /**
  70167. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70168. * @param mesh Define the mesh to render the occlusion bounding box for
  70169. */
  70170. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70171. /**
  70172. * Dispose and release the resources attached to this renderer.
  70173. */
  70174. dispose(): void;
  70175. }
  70176. }
  70177. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70178. import { Nullable } from "babylonjs/types";
  70179. import { Scene } from "babylonjs/scene";
  70180. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70181. import { Camera } from "babylonjs/Cameras/camera";
  70182. import { ISceneComponent } from "babylonjs/sceneComponent";
  70183. module "babylonjs/scene" {
  70184. interface Scene {
  70185. /** @hidden (Backing field) */
  70186. _depthRenderer: {
  70187. [id: string]: DepthRenderer;
  70188. };
  70189. /**
  70190. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70191. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70192. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70193. * @returns the created depth renderer
  70194. */
  70195. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70196. /**
  70197. * Disables a depth renderer for a given camera
  70198. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70199. */
  70200. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70201. }
  70202. }
  70203. /**
  70204. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70205. * in several rendering techniques.
  70206. */
  70207. export class DepthRendererSceneComponent implements ISceneComponent {
  70208. /**
  70209. * The component name helpfull to identify the component in the list of scene components.
  70210. */
  70211. readonly name: string;
  70212. /**
  70213. * The scene the component belongs to.
  70214. */
  70215. scene: Scene;
  70216. /**
  70217. * Creates a new instance of the component for the given scene
  70218. * @param scene Defines the scene to register the component in
  70219. */
  70220. constructor(scene: Scene);
  70221. /**
  70222. * Registers the component in a given scene
  70223. */
  70224. register(): void;
  70225. /**
  70226. * Rebuilds the elements related to this component in case of
  70227. * context lost for instance.
  70228. */
  70229. rebuild(): void;
  70230. /**
  70231. * Disposes the component and the associated ressources
  70232. */
  70233. dispose(): void;
  70234. private _gatherRenderTargets;
  70235. private _gatherActiveCameraRenderTargets;
  70236. }
  70237. }
  70238. declare module "babylonjs/Shaders/outline.fragment" {
  70239. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70240. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70241. /** @hidden */
  70242. export var outlinePixelShader: {
  70243. name: string;
  70244. shader: string;
  70245. };
  70246. }
  70247. declare module "babylonjs/Shaders/outline.vertex" {
  70248. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70249. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70250. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70251. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70252. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70253. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70254. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70255. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70256. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70257. /** @hidden */
  70258. export var outlineVertexShader: {
  70259. name: string;
  70260. shader: string;
  70261. };
  70262. }
  70263. declare module "babylonjs/Rendering/outlineRenderer" {
  70264. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70265. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70266. import { Scene } from "babylonjs/scene";
  70267. import { ISceneComponent } from "babylonjs/sceneComponent";
  70268. import "babylonjs/Shaders/outline.fragment";
  70269. import "babylonjs/Shaders/outline.vertex";
  70270. module "babylonjs/scene" {
  70271. interface Scene {
  70272. /** @hidden */
  70273. _outlineRenderer: OutlineRenderer;
  70274. /**
  70275. * Gets the outline renderer associated with the scene
  70276. * @returns a OutlineRenderer
  70277. */
  70278. getOutlineRenderer(): OutlineRenderer;
  70279. }
  70280. }
  70281. module "babylonjs/Meshes/abstractMesh" {
  70282. interface AbstractMesh {
  70283. /** @hidden (Backing field) */
  70284. _renderOutline: boolean;
  70285. /**
  70286. * Gets or sets a boolean indicating if the outline must be rendered as well
  70287. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70288. */
  70289. renderOutline: boolean;
  70290. /** @hidden (Backing field) */
  70291. _renderOverlay: boolean;
  70292. /**
  70293. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70294. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70295. */
  70296. renderOverlay: boolean;
  70297. }
  70298. }
  70299. /**
  70300. * This class is responsible to draw bothe outline/overlay of meshes.
  70301. * It should not be used directly but through the available method on mesh.
  70302. */
  70303. export class OutlineRenderer implements ISceneComponent {
  70304. /**
  70305. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70306. */
  70307. private static _StencilReference;
  70308. /**
  70309. * The name of the component. Each component must have a unique name.
  70310. */
  70311. name: string;
  70312. /**
  70313. * The scene the component belongs to.
  70314. */
  70315. scene: Scene;
  70316. /**
  70317. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70318. */
  70319. zOffset: number;
  70320. private _engine;
  70321. private _effect;
  70322. private _cachedDefines;
  70323. private _savedDepthWrite;
  70324. /**
  70325. * Instantiates a new outline renderer. (There could be only one per scene).
  70326. * @param scene Defines the scene it belongs to
  70327. */
  70328. constructor(scene: Scene);
  70329. /**
  70330. * Register the component to one instance of a scene.
  70331. */
  70332. register(): void;
  70333. /**
  70334. * Rebuilds the elements related to this component in case of
  70335. * context lost for instance.
  70336. */
  70337. rebuild(): void;
  70338. /**
  70339. * Disposes the component and the associated ressources.
  70340. */
  70341. dispose(): void;
  70342. /**
  70343. * Renders the outline in the canvas.
  70344. * @param subMesh Defines the sumesh to render
  70345. * @param batch Defines the batch of meshes in case of instances
  70346. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70347. */
  70348. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70349. /**
  70350. * Returns whether or not the outline renderer is ready for a given submesh.
  70351. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70352. * @param subMesh Defines the submesh to check readyness for
  70353. * @param useInstances Defines wheter wee are trying to render instances or not
  70354. * @returns true if ready otherwise false
  70355. */
  70356. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70357. private _beforeRenderingMesh;
  70358. private _afterRenderingMesh;
  70359. }
  70360. }
  70361. declare module "babylonjs/Rendering/index" {
  70362. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70363. export * from "babylonjs/Rendering/depthRenderer";
  70364. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70365. export * from "babylonjs/Rendering/edgesRenderer";
  70366. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70367. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70368. export * from "babylonjs/Rendering/outlineRenderer";
  70369. export * from "babylonjs/Rendering/renderingGroup";
  70370. export * from "babylonjs/Rendering/renderingManager";
  70371. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70372. }
  70373. declare module "babylonjs/Sprites/ISprites" {
  70374. /**
  70375. * Defines the basic options interface of a Sprite Frame Source Size.
  70376. */
  70377. export interface ISpriteJSONSpriteSourceSize {
  70378. /**
  70379. * number of the original width of the Frame
  70380. */
  70381. w: number;
  70382. /**
  70383. * number of the original height of the Frame
  70384. */
  70385. h: number;
  70386. }
  70387. /**
  70388. * Defines the basic options interface of a Sprite Frame Data.
  70389. */
  70390. export interface ISpriteJSONSpriteFrameData {
  70391. /**
  70392. * number of the x offset of the Frame
  70393. */
  70394. x: number;
  70395. /**
  70396. * number of the y offset of the Frame
  70397. */
  70398. y: number;
  70399. /**
  70400. * number of the width of the Frame
  70401. */
  70402. w: number;
  70403. /**
  70404. * number of the height of the Frame
  70405. */
  70406. h: number;
  70407. }
  70408. /**
  70409. * Defines the basic options interface of a JSON Sprite.
  70410. */
  70411. export interface ISpriteJSONSprite {
  70412. /**
  70413. * string name of the Frame
  70414. */
  70415. filename: string;
  70416. /**
  70417. * ISpriteJSONSpriteFrame basic object of the frame data
  70418. */
  70419. frame: ISpriteJSONSpriteFrameData;
  70420. /**
  70421. * boolean to flag is the frame was rotated.
  70422. */
  70423. rotated: boolean;
  70424. /**
  70425. * boolean to flag is the frame was trimmed.
  70426. */
  70427. trimmed: boolean;
  70428. /**
  70429. * ISpriteJSONSpriteFrame basic object of the source data
  70430. */
  70431. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70432. /**
  70433. * ISpriteJSONSpriteFrame basic object of the source data
  70434. */
  70435. sourceSize: ISpriteJSONSpriteSourceSize;
  70436. }
  70437. /**
  70438. * Defines the basic options interface of a JSON atlas.
  70439. */
  70440. export interface ISpriteJSONAtlas {
  70441. /**
  70442. * Array of objects that contain the frame data.
  70443. */
  70444. frames: Array<ISpriteJSONSprite>;
  70445. /**
  70446. * object basic object containing the sprite meta data.
  70447. */
  70448. meta?: object;
  70449. }
  70450. }
  70451. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70452. /** @hidden */
  70453. export var spriteMapPixelShader: {
  70454. name: string;
  70455. shader: string;
  70456. };
  70457. }
  70458. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70459. /** @hidden */
  70460. export var spriteMapVertexShader: {
  70461. name: string;
  70462. shader: string;
  70463. };
  70464. }
  70465. declare module "babylonjs/Sprites/spriteMap" {
  70466. import { IDisposable, Scene } from "babylonjs/scene";
  70467. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70468. import { Texture } from "babylonjs/Materials/Textures/texture";
  70469. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70470. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70471. import "babylonjs/Meshes/Builders/planeBuilder";
  70472. import "babylonjs/Shaders/spriteMap.fragment";
  70473. import "babylonjs/Shaders/spriteMap.vertex";
  70474. /**
  70475. * Defines the basic options interface of a SpriteMap
  70476. */
  70477. export interface ISpriteMapOptions {
  70478. /**
  70479. * Vector2 of the number of cells in the grid.
  70480. */
  70481. stageSize?: Vector2;
  70482. /**
  70483. * Vector2 of the size of the output plane in World Units.
  70484. */
  70485. outputSize?: Vector2;
  70486. /**
  70487. * Vector3 of the position of the output plane in World Units.
  70488. */
  70489. outputPosition?: Vector3;
  70490. /**
  70491. * Vector3 of the rotation of the output plane.
  70492. */
  70493. outputRotation?: Vector3;
  70494. /**
  70495. * number of layers that the system will reserve in resources.
  70496. */
  70497. layerCount?: number;
  70498. /**
  70499. * number of max animation frames a single cell will reserve in resources.
  70500. */
  70501. maxAnimationFrames?: number;
  70502. /**
  70503. * number cell index of the base tile when the system compiles.
  70504. */
  70505. baseTile?: number;
  70506. /**
  70507. * boolean flip the sprite after its been repositioned by the framing data.
  70508. */
  70509. flipU?: boolean;
  70510. /**
  70511. * Vector3 scalar of the global RGB values of the SpriteMap.
  70512. */
  70513. colorMultiply?: Vector3;
  70514. }
  70515. /**
  70516. * Defines the IDisposable interface in order to be cleanable from resources.
  70517. */
  70518. export interface ISpriteMap extends IDisposable {
  70519. /**
  70520. * String name of the SpriteMap.
  70521. */
  70522. name: string;
  70523. /**
  70524. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70525. */
  70526. atlasJSON: ISpriteJSONAtlas;
  70527. /**
  70528. * Texture of the SpriteMap.
  70529. */
  70530. spriteSheet: Texture;
  70531. /**
  70532. * The parameters to initialize the SpriteMap with.
  70533. */
  70534. options: ISpriteMapOptions;
  70535. }
  70536. /**
  70537. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70538. */
  70539. export class SpriteMap implements ISpriteMap {
  70540. /** The Name of the spriteMap */
  70541. name: string;
  70542. /** The JSON file with the frame and meta data */
  70543. atlasJSON: ISpriteJSONAtlas;
  70544. /** The systems Sprite Sheet Texture */
  70545. spriteSheet: Texture;
  70546. /** Arguments passed with the Constructor */
  70547. options: ISpriteMapOptions;
  70548. /** Public Sprite Storage array, parsed from atlasJSON */
  70549. sprites: Array<ISpriteJSONSprite>;
  70550. /** Returns the Number of Sprites in the System */
  70551. get spriteCount(): number;
  70552. /** Returns the Position of Output Plane*/
  70553. get position(): Vector3;
  70554. /** Returns the Position of Output Plane*/
  70555. set position(v: Vector3);
  70556. /** Returns the Rotation of Output Plane*/
  70557. get rotation(): Vector3;
  70558. /** Returns the Rotation of Output Plane*/
  70559. set rotation(v: Vector3);
  70560. /** Sets the AnimationMap*/
  70561. get animationMap(): RawTexture;
  70562. /** Sets the AnimationMap*/
  70563. set animationMap(v: RawTexture);
  70564. /** Scene that the SpriteMap was created in */
  70565. private _scene;
  70566. /** Texture Buffer of Float32 that holds tile frame data*/
  70567. private _frameMap;
  70568. /** Texture Buffers of Float32 that holds tileMap data*/
  70569. private _tileMaps;
  70570. /** Texture Buffer of Float32 that holds Animation Data*/
  70571. private _animationMap;
  70572. /** Custom ShaderMaterial Central to the System*/
  70573. private _material;
  70574. /** Custom ShaderMaterial Central to the System*/
  70575. private _output;
  70576. /** Systems Time Ticker*/
  70577. private _time;
  70578. /**
  70579. * Creates a new SpriteMap
  70580. * @param name defines the SpriteMaps Name
  70581. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70582. * @param spriteSheet is the Texture that the Sprites are on.
  70583. * @param options a basic deployment configuration
  70584. * @param scene The Scene that the map is deployed on
  70585. */
  70586. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70587. /**
  70588. * Returns tileID location
  70589. * @returns Vector2 the cell position ID
  70590. */
  70591. getTileID(): Vector2;
  70592. /**
  70593. * Gets the UV location of the mouse over the SpriteMap.
  70594. * @returns Vector2 the UV position of the mouse interaction
  70595. */
  70596. getMousePosition(): Vector2;
  70597. /**
  70598. * Creates the "frame" texture Buffer
  70599. * -------------------------------------
  70600. * Structure of frames
  70601. * "filename": "Falling-Water-2.png",
  70602. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70603. * "rotated": true,
  70604. * "trimmed": true,
  70605. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70606. * "sourceSize": {"w":32,"h":32}
  70607. * @returns RawTexture of the frameMap
  70608. */
  70609. private _createFrameBuffer;
  70610. /**
  70611. * Creates the tileMap texture Buffer
  70612. * @param buffer normally and array of numbers, or a false to generate from scratch
  70613. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70614. * @returns RawTexture of the tileMap
  70615. */
  70616. private _createTileBuffer;
  70617. /**
  70618. * Modifies the data of the tileMaps
  70619. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70620. * @param pos is the iVector2 Coordinates of the Tile
  70621. * @param tile The SpriteIndex of the new Tile
  70622. */
  70623. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70624. /**
  70625. * Creates the animationMap texture Buffer
  70626. * @param buffer normally and array of numbers, or a false to generate from scratch
  70627. * @returns RawTexture of the animationMap
  70628. */
  70629. private _createTileAnimationBuffer;
  70630. /**
  70631. * Modifies the data of the animationMap
  70632. * @param cellID is the Index of the Sprite
  70633. * @param _frame is the target Animation frame
  70634. * @param toCell is the Target Index of the next frame of the animation
  70635. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70636. * @param speed is a global scalar of the time variable on the map.
  70637. */
  70638. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70639. /**
  70640. * Exports the .tilemaps file
  70641. */
  70642. saveTileMaps(): void;
  70643. /**
  70644. * Imports the .tilemaps file
  70645. * @param url of the .tilemaps file
  70646. */
  70647. loadTileMaps(url: string): void;
  70648. /**
  70649. * Release associated resources
  70650. */
  70651. dispose(): void;
  70652. }
  70653. }
  70654. declare module "babylonjs/Sprites/spritePackedManager" {
  70655. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70656. import { Scene } from "babylonjs/scene";
  70657. /**
  70658. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70659. * @see http://doc.babylonjs.com/babylon101/sprites
  70660. */
  70661. export class SpritePackedManager extends SpriteManager {
  70662. /** defines the packed manager's name */
  70663. name: string;
  70664. /**
  70665. * Creates a new sprite manager from a packed sprite sheet
  70666. * @param name defines the manager's name
  70667. * @param imgUrl defines the sprite sheet url
  70668. * @param capacity defines the maximum allowed number of sprites
  70669. * @param scene defines the hosting scene
  70670. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70671. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70672. * @param samplingMode defines the smapling mode to use with spritesheet
  70673. * @param fromPacked set to true; do not alter
  70674. */
  70675. constructor(
  70676. /** defines the packed manager's name */
  70677. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70678. }
  70679. }
  70680. declare module "babylonjs/Sprites/index" {
  70681. export * from "babylonjs/Sprites/sprite";
  70682. export * from "babylonjs/Sprites/ISprites";
  70683. export * from "babylonjs/Sprites/spriteManager";
  70684. export * from "babylonjs/Sprites/spriteMap";
  70685. export * from "babylonjs/Sprites/spritePackedManager";
  70686. export * from "babylonjs/Sprites/spriteSceneComponent";
  70687. }
  70688. declare module "babylonjs/States/index" {
  70689. export * from "babylonjs/States/alphaCullingState";
  70690. export * from "babylonjs/States/depthCullingState";
  70691. export * from "babylonjs/States/stencilState";
  70692. }
  70693. declare module "babylonjs/Misc/assetsManager" {
  70694. import { Scene } from "babylonjs/scene";
  70695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70696. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70697. import { Skeleton } from "babylonjs/Bones/skeleton";
  70698. import { Observable } from "babylonjs/Misc/observable";
  70699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70700. import { Texture } from "babylonjs/Materials/Textures/texture";
  70701. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70702. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70703. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70704. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70705. /**
  70706. * Defines the list of states available for a task inside a AssetsManager
  70707. */
  70708. export enum AssetTaskState {
  70709. /**
  70710. * Initialization
  70711. */
  70712. INIT = 0,
  70713. /**
  70714. * Running
  70715. */
  70716. RUNNING = 1,
  70717. /**
  70718. * Done
  70719. */
  70720. DONE = 2,
  70721. /**
  70722. * Error
  70723. */
  70724. ERROR = 3
  70725. }
  70726. /**
  70727. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70728. */
  70729. export abstract class AbstractAssetTask {
  70730. /**
  70731. * Task name
  70732. */ name: string;
  70733. /**
  70734. * Callback called when the task is successful
  70735. */
  70736. onSuccess: (task: any) => void;
  70737. /**
  70738. * Callback called when the task is not successful
  70739. */
  70740. onError: (task: any, message?: string, exception?: any) => void;
  70741. /**
  70742. * Creates a new AssetsManager
  70743. * @param name defines the name of the task
  70744. */
  70745. constructor(
  70746. /**
  70747. * Task name
  70748. */ name: string);
  70749. private _isCompleted;
  70750. private _taskState;
  70751. private _errorObject;
  70752. /**
  70753. * Get if the task is completed
  70754. */
  70755. get isCompleted(): boolean;
  70756. /**
  70757. * Gets the current state of the task
  70758. */
  70759. get taskState(): AssetTaskState;
  70760. /**
  70761. * Gets the current error object (if task is in error)
  70762. */
  70763. get errorObject(): {
  70764. message?: string;
  70765. exception?: any;
  70766. };
  70767. /**
  70768. * Internal only
  70769. * @hidden
  70770. */
  70771. _setErrorObject(message?: string, exception?: any): void;
  70772. /**
  70773. * Execute the current task
  70774. * @param scene defines the scene where you want your assets to be loaded
  70775. * @param onSuccess is a callback called when the task is successfully executed
  70776. * @param onError is a callback called if an error occurs
  70777. */
  70778. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70779. /**
  70780. * Execute the current task
  70781. * @param scene defines the scene where you want your assets to be loaded
  70782. * @param onSuccess is a callback called when the task is successfully executed
  70783. * @param onError is a callback called if an error occurs
  70784. */
  70785. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70786. /**
  70787. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70788. * This can be used with failed tasks that have the reason for failure fixed.
  70789. */
  70790. reset(): void;
  70791. private onErrorCallback;
  70792. private onDoneCallback;
  70793. }
  70794. /**
  70795. * Define the interface used by progress events raised during assets loading
  70796. */
  70797. export interface IAssetsProgressEvent {
  70798. /**
  70799. * Defines the number of remaining tasks to process
  70800. */
  70801. remainingCount: number;
  70802. /**
  70803. * Defines the total number of tasks
  70804. */
  70805. totalCount: number;
  70806. /**
  70807. * Defines the task that was just processed
  70808. */
  70809. task: AbstractAssetTask;
  70810. }
  70811. /**
  70812. * Class used to share progress information about assets loading
  70813. */
  70814. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70815. /**
  70816. * Defines the number of remaining tasks to process
  70817. */
  70818. remainingCount: number;
  70819. /**
  70820. * Defines the total number of tasks
  70821. */
  70822. totalCount: number;
  70823. /**
  70824. * Defines the task that was just processed
  70825. */
  70826. task: AbstractAssetTask;
  70827. /**
  70828. * Creates a AssetsProgressEvent
  70829. * @param remainingCount defines the number of remaining tasks to process
  70830. * @param totalCount defines the total number of tasks
  70831. * @param task defines the task that was just processed
  70832. */
  70833. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70834. }
  70835. /**
  70836. * Define a task used by AssetsManager to load meshes
  70837. */
  70838. export class MeshAssetTask extends AbstractAssetTask {
  70839. /**
  70840. * Defines the name of the task
  70841. */
  70842. name: string;
  70843. /**
  70844. * Defines the list of mesh's names you want to load
  70845. */
  70846. meshesNames: any;
  70847. /**
  70848. * Defines the root url to use as a base to load your meshes and associated resources
  70849. */
  70850. rootUrl: string;
  70851. /**
  70852. * Defines the filename of the scene to load from
  70853. */
  70854. sceneFilename: string;
  70855. /**
  70856. * Gets the list of loaded meshes
  70857. */
  70858. loadedMeshes: Array<AbstractMesh>;
  70859. /**
  70860. * Gets the list of loaded particle systems
  70861. */
  70862. loadedParticleSystems: Array<IParticleSystem>;
  70863. /**
  70864. * Gets the list of loaded skeletons
  70865. */
  70866. loadedSkeletons: Array<Skeleton>;
  70867. /**
  70868. * Gets the list of loaded animation groups
  70869. */
  70870. loadedAnimationGroups: Array<AnimationGroup>;
  70871. /**
  70872. * Callback called when the task is successful
  70873. */
  70874. onSuccess: (task: MeshAssetTask) => void;
  70875. /**
  70876. * Callback called when the task is successful
  70877. */
  70878. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70879. /**
  70880. * Creates a new MeshAssetTask
  70881. * @param name defines the name of the task
  70882. * @param meshesNames defines the list of mesh's names you want to load
  70883. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70884. * @param sceneFilename defines the filename of the scene to load from
  70885. */
  70886. constructor(
  70887. /**
  70888. * Defines the name of the task
  70889. */
  70890. name: string,
  70891. /**
  70892. * Defines the list of mesh's names you want to load
  70893. */
  70894. meshesNames: any,
  70895. /**
  70896. * Defines the root url to use as a base to load your meshes and associated resources
  70897. */
  70898. rootUrl: string,
  70899. /**
  70900. * Defines the filename of the scene to load from
  70901. */
  70902. sceneFilename: string);
  70903. /**
  70904. * Execute the current task
  70905. * @param scene defines the scene where you want your assets to be loaded
  70906. * @param onSuccess is a callback called when the task is successfully executed
  70907. * @param onError is a callback called if an error occurs
  70908. */
  70909. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70910. }
  70911. /**
  70912. * Define a task used by AssetsManager to load text content
  70913. */
  70914. export class TextFileAssetTask extends AbstractAssetTask {
  70915. /**
  70916. * Defines the name of the task
  70917. */
  70918. name: string;
  70919. /**
  70920. * Defines the location of the file to load
  70921. */
  70922. url: string;
  70923. /**
  70924. * Gets the loaded text string
  70925. */
  70926. text: string;
  70927. /**
  70928. * Callback called when the task is successful
  70929. */
  70930. onSuccess: (task: TextFileAssetTask) => void;
  70931. /**
  70932. * Callback called when the task is successful
  70933. */
  70934. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70935. /**
  70936. * Creates a new TextFileAssetTask object
  70937. * @param name defines the name of the task
  70938. * @param url defines the location of the file to load
  70939. */
  70940. constructor(
  70941. /**
  70942. * Defines the name of the task
  70943. */
  70944. name: string,
  70945. /**
  70946. * Defines the location of the file to load
  70947. */
  70948. url: string);
  70949. /**
  70950. * Execute the current task
  70951. * @param scene defines the scene where you want your assets to be loaded
  70952. * @param onSuccess is a callback called when the task is successfully executed
  70953. * @param onError is a callback called if an error occurs
  70954. */
  70955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70956. }
  70957. /**
  70958. * Define a task used by AssetsManager to load binary data
  70959. */
  70960. export class BinaryFileAssetTask extends AbstractAssetTask {
  70961. /**
  70962. * Defines the name of the task
  70963. */
  70964. name: string;
  70965. /**
  70966. * Defines the location of the file to load
  70967. */
  70968. url: string;
  70969. /**
  70970. * Gets the lodaded data (as an array buffer)
  70971. */
  70972. data: ArrayBuffer;
  70973. /**
  70974. * Callback called when the task is successful
  70975. */
  70976. onSuccess: (task: BinaryFileAssetTask) => void;
  70977. /**
  70978. * Callback called when the task is successful
  70979. */
  70980. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70981. /**
  70982. * Creates a new BinaryFileAssetTask object
  70983. * @param name defines the name of the new task
  70984. * @param url defines the location of the file to load
  70985. */
  70986. constructor(
  70987. /**
  70988. * Defines the name of the task
  70989. */
  70990. name: string,
  70991. /**
  70992. * Defines the location of the file to load
  70993. */
  70994. url: string);
  70995. /**
  70996. * Execute the current task
  70997. * @param scene defines the scene where you want your assets to be loaded
  70998. * @param onSuccess is a callback called when the task is successfully executed
  70999. * @param onError is a callback called if an error occurs
  71000. */
  71001. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71002. }
  71003. /**
  71004. * Define a task used by AssetsManager to load images
  71005. */
  71006. export class ImageAssetTask extends AbstractAssetTask {
  71007. /**
  71008. * Defines the name of the task
  71009. */
  71010. name: string;
  71011. /**
  71012. * Defines the location of the image to load
  71013. */
  71014. url: string;
  71015. /**
  71016. * Gets the loaded images
  71017. */
  71018. image: HTMLImageElement;
  71019. /**
  71020. * Callback called when the task is successful
  71021. */
  71022. onSuccess: (task: ImageAssetTask) => void;
  71023. /**
  71024. * Callback called when the task is successful
  71025. */
  71026. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71027. /**
  71028. * Creates a new ImageAssetTask
  71029. * @param name defines the name of the task
  71030. * @param url defines the location of the image to load
  71031. */
  71032. constructor(
  71033. /**
  71034. * Defines the name of the task
  71035. */
  71036. name: string,
  71037. /**
  71038. * Defines the location of the image to load
  71039. */
  71040. url: string);
  71041. /**
  71042. * Execute the current task
  71043. * @param scene defines the scene where you want your assets to be loaded
  71044. * @param onSuccess is a callback called when the task is successfully executed
  71045. * @param onError is a callback called if an error occurs
  71046. */
  71047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71048. }
  71049. /**
  71050. * Defines the interface used by texture loading tasks
  71051. */
  71052. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71053. /**
  71054. * Gets the loaded texture
  71055. */
  71056. texture: TEX;
  71057. }
  71058. /**
  71059. * Define a task used by AssetsManager to load 2D textures
  71060. */
  71061. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71062. /**
  71063. * Defines the name of the task
  71064. */
  71065. name: string;
  71066. /**
  71067. * Defines the location of the file to load
  71068. */
  71069. url: string;
  71070. /**
  71071. * Defines if mipmap should not be generated (default is false)
  71072. */
  71073. noMipmap?: boolean | undefined;
  71074. /**
  71075. * Defines if texture must be inverted on Y axis (default is false)
  71076. */
  71077. invertY?: boolean | undefined;
  71078. /**
  71079. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71080. */
  71081. samplingMode: number;
  71082. /**
  71083. * Gets the loaded texture
  71084. */
  71085. texture: Texture;
  71086. /**
  71087. * Callback called when the task is successful
  71088. */
  71089. onSuccess: (task: TextureAssetTask) => void;
  71090. /**
  71091. * Callback called when the task is successful
  71092. */
  71093. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71094. /**
  71095. * Creates a new TextureAssetTask object
  71096. * @param name defines the name of the task
  71097. * @param url defines the location of the file to load
  71098. * @param noMipmap defines if mipmap should not be generated (default is false)
  71099. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71100. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71101. */
  71102. constructor(
  71103. /**
  71104. * Defines the name of the task
  71105. */
  71106. name: string,
  71107. /**
  71108. * Defines the location of the file to load
  71109. */
  71110. url: string,
  71111. /**
  71112. * Defines if mipmap should not be generated (default is false)
  71113. */
  71114. noMipmap?: boolean | undefined,
  71115. /**
  71116. * Defines if texture must be inverted on Y axis (default is false)
  71117. */
  71118. invertY?: boolean | undefined,
  71119. /**
  71120. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71121. */
  71122. samplingMode?: number);
  71123. /**
  71124. * Execute the current task
  71125. * @param scene defines the scene where you want your assets to be loaded
  71126. * @param onSuccess is a callback called when the task is successfully executed
  71127. * @param onError is a callback called if an error occurs
  71128. */
  71129. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71130. }
  71131. /**
  71132. * Define a task used by AssetsManager to load cube textures
  71133. */
  71134. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71135. /**
  71136. * Defines the name of the task
  71137. */
  71138. name: string;
  71139. /**
  71140. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71141. */
  71142. url: string;
  71143. /**
  71144. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71145. */
  71146. extensions?: string[] | undefined;
  71147. /**
  71148. * Defines if mipmaps should not be generated (default is false)
  71149. */
  71150. noMipmap?: boolean | undefined;
  71151. /**
  71152. * Defines the explicit list of files (undefined by default)
  71153. */
  71154. files?: string[] | undefined;
  71155. /**
  71156. * Gets the loaded texture
  71157. */
  71158. texture: CubeTexture;
  71159. /**
  71160. * Callback called when the task is successful
  71161. */
  71162. onSuccess: (task: CubeTextureAssetTask) => void;
  71163. /**
  71164. * Callback called when the task is successful
  71165. */
  71166. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71167. /**
  71168. * Creates a new CubeTextureAssetTask
  71169. * @param name defines the name of the task
  71170. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71171. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71172. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71173. * @param files defines the explicit list of files (undefined by default)
  71174. */
  71175. constructor(
  71176. /**
  71177. * Defines the name of the task
  71178. */
  71179. name: string,
  71180. /**
  71181. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71182. */
  71183. url: string,
  71184. /**
  71185. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71186. */
  71187. extensions?: string[] | undefined,
  71188. /**
  71189. * Defines if mipmaps should not be generated (default is false)
  71190. */
  71191. noMipmap?: boolean | undefined,
  71192. /**
  71193. * Defines the explicit list of files (undefined by default)
  71194. */
  71195. files?: string[] | undefined);
  71196. /**
  71197. * Execute the current task
  71198. * @param scene defines the scene where you want your assets to be loaded
  71199. * @param onSuccess is a callback called when the task is successfully executed
  71200. * @param onError is a callback called if an error occurs
  71201. */
  71202. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71203. }
  71204. /**
  71205. * Define a task used by AssetsManager to load HDR cube textures
  71206. */
  71207. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71208. /**
  71209. * Defines the name of the task
  71210. */
  71211. name: string;
  71212. /**
  71213. * Defines the location of the file to load
  71214. */
  71215. url: string;
  71216. /**
  71217. * Defines the desired size (the more it increases the longer the generation will be)
  71218. */
  71219. size: number;
  71220. /**
  71221. * Defines if mipmaps should not be generated (default is false)
  71222. */
  71223. noMipmap: boolean;
  71224. /**
  71225. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71226. */
  71227. generateHarmonics: boolean;
  71228. /**
  71229. * 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)
  71230. */
  71231. gammaSpace: boolean;
  71232. /**
  71233. * Internal Use Only
  71234. */
  71235. reserved: boolean;
  71236. /**
  71237. * Gets the loaded texture
  71238. */
  71239. texture: HDRCubeTexture;
  71240. /**
  71241. * Callback called when the task is successful
  71242. */
  71243. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71244. /**
  71245. * Callback called when the task is successful
  71246. */
  71247. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71248. /**
  71249. * Creates a new HDRCubeTextureAssetTask object
  71250. * @param name defines the name of the task
  71251. * @param url defines the location of the file to load
  71252. * @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.
  71253. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71254. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71255. * @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)
  71256. * @param reserved Internal use only
  71257. */
  71258. constructor(
  71259. /**
  71260. * Defines the name of the task
  71261. */
  71262. name: string,
  71263. /**
  71264. * Defines the location of the file to load
  71265. */
  71266. url: string,
  71267. /**
  71268. * Defines the desired size (the more it increases the longer the generation will be)
  71269. */
  71270. size: number,
  71271. /**
  71272. * Defines if mipmaps should not be generated (default is false)
  71273. */
  71274. noMipmap?: boolean,
  71275. /**
  71276. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71277. */
  71278. generateHarmonics?: boolean,
  71279. /**
  71280. * 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)
  71281. */
  71282. gammaSpace?: boolean,
  71283. /**
  71284. * Internal Use Only
  71285. */
  71286. reserved?: boolean);
  71287. /**
  71288. * Execute the current task
  71289. * @param scene defines the scene where you want your assets to be loaded
  71290. * @param onSuccess is a callback called when the task is successfully executed
  71291. * @param onError is a callback called if an error occurs
  71292. */
  71293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71294. }
  71295. /**
  71296. * Define a task used by AssetsManager to load Equirectangular cube textures
  71297. */
  71298. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71299. /**
  71300. * Defines the name of the task
  71301. */
  71302. name: string;
  71303. /**
  71304. * Defines the location of the file to load
  71305. */
  71306. url: string;
  71307. /**
  71308. * Defines the desired size (the more it increases the longer the generation will be)
  71309. */
  71310. size: number;
  71311. /**
  71312. * Defines if mipmaps should not be generated (default is false)
  71313. */
  71314. noMipmap: boolean;
  71315. /**
  71316. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71317. * but the standard material would require them in Gamma space) (default is true)
  71318. */
  71319. gammaSpace: boolean;
  71320. /**
  71321. * Gets the loaded texture
  71322. */
  71323. texture: EquiRectangularCubeTexture;
  71324. /**
  71325. * Callback called when the task is successful
  71326. */
  71327. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71328. /**
  71329. * Callback called when the task is successful
  71330. */
  71331. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71332. /**
  71333. * Creates a new EquiRectangularCubeTextureAssetTask object
  71334. * @param name defines the name of the task
  71335. * @param url defines the location of the file to load
  71336. * @param size defines the desired size (the more it increases the longer the generation will be)
  71337. * If the size is omitted this implies you are using a preprocessed cubemap.
  71338. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71339. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71340. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71341. * (default is true)
  71342. */
  71343. constructor(
  71344. /**
  71345. * Defines the name of the task
  71346. */
  71347. name: string,
  71348. /**
  71349. * Defines the location of the file to load
  71350. */
  71351. url: string,
  71352. /**
  71353. * Defines the desired size (the more it increases the longer the generation will be)
  71354. */
  71355. size: number,
  71356. /**
  71357. * Defines if mipmaps should not be generated (default is false)
  71358. */
  71359. noMipmap?: boolean,
  71360. /**
  71361. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71362. * but the standard material would require them in Gamma space) (default is true)
  71363. */
  71364. gammaSpace?: boolean);
  71365. /**
  71366. * Execute the current task
  71367. * @param scene defines the scene where you want your assets to be loaded
  71368. * @param onSuccess is a callback called when the task is successfully executed
  71369. * @param onError is a callback called if an error occurs
  71370. */
  71371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71372. }
  71373. /**
  71374. * This class can be used to easily import assets into a scene
  71375. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71376. */
  71377. export class AssetsManager {
  71378. private _scene;
  71379. private _isLoading;
  71380. protected _tasks: AbstractAssetTask[];
  71381. protected _waitingTasksCount: number;
  71382. protected _totalTasksCount: number;
  71383. /**
  71384. * Callback called when all tasks are processed
  71385. */
  71386. onFinish: (tasks: AbstractAssetTask[]) => void;
  71387. /**
  71388. * Callback called when a task is successful
  71389. */
  71390. onTaskSuccess: (task: AbstractAssetTask) => void;
  71391. /**
  71392. * Callback called when a task had an error
  71393. */
  71394. onTaskError: (task: AbstractAssetTask) => void;
  71395. /**
  71396. * Callback called when a task is done (whatever the result is)
  71397. */
  71398. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71399. /**
  71400. * Observable called when all tasks are processed
  71401. */
  71402. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71403. /**
  71404. * Observable called when a task had an error
  71405. */
  71406. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71407. /**
  71408. * Observable called when all tasks were executed
  71409. */
  71410. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71411. /**
  71412. * Observable called when a task is done (whatever the result is)
  71413. */
  71414. onProgressObservable: Observable<IAssetsProgressEvent>;
  71415. /**
  71416. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71417. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71418. */
  71419. useDefaultLoadingScreen: boolean;
  71420. /**
  71421. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71422. * when all assets have been downloaded.
  71423. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71424. */
  71425. autoHideLoadingUI: boolean;
  71426. /**
  71427. * Creates a new AssetsManager
  71428. * @param scene defines the scene to work on
  71429. */
  71430. constructor(scene: Scene);
  71431. /**
  71432. * Add a MeshAssetTask to the list of active tasks
  71433. * @param taskName defines the name of the new task
  71434. * @param meshesNames defines the name of meshes to load
  71435. * @param rootUrl defines the root url to use to locate files
  71436. * @param sceneFilename defines the filename of the scene file
  71437. * @returns a new MeshAssetTask object
  71438. */
  71439. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71440. /**
  71441. * Add a TextFileAssetTask to the list of active tasks
  71442. * @param taskName defines the name of the new task
  71443. * @param url defines the url of the file to load
  71444. * @returns a new TextFileAssetTask object
  71445. */
  71446. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71447. /**
  71448. * Add a BinaryFileAssetTask to the list of active tasks
  71449. * @param taskName defines the name of the new task
  71450. * @param url defines the url of the file to load
  71451. * @returns a new BinaryFileAssetTask object
  71452. */
  71453. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71454. /**
  71455. * Add a ImageAssetTask to the list of active tasks
  71456. * @param taskName defines the name of the new task
  71457. * @param url defines the url of the file to load
  71458. * @returns a new ImageAssetTask object
  71459. */
  71460. addImageTask(taskName: string, url: string): ImageAssetTask;
  71461. /**
  71462. * Add a TextureAssetTask to the list of active tasks
  71463. * @param taskName defines the name of the new task
  71464. * @param url defines the url of the file to load
  71465. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71466. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71467. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71468. * @returns a new TextureAssetTask object
  71469. */
  71470. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71471. /**
  71472. * Add a CubeTextureAssetTask to the list of active tasks
  71473. * @param taskName defines the name of the new task
  71474. * @param url defines the url of the file to load
  71475. * @param extensions defines the extension to use to load the cube map (can be null)
  71476. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71477. * @param files defines the list of files to load (can be null)
  71478. * @returns a new CubeTextureAssetTask object
  71479. */
  71480. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71481. /**
  71482. *
  71483. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71484. * @param taskName defines the name of the new task
  71485. * @param url defines the url of the file to load
  71486. * @param size defines the size you want for the cubemap (can be null)
  71487. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71488. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71489. * @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)
  71490. * @param reserved Internal use only
  71491. * @returns a new HDRCubeTextureAssetTask object
  71492. */
  71493. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71494. /**
  71495. *
  71496. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71497. * @param taskName defines the name of the new task
  71498. * @param url defines the url of the file to load
  71499. * @param size defines the size you want for the cubemap (can be null)
  71500. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71501. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71502. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71503. * @returns a new EquiRectangularCubeTextureAssetTask object
  71504. */
  71505. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71506. /**
  71507. * Remove a task from the assets manager.
  71508. * @param task the task to remove
  71509. */
  71510. removeTask(task: AbstractAssetTask): void;
  71511. private _decreaseWaitingTasksCount;
  71512. private _runTask;
  71513. /**
  71514. * Reset the AssetsManager and remove all tasks
  71515. * @return the current instance of the AssetsManager
  71516. */
  71517. reset(): AssetsManager;
  71518. /**
  71519. * Start the loading process
  71520. * @return the current instance of the AssetsManager
  71521. */
  71522. load(): AssetsManager;
  71523. /**
  71524. * Start the loading process as an async operation
  71525. * @return a promise returning the list of failed tasks
  71526. */
  71527. loadAsync(): Promise<void>;
  71528. }
  71529. }
  71530. declare module "babylonjs/Misc/deferred" {
  71531. /**
  71532. * Wrapper class for promise with external resolve and reject.
  71533. */
  71534. export class Deferred<T> {
  71535. /**
  71536. * The promise associated with this deferred object.
  71537. */
  71538. readonly promise: Promise<T>;
  71539. private _resolve;
  71540. private _reject;
  71541. /**
  71542. * The resolve method of the promise associated with this deferred object.
  71543. */
  71544. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71545. /**
  71546. * The reject method of the promise associated with this deferred object.
  71547. */
  71548. get reject(): (reason?: any) => void;
  71549. /**
  71550. * Constructor for this deferred object.
  71551. */
  71552. constructor();
  71553. }
  71554. }
  71555. declare module "babylonjs/Misc/meshExploder" {
  71556. import { Mesh } from "babylonjs/Meshes/mesh";
  71557. /**
  71558. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71559. */
  71560. export class MeshExploder {
  71561. private _centerMesh;
  71562. private _meshes;
  71563. private _meshesOrigins;
  71564. private _toCenterVectors;
  71565. private _scaledDirection;
  71566. private _newPosition;
  71567. private _centerPosition;
  71568. /**
  71569. * Explodes meshes from a center mesh.
  71570. * @param meshes The meshes to explode.
  71571. * @param centerMesh The mesh to be center of explosion.
  71572. */
  71573. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71574. private _setCenterMesh;
  71575. /**
  71576. * Get class name
  71577. * @returns "MeshExploder"
  71578. */
  71579. getClassName(): string;
  71580. /**
  71581. * "Exploded meshes"
  71582. * @returns Array of meshes with the centerMesh at index 0.
  71583. */
  71584. getMeshes(): Array<Mesh>;
  71585. /**
  71586. * Explodes meshes giving a specific direction
  71587. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71588. */
  71589. explode(direction?: number): void;
  71590. }
  71591. }
  71592. declare module "babylonjs/Misc/filesInput" {
  71593. import { Engine } from "babylonjs/Engines/engine";
  71594. import { Scene } from "babylonjs/scene";
  71595. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71596. /**
  71597. * Class used to help managing file picking and drag'n'drop
  71598. */
  71599. export class FilesInput {
  71600. /**
  71601. * List of files ready to be loaded
  71602. */
  71603. static get FilesToLoad(): {
  71604. [key: string]: File;
  71605. };
  71606. /**
  71607. * Callback called when a file is processed
  71608. */
  71609. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71610. private _engine;
  71611. private _currentScene;
  71612. private _sceneLoadedCallback;
  71613. private _progressCallback;
  71614. private _additionalRenderLoopLogicCallback;
  71615. private _textureLoadingCallback;
  71616. private _startingProcessingFilesCallback;
  71617. private _onReloadCallback;
  71618. private _errorCallback;
  71619. private _elementToMonitor;
  71620. private _sceneFileToLoad;
  71621. private _filesToLoad;
  71622. /**
  71623. * Creates a new FilesInput
  71624. * @param engine defines the rendering engine
  71625. * @param scene defines the hosting scene
  71626. * @param sceneLoadedCallback callback called when scene is loaded
  71627. * @param progressCallback callback called to track progress
  71628. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71629. * @param textureLoadingCallback callback called when a texture is loading
  71630. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71631. * @param onReloadCallback callback called when a reload is requested
  71632. * @param errorCallback callback call if an error occurs
  71633. */
  71634. 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);
  71635. private _dragEnterHandler;
  71636. private _dragOverHandler;
  71637. private _dropHandler;
  71638. /**
  71639. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71640. * @param elementToMonitor defines the DOM element to track
  71641. */
  71642. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71643. /**
  71644. * Release all associated resources
  71645. */
  71646. dispose(): void;
  71647. private renderFunction;
  71648. private drag;
  71649. private drop;
  71650. private _traverseFolder;
  71651. private _processFiles;
  71652. /**
  71653. * Load files from a drop event
  71654. * @param event defines the drop event to use as source
  71655. */
  71656. loadFiles(event: any): void;
  71657. private _processReload;
  71658. /**
  71659. * Reload the current scene from the loaded files
  71660. */
  71661. reload(): void;
  71662. }
  71663. }
  71664. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71665. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71666. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71667. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71668. }
  71669. declare module "babylonjs/Misc/sceneOptimizer" {
  71670. import { Scene, IDisposable } from "babylonjs/scene";
  71671. import { Observable } from "babylonjs/Misc/observable";
  71672. /**
  71673. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71675. */
  71676. export class SceneOptimization {
  71677. /**
  71678. * Defines the priority of this optimization (0 by default which means first in the list)
  71679. */
  71680. priority: number;
  71681. /**
  71682. * Gets a string describing the action executed by the current optimization
  71683. * @returns description string
  71684. */
  71685. getDescription(): string;
  71686. /**
  71687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71688. * @param scene defines the current scene where to apply this optimization
  71689. * @param optimizer defines the current optimizer
  71690. * @returns true if everything that can be done was applied
  71691. */
  71692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71693. /**
  71694. * Creates the SceneOptimization object
  71695. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71696. * @param desc defines the description associated with the optimization
  71697. */
  71698. constructor(
  71699. /**
  71700. * Defines the priority of this optimization (0 by default which means first in the list)
  71701. */
  71702. priority?: number);
  71703. }
  71704. /**
  71705. * Defines an optimization used to reduce the size of render target textures
  71706. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71707. */
  71708. export class TextureOptimization extends SceneOptimization {
  71709. /**
  71710. * Defines the priority of this optimization (0 by default which means first in the list)
  71711. */
  71712. priority: number;
  71713. /**
  71714. * 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
  71715. */
  71716. maximumSize: number;
  71717. /**
  71718. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71719. */
  71720. step: number;
  71721. /**
  71722. * Gets a string describing the action executed by the current optimization
  71723. * @returns description string
  71724. */
  71725. getDescription(): string;
  71726. /**
  71727. * Creates the TextureOptimization object
  71728. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71729. * @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
  71730. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71731. */
  71732. constructor(
  71733. /**
  71734. * Defines the priority of this optimization (0 by default which means first in the list)
  71735. */
  71736. priority?: number,
  71737. /**
  71738. * 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
  71739. */
  71740. maximumSize?: number,
  71741. /**
  71742. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71743. */
  71744. step?: number);
  71745. /**
  71746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71747. * @param scene defines the current scene where to apply this optimization
  71748. * @param optimizer defines the current optimizer
  71749. * @returns true if everything that can be done was applied
  71750. */
  71751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71752. }
  71753. /**
  71754. * Defines an optimization used to increase or decrease the rendering resolution
  71755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71756. */
  71757. export class HardwareScalingOptimization extends SceneOptimization {
  71758. /**
  71759. * Defines the priority of this optimization (0 by default which means first in the list)
  71760. */
  71761. priority: number;
  71762. /**
  71763. * Defines the maximum scale to use (2 by default)
  71764. */
  71765. maximumScale: number;
  71766. /**
  71767. * Defines the step to use between two passes (0.5 by default)
  71768. */
  71769. step: number;
  71770. private _currentScale;
  71771. private _directionOffset;
  71772. /**
  71773. * Gets a string describing the action executed by the current optimization
  71774. * @return description string
  71775. */
  71776. getDescription(): string;
  71777. /**
  71778. * Creates the HardwareScalingOptimization object
  71779. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71780. * @param maximumScale defines the maximum scale to use (2 by default)
  71781. * @param step defines the step to use between two passes (0.5 by default)
  71782. */
  71783. constructor(
  71784. /**
  71785. * Defines the priority of this optimization (0 by default which means first in the list)
  71786. */
  71787. priority?: number,
  71788. /**
  71789. * Defines the maximum scale to use (2 by default)
  71790. */
  71791. maximumScale?: number,
  71792. /**
  71793. * Defines the step to use between two passes (0.5 by default)
  71794. */
  71795. step?: number);
  71796. /**
  71797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71798. * @param scene defines the current scene where to apply this optimization
  71799. * @param optimizer defines the current optimizer
  71800. * @returns true if everything that can be done was applied
  71801. */
  71802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71803. }
  71804. /**
  71805. * Defines an optimization used to remove shadows
  71806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71807. */
  71808. export class ShadowsOptimization extends SceneOptimization {
  71809. /**
  71810. * Gets a string describing the action executed by the current optimization
  71811. * @return description string
  71812. */
  71813. getDescription(): string;
  71814. /**
  71815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71816. * @param scene defines the current scene where to apply this optimization
  71817. * @param optimizer defines the current optimizer
  71818. * @returns true if everything that can be done was applied
  71819. */
  71820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71821. }
  71822. /**
  71823. * Defines an optimization used to turn post-processes off
  71824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71825. */
  71826. export class PostProcessesOptimization extends SceneOptimization {
  71827. /**
  71828. * Gets a string describing the action executed by the current optimization
  71829. * @return description string
  71830. */
  71831. getDescription(): string;
  71832. /**
  71833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71834. * @param scene defines the current scene where to apply this optimization
  71835. * @param optimizer defines the current optimizer
  71836. * @returns true if everything that can be done was applied
  71837. */
  71838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71839. }
  71840. /**
  71841. * Defines an optimization used to turn lens flares off
  71842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71843. */
  71844. export class LensFlaresOptimization extends SceneOptimization {
  71845. /**
  71846. * Gets a string describing the action executed by the current optimization
  71847. * @return description string
  71848. */
  71849. getDescription(): string;
  71850. /**
  71851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71852. * @param scene defines the current scene where to apply this optimization
  71853. * @param optimizer defines the current optimizer
  71854. * @returns true if everything that can be done was applied
  71855. */
  71856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71857. }
  71858. /**
  71859. * Defines an optimization based on user defined callback.
  71860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71861. */
  71862. export class CustomOptimization extends SceneOptimization {
  71863. /**
  71864. * Callback called to apply the custom optimization.
  71865. */
  71866. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71867. /**
  71868. * Callback called to get custom description
  71869. */
  71870. onGetDescription: () => string;
  71871. /**
  71872. * Gets a string describing the action executed by the current optimization
  71873. * @returns description string
  71874. */
  71875. getDescription(): string;
  71876. /**
  71877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71878. * @param scene defines the current scene where to apply this optimization
  71879. * @param optimizer defines the current optimizer
  71880. * @returns true if everything that can be done was applied
  71881. */
  71882. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71883. }
  71884. /**
  71885. * Defines an optimization used to turn particles off
  71886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71887. */
  71888. export class ParticlesOptimization extends SceneOptimization {
  71889. /**
  71890. * Gets a string describing the action executed by the current optimization
  71891. * @return description string
  71892. */
  71893. getDescription(): string;
  71894. /**
  71895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71896. * @param scene defines the current scene where to apply this optimization
  71897. * @param optimizer defines the current optimizer
  71898. * @returns true if everything that can be done was applied
  71899. */
  71900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71901. }
  71902. /**
  71903. * Defines an optimization used to turn render targets off
  71904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71905. */
  71906. export class RenderTargetsOptimization extends SceneOptimization {
  71907. /**
  71908. * Gets a string describing the action executed by the current optimization
  71909. * @return description string
  71910. */
  71911. getDescription(): string;
  71912. /**
  71913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71914. * @param scene defines the current scene where to apply this optimization
  71915. * @param optimizer defines the current optimizer
  71916. * @returns true if everything that can be done was applied
  71917. */
  71918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71919. }
  71920. /**
  71921. * Defines an optimization used to merge meshes with compatible materials
  71922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71923. */
  71924. export class MergeMeshesOptimization extends SceneOptimization {
  71925. private static _UpdateSelectionTree;
  71926. /**
  71927. * Gets or sets a boolean which defines if optimization octree has to be updated
  71928. */
  71929. static get UpdateSelectionTree(): boolean;
  71930. /**
  71931. * Gets or sets a boolean which defines if optimization octree has to be updated
  71932. */
  71933. static set UpdateSelectionTree(value: boolean);
  71934. /**
  71935. * Gets a string describing the action executed by the current optimization
  71936. * @return description string
  71937. */
  71938. getDescription(): string;
  71939. private _canBeMerged;
  71940. /**
  71941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71942. * @param scene defines the current scene where to apply this optimization
  71943. * @param optimizer defines the current optimizer
  71944. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71945. * @returns true if everything that can be done was applied
  71946. */
  71947. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71948. }
  71949. /**
  71950. * Defines a list of options used by SceneOptimizer
  71951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71952. */
  71953. export class SceneOptimizerOptions {
  71954. /**
  71955. * Defines the target frame rate to reach (60 by default)
  71956. */
  71957. targetFrameRate: number;
  71958. /**
  71959. * Defines the interval between two checkes (2000ms by default)
  71960. */
  71961. trackerDuration: number;
  71962. /**
  71963. * Gets the list of optimizations to apply
  71964. */
  71965. optimizations: SceneOptimization[];
  71966. /**
  71967. * Creates a new list of options used by SceneOptimizer
  71968. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71969. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71970. */
  71971. constructor(
  71972. /**
  71973. * Defines the target frame rate to reach (60 by default)
  71974. */
  71975. targetFrameRate?: number,
  71976. /**
  71977. * Defines the interval between two checkes (2000ms by default)
  71978. */
  71979. trackerDuration?: number);
  71980. /**
  71981. * Add a new optimization
  71982. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71983. * @returns the current SceneOptimizerOptions
  71984. */
  71985. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71986. /**
  71987. * Add a new custom optimization
  71988. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71989. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71990. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71991. * @returns the current SceneOptimizerOptions
  71992. */
  71993. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71994. /**
  71995. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71996. * @param targetFrameRate defines the target frame rate (60 by default)
  71997. * @returns a SceneOptimizerOptions object
  71998. */
  71999. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72000. /**
  72001. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72002. * @param targetFrameRate defines the target frame rate (60 by default)
  72003. * @returns a SceneOptimizerOptions object
  72004. */
  72005. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72006. /**
  72007. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72008. * @param targetFrameRate defines the target frame rate (60 by default)
  72009. * @returns a SceneOptimizerOptions object
  72010. */
  72011. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72012. }
  72013. /**
  72014. * Class used to run optimizations in order to reach a target frame rate
  72015. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72016. */
  72017. export class SceneOptimizer implements IDisposable {
  72018. private _isRunning;
  72019. private _options;
  72020. private _scene;
  72021. private _currentPriorityLevel;
  72022. private _targetFrameRate;
  72023. private _trackerDuration;
  72024. private _currentFrameRate;
  72025. private _sceneDisposeObserver;
  72026. private _improvementMode;
  72027. /**
  72028. * Defines an observable called when the optimizer reaches the target frame rate
  72029. */
  72030. onSuccessObservable: Observable<SceneOptimizer>;
  72031. /**
  72032. * Defines an observable called when the optimizer enables an optimization
  72033. */
  72034. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72035. /**
  72036. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72037. */
  72038. onFailureObservable: Observable<SceneOptimizer>;
  72039. /**
  72040. * Gets a boolean indicating if the optimizer is in improvement mode
  72041. */
  72042. get isInImprovementMode(): boolean;
  72043. /**
  72044. * Gets the current priority level (0 at start)
  72045. */
  72046. get currentPriorityLevel(): number;
  72047. /**
  72048. * Gets the current frame rate checked by the SceneOptimizer
  72049. */
  72050. get currentFrameRate(): number;
  72051. /**
  72052. * Gets or sets the current target frame rate (60 by default)
  72053. */
  72054. get targetFrameRate(): number;
  72055. /**
  72056. * Gets or sets the current target frame rate (60 by default)
  72057. */
  72058. set targetFrameRate(value: number);
  72059. /**
  72060. * Gets or sets the current interval between two checks (every 2000ms by default)
  72061. */
  72062. get trackerDuration(): number;
  72063. /**
  72064. * Gets or sets the current interval between two checks (every 2000ms by default)
  72065. */
  72066. set trackerDuration(value: number);
  72067. /**
  72068. * Gets the list of active optimizations
  72069. */
  72070. get optimizations(): SceneOptimization[];
  72071. /**
  72072. * Creates a new SceneOptimizer
  72073. * @param scene defines the scene to work on
  72074. * @param options defines the options to use with the SceneOptimizer
  72075. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72076. * @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)
  72077. */
  72078. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72079. /**
  72080. * Stops the current optimizer
  72081. */
  72082. stop(): void;
  72083. /**
  72084. * Reset the optimizer to initial step (current priority level = 0)
  72085. */
  72086. reset(): void;
  72087. /**
  72088. * Start the optimizer. By default it will try to reach a specific framerate
  72089. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72090. */
  72091. start(): void;
  72092. private _checkCurrentState;
  72093. /**
  72094. * Release all resources
  72095. */
  72096. dispose(): void;
  72097. /**
  72098. * Helper function to create a SceneOptimizer with one single line of code
  72099. * @param scene defines the scene to work on
  72100. * @param options defines the options to use with the SceneOptimizer
  72101. * @param onSuccess defines a callback to call on success
  72102. * @param onFailure defines a callback to call on failure
  72103. * @returns the new SceneOptimizer object
  72104. */
  72105. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72106. }
  72107. }
  72108. declare module "babylonjs/Misc/sceneSerializer" {
  72109. import { Scene } from "babylonjs/scene";
  72110. /**
  72111. * Class used to serialize a scene into a string
  72112. */
  72113. export class SceneSerializer {
  72114. /**
  72115. * Clear cache used by a previous serialization
  72116. */
  72117. static ClearCache(): void;
  72118. /**
  72119. * Serialize a scene into a JSON compatible object
  72120. * @param scene defines the scene to serialize
  72121. * @returns a JSON compatible object
  72122. */
  72123. static Serialize(scene: Scene): any;
  72124. /**
  72125. * Serialize a mesh into a JSON compatible object
  72126. * @param toSerialize defines the mesh to serialize
  72127. * @param withParents defines if parents must be serialized as well
  72128. * @param withChildren defines if children must be serialized as well
  72129. * @returns a JSON compatible object
  72130. */
  72131. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72132. }
  72133. }
  72134. declare module "babylonjs/Misc/textureTools" {
  72135. import { Texture } from "babylonjs/Materials/Textures/texture";
  72136. /**
  72137. * Class used to host texture specific utilities
  72138. */
  72139. export class TextureTools {
  72140. /**
  72141. * Uses the GPU to create a copy texture rescaled at a given size
  72142. * @param texture Texture to copy from
  72143. * @param width defines the desired width
  72144. * @param height defines the desired height
  72145. * @param useBilinearMode defines if bilinear mode has to be used
  72146. * @return the generated texture
  72147. */
  72148. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72149. }
  72150. }
  72151. declare module "babylonjs/Misc/videoRecorder" {
  72152. import { Nullable } from "babylonjs/types";
  72153. import { Engine } from "babylonjs/Engines/engine";
  72154. /**
  72155. * This represents the different options available for the video capture.
  72156. */
  72157. export interface VideoRecorderOptions {
  72158. /** Defines the mime type of the video. */
  72159. mimeType: string;
  72160. /** Defines the FPS the video should be recorded at. */
  72161. fps: number;
  72162. /** Defines the chunk size for the recording data. */
  72163. recordChunckSize: number;
  72164. /** The audio tracks to attach to the recording. */
  72165. audioTracks?: MediaStreamTrack[];
  72166. }
  72167. /**
  72168. * This can help with recording videos from BabylonJS.
  72169. * This is based on the available WebRTC functionalities of the browser.
  72170. *
  72171. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72172. */
  72173. export class VideoRecorder {
  72174. private static readonly _defaultOptions;
  72175. /**
  72176. * Returns whether or not the VideoRecorder is available in your browser.
  72177. * @param engine Defines the Babylon Engine.
  72178. * @returns true if supported otherwise false.
  72179. */
  72180. static IsSupported(engine: Engine): boolean;
  72181. private readonly _options;
  72182. private _canvas;
  72183. private _mediaRecorder;
  72184. private _recordedChunks;
  72185. private _fileName;
  72186. private _resolve;
  72187. private _reject;
  72188. /**
  72189. * True when a recording is already in progress.
  72190. */
  72191. get isRecording(): boolean;
  72192. /**
  72193. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72194. * @param engine Defines the BabylonJS Engine you wish to record.
  72195. * @param options Defines options that can be used to customize the capture.
  72196. */
  72197. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72198. /**
  72199. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72200. */
  72201. stopRecording(): void;
  72202. /**
  72203. * Starts recording the canvas for a max duration specified in parameters.
  72204. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72205. * If null no automatic download will start and you can rely on the promise to get the data back.
  72206. * @param maxDuration Defines the maximum recording time in seconds.
  72207. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72208. * @return A promise callback at the end of the recording with the video data in Blob.
  72209. */
  72210. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72211. /**
  72212. * Releases internal resources used during the recording.
  72213. */
  72214. dispose(): void;
  72215. private _handleDataAvailable;
  72216. private _handleError;
  72217. private _handleStop;
  72218. }
  72219. }
  72220. declare module "babylonjs/Misc/screenshotTools" {
  72221. import { Camera } from "babylonjs/Cameras/camera";
  72222. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72223. import { Engine } from "babylonjs/Engines/engine";
  72224. /**
  72225. * Class containing a set of static utilities functions for screenshots
  72226. */
  72227. export class ScreenshotTools {
  72228. /**
  72229. * Captures a screenshot of the current rendering
  72230. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72231. * @param engine defines the rendering engine
  72232. * @param camera defines the source camera
  72233. * @param size This parameter can be set to a single number or to an object with the
  72234. * following (optional) properties: precision, width, height. If a single number is passed,
  72235. * it will be used for both width and height. If an object is passed, the screenshot size
  72236. * will be derived from the parameters. The precision property is a multiplier allowing
  72237. * rendering at a higher or lower resolution
  72238. * @param successCallback defines the callback receives a single parameter which contains the
  72239. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72240. * src parameter of an <img> to display it
  72241. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72242. * Check your browser for supported MIME types
  72243. */
  72244. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72245. /**
  72246. * Captures a screenshot of the current rendering
  72247. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72248. * @param engine defines the rendering engine
  72249. * @param camera defines the source camera
  72250. * @param size This parameter can be set to a single number or to an object with the
  72251. * following (optional) properties: precision, width, height. If a single number is passed,
  72252. * it will be used for both width and height. If an object is passed, the screenshot size
  72253. * will be derived from the parameters. The precision property is a multiplier allowing
  72254. * rendering at a higher or lower resolution
  72255. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72256. * Check your browser for supported MIME types
  72257. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72258. * to the src parameter of an <img> to display it
  72259. */
  72260. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72261. /**
  72262. * Generates an image screenshot from the specified camera.
  72263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72264. * @param engine The engine to use for rendering
  72265. * @param camera The camera to use for rendering
  72266. * @param size This parameter can be set to a single number or to an object with the
  72267. * following (optional) properties: precision, width, height. If a single number is passed,
  72268. * it will be used for both width and height. If an object is passed, the screenshot size
  72269. * will be derived from the parameters. The precision property is a multiplier allowing
  72270. * rendering at a higher or lower resolution
  72271. * @param successCallback The callback receives a single parameter which contains the
  72272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72273. * src parameter of an <img> to display it
  72274. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72275. * Check your browser for supported MIME types
  72276. * @param samples Texture samples (default: 1)
  72277. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72278. * @param fileName A name for for the downloaded file.
  72279. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72280. */
  72281. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72282. /**
  72283. * Generates an image screenshot from the specified camera.
  72284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72285. * @param engine The engine to use for rendering
  72286. * @param camera The camera to use for rendering
  72287. * @param size This parameter can be set to a single number or to an object with the
  72288. * following (optional) properties: precision, width, height. If a single number is passed,
  72289. * it will be used for both width and height. If an object is passed, the screenshot size
  72290. * will be derived from the parameters. The precision property is a multiplier allowing
  72291. * rendering at a higher or lower resolution
  72292. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72293. * Check your browser for supported MIME types
  72294. * @param samples Texture samples (default: 1)
  72295. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72296. * @param fileName A name for for the downloaded file.
  72297. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72298. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72299. * to the src parameter of an <img> to display it
  72300. */
  72301. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72302. /**
  72303. * Gets height and width for screenshot size
  72304. * @private
  72305. */
  72306. private static _getScreenshotSize;
  72307. }
  72308. }
  72309. declare module "babylonjs/Misc/dataReader" {
  72310. /**
  72311. * Interface for a data buffer
  72312. */
  72313. export interface IDataBuffer {
  72314. /**
  72315. * Reads bytes from the data buffer.
  72316. * @param byteOffset The byte offset to read
  72317. * @param byteLength The byte length to read
  72318. * @returns A promise that resolves when the bytes are read
  72319. */
  72320. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72321. /**
  72322. * The byte length of the buffer.
  72323. */
  72324. readonly byteLength: number;
  72325. }
  72326. /**
  72327. * Utility class for reading from a data buffer
  72328. */
  72329. export class DataReader {
  72330. /**
  72331. * The data buffer associated with this data reader.
  72332. */
  72333. readonly buffer: IDataBuffer;
  72334. /**
  72335. * The current byte offset from the beginning of the data buffer.
  72336. */
  72337. byteOffset: number;
  72338. private _dataView;
  72339. private _dataByteOffset;
  72340. /**
  72341. * Constructor
  72342. * @param buffer The buffer to read
  72343. */
  72344. constructor(buffer: IDataBuffer);
  72345. /**
  72346. * Loads the given byte length.
  72347. * @param byteLength The byte length to load
  72348. * @returns A promise that resolves when the load is complete
  72349. */
  72350. loadAsync(byteLength: number): Promise<void>;
  72351. /**
  72352. * Read a unsigned 32-bit integer from the currently loaded data range.
  72353. * @returns The 32-bit integer read
  72354. */
  72355. readUint32(): number;
  72356. /**
  72357. * Read a byte array from the currently loaded data range.
  72358. * @param byteLength The byte length to read
  72359. * @returns The byte array read
  72360. */
  72361. readUint8Array(byteLength: number): Uint8Array;
  72362. /**
  72363. * Read a string from the currently loaded data range.
  72364. * @param byteLength The byte length to read
  72365. * @returns The string read
  72366. */
  72367. readString(byteLength: number): string;
  72368. /**
  72369. * Skips the given byte length the currently loaded data range.
  72370. * @param byteLength The byte length to skip
  72371. */
  72372. skipBytes(byteLength: number): void;
  72373. }
  72374. }
  72375. declare module "babylonjs/Misc/dataStorage" {
  72376. /**
  72377. * Class for storing data to local storage if available or in-memory storage otherwise
  72378. */
  72379. export class DataStorage {
  72380. private static _Storage;
  72381. private static _GetStorage;
  72382. /**
  72383. * Reads a string from the data storage
  72384. * @param key The key to read
  72385. * @param defaultValue The value if the key doesn't exist
  72386. * @returns The string value
  72387. */
  72388. static ReadString(key: string, defaultValue: string): string;
  72389. /**
  72390. * Writes a string to the data storage
  72391. * @param key The key to write
  72392. * @param value The value to write
  72393. */
  72394. static WriteString(key: string, value: string): void;
  72395. /**
  72396. * Reads a boolean from the data storage
  72397. * @param key The key to read
  72398. * @param defaultValue The value if the key doesn't exist
  72399. * @returns The boolean value
  72400. */
  72401. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72402. /**
  72403. * Writes a boolean to the data storage
  72404. * @param key The key to write
  72405. * @param value The value to write
  72406. */
  72407. static WriteBoolean(key: string, value: boolean): void;
  72408. /**
  72409. * Reads a number from the data storage
  72410. * @param key The key to read
  72411. * @param defaultValue The value if the key doesn't exist
  72412. * @returns The number value
  72413. */
  72414. static ReadNumber(key: string, defaultValue: number): number;
  72415. /**
  72416. * Writes a number to the data storage
  72417. * @param key The key to write
  72418. * @param value The value to write
  72419. */
  72420. static WriteNumber(key: string, value: number): void;
  72421. }
  72422. }
  72423. declare module "babylonjs/Misc/index" {
  72424. export * from "babylonjs/Misc/andOrNotEvaluator";
  72425. export * from "babylonjs/Misc/assetsManager";
  72426. export * from "babylonjs/Misc/basis";
  72427. export * from "babylonjs/Misc/dds";
  72428. export * from "babylonjs/Misc/decorators";
  72429. export * from "babylonjs/Misc/deferred";
  72430. export * from "babylonjs/Misc/environmentTextureTools";
  72431. export * from "babylonjs/Misc/meshExploder";
  72432. export * from "babylonjs/Misc/filesInput";
  72433. export * from "babylonjs/Misc/HighDynamicRange/index";
  72434. export * from "babylonjs/Misc/khronosTextureContainer";
  72435. export * from "babylonjs/Misc/observable";
  72436. export * from "babylonjs/Misc/performanceMonitor";
  72437. export * from "babylonjs/Misc/promise";
  72438. export * from "babylonjs/Misc/sceneOptimizer";
  72439. export * from "babylonjs/Misc/sceneSerializer";
  72440. export * from "babylonjs/Misc/smartArray";
  72441. export * from "babylonjs/Misc/stringDictionary";
  72442. export * from "babylonjs/Misc/tags";
  72443. export * from "babylonjs/Misc/textureTools";
  72444. export * from "babylonjs/Misc/tga";
  72445. export * from "babylonjs/Misc/tools";
  72446. export * from "babylonjs/Misc/videoRecorder";
  72447. export * from "babylonjs/Misc/virtualJoystick";
  72448. export * from "babylonjs/Misc/workerPool";
  72449. export * from "babylonjs/Misc/logger";
  72450. export * from "babylonjs/Misc/typeStore";
  72451. export * from "babylonjs/Misc/filesInputStore";
  72452. export * from "babylonjs/Misc/deepCopier";
  72453. export * from "babylonjs/Misc/pivotTools";
  72454. export * from "babylonjs/Misc/precisionDate";
  72455. export * from "babylonjs/Misc/screenshotTools";
  72456. export * from "babylonjs/Misc/typeStore";
  72457. export * from "babylonjs/Misc/webRequest";
  72458. export * from "babylonjs/Misc/iInspectable";
  72459. export * from "babylonjs/Misc/brdfTextureTools";
  72460. export * from "babylonjs/Misc/rgbdTextureTools";
  72461. export * from "babylonjs/Misc/gradients";
  72462. export * from "babylonjs/Misc/perfCounter";
  72463. export * from "babylonjs/Misc/fileRequest";
  72464. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72465. export * from "babylonjs/Misc/retryStrategy";
  72466. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72467. export * from "babylonjs/Misc/canvasGenerator";
  72468. export * from "babylonjs/Misc/fileTools";
  72469. export * from "babylonjs/Misc/stringTools";
  72470. export * from "babylonjs/Misc/dataReader";
  72471. export * from "babylonjs/Misc/minMaxReducer";
  72472. export * from "babylonjs/Misc/depthReducer";
  72473. export * from "babylonjs/Misc/dataStorage";
  72474. }
  72475. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72476. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72477. import { Observable } from "babylonjs/Misc/observable";
  72478. import { Matrix } from "babylonjs/Maths/math.vector";
  72479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72480. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72481. /**
  72482. * Options used for hit testing
  72483. */
  72484. export interface IWebXRHitTestOptions {
  72485. /**
  72486. * Only test when user interacted with the scene. Default - hit test every frame
  72487. */
  72488. testOnPointerDownOnly?: boolean;
  72489. /**
  72490. * The node to use to transform the local results to world coordinates
  72491. */
  72492. worldParentNode?: TransformNode;
  72493. }
  72494. /**
  72495. * Interface defining the babylon result of raycasting/hit-test
  72496. */
  72497. export interface IWebXRHitResult {
  72498. /**
  72499. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72500. */
  72501. transformationMatrix: Matrix;
  72502. /**
  72503. * The native hit test result
  72504. */
  72505. xrHitResult: XRHitResult;
  72506. }
  72507. /**
  72508. * The currently-working hit-test module.
  72509. * Hit test (or Ray-casting) is used to interact with the real world.
  72510. * For further information read here - https://github.com/immersive-web/hit-test
  72511. */
  72512. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72513. /**
  72514. * options to use when constructing this feature
  72515. */
  72516. readonly options: IWebXRHitTestOptions;
  72517. private _direction;
  72518. private _mat;
  72519. private _onSelectEnabled;
  72520. private _origin;
  72521. /**
  72522. * The module's name
  72523. */
  72524. static readonly Name: string;
  72525. /**
  72526. * The (Babylon) version of this module.
  72527. * This is an integer representing the implementation version.
  72528. * This number does not correspond to the WebXR specs version
  72529. */
  72530. static readonly Version: number;
  72531. /**
  72532. * Populated with the last native XR Hit Results
  72533. */
  72534. lastNativeXRHitResults: XRHitResult[];
  72535. /**
  72536. * Triggered when new babylon (transformed) hit test results are available
  72537. */
  72538. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72539. /**
  72540. * Creates a new instance of the (legacy version) hit test feature
  72541. * @param _xrSessionManager an instance of WebXRSessionManager
  72542. * @param options options to use when constructing this feature
  72543. */
  72544. constructor(_xrSessionManager: WebXRSessionManager,
  72545. /**
  72546. * options to use when constructing this feature
  72547. */
  72548. options?: IWebXRHitTestOptions);
  72549. /**
  72550. * execute a hit test with an XR Ray
  72551. *
  72552. * @param xrSession a native xrSession that will execute this hit test
  72553. * @param xrRay the ray (position and direction) to use for ray-casting
  72554. * @param referenceSpace native XR reference space to use for the hit-test
  72555. * @param filter filter function that will filter the results
  72556. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72557. */
  72558. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72559. /**
  72560. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72561. * @param event the (select) event to use to select with
  72562. * @param referenceSpace the reference space to use for this hit test
  72563. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72564. */
  72565. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72566. /**
  72567. * attach this feature
  72568. * Will usually be called by the features manager
  72569. *
  72570. * @returns true if successful.
  72571. */
  72572. attach(): boolean;
  72573. /**
  72574. * detach this feature.
  72575. * Will usually be called by the features manager
  72576. *
  72577. * @returns true if successful.
  72578. */
  72579. detach(): boolean;
  72580. /**
  72581. * Dispose this feature and all of the resources attached
  72582. */
  72583. dispose(): void;
  72584. protected _onXRFrame(frame: XRFrame): void;
  72585. private _onHitTestResults;
  72586. private _onSelect;
  72587. }
  72588. }
  72589. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72590. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72591. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72592. import { Observable } from "babylonjs/Misc/observable";
  72593. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72594. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72595. /**
  72596. * Options used in the plane detector module
  72597. */
  72598. export interface IWebXRPlaneDetectorOptions {
  72599. /**
  72600. * The node to use to transform the local results to world coordinates
  72601. */
  72602. worldParentNode?: TransformNode;
  72603. }
  72604. /**
  72605. * A babylon interface for a WebXR plane.
  72606. * A Plane is actually a polygon, built from N points in space
  72607. *
  72608. * Supported in chrome 79, not supported in canary 81 ATM
  72609. */
  72610. export interface IWebXRPlane {
  72611. /**
  72612. * a babylon-assigned ID for this polygon
  72613. */
  72614. id: number;
  72615. /**
  72616. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72617. */
  72618. polygonDefinition: Array<Vector3>;
  72619. /**
  72620. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72621. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72622. */
  72623. transformationMatrix: Matrix;
  72624. /**
  72625. * the native xr-plane object
  72626. */
  72627. xrPlane: XRPlane;
  72628. }
  72629. /**
  72630. * The plane detector is used to detect planes in the real world when in AR
  72631. * For more information see https://github.com/immersive-web/real-world-geometry/
  72632. */
  72633. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72634. private _options;
  72635. private _detectedPlanes;
  72636. private _enabled;
  72637. private _lastFrameDetected;
  72638. /**
  72639. * The module's name
  72640. */
  72641. static readonly Name: string;
  72642. /**
  72643. * The (Babylon) version of this module.
  72644. * This is an integer representing the implementation version.
  72645. * This number does not correspond to the WebXR specs version
  72646. */
  72647. static readonly Version: number;
  72648. /**
  72649. * Observers registered here will be executed when a new plane was added to the session
  72650. */
  72651. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72652. /**
  72653. * Observers registered here will be executed when a plane is no longer detected in the session
  72654. */
  72655. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72656. /**
  72657. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72658. * This can execute N times every frame
  72659. */
  72660. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72661. /**
  72662. * construct a new Plane Detector
  72663. * @param _xrSessionManager an instance of xr Session manager
  72664. * @param _options configuration to use when constructing this feature
  72665. */
  72666. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72667. /**
  72668. * Dispose this feature and all of the resources attached
  72669. */
  72670. dispose(): void;
  72671. protected _onXRFrame(frame: XRFrame): void;
  72672. private _init;
  72673. private _updatePlaneWithXRPlane;
  72674. /**
  72675. * avoiding using Array.find for global support.
  72676. * @param xrPlane the plane to find in the array
  72677. */
  72678. private findIndexInPlaneArray;
  72679. }
  72680. }
  72681. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72682. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72683. import { Observable } from "babylonjs/Misc/observable";
  72684. import { Matrix } from "babylonjs/Maths/math.vector";
  72685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72686. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72687. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72688. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72689. /**
  72690. * Configuration options of the anchor system
  72691. */
  72692. export interface IWebXRAnchorSystemOptions {
  72693. /**
  72694. * Should a new anchor be added every time a select event is triggered
  72695. */
  72696. addAnchorOnSelect?: boolean;
  72697. /**
  72698. * should the anchor system use plane detection.
  72699. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72700. */
  72701. usePlaneDetection?: boolean;
  72702. /**
  72703. * a node that will be used to convert local to world coordinates
  72704. */
  72705. worldParentNode?: TransformNode;
  72706. }
  72707. /**
  72708. * A babylon container for an XR Anchor
  72709. */
  72710. export interface IWebXRAnchor {
  72711. /**
  72712. * A babylon-assigned ID for this anchor
  72713. */
  72714. id: number;
  72715. /**
  72716. * Transformation matrix to apply to an object attached to this anchor
  72717. */
  72718. transformationMatrix: Matrix;
  72719. /**
  72720. * The native anchor object
  72721. */
  72722. xrAnchor: XRAnchor;
  72723. }
  72724. /**
  72725. * An implementation of the anchor system of WebXR.
  72726. * Note that the current documented implementation is not available in any browser. Future implementations
  72727. * will use the frame to create an anchor and not the session or a detected plane
  72728. * For further information see https://github.com/immersive-web/anchors/
  72729. */
  72730. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72731. private _options;
  72732. private _enabled;
  72733. private _hitTestModule;
  72734. private _lastFrameDetected;
  72735. private _onSelect;
  72736. private _planeDetector;
  72737. private _trackedAnchors;
  72738. /**
  72739. * The module's name
  72740. */
  72741. static readonly Name: string;
  72742. /**
  72743. * The (Babylon) version of this module.
  72744. * This is an integer representing the implementation version.
  72745. * This number does not correspond to the WebXR specs version
  72746. */
  72747. static readonly Version: number;
  72748. /**
  72749. * Observers registered here will be executed when a new anchor was added to the session
  72750. */
  72751. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72752. /**
  72753. * Observers registered here will be executed when an anchor was removed from the session
  72754. */
  72755. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72756. /**
  72757. * Observers registered here will be executed when an existing anchor updates
  72758. * This can execute N times every frame
  72759. */
  72760. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72761. /**
  72762. * constructs a new anchor system
  72763. * @param _xrSessionManager an instance of WebXRSessionManager
  72764. * @param _options configuration object for this feature
  72765. */
  72766. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72767. /**
  72768. * Add anchor at a specific XR point.
  72769. *
  72770. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72771. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72772. * @returns a promise the fulfills when the anchor was created
  72773. */
  72774. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72775. /**
  72776. * attach this feature
  72777. * Will usually be called by the features manager
  72778. *
  72779. * @returns true if successful.
  72780. */
  72781. attach(): boolean;
  72782. /**
  72783. * detach this feature.
  72784. * Will usually be called by the features manager
  72785. *
  72786. * @returns true if successful.
  72787. */
  72788. detach(): boolean;
  72789. /**
  72790. * Dispose this feature and all of the resources attached
  72791. */
  72792. dispose(): void;
  72793. /**
  72794. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72795. * @param hitTestModule the hit-test module to use.
  72796. */
  72797. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72798. /**
  72799. * set the plane detector to use in order to create anchors from frames
  72800. * @param planeDetector the plane-detector module to use
  72801. * @param enable enable plane-anchors. default is true
  72802. */
  72803. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72804. protected _onXRFrame(frame: XRFrame): void;
  72805. /**
  72806. * avoiding using Array.find for global support.
  72807. * @param xrAnchor the plane to find in the array
  72808. */
  72809. private _findIndexInAnchorArray;
  72810. private _updateAnchorWithXRFrame;
  72811. }
  72812. }
  72813. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72814. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72816. import { Observable } from "babylonjs/Misc/observable";
  72817. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72818. /**
  72819. * Options interface for the background remover plugin
  72820. */
  72821. export interface IWebXRBackgroundRemoverOptions {
  72822. /**
  72823. * Further background meshes to disable when entering AR
  72824. */
  72825. backgroundMeshes?: AbstractMesh[];
  72826. /**
  72827. * flags to configure the removal of the environment helper.
  72828. * If not set, the entire background will be removed. If set, flags should be set as well.
  72829. */
  72830. environmentHelperRemovalFlags?: {
  72831. /**
  72832. * Should the skybox be removed (default false)
  72833. */
  72834. skyBox?: boolean;
  72835. /**
  72836. * Should the ground be removed (default false)
  72837. */
  72838. ground?: boolean;
  72839. };
  72840. /**
  72841. * don't disable the environment helper
  72842. */
  72843. ignoreEnvironmentHelper?: boolean;
  72844. }
  72845. /**
  72846. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72847. */
  72848. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72849. /**
  72850. * read-only options to be used in this module
  72851. */
  72852. readonly options: IWebXRBackgroundRemoverOptions;
  72853. /**
  72854. * The module's name
  72855. */
  72856. static readonly Name: string;
  72857. /**
  72858. * The (Babylon) version of this module.
  72859. * This is an integer representing the implementation version.
  72860. * This number does not correspond to the WebXR specs version
  72861. */
  72862. static readonly Version: number;
  72863. /**
  72864. * registered observers will be triggered when the background state changes
  72865. */
  72866. onBackgroundStateChangedObservable: Observable<boolean>;
  72867. /**
  72868. * constructs a new background remover module
  72869. * @param _xrSessionManager the session manager for this module
  72870. * @param options read-only options to be used in this module
  72871. */
  72872. constructor(_xrSessionManager: WebXRSessionManager,
  72873. /**
  72874. * read-only options to be used in this module
  72875. */
  72876. options?: IWebXRBackgroundRemoverOptions);
  72877. /**
  72878. * attach this feature
  72879. * Will usually be called by the features manager
  72880. *
  72881. * @returns true if successful.
  72882. */
  72883. attach(): boolean;
  72884. /**
  72885. * detach this feature.
  72886. * Will usually be called by the features manager
  72887. *
  72888. * @returns true if successful.
  72889. */
  72890. detach(): boolean;
  72891. /**
  72892. * Dispose this feature and all of the resources attached
  72893. */
  72894. dispose(): void;
  72895. protected _onXRFrame(_xrFrame: XRFrame): void;
  72896. private _setBackgroundState;
  72897. }
  72898. }
  72899. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72900. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72901. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72902. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72903. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72904. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72905. import { Nullable } from "babylonjs/types";
  72906. /**
  72907. * Options for the controller physics feature
  72908. */
  72909. export class IWebXRControllerPhysicsOptions {
  72910. /**
  72911. * Should the headset get its own impostor
  72912. */
  72913. enableHeadsetImpostor?: boolean;
  72914. /**
  72915. * Optional parameters for the headset impostor
  72916. */
  72917. headsetImpostorParams?: {
  72918. /**
  72919. * The type of impostor to create. Default is sphere
  72920. */
  72921. impostorType: number;
  72922. /**
  72923. * the size of the impostor. Defaults to 10cm
  72924. */
  72925. impostorSize?: number | {
  72926. width: number;
  72927. height: number;
  72928. depth: number;
  72929. };
  72930. /**
  72931. * Friction definitions
  72932. */
  72933. friction?: number;
  72934. /**
  72935. * Restitution
  72936. */
  72937. restitution?: number;
  72938. };
  72939. /**
  72940. * The physics properties of the future impostors
  72941. */
  72942. physicsProperties?: {
  72943. /**
  72944. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72945. * Note that this requires a physics engine that supports mesh impostors!
  72946. */
  72947. useControllerMesh?: boolean;
  72948. /**
  72949. * The type of impostor to create. Default is sphere
  72950. */
  72951. impostorType?: number;
  72952. /**
  72953. * the size of the impostor. Defaults to 10cm
  72954. */
  72955. impostorSize?: number | {
  72956. width: number;
  72957. height: number;
  72958. depth: number;
  72959. };
  72960. /**
  72961. * Friction definitions
  72962. */
  72963. friction?: number;
  72964. /**
  72965. * Restitution
  72966. */
  72967. restitution?: number;
  72968. };
  72969. /**
  72970. * the xr input to use with this pointer selection
  72971. */
  72972. xrInput: WebXRInput;
  72973. }
  72974. /**
  72975. * Add physics impostor to your webxr controllers,
  72976. * including naive calculation of their linear and angular velocity
  72977. */
  72978. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72979. private readonly _options;
  72980. private _attachController;
  72981. private _controllers;
  72982. private _debugMode;
  72983. private _delta;
  72984. private _headsetImpostor?;
  72985. private _headsetMesh?;
  72986. private _lastTimestamp;
  72987. private _tmpQuaternion;
  72988. private _tmpVector;
  72989. /**
  72990. * The module's name
  72991. */
  72992. static readonly Name: string;
  72993. /**
  72994. * The (Babylon) version of this module.
  72995. * This is an integer representing the implementation version.
  72996. * This number does not correspond to the webxr specs version
  72997. */
  72998. static readonly Version: number;
  72999. /**
  73000. * Construct a new Controller Physics Feature
  73001. * @param _xrSessionManager the corresponding xr session manager
  73002. * @param _options options to create this feature with
  73003. */
  73004. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73005. /**
  73006. * @hidden
  73007. * enable debugging - will show console outputs and the impostor mesh
  73008. */
  73009. _enablePhysicsDebug(): void;
  73010. /**
  73011. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73012. * @param xrController the controller to add
  73013. */
  73014. addController(xrController: WebXRInputSource): void;
  73015. /**
  73016. * attach this feature
  73017. * Will usually be called by the features manager
  73018. *
  73019. * @returns true if successful.
  73020. */
  73021. attach(): boolean;
  73022. /**
  73023. * detach this feature.
  73024. * Will usually be called by the features manager
  73025. *
  73026. * @returns true if successful.
  73027. */
  73028. detach(): boolean;
  73029. /**
  73030. * Get the headset impostor, if enabled
  73031. * @returns the impostor
  73032. */
  73033. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73034. /**
  73035. * Get the physics impostor of a specific controller.
  73036. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73037. * @param controller the controller or the controller id of which to get the impostor
  73038. * @returns the impostor or null
  73039. */
  73040. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73041. /**
  73042. * Update the physics properties provided in the constructor
  73043. * @param newProperties the new properties object
  73044. */
  73045. setPhysicsProperties(newProperties: {
  73046. impostorType?: number;
  73047. impostorSize?: number | {
  73048. width: number;
  73049. height: number;
  73050. depth: number;
  73051. };
  73052. friction?: number;
  73053. restitution?: number;
  73054. }): void;
  73055. protected _onXRFrame(_xrFrame: any): void;
  73056. private _detachController;
  73057. }
  73058. }
  73059. declare module "babylonjs/XR/features/index" {
  73060. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73061. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73062. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73063. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73064. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73065. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73066. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73067. }
  73068. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73069. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73071. import { Scene } from "babylonjs/scene";
  73072. /**
  73073. * The motion controller class for all microsoft mixed reality controllers
  73074. */
  73075. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73076. protected readonly _mapping: {
  73077. defaultButton: {
  73078. "valueNodeName": string;
  73079. "unpressedNodeName": string;
  73080. "pressedNodeName": string;
  73081. };
  73082. defaultAxis: {
  73083. "valueNodeName": string;
  73084. "minNodeName": string;
  73085. "maxNodeName": string;
  73086. };
  73087. buttons: {
  73088. "xr-standard-trigger": {
  73089. "rootNodeName": string;
  73090. "componentProperty": string;
  73091. "states": string[];
  73092. };
  73093. "xr-standard-squeeze": {
  73094. "rootNodeName": string;
  73095. "componentProperty": string;
  73096. "states": string[];
  73097. };
  73098. "xr-standard-touchpad": {
  73099. "rootNodeName": string;
  73100. "labelAnchorNodeName": string;
  73101. "touchPointNodeName": string;
  73102. };
  73103. "xr-standard-thumbstick": {
  73104. "rootNodeName": string;
  73105. "componentProperty": string;
  73106. "states": string[];
  73107. };
  73108. };
  73109. axes: {
  73110. "xr-standard-touchpad": {
  73111. "x-axis": {
  73112. "rootNodeName": string;
  73113. };
  73114. "y-axis": {
  73115. "rootNodeName": string;
  73116. };
  73117. };
  73118. "xr-standard-thumbstick": {
  73119. "x-axis": {
  73120. "rootNodeName": string;
  73121. };
  73122. "y-axis": {
  73123. "rootNodeName": string;
  73124. };
  73125. };
  73126. };
  73127. };
  73128. /**
  73129. * The base url used to load the left and right controller models
  73130. */
  73131. static MODEL_BASE_URL: string;
  73132. /**
  73133. * The name of the left controller model file
  73134. */
  73135. static MODEL_LEFT_FILENAME: string;
  73136. /**
  73137. * The name of the right controller model file
  73138. */
  73139. static MODEL_RIGHT_FILENAME: string;
  73140. profileId: string;
  73141. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73142. protected _getFilenameAndPath(): {
  73143. filename: string;
  73144. path: string;
  73145. };
  73146. protected _getModelLoadingConstraints(): boolean;
  73147. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73148. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73149. protected _updateModel(): void;
  73150. }
  73151. }
  73152. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73153. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73155. import { Scene } from "babylonjs/scene";
  73156. /**
  73157. * The motion controller class for oculus touch (quest, rift).
  73158. * This class supports legacy mapping as well the standard xr mapping
  73159. */
  73160. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73161. private _forceLegacyControllers;
  73162. private _modelRootNode;
  73163. /**
  73164. * The base url used to load the left and right controller models
  73165. */
  73166. static MODEL_BASE_URL: string;
  73167. /**
  73168. * The name of the left controller model file
  73169. */
  73170. static MODEL_LEFT_FILENAME: string;
  73171. /**
  73172. * The name of the right controller model file
  73173. */
  73174. static MODEL_RIGHT_FILENAME: string;
  73175. /**
  73176. * Base Url for the Quest controller model.
  73177. */
  73178. static QUEST_MODEL_BASE_URL: string;
  73179. profileId: string;
  73180. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73181. protected _getFilenameAndPath(): {
  73182. filename: string;
  73183. path: string;
  73184. };
  73185. protected _getModelLoadingConstraints(): boolean;
  73186. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73187. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73188. protected _updateModel(): void;
  73189. /**
  73190. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73191. * between the touch and touch 2.
  73192. */
  73193. private _isQuest;
  73194. }
  73195. }
  73196. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73197. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73198. import { Scene } from "babylonjs/scene";
  73199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73200. /**
  73201. * The motion controller class for the standard HTC-Vive controllers
  73202. */
  73203. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73204. private _modelRootNode;
  73205. /**
  73206. * The base url used to load the left and right controller models
  73207. */
  73208. static MODEL_BASE_URL: string;
  73209. /**
  73210. * File name for the controller model.
  73211. */
  73212. static MODEL_FILENAME: string;
  73213. profileId: string;
  73214. /**
  73215. * Create a new Vive motion controller object
  73216. * @param scene the scene to use to create this controller
  73217. * @param gamepadObject the corresponding gamepad object
  73218. * @param handness the handness of the controller
  73219. */
  73220. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73221. protected _getFilenameAndPath(): {
  73222. filename: string;
  73223. path: string;
  73224. };
  73225. protected _getModelLoadingConstraints(): boolean;
  73226. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73227. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73228. protected _updateModel(): void;
  73229. }
  73230. }
  73231. declare module "babylonjs/XR/motionController/index" {
  73232. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73233. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73234. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73235. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73236. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73237. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73238. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73239. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73240. }
  73241. declare module "babylonjs/XR/index" {
  73242. export * from "babylonjs/XR/webXRCamera";
  73243. export * from "babylonjs/XR/webXREnterExitUI";
  73244. export * from "babylonjs/XR/webXRExperienceHelper";
  73245. export * from "babylonjs/XR/webXRInput";
  73246. export * from "babylonjs/XR/webXRInputSource";
  73247. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73248. export * from "babylonjs/XR/webXRTypes";
  73249. export * from "babylonjs/XR/webXRSessionManager";
  73250. export * from "babylonjs/XR/webXRDefaultExperience";
  73251. export * from "babylonjs/XR/webXRFeaturesManager";
  73252. export * from "babylonjs/XR/features/index";
  73253. export * from "babylonjs/XR/motionController/index";
  73254. }
  73255. declare module "babylonjs/index" {
  73256. export * from "babylonjs/abstractScene";
  73257. export * from "babylonjs/Actions/index";
  73258. export * from "babylonjs/Animations/index";
  73259. export * from "babylonjs/assetContainer";
  73260. export * from "babylonjs/Audio/index";
  73261. export * from "babylonjs/Behaviors/index";
  73262. export * from "babylonjs/Bones/index";
  73263. export * from "babylonjs/Cameras/index";
  73264. export * from "babylonjs/Collisions/index";
  73265. export * from "babylonjs/Culling/index";
  73266. export * from "babylonjs/Debug/index";
  73267. export * from "babylonjs/Engines/index";
  73268. export * from "babylonjs/Events/index";
  73269. export * from "babylonjs/Gamepads/index";
  73270. export * from "babylonjs/Gizmos/index";
  73271. export * from "babylonjs/Helpers/index";
  73272. export * from "babylonjs/Instrumentation/index";
  73273. export * from "babylonjs/Layers/index";
  73274. export * from "babylonjs/LensFlares/index";
  73275. export * from "babylonjs/Lights/index";
  73276. export * from "babylonjs/Loading/index";
  73277. export * from "babylonjs/Materials/index";
  73278. export * from "babylonjs/Maths/index";
  73279. export * from "babylonjs/Meshes/index";
  73280. export * from "babylonjs/Morph/index";
  73281. export * from "babylonjs/Navigation/index";
  73282. export * from "babylonjs/node";
  73283. export * from "babylonjs/Offline/index";
  73284. export * from "babylonjs/Particles/index";
  73285. export * from "babylonjs/Physics/index";
  73286. export * from "babylonjs/PostProcesses/index";
  73287. export * from "babylonjs/Probes/index";
  73288. export * from "babylonjs/Rendering/index";
  73289. export * from "babylonjs/scene";
  73290. export * from "babylonjs/sceneComponent";
  73291. export * from "babylonjs/Sprites/index";
  73292. export * from "babylonjs/States/index";
  73293. export * from "babylonjs/Misc/index";
  73294. export * from "babylonjs/XR/index";
  73295. export * from "babylonjs/types";
  73296. }
  73297. declare module "babylonjs/Animations/pathCursor" {
  73298. import { Vector3 } from "babylonjs/Maths/math.vector";
  73299. import { Path2 } from "babylonjs/Maths/math.path";
  73300. /**
  73301. * A cursor which tracks a point on a path
  73302. */
  73303. export class PathCursor {
  73304. private path;
  73305. /**
  73306. * Stores path cursor callbacks for when an onchange event is triggered
  73307. */
  73308. private _onchange;
  73309. /**
  73310. * The value of the path cursor
  73311. */
  73312. value: number;
  73313. /**
  73314. * The animation array of the path cursor
  73315. */
  73316. animations: Animation[];
  73317. /**
  73318. * Initializes the path cursor
  73319. * @param path The path to track
  73320. */
  73321. constructor(path: Path2);
  73322. /**
  73323. * Gets the cursor point on the path
  73324. * @returns A point on the path cursor at the cursor location
  73325. */
  73326. getPoint(): Vector3;
  73327. /**
  73328. * Moves the cursor ahead by the step amount
  73329. * @param step The amount to move the cursor forward
  73330. * @returns This path cursor
  73331. */
  73332. moveAhead(step?: number): PathCursor;
  73333. /**
  73334. * Moves the cursor behind by the step amount
  73335. * @param step The amount to move the cursor back
  73336. * @returns This path cursor
  73337. */
  73338. moveBack(step?: number): PathCursor;
  73339. /**
  73340. * Moves the cursor by the step amount
  73341. * If the step amount is greater than one, an exception is thrown
  73342. * @param step The amount to move the cursor
  73343. * @returns This path cursor
  73344. */
  73345. move(step: number): PathCursor;
  73346. /**
  73347. * Ensures that the value is limited between zero and one
  73348. * @returns This path cursor
  73349. */
  73350. private ensureLimits;
  73351. /**
  73352. * Runs onchange callbacks on change (used by the animation engine)
  73353. * @returns This path cursor
  73354. */
  73355. private raiseOnChange;
  73356. /**
  73357. * Executes a function on change
  73358. * @param f A path cursor onchange callback
  73359. * @returns This path cursor
  73360. */
  73361. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73362. }
  73363. }
  73364. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73365. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73366. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73367. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73368. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73369. }
  73370. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73371. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73372. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73373. }
  73374. declare module "babylonjs/Engines/Processors/index" {
  73375. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73376. export * from "babylonjs/Engines/Processors/Expressions/index";
  73377. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73378. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73379. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73380. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73381. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73382. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73383. }
  73384. declare module "babylonjs/Legacy/legacy" {
  73385. import * as Babylon from "babylonjs/index";
  73386. export * from "babylonjs/index";
  73387. }
  73388. declare module "babylonjs/Shaders/blur.fragment" {
  73389. /** @hidden */
  73390. export var blurPixelShader: {
  73391. name: string;
  73392. shader: string;
  73393. };
  73394. }
  73395. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73396. /** @hidden */
  73397. export var pointCloudVertexDeclaration: {
  73398. name: string;
  73399. shader: string;
  73400. };
  73401. }
  73402. declare module "babylonjs" {
  73403. export * from "babylonjs/Legacy/legacy";
  73404. }
  73405. declare module BABYLON {
  73406. /** Alias type for value that can be null */
  73407. export type Nullable<T> = T | null;
  73408. /**
  73409. * Alias type for number that are floats
  73410. * @ignorenaming
  73411. */
  73412. export type float = number;
  73413. /**
  73414. * Alias type for number that are doubles.
  73415. * @ignorenaming
  73416. */
  73417. export type double = number;
  73418. /**
  73419. * Alias type for number that are integer
  73420. * @ignorenaming
  73421. */
  73422. export type int = number;
  73423. /** Alias type for number array or Float32Array */
  73424. export type FloatArray = number[] | Float32Array;
  73425. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73426. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73427. /**
  73428. * Alias for types that can be used by a Buffer or VertexBuffer.
  73429. */
  73430. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73431. /**
  73432. * Alias type for primitive types
  73433. * @ignorenaming
  73434. */
  73435. type Primitive = undefined | null | boolean | string | number | Function;
  73436. /**
  73437. * Type modifier to make all the properties of an object Readonly
  73438. */
  73439. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73440. /**
  73441. * Type modifier to make all the properties of an object Readonly recursively
  73442. */
  73443. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73444. /**
  73445. * Type modifier to make object properties readonly.
  73446. */
  73447. export type DeepImmutableObject<T> = {
  73448. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73449. };
  73450. /** @hidden */
  73451. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73452. }
  73453. }
  73454. declare module BABYLON {
  73455. /**
  73456. * A class serves as a medium between the observable and its observers
  73457. */
  73458. export class EventState {
  73459. /**
  73460. * Create a new EventState
  73461. * @param mask defines the mask associated with this state
  73462. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73463. * @param target defines the original target of the state
  73464. * @param currentTarget defines the current target of the state
  73465. */
  73466. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73467. /**
  73468. * Initialize the current event state
  73469. * @param mask defines the mask associated with this state
  73470. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73471. * @param target defines the original target of the state
  73472. * @param currentTarget defines the current target of the state
  73473. * @returns the current event state
  73474. */
  73475. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73476. /**
  73477. * An Observer can set this property to true to prevent subsequent observers of being notified
  73478. */
  73479. skipNextObservers: boolean;
  73480. /**
  73481. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73482. */
  73483. mask: number;
  73484. /**
  73485. * The object that originally notified the event
  73486. */
  73487. target?: any;
  73488. /**
  73489. * The current object in the bubbling phase
  73490. */
  73491. currentTarget?: any;
  73492. /**
  73493. * This will be populated with the return value of the last function that was executed.
  73494. * If it is the first function in the callback chain it will be the event data.
  73495. */
  73496. lastReturnValue?: any;
  73497. }
  73498. /**
  73499. * Represent an Observer registered to a given Observable object.
  73500. */
  73501. export class Observer<T> {
  73502. /**
  73503. * Defines the callback to call when the observer is notified
  73504. */
  73505. callback: (eventData: T, eventState: EventState) => void;
  73506. /**
  73507. * Defines the mask of the observer (used to filter notifications)
  73508. */
  73509. mask: number;
  73510. /**
  73511. * Defines the current scope used to restore the JS context
  73512. */
  73513. scope: any;
  73514. /** @hidden */
  73515. _willBeUnregistered: boolean;
  73516. /**
  73517. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73518. */
  73519. unregisterOnNextCall: boolean;
  73520. /**
  73521. * Creates a new observer
  73522. * @param callback defines the callback to call when the observer is notified
  73523. * @param mask defines the mask of the observer (used to filter notifications)
  73524. * @param scope defines the current scope used to restore the JS context
  73525. */
  73526. constructor(
  73527. /**
  73528. * Defines the callback to call when the observer is notified
  73529. */
  73530. callback: (eventData: T, eventState: EventState) => void,
  73531. /**
  73532. * Defines the mask of the observer (used to filter notifications)
  73533. */
  73534. mask: number,
  73535. /**
  73536. * Defines the current scope used to restore the JS context
  73537. */
  73538. scope?: any);
  73539. }
  73540. /**
  73541. * Represent a list of observers registered to multiple Observables object.
  73542. */
  73543. export class MultiObserver<T> {
  73544. private _observers;
  73545. private _observables;
  73546. /**
  73547. * Release associated resources
  73548. */
  73549. dispose(): void;
  73550. /**
  73551. * Raise a callback when one of the observable will notify
  73552. * @param observables defines a list of observables to watch
  73553. * @param callback defines the callback to call on notification
  73554. * @param mask defines the mask used to filter notifications
  73555. * @param scope defines the current scope used to restore the JS context
  73556. * @returns the new MultiObserver
  73557. */
  73558. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73559. }
  73560. /**
  73561. * The Observable class is a simple implementation of the Observable pattern.
  73562. *
  73563. * 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.
  73564. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73565. * 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).
  73566. * 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.
  73567. */
  73568. export class Observable<T> {
  73569. private _observers;
  73570. private _eventState;
  73571. private _onObserverAdded;
  73572. /**
  73573. * Gets the list of observers
  73574. */
  73575. get observers(): Array<Observer<T>>;
  73576. /**
  73577. * Creates a new observable
  73578. * @param onObserverAdded defines a callback to call when a new observer is added
  73579. */
  73580. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73581. /**
  73582. * Create a new Observer with the specified callback
  73583. * @param callback the callback that will be executed for that Observer
  73584. * @param mask the mask used to filter observers
  73585. * @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.
  73586. * @param scope optional scope for the callback to be called from
  73587. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73588. * @returns the new observer created for the callback
  73589. */
  73590. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73591. /**
  73592. * Create a new Observer with the specified callback and unregisters after the next notification
  73593. * @param callback the callback that will be executed for that Observer
  73594. * @returns the new observer created for the callback
  73595. */
  73596. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73597. /**
  73598. * Remove an Observer from the Observable object
  73599. * @param observer the instance of the Observer to remove
  73600. * @returns false if it doesn't belong to this Observable
  73601. */
  73602. remove(observer: Nullable<Observer<T>>): boolean;
  73603. /**
  73604. * Remove a callback from the Observable object
  73605. * @param callback the callback to remove
  73606. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73607. * @returns false if it doesn't belong to this Observable
  73608. */
  73609. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73610. private _deferUnregister;
  73611. private _remove;
  73612. /**
  73613. * Moves the observable to the top of the observer list making it get called first when notified
  73614. * @param observer the observer to move
  73615. */
  73616. makeObserverTopPriority(observer: Observer<T>): void;
  73617. /**
  73618. * Moves the observable to the bottom of the observer list making it get called last when notified
  73619. * @param observer the observer to move
  73620. */
  73621. makeObserverBottomPriority(observer: Observer<T>): void;
  73622. /**
  73623. * Notify all Observers by calling their respective callback with the given data
  73624. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73625. * @param eventData defines the data to send to all observers
  73626. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73627. * @param target defines the original target of the state
  73628. * @param currentTarget defines the current target of the state
  73629. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73630. */
  73631. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73632. /**
  73633. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73634. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73635. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73636. * and it is crucial that all callbacks will be executed.
  73637. * The order of the callbacks is kept, callbacks are not executed parallel.
  73638. *
  73639. * @param eventData The data to be sent to each callback
  73640. * @param mask is used to filter observers defaults to -1
  73641. * @param target defines the callback target (see EventState)
  73642. * @param currentTarget defines he current object in the bubbling phase
  73643. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73644. */
  73645. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73646. /**
  73647. * Notify a specific observer
  73648. * @param observer defines the observer to notify
  73649. * @param eventData defines the data to be sent to each callback
  73650. * @param mask is used to filter observers defaults to -1
  73651. */
  73652. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73653. /**
  73654. * Gets a boolean indicating if the observable has at least one observer
  73655. * @returns true is the Observable has at least one Observer registered
  73656. */
  73657. hasObservers(): boolean;
  73658. /**
  73659. * Clear the list of observers
  73660. */
  73661. clear(): void;
  73662. /**
  73663. * Clone the current observable
  73664. * @returns a new observable
  73665. */
  73666. clone(): Observable<T>;
  73667. /**
  73668. * Does this observable handles observer registered with a given mask
  73669. * @param mask defines the mask to be tested
  73670. * @return whether or not one observer registered with the given mask is handeled
  73671. **/
  73672. hasSpecificMask(mask?: number): boolean;
  73673. }
  73674. }
  73675. declare module BABYLON {
  73676. /**
  73677. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73678. * Babylon.js
  73679. */
  73680. export class DomManagement {
  73681. /**
  73682. * Checks if the window object exists
  73683. * @returns true if the window object exists
  73684. */
  73685. static IsWindowObjectExist(): boolean;
  73686. /**
  73687. * Checks if the navigator object exists
  73688. * @returns true if the navigator object exists
  73689. */
  73690. static IsNavigatorAvailable(): boolean;
  73691. /**
  73692. * Extracts text content from a DOM element hierarchy
  73693. * @param element defines the root element
  73694. * @returns a string
  73695. */
  73696. static GetDOMTextContent(element: HTMLElement): string;
  73697. }
  73698. }
  73699. declare module BABYLON {
  73700. /**
  73701. * Logger used througouht the application to allow configuration of
  73702. * the log level required for the messages.
  73703. */
  73704. export class Logger {
  73705. /**
  73706. * No log
  73707. */
  73708. static readonly NoneLogLevel: number;
  73709. /**
  73710. * Only message logs
  73711. */
  73712. static readonly MessageLogLevel: number;
  73713. /**
  73714. * Only warning logs
  73715. */
  73716. static readonly WarningLogLevel: number;
  73717. /**
  73718. * Only error logs
  73719. */
  73720. static readonly ErrorLogLevel: number;
  73721. /**
  73722. * All logs
  73723. */
  73724. static readonly AllLogLevel: number;
  73725. private static _LogCache;
  73726. /**
  73727. * Gets a value indicating the number of loading errors
  73728. * @ignorenaming
  73729. */
  73730. static errorsCount: number;
  73731. /**
  73732. * Callback called when a new log is added
  73733. */
  73734. static OnNewCacheEntry: (entry: string) => void;
  73735. private static _AddLogEntry;
  73736. private static _FormatMessage;
  73737. private static _LogDisabled;
  73738. private static _LogEnabled;
  73739. private static _WarnDisabled;
  73740. private static _WarnEnabled;
  73741. private static _ErrorDisabled;
  73742. private static _ErrorEnabled;
  73743. /**
  73744. * Log a message to the console
  73745. */
  73746. static Log: (message: string) => void;
  73747. /**
  73748. * Write a warning message to the console
  73749. */
  73750. static Warn: (message: string) => void;
  73751. /**
  73752. * Write an error message to the console
  73753. */
  73754. static Error: (message: string) => void;
  73755. /**
  73756. * Gets current log cache (list of logs)
  73757. */
  73758. static get LogCache(): string;
  73759. /**
  73760. * Clears the log cache
  73761. */
  73762. static ClearLogCache(): void;
  73763. /**
  73764. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73765. */
  73766. static set LogLevels(level: number);
  73767. }
  73768. }
  73769. declare module BABYLON {
  73770. /** @hidden */
  73771. export class _TypeStore {
  73772. /** @hidden */
  73773. static RegisteredTypes: {
  73774. [key: string]: Object;
  73775. };
  73776. /** @hidden */
  73777. static GetClass(fqdn: string): any;
  73778. }
  73779. }
  73780. declare module BABYLON {
  73781. /**
  73782. * Helper to manipulate strings
  73783. */
  73784. export class StringTools {
  73785. /**
  73786. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73787. * @param str Source string
  73788. * @param suffix Suffix to search for in the source string
  73789. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73790. */
  73791. static EndsWith(str: string, suffix: string): boolean;
  73792. /**
  73793. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73794. * @param str Source string
  73795. * @param suffix Suffix to search for in the source string
  73796. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73797. */
  73798. static StartsWith(str: string, suffix: string): boolean;
  73799. /**
  73800. * Decodes a buffer into a string
  73801. * @param buffer The buffer to decode
  73802. * @returns The decoded string
  73803. */
  73804. static Decode(buffer: Uint8Array | Uint16Array): string;
  73805. /**
  73806. * Encode a buffer to a base64 string
  73807. * @param buffer defines the buffer to encode
  73808. * @returns the encoded string
  73809. */
  73810. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /**
  73815. * Class containing a set of static utilities functions for deep copy.
  73816. */
  73817. export class DeepCopier {
  73818. /**
  73819. * Tries to copy an object by duplicating every property
  73820. * @param source defines the source object
  73821. * @param destination defines the target object
  73822. * @param doNotCopyList defines a list of properties to avoid
  73823. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73824. */
  73825. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73826. }
  73827. }
  73828. declare module BABYLON {
  73829. /**
  73830. * Class containing a set of static utilities functions for precision date
  73831. */
  73832. export class PrecisionDate {
  73833. /**
  73834. * Gets either window.performance.now() if supported or Date.now() else
  73835. */
  73836. static get Now(): number;
  73837. }
  73838. }
  73839. declare module BABYLON {
  73840. /** @hidden */
  73841. export class _DevTools {
  73842. static WarnImport(name: string): string;
  73843. }
  73844. }
  73845. declare module BABYLON {
  73846. /**
  73847. * Interface used to define the mechanism to get data from the network
  73848. */
  73849. export interface IWebRequest {
  73850. /**
  73851. * Returns client's response url
  73852. */
  73853. responseURL: string;
  73854. /**
  73855. * Returns client's status
  73856. */
  73857. status: number;
  73858. /**
  73859. * Returns client's status as a text
  73860. */
  73861. statusText: string;
  73862. }
  73863. }
  73864. declare module BABYLON {
  73865. /**
  73866. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73867. */
  73868. export class WebRequest implements IWebRequest {
  73869. private _xhr;
  73870. /**
  73871. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73872. * i.e. when loading files, where the server/service expects an Authorization header
  73873. */
  73874. static CustomRequestHeaders: {
  73875. [key: string]: string;
  73876. };
  73877. /**
  73878. * Add callback functions in this array to update all the requests before they get sent to the network
  73879. */
  73880. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73881. private _injectCustomRequestHeaders;
  73882. /**
  73883. * Gets or sets a function to be called when loading progress changes
  73884. */
  73885. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73886. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73887. /**
  73888. * Returns client's state
  73889. */
  73890. get readyState(): number;
  73891. /**
  73892. * Returns client's status
  73893. */
  73894. get status(): number;
  73895. /**
  73896. * Returns client's status as a text
  73897. */
  73898. get statusText(): string;
  73899. /**
  73900. * Returns client's response
  73901. */
  73902. get response(): any;
  73903. /**
  73904. * Returns client's response url
  73905. */
  73906. get responseURL(): string;
  73907. /**
  73908. * Returns client's response as text
  73909. */
  73910. get responseText(): string;
  73911. /**
  73912. * Gets or sets the expected response type
  73913. */
  73914. get responseType(): XMLHttpRequestResponseType;
  73915. set responseType(value: XMLHttpRequestResponseType);
  73916. /** @hidden */
  73917. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73918. /** @hidden */
  73919. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73920. /**
  73921. * Cancels any network activity
  73922. */
  73923. abort(): void;
  73924. /**
  73925. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73926. * @param body defines an optional request body
  73927. */
  73928. send(body?: Document | BodyInit | null): void;
  73929. /**
  73930. * Sets the request method, request URL
  73931. * @param method defines the method to use (GET, POST, etc..)
  73932. * @param url defines the url to connect with
  73933. */
  73934. open(method: string, url: string): void;
  73935. /**
  73936. * Sets the value of a request header.
  73937. * @param name The name of the header whose value is to be set
  73938. * @param value The value to set as the body of the header
  73939. */
  73940. setRequestHeader(name: string, value: string): void;
  73941. /**
  73942. * Get the string containing the text of a particular header's value.
  73943. * @param name The name of the header
  73944. * @returns The string containing the text of the given header name
  73945. */
  73946. getResponseHeader(name: string): Nullable<string>;
  73947. }
  73948. }
  73949. declare module BABYLON {
  73950. /**
  73951. * File request interface
  73952. */
  73953. export interface IFileRequest {
  73954. /**
  73955. * Raised when the request is complete (success or error).
  73956. */
  73957. onCompleteObservable: Observable<IFileRequest>;
  73958. /**
  73959. * Aborts the request for a file.
  73960. */
  73961. abort: () => void;
  73962. }
  73963. }
  73964. declare module BABYLON {
  73965. /**
  73966. * Define options used to create a render target texture
  73967. */
  73968. export class RenderTargetCreationOptions {
  73969. /**
  73970. * Specifies is mipmaps must be generated
  73971. */
  73972. generateMipMaps?: boolean;
  73973. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73974. generateDepthBuffer?: boolean;
  73975. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73976. generateStencilBuffer?: boolean;
  73977. /** Defines texture type (int by default) */
  73978. type?: number;
  73979. /** Defines sampling mode (trilinear by default) */
  73980. samplingMode?: number;
  73981. /** Defines format (RGBA by default) */
  73982. format?: number;
  73983. }
  73984. }
  73985. declare module BABYLON {
  73986. /** Defines the cross module used constants to avoid circular dependncies */
  73987. export class Constants {
  73988. /** Defines that alpha blending is disabled */
  73989. static readonly ALPHA_DISABLE: number;
  73990. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73991. static readonly ALPHA_ADD: number;
  73992. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73993. static readonly ALPHA_COMBINE: number;
  73994. /** Defines that alpha blending is DEST - SRC * DEST */
  73995. static readonly ALPHA_SUBTRACT: number;
  73996. /** Defines that alpha blending is SRC * DEST */
  73997. static readonly ALPHA_MULTIPLY: number;
  73998. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73999. static readonly ALPHA_MAXIMIZED: number;
  74000. /** Defines that alpha blending is SRC + DEST */
  74001. static readonly ALPHA_ONEONE: number;
  74002. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74003. static readonly ALPHA_PREMULTIPLIED: number;
  74004. /**
  74005. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74006. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74007. */
  74008. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74009. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74010. static readonly ALPHA_INTERPOLATE: number;
  74011. /**
  74012. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74013. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74014. */
  74015. static readonly ALPHA_SCREENMODE: number;
  74016. /**
  74017. * Defines that alpha blending is SRC + DST
  74018. * Alpha will be set to SRC ALPHA + DST ALPHA
  74019. */
  74020. static readonly ALPHA_ONEONE_ONEONE: number;
  74021. /**
  74022. * Defines that alpha blending is SRC * DST ALPHA + DST
  74023. * Alpha will be set to 0
  74024. */
  74025. static readonly ALPHA_ALPHATOCOLOR: number;
  74026. /**
  74027. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74028. */
  74029. static readonly ALPHA_REVERSEONEMINUS: number;
  74030. /**
  74031. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74032. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74033. */
  74034. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74035. /**
  74036. * Defines that alpha blending is SRC + DST
  74037. * Alpha will be set to SRC ALPHA
  74038. */
  74039. static readonly ALPHA_ONEONE_ONEZERO: number;
  74040. /**
  74041. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74042. * Alpha will be set to DST ALPHA
  74043. */
  74044. static readonly ALPHA_EXCLUSION: number;
  74045. /** Defines that alpha blending equation a SUM */
  74046. static readonly ALPHA_EQUATION_ADD: number;
  74047. /** Defines that alpha blending equation a SUBSTRACTION */
  74048. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74049. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74050. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74051. /** Defines that alpha blending equation a MAX operation */
  74052. static readonly ALPHA_EQUATION_MAX: number;
  74053. /** Defines that alpha blending equation a MIN operation */
  74054. static readonly ALPHA_EQUATION_MIN: number;
  74055. /**
  74056. * Defines that alpha blending equation a DARKEN operation:
  74057. * It takes the min of the src and sums the alpha channels.
  74058. */
  74059. static readonly ALPHA_EQUATION_DARKEN: number;
  74060. /** Defines that the ressource is not delayed*/
  74061. static readonly DELAYLOADSTATE_NONE: number;
  74062. /** Defines that the ressource was successfully delay loaded */
  74063. static readonly DELAYLOADSTATE_LOADED: number;
  74064. /** Defines that the ressource is currently delay loading */
  74065. static readonly DELAYLOADSTATE_LOADING: number;
  74066. /** Defines that the ressource is delayed and has not started loading */
  74067. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74068. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74069. static readonly NEVER: number;
  74070. /** 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 */
  74071. static readonly ALWAYS: number;
  74072. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74073. static readonly LESS: number;
  74074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74075. static readonly EQUAL: number;
  74076. /** 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 */
  74077. static readonly LEQUAL: number;
  74078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74079. static readonly GREATER: number;
  74080. /** 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 */
  74081. static readonly GEQUAL: number;
  74082. /** 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 */
  74083. static readonly NOTEQUAL: number;
  74084. /** Passed to stencilOperation to specify that stencil value must be kept */
  74085. static readonly KEEP: number;
  74086. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74087. static readonly REPLACE: number;
  74088. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74089. static readonly INCR: number;
  74090. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74091. static readonly DECR: number;
  74092. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74093. static readonly INVERT: number;
  74094. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74095. static readonly INCR_WRAP: number;
  74096. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74097. static readonly DECR_WRAP: number;
  74098. /** Texture is not repeating outside of 0..1 UVs */
  74099. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74100. /** Texture is repeating outside of 0..1 UVs */
  74101. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74102. /** Texture is repeating and mirrored */
  74103. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74104. /** ALPHA */
  74105. static readonly TEXTUREFORMAT_ALPHA: number;
  74106. /** LUMINANCE */
  74107. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74108. /** LUMINANCE_ALPHA */
  74109. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74110. /** RGB */
  74111. static readonly TEXTUREFORMAT_RGB: number;
  74112. /** RGBA */
  74113. static readonly TEXTUREFORMAT_RGBA: number;
  74114. /** RED */
  74115. static readonly TEXTUREFORMAT_RED: number;
  74116. /** RED (2nd reference) */
  74117. static readonly TEXTUREFORMAT_R: number;
  74118. /** RG */
  74119. static readonly TEXTUREFORMAT_RG: number;
  74120. /** RED_INTEGER */
  74121. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74122. /** RED_INTEGER (2nd reference) */
  74123. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74124. /** RG_INTEGER */
  74125. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74126. /** RGB_INTEGER */
  74127. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74128. /** RGBA_INTEGER */
  74129. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74130. /** UNSIGNED_BYTE */
  74131. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74132. /** UNSIGNED_BYTE (2nd reference) */
  74133. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74134. /** FLOAT */
  74135. static readonly TEXTURETYPE_FLOAT: number;
  74136. /** HALF_FLOAT */
  74137. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74138. /** BYTE */
  74139. static readonly TEXTURETYPE_BYTE: number;
  74140. /** SHORT */
  74141. static readonly TEXTURETYPE_SHORT: number;
  74142. /** UNSIGNED_SHORT */
  74143. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74144. /** INT */
  74145. static readonly TEXTURETYPE_INT: number;
  74146. /** UNSIGNED_INT */
  74147. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74148. /** UNSIGNED_SHORT_4_4_4_4 */
  74149. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74150. /** UNSIGNED_SHORT_5_5_5_1 */
  74151. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74152. /** UNSIGNED_SHORT_5_6_5 */
  74153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74154. /** UNSIGNED_INT_2_10_10_10_REV */
  74155. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74156. /** UNSIGNED_INT_24_8 */
  74157. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74158. /** UNSIGNED_INT_10F_11F_11F_REV */
  74159. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74160. /** UNSIGNED_INT_5_9_9_9_REV */
  74161. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74162. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74163. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74164. /** nearest is mag = nearest and min = nearest and no mip */
  74165. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74166. /** mag = nearest and min = nearest and mip = none */
  74167. static readonly TEXTURE_NEAREST_NEAREST: number;
  74168. /** Bilinear is mag = linear and min = linear and no mip */
  74169. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74170. /** mag = linear and min = linear and mip = none */
  74171. static readonly TEXTURE_LINEAR_LINEAR: number;
  74172. /** Trilinear is mag = linear and min = linear and mip = linear */
  74173. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74174. /** Trilinear is mag = linear and min = linear and mip = linear */
  74175. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74176. /** mag = nearest and min = nearest and mip = nearest */
  74177. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74178. /** mag = nearest and min = linear and mip = nearest */
  74179. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74180. /** mag = nearest and min = linear and mip = linear */
  74181. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74182. /** mag = nearest and min = linear and mip = none */
  74183. static readonly TEXTURE_NEAREST_LINEAR: number;
  74184. /** nearest is mag = nearest and min = nearest and mip = linear */
  74185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74186. /** mag = linear and min = nearest and mip = nearest */
  74187. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74188. /** mag = linear and min = nearest and mip = linear */
  74189. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74191. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74192. /** mag = linear and min = nearest and mip = none */
  74193. static readonly TEXTURE_LINEAR_NEAREST: number;
  74194. /** Explicit coordinates mode */
  74195. static readonly TEXTURE_EXPLICIT_MODE: number;
  74196. /** Spherical coordinates mode */
  74197. static readonly TEXTURE_SPHERICAL_MODE: number;
  74198. /** Planar coordinates mode */
  74199. static readonly TEXTURE_PLANAR_MODE: number;
  74200. /** Cubic coordinates mode */
  74201. static readonly TEXTURE_CUBIC_MODE: number;
  74202. /** Projection coordinates mode */
  74203. static readonly TEXTURE_PROJECTION_MODE: number;
  74204. /** Skybox coordinates mode */
  74205. static readonly TEXTURE_SKYBOX_MODE: number;
  74206. /** Inverse Cubic coordinates mode */
  74207. static readonly TEXTURE_INVCUBIC_MODE: number;
  74208. /** Equirectangular coordinates mode */
  74209. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74210. /** Equirectangular Fixed coordinates mode */
  74211. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74212. /** Equirectangular Fixed Mirrored coordinates mode */
  74213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74214. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74215. static readonly SCALEMODE_FLOOR: number;
  74216. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74217. static readonly SCALEMODE_NEAREST: number;
  74218. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74219. static readonly SCALEMODE_CEILING: number;
  74220. /**
  74221. * The dirty texture flag value
  74222. */
  74223. static readonly MATERIAL_TextureDirtyFlag: number;
  74224. /**
  74225. * The dirty light flag value
  74226. */
  74227. static readonly MATERIAL_LightDirtyFlag: number;
  74228. /**
  74229. * The dirty fresnel flag value
  74230. */
  74231. static readonly MATERIAL_FresnelDirtyFlag: number;
  74232. /**
  74233. * The dirty attribute flag value
  74234. */
  74235. static readonly MATERIAL_AttributesDirtyFlag: number;
  74236. /**
  74237. * The dirty misc flag value
  74238. */
  74239. static readonly MATERIAL_MiscDirtyFlag: number;
  74240. /**
  74241. * The all dirty flag value
  74242. */
  74243. static readonly MATERIAL_AllDirtyFlag: number;
  74244. /**
  74245. * Returns the triangle fill mode
  74246. */
  74247. static readonly MATERIAL_TriangleFillMode: number;
  74248. /**
  74249. * Returns the wireframe mode
  74250. */
  74251. static readonly MATERIAL_WireFrameFillMode: number;
  74252. /**
  74253. * Returns the point fill mode
  74254. */
  74255. static readonly MATERIAL_PointFillMode: number;
  74256. /**
  74257. * Returns the point list draw mode
  74258. */
  74259. static readonly MATERIAL_PointListDrawMode: number;
  74260. /**
  74261. * Returns the line list draw mode
  74262. */
  74263. static readonly MATERIAL_LineListDrawMode: number;
  74264. /**
  74265. * Returns the line loop draw mode
  74266. */
  74267. static readonly MATERIAL_LineLoopDrawMode: number;
  74268. /**
  74269. * Returns the line strip draw mode
  74270. */
  74271. static readonly MATERIAL_LineStripDrawMode: number;
  74272. /**
  74273. * Returns the triangle strip draw mode
  74274. */
  74275. static readonly MATERIAL_TriangleStripDrawMode: number;
  74276. /**
  74277. * Returns the triangle fan draw mode
  74278. */
  74279. static readonly MATERIAL_TriangleFanDrawMode: number;
  74280. /**
  74281. * Stores the clock-wise side orientation
  74282. */
  74283. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74284. /**
  74285. * Stores the counter clock-wise side orientation
  74286. */
  74287. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74288. /**
  74289. * Nothing
  74290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74291. */
  74292. static readonly ACTION_NothingTrigger: number;
  74293. /**
  74294. * On pick
  74295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74296. */
  74297. static readonly ACTION_OnPickTrigger: number;
  74298. /**
  74299. * On left pick
  74300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74301. */
  74302. static readonly ACTION_OnLeftPickTrigger: number;
  74303. /**
  74304. * On right pick
  74305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74306. */
  74307. static readonly ACTION_OnRightPickTrigger: number;
  74308. /**
  74309. * On center pick
  74310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74311. */
  74312. static readonly ACTION_OnCenterPickTrigger: number;
  74313. /**
  74314. * On pick down
  74315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74316. */
  74317. static readonly ACTION_OnPickDownTrigger: number;
  74318. /**
  74319. * On double pick
  74320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74321. */
  74322. static readonly ACTION_OnDoublePickTrigger: number;
  74323. /**
  74324. * On pick up
  74325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74326. */
  74327. static readonly ACTION_OnPickUpTrigger: number;
  74328. /**
  74329. * On pick out.
  74330. * This trigger will only be raised if you also declared a OnPickDown
  74331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74332. */
  74333. static readonly ACTION_OnPickOutTrigger: number;
  74334. /**
  74335. * On long press
  74336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74337. */
  74338. static readonly ACTION_OnLongPressTrigger: number;
  74339. /**
  74340. * On pointer over
  74341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74342. */
  74343. static readonly ACTION_OnPointerOverTrigger: number;
  74344. /**
  74345. * On pointer out
  74346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74347. */
  74348. static readonly ACTION_OnPointerOutTrigger: number;
  74349. /**
  74350. * On every frame
  74351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74352. */
  74353. static readonly ACTION_OnEveryFrameTrigger: number;
  74354. /**
  74355. * On intersection enter
  74356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74357. */
  74358. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74359. /**
  74360. * On intersection exit
  74361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74362. */
  74363. static readonly ACTION_OnIntersectionExitTrigger: number;
  74364. /**
  74365. * On key down
  74366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74367. */
  74368. static readonly ACTION_OnKeyDownTrigger: number;
  74369. /**
  74370. * On key up
  74371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74372. */
  74373. static readonly ACTION_OnKeyUpTrigger: number;
  74374. /**
  74375. * Billboard mode will only apply to Y axis
  74376. */
  74377. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74378. /**
  74379. * Billboard mode will apply to all axes
  74380. */
  74381. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74382. /**
  74383. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74384. */
  74385. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74386. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74387. * Test order :
  74388. * Is the bounding sphere outside the frustum ?
  74389. * If not, are the bounding box vertices outside the frustum ?
  74390. * It not, then the cullable object is in the frustum.
  74391. */
  74392. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74393. /** Culling strategy : Bounding Sphere Only.
  74394. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74395. * It's also less accurate than the standard because some not visible objects can still be selected.
  74396. * Test : is the bounding sphere outside the frustum ?
  74397. * If not, then the cullable object is in the frustum.
  74398. */
  74399. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74400. /** Culling strategy : Optimistic Inclusion.
  74401. * This in an inclusion test first, then the standard exclusion test.
  74402. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74403. * 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.
  74404. * Anyway, it's as accurate as the standard strategy.
  74405. * Test :
  74406. * Is the cullable object bounding sphere center in the frustum ?
  74407. * If not, apply the default culling strategy.
  74408. */
  74409. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74410. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74411. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74412. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74413. * 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.
  74414. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74415. * Test :
  74416. * Is the cullable object bounding sphere center in the frustum ?
  74417. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74418. */
  74419. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74420. /**
  74421. * No logging while loading
  74422. */
  74423. static readonly SCENELOADER_NO_LOGGING: number;
  74424. /**
  74425. * Minimal logging while loading
  74426. */
  74427. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74428. /**
  74429. * Summary logging while loading
  74430. */
  74431. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74432. /**
  74433. * Detailled logging while loading
  74434. */
  74435. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74436. }
  74437. }
  74438. declare module BABYLON {
  74439. /**
  74440. * This represents the required contract to create a new type of texture loader.
  74441. */
  74442. export interface IInternalTextureLoader {
  74443. /**
  74444. * Defines wether the loader supports cascade loading the different faces.
  74445. */
  74446. supportCascades: boolean;
  74447. /**
  74448. * This returns if the loader support the current file information.
  74449. * @param extension defines the file extension of the file being loaded
  74450. * @returns true if the loader can load the specified file
  74451. */
  74452. canLoad(extension: string): boolean;
  74453. /**
  74454. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74455. * @param data contains the texture data
  74456. * @param texture defines the BabylonJS internal texture
  74457. * @param createPolynomials will be true if polynomials have been requested
  74458. * @param onLoad defines the callback to trigger once the texture is ready
  74459. * @param onError defines the callback to trigger in case of error
  74460. */
  74461. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74462. /**
  74463. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74464. * @param data contains the texture data
  74465. * @param texture defines the BabylonJS internal texture
  74466. * @param callback defines the method to call once ready to upload
  74467. */
  74468. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74469. }
  74470. }
  74471. declare module BABYLON {
  74472. /**
  74473. * Class used to store and describe the pipeline context associated with an effect
  74474. */
  74475. export interface IPipelineContext {
  74476. /**
  74477. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74478. */
  74479. isAsync: boolean;
  74480. /**
  74481. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74482. */
  74483. isReady: boolean;
  74484. /** @hidden */
  74485. _getVertexShaderCode(): string | null;
  74486. /** @hidden */
  74487. _getFragmentShaderCode(): string | null;
  74488. /** @hidden */
  74489. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74490. }
  74491. }
  74492. declare module BABYLON {
  74493. /**
  74494. * Class used to store gfx data (like WebGLBuffer)
  74495. */
  74496. export class DataBuffer {
  74497. /**
  74498. * Gets or sets the number of objects referencing this buffer
  74499. */
  74500. references: number;
  74501. /** Gets or sets the size of the underlying buffer */
  74502. capacity: number;
  74503. /**
  74504. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74505. */
  74506. is32Bits: boolean;
  74507. /**
  74508. * Gets the underlying buffer
  74509. */
  74510. get underlyingResource(): any;
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. /** @hidden */
  74515. export interface IShaderProcessor {
  74516. attributeProcessor?: (attribute: string) => string;
  74517. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74518. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74519. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74520. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74521. lineProcessor?: (line: string, isFragment: boolean) => string;
  74522. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74523. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74524. }
  74525. }
  74526. declare module BABYLON {
  74527. /** @hidden */
  74528. export interface ProcessingOptions {
  74529. defines: string[];
  74530. indexParameters: any;
  74531. isFragment: boolean;
  74532. shouldUseHighPrecisionShader: boolean;
  74533. supportsUniformBuffers: boolean;
  74534. shadersRepository: string;
  74535. includesShadersStore: {
  74536. [key: string]: string;
  74537. };
  74538. processor?: IShaderProcessor;
  74539. version: string;
  74540. platformName: string;
  74541. lookForClosingBracketForUniformBuffer?: boolean;
  74542. }
  74543. }
  74544. declare module BABYLON {
  74545. /** @hidden */
  74546. export class ShaderCodeNode {
  74547. line: string;
  74548. children: ShaderCodeNode[];
  74549. additionalDefineKey?: string;
  74550. additionalDefineValue?: string;
  74551. isValid(preprocessors: {
  74552. [key: string]: string;
  74553. }): boolean;
  74554. process(preprocessors: {
  74555. [key: string]: string;
  74556. }, options: ProcessingOptions): string;
  74557. }
  74558. }
  74559. declare module BABYLON {
  74560. /** @hidden */
  74561. export class ShaderCodeCursor {
  74562. private _lines;
  74563. lineIndex: number;
  74564. get currentLine(): string;
  74565. get canRead(): boolean;
  74566. set lines(value: string[]);
  74567. }
  74568. }
  74569. declare module BABYLON {
  74570. /** @hidden */
  74571. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74572. process(preprocessors: {
  74573. [key: string]: string;
  74574. }, options: ProcessingOptions): string;
  74575. }
  74576. }
  74577. declare module BABYLON {
  74578. /** @hidden */
  74579. export class ShaderDefineExpression {
  74580. isTrue(preprocessors: {
  74581. [key: string]: string;
  74582. }): boolean;
  74583. }
  74584. }
  74585. declare module BABYLON {
  74586. /** @hidden */
  74587. export class ShaderCodeTestNode extends ShaderCodeNode {
  74588. testExpression: ShaderDefineExpression;
  74589. isValid(preprocessors: {
  74590. [key: string]: string;
  74591. }): boolean;
  74592. }
  74593. }
  74594. declare module BABYLON {
  74595. /** @hidden */
  74596. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74597. define: string;
  74598. not: boolean;
  74599. constructor(define: string, not?: boolean);
  74600. isTrue(preprocessors: {
  74601. [key: string]: string;
  74602. }): boolean;
  74603. }
  74604. }
  74605. declare module BABYLON {
  74606. /** @hidden */
  74607. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74608. leftOperand: ShaderDefineExpression;
  74609. rightOperand: ShaderDefineExpression;
  74610. isTrue(preprocessors: {
  74611. [key: string]: string;
  74612. }): boolean;
  74613. }
  74614. }
  74615. declare module BABYLON {
  74616. /** @hidden */
  74617. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74618. leftOperand: ShaderDefineExpression;
  74619. rightOperand: ShaderDefineExpression;
  74620. isTrue(preprocessors: {
  74621. [key: string]: string;
  74622. }): boolean;
  74623. }
  74624. }
  74625. declare module BABYLON {
  74626. /** @hidden */
  74627. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74628. define: string;
  74629. operand: string;
  74630. testValue: string;
  74631. constructor(define: string, operand: string, testValue: string);
  74632. isTrue(preprocessors: {
  74633. [key: string]: string;
  74634. }): boolean;
  74635. }
  74636. }
  74637. declare module BABYLON {
  74638. /**
  74639. * Class used to enable access to offline support
  74640. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74641. */
  74642. export interface IOfflineProvider {
  74643. /**
  74644. * Gets a boolean indicating if scene must be saved in the database
  74645. */
  74646. enableSceneOffline: boolean;
  74647. /**
  74648. * Gets a boolean indicating if textures must be saved in the database
  74649. */
  74650. enableTexturesOffline: boolean;
  74651. /**
  74652. * Open the offline support and make it available
  74653. * @param successCallback defines the callback to call on success
  74654. * @param errorCallback defines the callback to call on error
  74655. */
  74656. open(successCallback: () => void, errorCallback: () => void): void;
  74657. /**
  74658. * Loads an image from the offline support
  74659. * @param url defines the url to load from
  74660. * @param image defines the target DOM image
  74661. */
  74662. loadImage(url: string, image: HTMLImageElement): void;
  74663. /**
  74664. * Loads a file from offline support
  74665. * @param url defines the URL to load from
  74666. * @param sceneLoaded defines a callback to call on success
  74667. * @param progressCallBack defines a callback to call when progress changed
  74668. * @param errorCallback defines a callback to call on error
  74669. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74670. */
  74671. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74672. }
  74673. }
  74674. declare module BABYLON {
  74675. /**
  74676. * Class used to help managing file picking and drag'n'drop
  74677. * File Storage
  74678. */
  74679. export class FilesInputStore {
  74680. /**
  74681. * List of files ready to be loaded
  74682. */
  74683. static FilesToLoad: {
  74684. [key: string]: File;
  74685. };
  74686. }
  74687. }
  74688. declare module BABYLON {
  74689. /**
  74690. * Class used to define a retry strategy when error happens while loading assets
  74691. */
  74692. export class RetryStrategy {
  74693. /**
  74694. * Function used to defines an exponential back off strategy
  74695. * @param maxRetries defines the maximum number of retries (3 by default)
  74696. * @param baseInterval defines the interval between retries
  74697. * @returns the strategy function to use
  74698. */
  74699. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74700. }
  74701. }
  74702. declare module BABYLON {
  74703. /**
  74704. * @ignore
  74705. * Application error to support additional information when loading a file
  74706. */
  74707. export abstract class BaseError extends Error {
  74708. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74709. }
  74710. }
  74711. declare module BABYLON {
  74712. /** @ignore */
  74713. export class LoadFileError extends BaseError {
  74714. request?: WebRequest;
  74715. file?: File;
  74716. /**
  74717. * Creates a new LoadFileError
  74718. * @param message defines the message of the error
  74719. * @param request defines the optional web request
  74720. * @param file defines the optional file
  74721. */
  74722. constructor(message: string, object?: WebRequest | File);
  74723. }
  74724. /** @ignore */
  74725. export class RequestFileError extends BaseError {
  74726. request: WebRequest;
  74727. /**
  74728. * Creates a new LoadFileError
  74729. * @param message defines the message of the error
  74730. * @param request defines the optional web request
  74731. */
  74732. constructor(message: string, request: WebRequest);
  74733. }
  74734. /** @ignore */
  74735. export class ReadFileError extends BaseError {
  74736. file: File;
  74737. /**
  74738. * Creates a new ReadFileError
  74739. * @param message defines the message of the error
  74740. * @param file defines the optional file
  74741. */
  74742. constructor(message: string, file: File);
  74743. }
  74744. /**
  74745. * @hidden
  74746. */
  74747. export class FileTools {
  74748. /**
  74749. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74750. */
  74751. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74752. /**
  74753. * Gets or sets the base URL to use to load assets
  74754. */
  74755. static BaseUrl: string;
  74756. /**
  74757. * Default behaviour for cors in the application.
  74758. * It can be a string if the expected behavior is identical in the entire app.
  74759. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74760. */
  74761. static CorsBehavior: string | ((url: string | string[]) => string);
  74762. /**
  74763. * Gets or sets a function used to pre-process url before using them to load assets
  74764. */
  74765. static PreprocessUrl: (url: string) => string;
  74766. /**
  74767. * Removes unwanted characters from an url
  74768. * @param url defines the url to clean
  74769. * @returns the cleaned url
  74770. */
  74771. private static _CleanUrl;
  74772. /**
  74773. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74774. * @param url define the url we are trying
  74775. * @param element define the dom element where to configure the cors policy
  74776. */
  74777. static SetCorsBehavior(url: string | string[], element: {
  74778. crossOrigin: string | null;
  74779. }): void;
  74780. /**
  74781. * Loads an image as an HTMLImageElement.
  74782. * @param input url string, ArrayBuffer, or Blob to load
  74783. * @param onLoad callback called when the image successfully loads
  74784. * @param onError callback called when the image fails to load
  74785. * @param offlineProvider offline provider for caching
  74786. * @param mimeType optional mime type
  74787. * @returns the HTMLImageElement of the loaded image
  74788. */
  74789. 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>;
  74790. /**
  74791. * Reads a file from a File object
  74792. * @param file defines the file to load
  74793. * @param onSuccess defines the callback to call when data is loaded
  74794. * @param onProgress defines the callback to call during loading process
  74795. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74796. * @param onError defines the callback to call when an error occurs
  74797. * @returns a file request object
  74798. */
  74799. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74800. /**
  74801. * Loads a file from a url
  74802. * @param url url to load
  74803. * @param onSuccess callback called when the file successfully loads
  74804. * @param onProgress callback called while file is loading (if the server supports this mode)
  74805. * @param offlineProvider defines the offline provider for caching
  74806. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74807. * @param onError callback called when the file fails to load
  74808. * @returns a file request object
  74809. */
  74810. 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;
  74811. /**
  74812. * Loads a file
  74813. * @param url url to load
  74814. * @param onSuccess callback called when the file successfully loads
  74815. * @param onProgress callback called while file is loading (if the server supports this mode)
  74816. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74817. * @param onError callback called when the file fails to load
  74818. * @param onOpened callback called when the web request is opened
  74819. * @returns a file request object
  74820. */
  74821. 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;
  74822. /**
  74823. * Checks if the loaded document was accessed via `file:`-Protocol.
  74824. * @returns boolean
  74825. */
  74826. static IsFileURL(): boolean;
  74827. }
  74828. }
  74829. declare module BABYLON {
  74830. /** @hidden */
  74831. export class ShaderProcessor {
  74832. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74833. private static _ProcessPrecision;
  74834. private static _ExtractOperation;
  74835. private static _BuildSubExpression;
  74836. private static _BuildExpression;
  74837. private static _MoveCursorWithinIf;
  74838. private static _MoveCursor;
  74839. private static _EvaluatePreProcessors;
  74840. private static _PreparePreProcessors;
  74841. private static _ProcessShaderConversion;
  74842. private static _ProcessIncludes;
  74843. /**
  74844. * Loads a file from a url
  74845. * @param url url to load
  74846. * @param onSuccess callback called when the file successfully loads
  74847. * @param onProgress callback called while file is loading (if the server supports this mode)
  74848. * @param offlineProvider defines the offline provider for caching
  74849. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74850. * @param onError callback called when the file fails to load
  74851. * @returns a file request object
  74852. * @hidden
  74853. */
  74854. 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;
  74855. }
  74856. }
  74857. declare module BABYLON {
  74858. /**
  74859. * @hidden
  74860. */
  74861. export interface IColor4Like {
  74862. r: float;
  74863. g: float;
  74864. b: float;
  74865. a: float;
  74866. }
  74867. /**
  74868. * @hidden
  74869. */
  74870. export interface IColor3Like {
  74871. r: float;
  74872. g: float;
  74873. b: float;
  74874. }
  74875. /**
  74876. * @hidden
  74877. */
  74878. export interface IVector4Like {
  74879. x: float;
  74880. y: float;
  74881. z: float;
  74882. w: float;
  74883. }
  74884. /**
  74885. * @hidden
  74886. */
  74887. export interface IVector3Like {
  74888. x: float;
  74889. y: float;
  74890. z: float;
  74891. }
  74892. /**
  74893. * @hidden
  74894. */
  74895. export interface IVector2Like {
  74896. x: float;
  74897. y: float;
  74898. }
  74899. /**
  74900. * @hidden
  74901. */
  74902. export interface IMatrixLike {
  74903. toArray(): DeepImmutable<Float32Array>;
  74904. updateFlag: int;
  74905. }
  74906. /**
  74907. * @hidden
  74908. */
  74909. export interface IViewportLike {
  74910. x: float;
  74911. y: float;
  74912. width: float;
  74913. height: float;
  74914. }
  74915. /**
  74916. * @hidden
  74917. */
  74918. export interface IPlaneLike {
  74919. normal: IVector3Like;
  74920. d: float;
  74921. normalize(): void;
  74922. }
  74923. }
  74924. declare module BABYLON {
  74925. /**
  74926. * Interface used to define common properties for effect fallbacks
  74927. */
  74928. export interface IEffectFallbacks {
  74929. /**
  74930. * Removes the defines that should be removed when falling back.
  74931. * @param currentDefines defines the current define statements for the shader.
  74932. * @param effect defines the current effect we try to compile
  74933. * @returns The resulting defines with defines of the current rank removed.
  74934. */
  74935. reduce(currentDefines: string, effect: Effect): string;
  74936. /**
  74937. * Removes the fallback from the bound mesh.
  74938. */
  74939. unBindMesh(): void;
  74940. /**
  74941. * Checks to see if more fallbacks are still availible.
  74942. */
  74943. hasMoreFallbacks: boolean;
  74944. }
  74945. }
  74946. declare module BABYLON {
  74947. /**
  74948. * Class used to evalaute queries containing `and` and `or` operators
  74949. */
  74950. export class AndOrNotEvaluator {
  74951. /**
  74952. * Evaluate a query
  74953. * @param query defines the query to evaluate
  74954. * @param evaluateCallback defines the callback used to filter result
  74955. * @returns true if the query matches
  74956. */
  74957. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74958. private static _HandleParenthesisContent;
  74959. private static _SimplifyNegation;
  74960. }
  74961. }
  74962. declare module BABYLON {
  74963. /**
  74964. * Class used to store custom tags
  74965. */
  74966. export class Tags {
  74967. /**
  74968. * Adds support for tags on the given object
  74969. * @param obj defines the object to use
  74970. */
  74971. static EnableFor(obj: any): void;
  74972. /**
  74973. * Removes tags support
  74974. * @param obj defines the object to use
  74975. */
  74976. static DisableFor(obj: any): void;
  74977. /**
  74978. * Gets a boolean indicating if the given object has tags
  74979. * @param obj defines the object to use
  74980. * @returns a boolean
  74981. */
  74982. static HasTags(obj: any): boolean;
  74983. /**
  74984. * Gets the tags available on a given object
  74985. * @param obj defines the object to use
  74986. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74987. * @returns the tags
  74988. */
  74989. static GetTags(obj: any, asString?: boolean): any;
  74990. /**
  74991. * Adds tags to an object
  74992. * @param obj defines the object to use
  74993. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74994. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74995. */
  74996. static AddTagsTo(obj: any, tagsString: string): void;
  74997. /**
  74998. * @hidden
  74999. */
  75000. static _AddTagTo(obj: any, tag: string): void;
  75001. /**
  75002. * Removes specific tags from a specific object
  75003. * @param obj defines the object to use
  75004. * @param tagsString defines the tags to remove
  75005. */
  75006. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75007. /**
  75008. * @hidden
  75009. */
  75010. static _RemoveTagFrom(obj: any, tag: string): void;
  75011. /**
  75012. * Defines if tags hosted on an object match a given query
  75013. * @param obj defines the object to use
  75014. * @param tagsQuery defines the tag query
  75015. * @returns a boolean
  75016. */
  75017. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75018. }
  75019. }
  75020. declare module BABYLON {
  75021. /**
  75022. * Scalar computation library
  75023. */
  75024. export class Scalar {
  75025. /**
  75026. * Two pi constants convenient for computation.
  75027. */
  75028. static TwoPi: number;
  75029. /**
  75030. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75031. * @param a number
  75032. * @param b number
  75033. * @param epsilon (default = 1.401298E-45)
  75034. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75035. */
  75036. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75037. /**
  75038. * Returns a string : the upper case translation of the number i to hexadecimal.
  75039. * @param i number
  75040. * @returns the upper case translation of the number i to hexadecimal.
  75041. */
  75042. static ToHex(i: number): string;
  75043. /**
  75044. * Returns -1 if value is negative and +1 is value is positive.
  75045. * @param value the value
  75046. * @returns the value itself if it's equal to zero.
  75047. */
  75048. static Sign(value: number): number;
  75049. /**
  75050. * Returns the value itself if it's between min and max.
  75051. * Returns min if the value is lower than min.
  75052. * Returns max if the value is greater than max.
  75053. * @param value the value to clmap
  75054. * @param min the min value to clamp to (default: 0)
  75055. * @param max the max value to clamp to (default: 1)
  75056. * @returns the clamped value
  75057. */
  75058. static Clamp(value: number, min?: number, max?: number): number;
  75059. /**
  75060. * the log2 of value.
  75061. * @param value the value to compute log2 of
  75062. * @returns the log2 of value.
  75063. */
  75064. static Log2(value: number): number;
  75065. /**
  75066. * Loops the value, so that it is never larger than length and never smaller than 0.
  75067. *
  75068. * This is similar to the modulo operator but it works with floating point numbers.
  75069. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75070. * With t = 5 and length = 2.5, the result would be 0.0.
  75071. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75072. * @param value the value
  75073. * @param length the length
  75074. * @returns the looped value
  75075. */
  75076. static Repeat(value: number, length: number): number;
  75077. /**
  75078. * Normalize the value between 0.0 and 1.0 using min and max values
  75079. * @param value value to normalize
  75080. * @param min max to normalize between
  75081. * @param max min to normalize between
  75082. * @returns the normalized value
  75083. */
  75084. static Normalize(value: number, min: number, max: number): number;
  75085. /**
  75086. * Denormalize the value from 0.0 and 1.0 using min and max values
  75087. * @param normalized value to denormalize
  75088. * @param min max to denormalize between
  75089. * @param max min to denormalize between
  75090. * @returns the denormalized value
  75091. */
  75092. static Denormalize(normalized: number, min: number, max: number): number;
  75093. /**
  75094. * Calculates the shortest difference between two given angles given in degrees.
  75095. * @param current current angle in degrees
  75096. * @param target target angle in degrees
  75097. * @returns the delta
  75098. */
  75099. static DeltaAngle(current: number, target: number): number;
  75100. /**
  75101. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75102. * @param tx value
  75103. * @param length length
  75104. * @returns The returned value will move back and forth between 0 and length
  75105. */
  75106. static PingPong(tx: number, length: number): number;
  75107. /**
  75108. * Interpolates between min and max with smoothing at the limits.
  75109. *
  75110. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75111. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75112. * @param from from
  75113. * @param to to
  75114. * @param tx value
  75115. * @returns the smooth stepped value
  75116. */
  75117. static SmoothStep(from: number, to: number, tx: number): number;
  75118. /**
  75119. * Moves a value current towards target.
  75120. *
  75121. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75122. * Negative values of maxDelta pushes the value away from target.
  75123. * @param current current value
  75124. * @param target target value
  75125. * @param maxDelta max distance to move
  75126. * @returns resulting value
  75127. */
  75128. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75129. /**
  75130. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75131. *
  75132. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75133. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75134. * @param current current value
  75135. * @param target target value
  75136. * @param maxDelta max distance to move
  75137. * @returns resulting angle
  75138. */
  75139. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75140. /**
  75141. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75142. * @param start start value
  75143. * @param end target value
  75144. * @param amount amount to lerp between
  75145. * @returns the lerped value
  75146. */
  75147. static Lerp(start: number, end: number, amount: number): number;
  75148. /**
  75149. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75150. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75151. * @param start start value
  75152. * @param end target value
  75153. * @param amount amount to lerp between
  75154. * @returns the lerped value
  75155. */
  75156. static LerpAngle(start: number, end: number, amount: number): number;
  75157. /**
  75158. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75159. * @param a start value
  75160. * @param b target value
  75161. * @param value value between a and b
  75162. * @returns the inverseLerp value
  75163. */
  75164. static InverseLerp(a: number, b: number, value: number): number;
  75165. /**
  75166. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75167. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75168. * @param value1 spline value
  75169. * @param tangent1 spline value
  75170. * @param value2 spline value
  75171. * @param tangent2 spline value
  75172. * @param amount input value
  75173. * @returns hermite result
  75174. */
  75175. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75176. /**
  75177. * Returns a random float number between and min and max values
  75178. * @param min min value of random
  75179. * @param max max value of random
  75180. * @returns random value
  75181. */
  75182. static RandomRange(min: number, max: number): number;
  75183. /**
  75184. * This function returns percentage of a number in a given range.
  75185. *
  75186. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75187. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75188. * @param number to convert to percentage
  75189. * @param min min range
  75190. * @param max max range
  75191. * @returns the percentage
  75192. */
  75193. static RangeToPercent(number: number, min: number, max: number): number;
  75194. /**
  75195. * This function returns number that corresponds to the percentage in a given range.
  75196. *
  75197. * PercentToRange(0.34,0,100) will return 34.
  75198. * @param percent to convert to number
  75199. * @param min min range
  75200. * @param max max range
  75201. * @returns the number
  75202. */
  75203. static PercentToRange(percent: number, min: number, max: number): number;
  75204. /**
  75205. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75206. * @param angle The angle to normalize in radian.
  75207. * @return The converted angle.
  75208. */
  75209. static NormalizeRadians(angle: number): number;
  75210. }
  75211. }
  75212. declare module BABYLON {
  75213. /**
  75214. * Constant used to convert a value to gamma space
  75215. * @ignorenaming
  75216. */
  75217. export const ToGammaSpace: number;
  75218. /**
  75219. * Constant used to convert a value to linear space
  75220. * @ignorenaming
  75221. */
  75222. export const ToLinearSpace = 2.2;
  75223. /**
  75224. * Constant used to define the minimal number value in Babylon.js
  75225. * @ignorenaming
  75226. */
  75227. let Epsilon: number;
  75228. }
  75229. declare module BABYLON {
  75230. /**
  75231. * Class used to represent a viewport on screen
  75232. */
  75233. export class Viewport {
  75234. /** viewport left coordinate */
  75235. x: number;
  75236. /** viewport top coordinate */
  75237. y: number;
  75238. /**viewport width */
  75239. width: number;
  75240. /** viewport height */
  75241. height: number;
  75242. /**
  75243. * Creates a Viewport object located at (x, y) and sized (width, height)
  75244. * @param x defines viewport left coordinate
  75245. * @param y defines viewport top coordinate
  75246. * @param width defines the viewport width
  75247. * @param height defines the viewport height
  75248. */
  75249. constructor(
  75250. /** viewport left coordinate */
  75251. x: number,
  75252. /** viewport top coordinate */
  75253. y: number,
  75254. /**viewport width */
  75255. width: number,
  75256. /** viewport height */
  75257. height: number);
  75258. /**
  75259. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75260. * @param renderWidth defines the rendering width
  75261. * @param renderHeight defines the rendering height
  75262. * @returns a new Viewport
  75263. */
  75264. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75265. /**
  75266. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75267. * @param renderWidth defines the rendering width
  75268. * @param renderHeight defines the rendering height
  75269. * @param ref defines the target viewport
  75270. * @returns the current viewport
  75271. */
  75272. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75273. /**
  75274. * Returns a new Viewport copied from the current one
  75275. * @returns a new Viewport
  75276. */
  75277. clone(): Viewport;
  75278. }
  75279. }
  75280. declare module BABYLON {
  75281. /**
  75282. * Class containing a set of static utilities functions for arrays.
  75283. */
  75284. export class ArrayTools {
  75285. /**
  75286. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75287. * @param size the number of element to construct and put in the array
  75288. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75289. * @returns a new array filled with new objects
  75290. */
  75291. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75292. }
  75293. }
  75294. declare module BABYLON {
  75295. /**
  75296. * Class representing a vector containing 2 coordinates
  75297. */
  75298. export class Vector2 {
  75299. /** defines the first coordinate */
  75300. x: number;
  75301. /** defines the second coordinate */
  75302. y: number;
  75303. /**
  75304. * Creates a new Vector2 from the given x and y coordinates
  75305. * @param x defines the first coordinate
  75306. * @param y defines the second coordinate
  75307. */
  75308. constructor(
  75309. /** defines the first coordinate */
  75310. x?: number,
  75311. /** defines the second coordinate */
  75312. y?: number);
  75313. /**
  75314. * Gets a string with the Vector2 coordinates
  75315. * @returns a string with the Vector2 coordinates
  75316. */
  75317. toString(): string;
  75318. /**
  75319. * Gets class name
  75320. * @returns the string "Vector2"
  75321. */
  75322. getClassName(): string;
  75323. /**
  75324. * Gets current vector hash code
  75325. * @returns the Vector2 hash code as a number
  75326. */
  75327. getHashCode(): number;
  75328. /**
  75329. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75330. * @param array defines the source array
  75331. * @param index defines the offset in source array
  75332. * @returns the current Vector2
  75333. */
  75334. toArray(array: FloatArray, index?: number): Vector2;
  75335. /**
  75336. * Copy the current vector to an array
  75337. * @returns a new array with 2 elements: the Vector2 coordinates.
  75338. */
  75339. asArray(): number[];
  75340. /**
  75341. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75342. * @param source defines the source Vector2
  75343. * @returns the current updated Vector2
  75344. */
  75345. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75346. /**
  75347. * Sets the Vector2 coordinates with the given floats
  75348. * @param x defines the first coordinate
  75349. * @param y defines the second coordinate
  75350. * @returns the current updated Vector2
  75351. */
  75352. copyFromFloats(x: number, y: number): Vector2;
  75353. /**
  75354. * Sets the Vector2 coordinates with the given floats
  75355. * @param x defines the first coordinate
  75356. * @param y defines the second coordinate
  75357. * @returns the current updated Vector2
  75358. */
  75359. set(x: number, y: number): Vector2;
  75360. /**
  75361. * Add another vector with the current one
  75362. * @param otherVector defines the other vector
  75363. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75364. */
  75365. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75366. /**
  75367. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75368. * @param otherVector defines the other vector
  75369. * @param result defines the target vector
  75370. * @returns the unmodified current Vector2
  75371. */
  75372. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75373. /**
  75374. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75375. * @param otherVector defines the other vector
  75376. * @returns the current updated Vector2
  75377. */
  75378. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75379. /**
  75380. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75381. * @param otherVector defines the other vector
  75382. * @returns a new Vector2
  75383. */
  75384. addVector3(otherVector: Vector3): Vector2;
  75385. /**
  75386. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75387. * @param otherVector defines the other vector
  75388. * @returns a new Vector2
  75389. */
  75390. subtract(otherVector: Vector2): Vector2;
  75391. /**
  75392. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75393. * @param otherVector defines the other vector
  75394. * @param result defines the target vector
  75395. * @returns the unmodified current Vector2
  75396. */
  75397. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75398. /**
  75399. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75400. * @param otherVector defines the other vector
  75401. * @returns the current updated Vector2
  75402. */
  75403. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75404. /**
  75405. * Multiplies in place the current Vector2 coordinates by the given ones
  75406. * @param otherVector defines the other vector
  75407. * @returns the current updated Vector2
  75408. */
  75409. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75410. /**
  75411. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75412. * @param otherVector defines the other vector
  75413. * @returns a new Vector2
  75414. */
  75415. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75416. /**
  75417. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75418. * @param otherVector defines the other vector
  75419. * @param result defines the target vector
  75420. * @returns the unmodified current Vector2
  75421. */
  75422. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75423. /**
  75424. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75425. * @param x defines the first coordinate
  75426. * @param y defines the second coordinate
  75427. * @returns a new Vector2
  75428. */
  75429. multiplyByFloats(x: number, y: number): Vector2;
  75430. /**
  75431. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75432. * @param otherVector defines the other vector
  75433. * @returns a new Vector2
  75434. */
  75435. divide(otherVector: Vector2): Vector2;
  75436. /**
  75437. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75438. * @param otherVector defines the other vector
  75439. * @param result defines the target vector
  75440. * @returns the unmodified current Vector2
  75441. */
  75442. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75443. /**
  75444. * Divides the current Vector2 coordinates by the given ones
  75445. * @param otherVector defines the other vector
  75446. * @returns the current updated Vector2
  75447. */
  75448. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75449. /**
  75450. * Gets a new Vector2 with current Vector2 negated coordinates
  75451. * @returns a new Vector2
  75452. */
  75453. negate(): Vector2;
  75454. /**
  75455. * Negate this vector in place
  75456. * @returns this
  75457. */
  75458. negateInPlace(): Vector2;
  75459. /**
  75460. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75461. * @param result defines the Vector3 object where to store the result
  75462. * @returns the current Vector2
  75463. */
  75464. negateToRef(result: Vector2): Vector2;
  75465. /**
  75466. * Multiply the Vector2 coordinates by scale
  75467. * @param scale defines the scaling factor
  75468. * @returns the current updated Vector2
  75469. */
  75470. scaleInPlace(scale: number): Vector2;
  75471. /**
  75472. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75473. * @param scale defines the scaling factor
  75474. * @returns a new Vector2
  75475. */
  75476. scale(scale: number): Vector2;
  75477. /**
  75478. * Scale the current Vector2 values by a factor to a given Vector2
  75479. * @param scale defines the scale factor
  75480. * @param result defines the Vector2 object where to store the result
  75481. * @returns the unmodified current Vector2
  75482. */
  75483. scaleToRef(scale: number, result: Vector2): Vector2;
  75484. /**
  75485. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75486. * @param scale defines the scale factor
  75487. * @param result defines the Vector2 object where to store the result
  75488. * @returns the unmodified current Vector2
  75489. */
  75490. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75491. /**
  75492. * Gets a boolean if two vectors are equals
  75493. * @param otherVector defines the other vector
  75494. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75495. */
  75496. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75497. /**
  75498. * Gets a boolean if two vectors are equals (using an epsilon value)
  75499. * @param otherVector defines the other vector
  75500. * @param epsilon defines the minimal distance to consider equality
  75501. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75502. */
  75503. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75504. /**
  75505. * Gets a new Vector2 from current Vector2 floored values
  75506. * @returns a new Vector2
  75507. */
  75508. floor(): Vector2;
  75509. /**
  75510. * Gets a new Vector2 from current Vector2 floored values
  75511. * @returns a new Vector2
  75512. */
  75513. fract(): Vector2;
  75514. /**
  75515. * Gets the length of the vector
  75516. * @returns the vector length (float)
  75517. */
  75518. length(): number;
  75519. /**
  75520. * Gets the vector squared length
  75521. * @returns the vector squared length (float)
  75522. */
  75523. lengthSquared(): number;
  75524. /**
  75525. * Normalize the vector
  75526. * @returns the current updated Vector2
  75527. */
  75528. normalize(): Vector2;
  75529. /**
  75530. * Gets a new Vector2 copied from the Vector2
  75531. * @returns a new Vector2
  75532. */
  75533. clone(): Vector2;
  75534. /**
  75535. * Gets a new Vector2(0, 0)
  75536. * @returns a new Vector2
  75537. */
  75538. static Zero(): Vector2;
  75539. /**
  75540. * Gets a new Vector2(1, 1)
  75541. * @returns a new Vector2
  75542. */
  75543. static One(): Vector2;
  75544. /**
  75545. * Gets a new Vector2 set from the given index element of the given array
  75546. * @param array defines the data source
  75547. * @param offset defines the offset in the data source
  75548. * @returns a new Vector2
  75549. */
  75550. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75551. /**
  75552. * Sets "result" from the given index element of the given array
  75553. * @param array defines the data source
  75554. * @param offset defines the offset in the data source
  75555. * @param result defines the target vector
  75556. */
  75557. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75558. /**
  75559. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75560. * @param value1 defines 1st point of control
  75561. * @param value2 defines 2nd point of control
  75562. * @param value3 defines 3rd point of control
  75563. * @param value4 defines 4th point of control
  75564. * @param amount defines the interpolation factor
  75565. * @returns a new Vector2
  75566. */
  75567. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75568. /**
  75569. * 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".
  75570. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75571. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75572. * @param value defines the value to clamp
  75573. * @param min defines the lower limit
  75574. * @param max defines the upper limit
  75575. * @returns a new Vector2
  75576. */
  75577. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75578. /**
  75579. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75580. * @param value1 defines the 1st control point
  75581. * @param tangent1 defines the outgoing tangent
  75582. * @param value2 defines the 2nd control point
  75583. * @param tangent2 defines the incoming tangent
  75584. * @param amount defines the interpolation factor
  75585. * @returns a new Vector2
  75586. */
  75587. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75588. /**
  75589. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75590. * @param start defines the start vector
  75591. * @param end defines the end vector
  75592. * @param amount defines the interpolation factor
  75593. * @returns a new Vector2
  75594. */
  75595. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75596. /**
  75597. * Gets the dot product of the vector "left" and the vector "right"
  75598. * @param left defines first vector
  75599. * @param right defines second vector
  75600. * @returns the dot product (float)
  75601. */
  75602. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75603. /**
  75604. * Returns a new Vector2 equal to the normalized given vector
  75605. * @param vector defines the vector to normalize
  75606. * @returns a new Vector2
  75607. */
  75608. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75609. /**
  75610. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75611. * @param left defines 1st vector
  75612. * @param right defines 2nd vector
  75613. * @returns a new Vector2
  75614. */
  75615. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75616. /**
  75617. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75618. * @param left defines 1st vector
  75619. * @param right defines 2nd vector
  75620. * @returns a new Vector2
  75621. */
  75622. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75623. /**
  75624. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75625. * @param vector defines the vector to transform
  75626. * @param transformation defines the matrix to apply
  75627. * @returns a new Vector2
  75628. */
  75629. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75630. /**
  75631. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75632. * @param vector defines the vector to transform
  75633. * @param transformation defines the matrix to apply
  75634. * @param result defines the target vector
  75635. */
  75636. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75637. /**
  75638. * Determines if a given vector is included in a triangle
  75639. * @param p defines the vector to test
  75640. * @param p0 defines 1st triangle point
  75641. * @param p1 defines 2nd triangle point
  75642. * @param p2 defines 3rd triangle point
  75643. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75644. */
  75645. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75646. /**
  75647. * Gets the distance between the vectors "value1" and "value2"
  75648. * @param value1 defines first vector
  75649. * @param value2 defines second vector
  75650. * @returns the distance between vectors
  75651. */
  75652. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75653. /**
  75654. * Returns the squared distance between the vectors "value1" and "value2"
  75655. * @param value1 defines first vector
  75656. * @param value2 defines second vector
  75657. * @returns the squared distance between vectors
  75658. */
  75659. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75660. /**
  75661. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75662. * @param value1 defines first vector
  75663. * @param value2 defines second vector
  75664. * @returns a new Vector2
  75665. */
  75666. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75667. /**
  75668. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75669. * @param p defines the middle point
  75670. * @param segA defines one point of the segment
  75671. * @param segB defines the other point of the segment
  75672. * @returns the shortest distance
  75673. */
  75674. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75675. }
  75676. /**
  75677. * Class used to store (x,y,z) vector representation
  75678. * A Vector3 is the main object used in 3D geometry
  75679. * It can represent etiher the coordinates of a point the space, either a direction
  75680. * Reminder: js uses a left handed forward facing system
  75681. */
  75682. export class Vector3 {
  75683. /**
  75684. * Defines the first coordinates (on X axis)
  75685. */
  75686. x: number;
  75687. /**
  75688. * Defines the second coordinates (on Y axis)
  75689. */
  75690. y: number;
  75691. /**
  75692. * Defines the third coordinates (on Z axis)
  75693. */
  75694. z: number;
  75695. private static _UpReadOnly;
  75696. private static _ZeroReadOnly;
  75697. /**
  75698. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75699. * @param x defines the first coordinates (on X axis)
  75700. * @param y defines the second coordinates (on Y axis)
  75701. * @param z defines the third coordinates (on Z axis)
  75702. */
  75703. constructor(
  75704. /**
  75705. * Defines the first coordinates (on X axis)
  75706. */
  75707. x?: number,
  75708. /**
  75709. * Defines the second coordinates (on Y axis)
  75710. */
  75711. y?: number,
  75712. /**
  75713. * Defines the third coordinates (on Z axis)
  75714. */
  75715. z?: number);
  75716. /**
  75717. * Creates a string representation of the Vector3
  75718. * @returns a string with the Vector3 coordinates.
  75719. */
  75720. toString(): string;
  75721. /**
  75722. * Gets the class name
  75723. * @returns the string "Vector3"
  75724. */
  75725. getClassName(): string;
  75726. /**
  75727. * Creates the Vector3 hash code
  75728. * @returns a number which tends to be unique between Vector3 instances
  75729. */
  75730. getHashCode(): number;
  75731. /**
  75732. * Creates an array containing three elements : the coordinates of the Vector3
  75733. * @returns a new array of numbers
  75734. */
  75735. asArray(): number[];
  75736. /**
  75737. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75738. * @param array defines the destination array
  75739. * @param index defines the offset in the destination array
  75740. * @returns the current Vector3
  75741. */
  75742. toArray(array: FloatArray, index?: number): Vector3;
  75743. /**
  75744. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75745. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75746. */
  75747. toQuaternion(): Quaternion;
  75748. /**
  75749. * Adds the given vector to the current Vector3
  75750. * @param otherVector defines the second operand
  75751. * @returns the current updated Vector3
  75752. */
  75753. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75754. /**
  75755. * Adds the given coordinates to the current Vector3
  75756. * @param x defines the x coordinate of the operand
  75757. * @param y defines the y coordinate of the operand
  75758. * @param z defines the z coordinate of the operand
  75759. * @returns the current updated Vector3
  75760. */
  75761. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75762. /**
  75763. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75764. * @param otherVector defines the second operand
  75765. * @returns the resulting Vector3
  75766. */
  75767. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75768. /**
  75769. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75770. * @param otherVector defines the second operand
  75771. * @param result defines the Vector3 object where to store the result
  75772. * @returns the current Vector3
  75773. */
  75774. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75775. /**
  75776. * Subtract the given vector from the current Vector3
  75777. * @param otherVector defines the second operand
  75778. * @returns the current updated Vector3
  75779. */
  75780. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75781. /**
  75782. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75783. * @param otherVector defines the second operand
  75784. * @returns the resulting Vector3
  75785. */
  75786. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75787. /**
  75788. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75789. * @param otherVector defines the second operand
  75790. * @param result defines the Vector3 object where to store the result
  75791. * @returns the current Vector3
  75792. */
  75793. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75794. /**
  75795. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75796. * @param x defines the x coordinate of the operand
  75797. * @param y defines the y coordinate of the operand
  75798. * @param z defines the z coordinate of the operand
  75799. * @returns the resulting Vector3
  75800. */
  75801. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75802. /**
  75803. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75804. * @param x defines the x coordinate of the operand
  75805. * @param y defines the y coordinate of the operand
  75806. * @param z defines the z coordinate of the operand
  75807. * @param result defines the Vector3 object where to store the result
  75808. * @returns the current Vector3
  75809. */
  75810. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75811. /**
  75812. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75813. * @returns a new Vector3
  75814. */
  75815. negate(): Vector3;
  75816. /**
  75817. * Negate this vector in place
  75818. * @returns this
  75819. */
  75820. negateInPlace(): Vector3;
  75821. /**
  75822. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75823. * @param result defines the Vector3 object where to store the result
  75824. * @returns the current Vector3
  75825. */
  75826. negateToRef(result: Vector3): Vector3;
  75827. /**
  75828. * Multiplies the Vector3 coordinates by the float "scale"
  75829. * @param scale defines the multiplier factor
  75830. * @returns the current updated Vector3
  75831. */
  75832. scaleInPlace(scale: number): Vector3;
  75833. /**
  75834. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75835. * @param scale defines the multiplier factor
  75836. * @returns a new Vector3
  75837. */
  75838. scale(scale: number): Vector3;
  75839. /**
  75840. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75841. * @param scale defines the multiplier factor
  75842. * @param result defines the Vector3 object where to store the result
  75843. * @returns the current Vector3
  75844. */
  75845. scaleToRef(scale: number, result: Vector3): Vector3;
  75846. /**
  75847. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75848. * @param scale defines the scale factor
  75849. * @param result defines the Vector3 object where to store the result
  75850. * @returns the unmodified current Vector3
  75851. */
  75852. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75853. /**
  75854. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75855. * @param otherVector defines the second operand
  75856. * @returns true if both vectors are equals
  75857. */
  75858. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75859. /**
  75860. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75861. * @param otherVector defines the second operand
  75862. * @param epsilon defines the minimal distance to define values as equals
  75863. * @returns true if both vectors are distant less than epsilon
  75864. */
  75865. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75866. /**
  75867. * Returns true if the current Vector3 coordinates equals the given floats
  75868. * @param x defines the x coordinate of the operand
  75869. * @param y defines the y coordinate of the operand
  75870. * @param z defines the z coordinate of the operand
  75871. * @returns true if both vectors are equals
  75872. */
  75873. equalsToFloats(x: number, y: number, z: number): boolean;
  75874. /**
  75875. * Multiplies the current Vector3 coordinates by the given ones
  75876. * @param otherVector defines the second operand
  75877. * @returns the current updated Vector3
  75878. */
  75879. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75880. /**
  75881. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75882. * @param otherVector defines the second operand
  75883. * @returns the new Vector3
  75884. */
  75885. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75886. /**
  75887. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75888. * @param otherVector defines the second operand
  75889. * @param result defines the Vector3 object where to store the result
  75890. * @returns the current Vector3
  75891. */
  75892. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75893. /**
  75894. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75895. * @param x defines the x coordinate of the operand
  75896. * @param y defines the y coordinate of the operand
  75897. * @param z defines the z coordinate of the operand
  75898. * @returns the new Vector3
  75899. */
  75900. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75901. /**
  75902. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75903. * @param otherVector defines the second operand
  75904. * @returns the new Vector3
  75905. */
  75906. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75907. /**
  75908. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75909. * @param otherVector defines the second operand
  75910. * @param result defines the Vector3 object where to store the result
  75911. * @returns the current Vector3
  75912. */
  75913. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75914. /**
  75915. * Divides the current Vector3 coordinates by the given ones.
  75916. * @param otherVector defines the second operand
  75917. * @returns the current updated Vector3
  75918. */
  75919. divideInPlace(otherVector: Vector3): Vector3;
  75920. /**
  75921. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75922. * @param other defines the second operand
  75923. * @returns the current updated Vector3
  75924. */
  75925. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75926. /**
  75927. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75928. * @param other defines the second operand
  75929. * @returns the current updated Vector3
  75930. */
  75931. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75932. /**
  75933. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75934. * @param x defines the x coordinate of the operand
  75935. * @param y defines the y coordinate of the operand
  75936. * @param z defines the z coordinate of the operand
  75937. * @returns the current updated Vector3
  75938. */
  75939. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75940. /**
  75941. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75942. * @param x defines the x coordinate of the operand
  75943. * @param y defines the y coordinate of the operand
  75944. * @param z defines the z coordinate of the operand
  75945. * @returns the current updated Vector3
  75946. */
  75947. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75948. /**
  75949. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75950. * Check if is non uniform within a certain amount of decimal places to account for this
  75951. * @param epsilon the amount the values can differ
  75952. * @returns if the the vector is non uniform to a certain number of decimal places
  75953. */
  75954. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75955. /**
  75956. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75957. */
  75958. get isNonUniform(): boolean;
  75959. /**
  75960. * Gets a new Vector3 from current Vector3 floored values
  75961. * @returns a new Vector3
  75962. */
  75963. floor(): Vector3;
  75964. /**
  75965. * Gets a new Vector3 from current Vector3 floored values
  75966. * @returns a new Vector3
  75967. */
  75968. fract(): Vector3;
  75969. /**
  75970. * Gets the length of the Vector3
  75971. * @returns the length of the Vector3
  75972. */
  75973. length(): number;
  75974. /**
  75975. * Gets the squared length of the Vector3
  75976. * @returns squared length of the Vector3
  75977. */
  75978. lengthSquared(): number;
  75979. /**
  75980. * Normalize the current Vector3.
  75981. * Please note that this is an in place operation.
  75982. * @returns the current updated Vector3
  75983. */
  75984. normalize(): Vector3;
  75985. /**
  75986. * Reorders the x y z properties of the vector in place
  75987. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75988. * @returns the current updated vector
  75989. */
  75990. reorderInPlace(order: string): this;
  75991. /**
  75992. * Rotates the vector around 0,0,0 by a quaternion
  75993. * @param quaternion the rotation quaternion
  75994. * @param result vector to store the result
  75995. * @returns the resulting vector
  75996. */
  75997. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75998. /**
  75999. * Rotates a vector around a given point
  76000. * @param quaternion the rotation quaternion
  76001. * @param point the point to rotate around
  76002. * @param result vector to store the result
  76003. * @returns the resulting vector
  76004. */
  76005. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76006. /**
  76007. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76008. * The cross product is then orthogonal to both current and "other"
  76009. * @param other defines the right operand
  76010. * @returns the cross product
  76011. */
  76012. cross(other: Vector3): Vector3;
  76013. /**
  76014. * Normalize the current Vector3 with the given input length.
  76015. * Please note that this is an in place operation.
  76016. * @param len the length of the vector
  76017. * @returns the current updated Vector3
  76018. */
  76019. normalizeFromLength(len: number): Vector3;
  76020. /**
  76021. * Normalize the current Vector3 to a new vector
  76022. * @returns the new Vector3
  76023. */
  76024. normalizeToNew(): Vector3;
  76025. /**
  76026. * Normalize the current Vector3 to the reference
  76027. * @param reference define the Vector3 to update
  76028. * @returns the updated Vector3
  76029. */
  76030. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76031. /**
  76032. * Creates a new Vector3 copied from the current Vector3
  76033. * @returns the new Vector3
  76034. */
  76035. clone(): Vector3;
  76036. /**
  76037. * Copies the given vector coordinates to the current Vector3 ones
  76038. * @param source defines the source Vector3
  76039. * @returns the current updated Vector3
  76040. */
  76041. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76042. /**
  76043. * Copies the given floats to the current Vector3 coordinates
  76044. * @param x defines the x coordinate of the operand
  76045. * @param y defines the y coordinate of the operand
  76046. * @param z defines the z coordinate of the operand
  76047. * @returns the current updated Vector3
  76048. */
  76049. copyFromFloats(x: number, y: number, z: number): Vector3;
  76050. /**
  76051. * Copies the given floats to the current Vector3 coordinates
  76052. * @param x defines the x coordinate of the operand
  76053. * @param y defines the y coordinate of the operand
  76054. * @param z defines the z coordinate of the operand
  76055. * @returns the current updated Vector3
  76056. */
  76057. set(x: number, y: number, z: number): Vector3;
  76058. /**
  76059. * Copies the given float to the current Vector3 coordinates
  76060. * @param v defines the x, y and z coordinates of the operand
  76061. * @returns the current updated Vector3
  76062. */
  76063. setAll(v: number): Vector3;
  76064. /**
  76065. * Get the clip factor between two vectors
  76066. * @param vector0 defines the first operand
  76067. * @param vector1 defines the second operand
  76068. * @param axis defines the axis to use
  76069. * @param size defines the size along the axis
  76070. * @returns the clip factor
  76071. */
  76072. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76073. /**
  76074. * Get angle between two vectors
  76075. * @param vector0 angle between vector0 and vector1
  76076. * @param vector1 angle between vector0 and vector1
  76077. * @param normal direction of the normal
  76078. * @return the angle between vector0 and vector1
  76079. */
  76080. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76081. /**
  76082. * Returns a new Vector3 set from the index "offset" of the given array
  76083. * @param array defines the source array
  76084. * @param offset defines the offset in the source array
  76085. * @returns the new Vector3
  76086. */
  76087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76088. /**
  76089. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76090. * @param array defines the source array
  76091. * @param offset defines the offset in the source array
  76092. * @returns the new Vector3
  76093. * @deprecated Please use FromArray instead.
  76094. */
  76095. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76096. /**
  76097. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76098. * @param array defines the source array
  76099. * @param offset defines the offset in the source array
  76100. * @param result defines the Vector3 where to store the result
  76101. */
  76102. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76103. /**
  76104. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76105. * @param array defines the source array
  76106. * @param offset defines the offset in the source array
  76107. * @param result defines the Vector3 where to store the result
  76108. * @deprecated Please use FromArrayToRef instead.
  76109. */
  76110. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76111. /**
  76112. * Sets the given vector "result" with the given floats.
  76113. * @param x defines the x coordinate of the source
  76114. * @param y defines the y coordinate of the source
  76115. * @param z defines the z coordinate of the source
  76116. * @param result defines the Vector3 where to store the result
  76117. */
  76118. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76119. /**
  76120. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76121. * @returns a new empty Vector3
  76122. */
  76123. static Zero(): Vector3;
  76124. /**
  76125. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76126. * @returns a new unit Vector3
  76127. */
  76128. static One(): Vector3;
  76129. /**
  76130. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76131. * @returns a new up Vector3
  76132. */
  76133. static Up(): Vector3;
  76134. /**
  76135. * Gets a up Vector3 that must not be updated
  76136. */
  76137. static get UpReadOnly(): DeepImmutable<Vector3>;
  76138. /**
  76139. * Gets a zero Vector3 that must not be updated
  76140. */
  76141. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76142. /**
  76143. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76144. * @returns a new down Vector3
  76145. */
  76146. static Down(): Vector3;
  76147. /**
  76148. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76149. * @returns a new forward Vector3
  76150. */
  76151. static Forward(): Vector3;
  76152. /**
  76153. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76154. * @returns a new forward Vector3
  76155. */
  76156. static Backward(): Vector3;
  76157. /**
  76158. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76159. * @returns a new right Vector3
  76160. */
  76161. static Right(): Vector3;
  76162. /**
  76163. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76164. * @returns a new left Vector3
  76165. */
  76166. static Left(): Vector3;
  76167. /**
  76168. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76169. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76170. * @param vector defines the Vector3 to transform
  76171. * @param transformation defines the transformation matrix
  76172. * @returns the transformed Vector3
  76173. */
  76174. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76175. /**
  76176. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76177. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76178. * @param vector defines the Vector3 to transform
  76179. * @param transformation defines the transformation matrix
  76180. * @param result defines the Vector3 where to store the result
  76181. */
  76182. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76183. /**
  76184. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76185. * This method computes tranformed coordinates only, not transformed direction vectors
  76186. * @param x define the x coordinate of the source vector
  76187. * @param y define the y coordinate of the source vector
  76188. * @param z define the z coordinate of the source vector
  76189. * @param transformation defines the transformation matrix
  76190. * @param result defines the Vector3 where to store the result
  76191. */
  76192. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76193. /**
  76194. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76195. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76196. * @param vector defines the Vector3 to transform
  76197. * @param transformation defines the transformation matrix
  76198. * @returns the new Vector3
  76199. */
  76200. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76201. /**
  76202. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76203. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76204. * @param vector defines the Vector3 to transform
  76205. * @param transformation defines the transformation matrix
  76206. * @param result defines the Vector3 where to store the result
  76207. */
  76208. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76209. /**
  76210. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76211. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76212. * @param x define the x coordinate of the source vector
  76213. * @param y define the y coordinate of the source vector
  76214. * @param z define the z coordinate of the source vector
  76215. * @param transformation defines the transformation matrix
  76216. * @param result defines the Vector3 where to store the result
  76217. */
  76218. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76219. /**
  76220. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76221. * @param value1 defines the first control point
  76222. * @param value2 defines the second control point
  76223. * @param value3 defines the third control point
  76224. * @param value4 defines the fourth control point
  76225. * @param amount defines the amount on the spline to use
  76226. * @returns the new Vector3
  76227. */
  76228. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76229. /**
  76230. * 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"
  76231. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76232. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76233. * @param value defines the current value
  76234. * @param min defines the lower range value
  76235. * @param max defines the upper range value
  76236. * @returns the new Vector3
  76237. */
  76238. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76239. /**
  76240. * 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"
  76241. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76242. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76243. * @param value defines the current value
  76244. * @param min defines the lower range value
  76245. * @param max defines the upper range value
  76246. * @param result defines the Vector3 where to store the result
  76247. */
  76248. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76249. /**
  76250. * Checks if a given vector is inside a specific range
  76251. * @param v defines the vector to test
  76252. * @param min defines the minimum range
  76253. * @param max defines the maximum range
  76254. */
  76255. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76256. /**
  76257. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76258. * @param value1 defines the first control point
  76259. * @param tangent1 defines the first tangent vector
  76260. * @param value2 defines the second control point
  76261. * @param tangent2 defines the second tangent vector
  76262. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76263. * @returns the new Vector3
  76264. */
  76265. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76266. /**
  76267. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76268. * @param start defines the start value
  76269. * @param end defines the end value
  76270. * @param amount max defines amount between both (between 0 and 1)
  76271. * @returns the new Vector3
  76272. */
  76273. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76274. /**
  76275. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76276. * @param start defines the start value
  76277. * @param end defines the end value
  76278. * @param amount max defines amount between both (between 0 and 1)
  76279. * @param result defines the Vector3 where to store the result
  76280. */
  76281. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76282. /**
  76283. * Returns the dot product (float) between the vectors "left" and "right"
  76284. * @param left defines the left operand
  76285. * @param right defines the right operand
  76286. * @returns the dot product
  76287. */
  76288. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76289. /**
  76290. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76291. * The cross product is then orthogonal to both "left" and "right"
  76292. * @param left defines the left operand
  76293. * @param right defines the right operand
  76294. * @returns the cross product
  76295. */
  76296. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76297. /**
  76298. * Sets the given vector "result" with the cross product of "left" and "right"
  76299. * The cross product is then orthogonal to both "left" and "right"
  76300. * @param left defines the left operand
  76301. * @param right defines the right operand
  76302. * @param result defines the Vector3 where to store the result
  76303. */
  76304. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76305. /**
  76306. * Returns a new Vector3 as the normalization of the given vector
  76307. * @param vector defines the Vector3 to normalize
  76308. * @returns the new Vector3
  76309. */
  76310. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76311. /**
  76312. * Sets the given vector "result" with the normalization of the given first vector
  76313. * @param vector defines the Vector3 to normalize
  76314. * @param result defines the Vector3 where to store the result
  76315. */
  76316. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76317. /**
  76318. * Project a Vector3 onto screen space
  76319. * @param vector defines the Vector3 to project
  76320. * @param world defines the world matrix to use
  76321. * @param transform defines the transform (view x projection) matrix to use
  76322. * @param viewport defines the screen viewport to use
  76323. * @returns the new Vector3
  76324. */
  76325. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76326. /** @hidden */
  76327. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76328. /**
  76329. * Unproject from screen space to object space
  76330. * @param source defines the screen space Vector3 to use
  76331. * @param viewportWidth defines the current width of the viewport
  76332. * @param viewportHeight defines the current height of the viewport
  76333. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76334. * @param transform defines the transform (view x projection) matrix to use
  76335. * @returns the new Vector3
  76336. */
  76337. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76338. /**
  76339. * Unproject from screen space to object space
  76340. * @param source defines the screen space Vector3 to use
  76341. * @param viewportWidth defines the current width of the viewport
  76342. * @param viewportHeight defines the current height of the viewport
  76343. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76344. * @param view defines the view matrix to use
  76345. * @param projection defines the projection matrix to use
  76346. * @returns the new Vector3
  76347. */
  76348. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76349. /**
  76350. * Unproject from screen space to object space
  76351. * @param source defines the screen space Vector3 to use
  76352. * @param viewportWidth defines the current width of the viewport
  76353. * @param viewportHeight defines the current height of the viewport
  76354. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76355. * @param view defines the view matrix to use
  76356. * @param projection defines the projection matrix to use
  76357. * @param result defines the Vector3 where to store the result
  76358. */
  76359. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76360. /**
  76361. * Unproject from screen space to object space
  76362. * @param sourceX defines the screen space x coordinate to use
  76363. * @param sourceY defines the screen space y coordinate to use
  76364. * @param sourceZ defines the screen space z coordinate to use
  76365. * @param viewportWidth defines the current width of the viewport
  76366. * @param viewportHeight defines the current height of the viewport
  76367. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76368. * @param view defines the view matrix to use
  76369. * @param projection defines the projection matrix to use
  76370. * @param result defines the Vector3 where to store the result
  76371. */
  76372. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76373. /**
  76374. * Gets the minimal coordinate values between two Vector3
  76375. * @param left defines the first operand
  76376. * @param right defines the second operand
  76377. * @returns the new Vector3
  76378. */
  76379. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76380. /**
  76381. * Gets the maximal coordinate values between two Vector3
  76382. * @param left defines the first operand
  76383. * @param right defines the second operand
  76384. * @returns the new Vector3
  76385. */
  76386. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76387. /**
  76388. * Returns the distance between the vectors "value1" and "value2"
  76389. * @param value1 defines the first operand
  76390. * @param value2 defines the second operand
  76391. * @returns the distance
  76392. */
  76393. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76394. /**
  76395. * Returns the squared distance between the vectors "value1" and "value2"
  76396. * @param value1 defines the first operand
  76397. * @param value2 defines the second operand
  76398. * @returns the squared distance
  76399. */
  76400. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76401. /**
  76402. * Returns a new Vector3 located at the center between "value1" and "value2"
  76403. * @param value1 defines the first operand
  76404. * @param value2 defines the second operand
  76405. * @returns the new Vector3
  76406. */
  76407. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76408. /**
  76409. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76410. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76411. * to something in order to rotate it from its local system to the given target system
  76412. * Note: axis1, axis2 and axis3 are normalized during this operation
  76413. * @param axis1 defines the first axis
  76414. * @param axis2 defines the second axis
  76415. * @param axis3 defines the third axis
  76416. * @returns a new Vector3
  76417. */
  76418. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76419. /**
  76420. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76421. * @param axis1 defines the first axis
  76422. * @param axis2 defines the second axis
  76423. * @param axis3 defines the third axis
  76424. * @param ref defines the Vector3 where to store the result
  76425. */
  76426. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76427. }
  76428. /**
  76429. * Vector4 class created for EulerAngle class conversion to Quaternion
  76430. */
  76431. export class Vector4 {
  76432. /** x value of the vector */
  76433. x: number;
  76434. /** y value of the vector */
  76435. y: number;
  76436. /** z value of the vector */
  76437. z: number;
  76438. /** w value of the vector */
  76439. w: number;
  76440. /**
  76441. * Creates a Vector4 object from the given floats.
  76442. * @param x x value of the vector
  76443. * @param y y value of the vector
  76444. * @param z z value of the vector
  76445. * @param w w value of the vector
  76446. */
  76447. constructor(
  76448. /** x value of the vector */
  76449. x: number,
  76450. /** y value of the vector */
  76451. y: number,
  76452. /** z value of the vector */
  76453. z: number,
  76454. /** w value of the vector */
  76455. w: number);
  76456. /**
  76457. * Returns the string with the Vector4 coordinates.
  76458. * @returns a string containing all the vector values
  76459. */
  76460. toString(): string;
  76461. /**
  76462. * Returns the string "Vector4".
  76463. * @returns "Vector4"
  76464. */
  76465. getClassName(): string;
  76466. /**
  76467. * Returns the Vector4 hash code.
  76468. * @returns a unique hash code
  76469. */
  76470. getHashCode(): number;
  76471. /**
  76472. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76473. * @returns the resulting array
  76474. */
  76475. asArray(): number[];
  76476. /**
  76477. * Populates the given array from the given index with the Vector4 coordinates.
  76478. * @param array array to populate
  76479. * @param index index of the array to start at (default: 0)
  76480. * @returns the Vector4.
  76481. */
  76482. toArray(array: FloatArray, index?: number): Vector4;
  76483. /**
  76484. * Adds the given vector to the current Vector4.
  76485. * @param otherVector the vector to add
  76486. * @returns the updated Vector4.
  76487. */
  76488. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76489. /**
  76490. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76491. * @param otherVector the vector to add
  76492. * @returns the resulting vector
  76493. */
  76494. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76495. /**
  76496. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76497. * @param otherVector the vector to add
  76498. * @param result the vector to store the result
  76499. * @returns the current Vector4.
  76500. */
  76501. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76502. /**
  76503. * Subtract in place the given vector from the current Vector4.
  76504. * @param otherVector the vector to subtract
  76505. * @returns the updated Vector4.
  76506. */
  76507. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76508. /**
  76509. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76510. * @param otherVector the vector to add
  76511. * @returns the new vector with the result
  76512. */
  76513. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76514. /**
  76515. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76516. * @param otherVector the vector to subtract
  76517. * @param result the vector to store the result
  76518. * @returns the current Vector4.
  76519. */
  76520. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76521. /**
  76522. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76523. */
  76524. /**
  76525. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76526. * @param x value to subtract
  76527. * @param y value to subtract
  76528. * @param z value to subtract
  76529. * @param w value to subtract
  76530. * @returns new vector containing the result
  76531. */
  76532. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76533. /**
  76534. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76535. * @param x value to subtract
  76536. * @param y value to subtract
  76537. * @param z value to subtract
  76538. * @param w value to subtract
  76539. * @param result the vector to store the result in
  76540. * @returns the current Vector4.
  76541. */
  76542. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76543. /**
  76544. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76545. * @returns a new vector with the negated values
  76546. */
  76547. negate(): Vector4;
  76548. /**
  76549. * Negate this vector in place
  76550. * @returns this
  76551. */
  76552. negateInPlace(): Vector4;
  76553. /**
  76554. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76555. * @param result defines the Vector3 object where to store the result
  76556. * @returns the current Vector4
  76557. */
  76558. negateToRef(result: Vector4): Vector4;
  76559. /**
  76560. * Multiplies the current Vector4 coordinates by scale (float).
  76561. * @param scale the number to scale with
  76562. * @returns the updated Vector4.
  76563. */
  76564. scaleInPlace(scale: number): Vector4;
  76565. /**
  76566. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76567. * @param scale the number to scale with
  76568. * @returns a new vector with the result
  76569. */
  76570. scale(scale: number): Vector4;
  76571. /**
  76572. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76573. * @param scale the number to scale with
  76574. * @param result a vector to store the result in
  76575. * @returns the current Vector4.
  76576. */
  76577. scaleToRef(scale: number, result: Vector4): Vector4;
  76578. /**
  76579. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76580. * @param scale defines the scale factor
  76581. * @param result defines the Vector4 object where to store the result
  76582. * @returns the unmodified current Vector4
  76583. */
  76584. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76585. /**
  76586. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76587. * @param otherVector the vector to compare against
  76588. * @returns true if they are equal
  76589. */
  76590. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76591. /**
  76592. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76593. * @param otherVector vector to compare against
  76594. * @param epsilon (Default: very small number)
  76595. * @returns true if they are equal
  76596. */
  76597. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76598. /**
  76599. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76600. * @param x x value to compare against
  76601. * @param y y value to compare against
  76602. * @param z z value to compare against
  76603. * @param w w value to compare against
  76604. * @returns true if equal
  76605. */
  76606. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76607. /**
  76608. * Multiplies in place the current Vector4 by the given one.
  76609. * @param otherVector vector to multiple with
  76610. * @returns the updated Vector4.
  76611. */
  76612. multiplyInPlace(otherVector: Vector4): Vector4;
  76613. /**
  76614. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76615. * @param otherVector vector to multiple with
  76616. * @returns resulting new vector
  76617. */
  76618. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76619. /**
  76620. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76621. * @param otherVector vector to multiple with
  76622. * @param result vector to store the result
  76623. * @returns the current Vector4.
  76624. */
  76625. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76626. /**
  76627. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76628. * @param x x value multiply with
  76629. * @param y y value multiply with
  76630. * @param z z value multiply with
  76631. * @param w w value multiply with
  76632. * @returns resulting new vector
  76633. */
  76634. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76635. /**
  76636. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76637. * @param otherVector vector to devide with
  76638. * @returns resulting new vector
  76639. */
  76640. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76641. /**
  76642. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76643. * @param otherVector vector to devide with
  76644. * @param result vector to store the result
  76645. * @returns the current Vector4.
  76646. */
  76647. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76648. /**
  76649. * Divides the current Vector3 coordinates by the given ones.
  76650. * @param otherVector vector to devide with
  76651. * @returns the updated Vector3.
  76652. */
  76653. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76654. /**
  76655. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76656. * @param other defines the second operand
  76657. * @returns the current updated Vector4
  76658. */
  76659. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76660. /**
  76661. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76662. * @param other defines the second operand
  76663. * @returns the current updated Vector4
  76664. */
  76665. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76666. /**
  76667. * Gets a new Vector4 from current Vector4 floored values
  76668. * @returns a new Vector4
  76669. */
  76670. floor(): Vector4;
  76671. /**
  76672. * Gets a new Vector4 from current Vector3 floored values
  76673. * @returns a new Vector4
  76674. */
  76675. fract(): Vector4;
  76676. /**
  76677. * Returns the Vector4 length (float).
  76678. * @returns the length
  76679. */
  76680. length(): number;
  76681. /**
  76682. * Returns the Vector4 squared length (float).
  76683. * @returns the length squared
  76684. */
  76685. lengthSquared(): number;
  76686. /**
  76687. * Normalizes in place the Vector4.
  76688. * @returns the updated Vector4.
  76689. */
  76690. normalize(): Vector4;
  76691. /**
  76692. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76693. * @returns this converted to a new vector3
  76694. */
  76695. toVector3(): Vector3;
  76696. /**
  76697. * Returns a new Vector4 copied from the current one.
  76698. * @returns the new cloned vector
  76699. */
  76700. clone(): Vector4;
  76701. /**
  76702. * Updates the current Vector4 with the given one coordinates.
  76703. * @param source the source vector to copy from
  76704. * @returns the updated Vector4.
  76705. */
  76706. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76707. /**
  76708. * Updates the current Vector4 coordinates with the given floats.
  76709. * @param x float to copy from
  76710. * @param y float to copy from
  76711. * @param z float to copy from
  76712. * @param w float to copy from
  76713. * @returns the updated Vector4.
  76714. */
  76715. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76716. /**
  76717. * Updates the current Vector4 coordinates with the given floats.
  76718. * @param x float to set from
  76719. * @param y float to set from
  76720. * @param z float to set from
  76721. * @param w float to set from
  76722. * @returns the updated Vector4.
  76723. */
  76724. set(x: number, y: number, z: number, w: number): Vector4;
  76725. /**
  76726. * Copies the given float to the current Vector3 coordinates
  76727. * @param v defines the x, y, z and w coordinates of the operand
  76728. * @returns the current updated Vector3
  76729. */
  76730. setAll(v: number): Vector4;
  76731. /**
  76732. * Returns a new Vector4 set from the starting index of the given array.
  76733. * @param array the array to pull values from
  76734. * @param offset the offset into the array to start at
  76735. * @returns the new vector
  76736. */
  76737. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76738. /**
  76739. * Updates the given vector "result" from the starting index of the given array.
  76740. * @param array the array to pull values from
  76741. * @param offset the offset into the array to start at
  76742. * @param result the vector to store the result in
  76743. */
  76744. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76745. /**
  76746. * Updates the given vector "result" from the starting index of the given Float32Array.
  76747. * @param array the array to pull values from
  76748. * @param offset the offset into the array to start at
  76749. * @param result the vector to store the result in
  76750. */
  76751. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76752. /**
  76753. * Updates the given vector "result" coordinates from the given floats.
  76754. * @param x float to set from
  76755. * @param y float to set from
  76756. * @param z float to set from
  76757. * @param w float to set from
  76758. * @param result the vector to the floats in
  76759. */
  76760. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76761. /**
  76762. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76763. * @returns the new vector
  76764. */
  76765. static Zero(): Vector4;
  76766. /**
  76767. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76768. * @returns the new vector
  76769. */
  76770. static One(): Vector4;
  76771. /**
  76772. * Returns a new normalized Vector4 from the given one.
  76773. * @param vector the vector to normalize
  76774. * @returns the vector
  76775. */
  76776. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76777. /**
  76778. * Updates the given vector "result" from the normalization of the given one.
  76779. * @param vector the vector to normalize
  76780. * @param result the vector to store the result in
  76781. */
  76782. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76783. /**
  76784. * Returns a vector with the minimum values from the left and right vectors
  76785. * @param left left vector to minimize
  76786. * @param right right vector to minimize
  76787. * @returns a new vector with the minimum of the left and right vector values
  76788. */
  76789. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76790. /**
  76791. * Returns a vector with the maximum values from the left and right vectors
  76792. * @param left left vector to maximize
  76793. * @param right right vector to maximize
  76794. * @returns a new vector with the maximum of the left and right vector values
  76795. */
  76796. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76797. /**
  76798. * Returns the distance (float) between the vectors "value1" and "value2".
  76799. * @param value1 value to calulate the distance between
  76800. * @param value2 value to calulate the distance between
  76801. * @return the distance between the two vectors
  76802. */
  76803. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76804. /**
  76805. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76806. * @param value1 value to calulate the distance between
  76807. * @param value2 value to calulate the distance between
  76808. * @return the distance between the two vectors squared
  76809. */
  76810. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76811. /**
  76812. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76813. * @param value1 value to calulate the center between
  76814. * @param value2 value to calulate the center between
  76815. * @return the center between the two vectors
  76816. */
  76817. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76818. /**
  76819. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76820. * This methods computes transformed normalized direction vectors only.
  76821. * @param vector the vector to transform
  76822. * @param transformation the transformation matrix to apply
  76823. * @returns the new vector
  76824. */
  76825. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76826. /**
  76827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76828. * This methods computes transformed normalized direction vectors only.
  76829. * @param vector the vector to transform
  76830. * @param transformation the transformation matrix to apply
  76831. * @param result the vector to store the result in
  76832. */
  76833. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76834. /**
  76835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76836. * This methods computes transformed normalized direction vectors only.
  76837. * @param x value to transform
  76838. * @param y value to transform
  76839. * @param z value to transform
  76840. * @param w value to transform
  76841. * @param transformation the transformation matrix to apply
  76842. * @param result the vector to store the results in
  76843. */
  76844. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76845. /**
  76846. * Creates a new Vector4 from a Vector3
  76847. * @param source defines the source data
  76848. * @param w defines the 4th component (default is 0)
  76849. * @returns a new Vector4
  76850. */
  76851. static FromVector3(source: Vector3, w?: number): Vector4;
  76852. }
  76853. /**
  76854. * Class used to store quaternion data
  76855. * @see https://en.wikipedia.org/wiki/Quaternion
  76856. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76857. */
  76858. export class Quaternion {
  76859. /** defines the first component (0 by default) */
  76860. x: number;
  76861. /** defines the second component (0 by default) */
  76862. y: number;
  76863. /** defines the third component (0 by default) */
  76864. z: number;
  76865. /** defines the fourth component (1.0 by default) */
  76866. w: number;
  76867. /**
  76868. * Creates a new Quaternion from the given floats
  76869. * @param x defines the first component (0 by default)
  76870. * @param y defines the second component (0 by default)
  76871. * @param z defines the third component (0 by default)
  76872. * @param w defines the fourth component (1.0 by default)
  76873. */
  76874. constructor(
  76875. /** defines the first component (0 by default) */
  76876. x?: number,
  76877. /** defines the second component (0 by default) */
  76878. y?: number,
  76879. /** defines the third component (0 by default) */
  76880. z?: number,
  76881. /** defines the fourth component (1.0 by default) */
  76882. w?: number);
  76883. /**
  76884. * Gets a string representation for the current quaternion
  76885. * @returns a string with the Quaternion coordinates
  76886. */
  76887. toString(): string;
  76888. /**
  76889. * Gets the class name of the quaternion
  76890. * @returns the string "Quaternion"
  76891. */
  76892. getClassName(): string;
  76893. /**
  76894. * Gets a hash code for this quaternion
  76895. * @returns the quaternion hash code
  76896. */
  76897. getHashCode(): number;
  76898. /**
  76899. * Copy the quaternion to an array
  76900. * @returns a new array populated with 4 elements from the quaternion coordinates
  76901. */
  76902. asArray(): number[];
  76903. /**
  76904. * Check if two quaternions are equals
  76905. * @param otherQuaternion defines the second operand
  76906. * @return true if the current quaternion and the given one coordinates are strictly equals
  76907. */
  76908. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76909. /**
  76910. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76911. * @param otherQuaternion defines the other quaternion
  76912. * @param epsilon defines the minimal distance to consider equality
  76913. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76914. */
  76915. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76916. /**
  76917. * Clone the current quaternion
  76918. * @returns a new quaternion copied from the current one
  76919. */
  76920. clone(): Quaternion;
  76921. /**
  76922. * Copy a quaternion to the current one
  76923. * @param other defines the other quaternion
  76924. * @returns the updated current quaternion
  76925. */
  76926. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76927. /**
  76928. * Updates the current quaternion with the given float coordinates
  76929. * @param x defines the x coordinate
  76930. * @param y defines the y coordinate
  76931. * @param z defines the z coordinate
  76932. * @param w defines the w coordinate
  76933. * @returns the updated current quaternion
  76934. */
  76935. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76936. /**
  76937. * Updates the current quaternion from the given float coordinates
  76938. * @param x defines the x coordinate
  76939. * @param y defines the y coordinate
  76940. * @param z defines the z coordinate
  76941. * @param w defines the w coordinate
  76942. * @returns the updated current quaternion
  76943. */
  76944. set(x: number, y: number, z: number, w: number): Quaternion;
  76945. /**
  76946. * Adds two quaternions
  76947. * @param other defines the second operand
  76948. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76949. */
  76950. add(other: DeepImmutable<Quaternion>): Quaternion;
  76951. /**
  76952. * Add a quaternion to the current one
  76953. * @param other defines the quaternion to add
  76954. * @returns the current quaternion
  76955. */
  76956. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76957. /**
  76958. * Subtract two quaternions
  76959. * @param other defines the second operand
  76960. * @returns a new quaternion as the subtraction result of the given one from the current one
  76961. */
  76962. subtract(other: Quaternion): Quaternion;
  76963. /**
  76964. * Multiplies the current quaternion by a scale factor
  76965. * @param value defines the scale factor
  76966. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76967. */
  76968. scale(value: number): Quaternion;
  76969. /**
  76970. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76971. * @param scale defines the scale factor
  76972. * @param result defines the Quaternion object where to store the result
  76973. * @returns the unmodified current quaternion
  76974. */
  76975. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76976. /**
  76977. * Multiplies in place the current quaternion by a scale factor
  76978. * @param value defines the scale factor
  76979. * @returns the current modified quaternion
  76980. */
  76981. scaleInPlace(value: number): Quaternion;
  76982. /**
  76983. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76984. * @param scale defines the scale factor
  76985. * @param result defines the Quaternion object where to store the result
  76986. * @returns the unmodified current quaternion
  76987. */
  76988. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76989. /**
  76990. * Multiplies two quaternions
  76991. * @param q1 defines the second operand
  76992. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76993. */
  76994. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76995. /**
  76996. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76997. * @param q1 defines the second operand
  76998. * @param result defines the target quaternion
  76999. * @returns the current quaternion
  77000. */
  77001. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77002. /**
  77003. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77004. * @param q1 defines the second operand
  77005. * @returns the currentupdated quaternion
  77006. */
  77007. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77008. /**
  77009. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77010. * @param ref defines the target quaternion
  77011. * @returns the current quaternion
  77012. */
  77013. conjugateToRef(ref: Quaternion): Quaternion;
  77014. /**
  77015. * Conjugates in place (1-q) the current quaternion
  77016. * @returns the current updated quaternion
  77017. */
  77018. conjugateInPlace(): Quaternion;
  77019. /**
  77020. * Conjugates in place (1-q) the current quaternion
  77021. * @returns a new quaternion
  77022. */
  77023. conjugate(): Quaternion;
  77024. /**
  77025. * Gets length of current quaternion
  77026. * @returns the quaternion length (float)
  77027. */
  77028. length(): number;
  77029. /**
  77030. * Normalize in place the current quaternion
  77031. * @returns the current updated quaternion
  77032. */
  77033. normalize(): Quaternion;
  77034. /**
  77035. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77036. * @param order is a reserved parameter and is ignore for now
  77037. * @returns a new Vector3 containing the Euler angles
  77038. */
  77039. toEulerAngles(order?: string): Vector3;
  77040. /**
  77041. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77042. * @param result defines the vector which will be filled with the Euler angles
  77043. * @param order is a reserved parameter and is ignore for now
  77044. * @returns the current unchanged quaternion
  77045. */
  77046. toEulerAnglesToRef(result: Vector3): Quaternion;
  77047. /**
  77048. * Updates the given rotation matrix with the current quaternion values
  77049. * @param result defines the target matrix
  77050. * @returns the current unchanged quaternion
  77051. */
  77052. toRotationMatrix(result: Matrix): Quaternion;
  77053. /**
  77054. * Updates the current quaternion from the given rotation matrix values
  77055. * @param matrix defines the source matrix
  77056. * @returns the current updated quaternion
  77057. */
  77058. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77059. /**
  77060. * Creates a new quaternion from a rotation matrix
  77061. * @param matrix defines the source matrix
  77062. * @returns a new quaternion created from the given rotation matrix values
  77063. */
  77064. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77065. /**
  77066. * Updates the given quaternion with the given rotation matrix values
  77067. * @param matrix defines the source matrix
  77068. * @param result defines the target quaternion
  77069. */
  77070. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77071. /**
  77072. * Returns the dot product (float) between the quaternions "left" and "right"
  77073. * @param left defines the left operand
  77074. * @param right defines the right operand
  77075. * @returns the dot product
  77076. */
  77077. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77078. /**
  77079. * Checks if the two quaternions are close to each other
  77080. * @param quat0 defines the first quaternion to check
  77081. * @param quat1 defines the second quaternion to check
  77082. * @returns true if the two quaternions are close to each other
  77083. */
  77084. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77085. /**
  77086. * Creates an empty quaternion
  77087. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77088. */
  77089. static Zero(): Quaternion;
  77090. /**
  77091. * Inverse a given quaternion
  77092. * @param q defines the source quaternion
  77093. * @returns a new quaternion as the inverted current quaternion
  77094. */
  77095. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77096. /**
  77097. * Inverse a given quaternion
  77098. * @param q defines the source quaternion
  77099. * @param result the quaternion the result will be stored in
  77100. * @returns the result quaternion
  77101. */
  77102. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77103. /**
  77104. * Creates an identity quaternion
  77105. * @returns the identity quaternion
  77106. */
  77107. static Identity(): Quaternion;
  77108. /**
  77109. * Gets a boolean indicating if the given quaternion is identity
  77110. * @param quaternion defines the quaternion to check
  77111. * @returns true if the quaternion is identity
  77112. */
  77113. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77114. /**
  77115. * Creates a quaternion from a rotation around an axis
  77116. * @param axis defines the axis to use
  77117. * @param angle defines the angle to use
  77118. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77119. */
  77120. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77121. /**
  77122. * Creates a rotation around an axis and stores it into the given quaternion
  77123. * @param axis defines the axis to use
  77124. * @param angle defines the angle to use
  77125. * @param result defines the target quaternion
  77126. * @returns the target quaternion
  77127. */
  77128. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77129. /**
  77130. * Creates a new quaternion from data stored into an array
  77131. * @param array defines the data source
  77132. * @param offset defines the offset in the source array where the data starts
  77133. * @returns a new quaternion
  77134. */
  77135. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77136. /**
  77137. * Create a quaternion from Euler rotation angles
  77138. * @param x Pitch
  77139. * @param y Yaw
  77140. * @param z Roll
  77141. * @returns the new Quaternion
  77142. */
  77143. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77144. /**
  77145. * Updates a quaternion from Euler rotation angles
  77146. * @param x Pitch
  77147. * @param y Yaw
  77148. * @param z Roll
  77149. * @param result the quaternion to store the result
  77150. * @returns the updated quaternion
  77151. */
  77152. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77153. /**
  77154. * Create a quaternion from Euler rotation vector
  77155. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77156. * @returns the new Quaternion
  77157. */
  77158. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77159. /**
  77160. * Updates a quaternion from Euler rotation vector
  77161. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77162. * @param result the quaternion to store the result
  77163. * @returns the updated quaternion
  77164. */
  77165. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77166. /**
  77167. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77168. * @param yaw defines the rotation around Y axis
  77169. * @param pitch defines the rotation around X axis
  77170. * @param roll defines the rotation around Z axis
  77171. * @returns the new quaternion
  77172. */
  77173. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77174. /**
  77175. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77176. * @param yaw defines the rotation around Y axis
  77177. * @param pitch defines the rotation around X axis
  77178. * @param roll defines the rotation around Z axis
  77179. * @param result defines the target quaternion
  77180. */
  77181. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77182. /**
  77183. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77184. * @param alpha defines the rotation around first axis
  77185. * @param beta defines the rotation around second axis
  77186. * @param gamma defines the rotation around third axis
  77187. * @returns the new quaternion
  77188. */
  77189. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77190. /**
  77191. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77192. * @param alpha defines the rotation around first axis
  77193. * @param beta defines the rotation around second axis
  77194. * @param gamma defines the rotation around third axis
  77195. * @param result defines the target quaternion
  77196. */
  77197. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77198. /**
  77199. * 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)
  77200. * @param axis1 defines the first axis
  77201. * @param axis2 defines the second axis
  77202. * @param axis3 defines the third axis
  77203. * @returns the new quaternion
  77204. */
  77205. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77206. /**
  77207. * 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
  77208. * @param axis1 defines the first axis
  77209. * @param axis2 defines the second axis
  77210. * @param axis3 defines the third axis
  77211. * @param ref defines the target quaternion
  77212. */
  77213. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77214. /**
  77215. * Interpolates between two quaternions
  77216. * @param left defines first quaternion
  77217. * @param right defines second quaternion
  77218. * @param amount defines the gradient to use
  77219. * @returns the new interpolated quaternion
  77220. */
  77221. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77222. /**
  77223. * Interpolates between two quaternions and stores it into a target quaternion
  77224. * @param left defines first quaternion
  77225. * @param right defines second quaternion
  77226. * @param amount defines the gradient to use
  77227. * @param result defines the target quaternion
  77228. */
  77229. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77230. /**
  77231. * Interpolate between two quaternions using Hermite interpolation
  77232. * @param value1 defines first quaternion
  77233. * @param tangent1 defines the incoming tangent
  77234. * @param value2 defines second quaternion
  77235. * @param tangent2 defines the outgoing tangent
  77236. * @param amount defines the target quaternion
  77237. * @returns the new interpolated quaternion
  77238. */
  77239. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77240. }
  77241. /**
  77242. * Class used to store matrix data (4x4)
  77243. */
  77244. export class Matrix {
  77245. private static _updateFlagSeed;
  77246. private static _identityReadOnly;
  77247. private _isIdentity;
  77248. private _isIdentityDirty;
  77249. private _isIdentity3x2;
  77250. private _isIdentity3x2Dirty;
  77251. /**
  77252. * Gets the update flag of the matrix which is an unique number for the matrix.
  77253. * It will be incremented every time the matrix data change.
  77254. * You can use it to speed the comparison between two versions of the same matrix.
  77255. */
  77256. updateFlag: number;
  77257. private readonly _m;
  77258. /**
  77259. * Gets the internal data of the matrix
  77260. */
  77261. get m(): DeepImmutable<Float32Array>;
  77262. /** @hidden */
  77263. _markAsUpdated(): void;
  77264. /** @hidden */
  77265. private _updateIdentityStatus;
  77266. /**
  77267. * Creates an empty matrix (filled with zeros)
  77268. */
  77269. constructor();
  77270. /**
  77271. * Check if the current matrix is identity
  77272. * @returns true is the matrix is the identity matrix
  77273. */
  77274. isIdentity(): boolean;
  77275. /**
  77276. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77277. * @returns true is the matrix is the identity matrix
  77278. */
  77279. isIdentityAs3x2(): boolean;
  77280. /**
  77281. * Gets the determinant of the matrix
  77282. * @returns the matrix determinant
  77283. */
  77284. determinant(): number;
  77285. /**
  77286. * Returns the matrix as a Float32Array
  77287. * @returns the matrix underlying array
  77288. */
  77289. toArray(): DeepImmutable<Float32Array>;
  77290. /**
  77291. * Returns the matrix as a Float32Array
  77292. * @returns the matrix underlying array.
  77293. */
  77294. asArray(): DeepImmutable<Float32Array>;
  77295. /**
  77296. * Inverts the current matrix in place
  77297. * @returns the current inverted matrix
  77298. */
  77299. invert(): Matrix;
  77300. /**
  77301. * Sets all the matrix elements to zero
  77302. * @returns the current matrix
  77303. */
  77304. reset(): Matrix;
  77305. /**
  77306. * Adds the current matrix with a second one
  77307. * @param other defines the matrix to add
  77308. * @returns a new matrix as the addition of the current matrix and the given one
  77309. */
  77310. add(other: DeepImmutable<Matrix>): Matrix;
  77311. /**
  77312. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77313. * @param other defines the matrix to add
  77314. * @param result defines the target matrix
  77315. * @returns the current matrix
  77316. */
  77317. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77318. /**
  77319. * Adds in place the given matrix to the current matrix
  77320. * @param other defines the second operand
  77321. * @returns the current updated matrix
  77322. */
  77323. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77324. /**
  77325. * Sets the given matrix to the current inverted Matrix
  77326. * @param other defines the target matrix
  77327. * @returns the unmodified current matrix
  77328. */
  77329. invertToRef(other: Matrix): Matrix;
  77330. /**
  77331. * add a value at the specified position in the current Matrix
  77332. * @param index the index of the value within the matrix. between 0 and 15.
  77333. * @param value the value to be added
  77334. * @returns the current updated matrix
  77335. */
  77336. addAtIndex(index: number, value: number): Matrix;
  77337. /**
  77338. * mutiply the specified position in the current Matrix by a value
  77339. * @param index the index of the value within the matrix. between 0 and 15.
  77340. * @param value the value to be added
  77341. * @returns the current updated matrix
  77342. */
  77343. multiplyAtIndex(index: number, value: number): Matrix;
  77344. /**
  77345. * Inserts the translation vector (using 3 floats) in the current matrix
  77346. * @param x defines the 1st component of the translation
  77347. * @param y defines the 2nd component of the translation
  77348. * @param z defines the 3rd component of the translation
  77349. * @returns the current updated matrix
  77350. */
  77351. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77352. /**
  77353. * Adds the translation vector (using 3 floats) in the current matrix
  77354. * @param x defines the 1st component of the translation
  77355. * @param y defines the 2nd component of the translation
  77356. * @param z defines the 3rd component of the translation
  77357. * @returns the current updated matrix
  77358. */
  77359. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77360. /**
  77361. * Inserts the translation vector in the current matrix
  77362. * @param vector3 defines the translation to insert
  77363. * @returns the current updated matrix
  77364. */
  77365. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77366. /**
  77367. * Gets the translation value of the current matrix
  77368. * @returns a new Vector3 as the extracted translation from the matrix
  77369. */
  77370. getTranslation(): Vector3;
  77371. /**
  77372. * Fill a Vector3 with the extracted translation from the matrix
  77373. * @param result defines the Vector3 where to store the translation
  77374. * @returns the current matrix
  77375. */
  77376. getTranslationToRef(result: Vector3): Matrix;
  77377. /**
  77378. * Remove rotation and scaling part from the matrix
  77379. * @returns the updated matrix
  77380. */
  77381. removeRotationAndScaling(): Matrix;
  77382. /**
  77383. * Multiply two matrices
  77384. * @param other defines the second operand
  77385. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77386. */
  77387. multiply(other: DeepImmutable<Matrix>): Matrix;
  77388. /**
  77389. * Copy the current matrix from the given one
  77390. * @param other defines the source matrix
  77391. * @returns the current updated matrix
  77392. */
  77393. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77394. /**
  77395. * Populates the given array from the starting index with the current matrix values
  77396. * @param array defines the target array
  77397. * @param offset defines the offset in the target array where to start storing values
  77398. * @returns the current matrix
  77399. */
  77400. copyToArray(array: Float32Array, offset?: number): Matrix;
  77401. /**
  77402. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77403. * @param other defines the second operand
  77404. * @param result defines the matrix where to store the multiplication
  77405. * @returns the current matrix
  77406. */
  77407. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77408. /**
  77409. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77410. * @param other defines the second operand
  77411. * @param result defines the array where to store the multiplication
  77412. * @param offset defines the offset in the target array where to start storing values
  77413. * @returns the current matrix
  77414. */
  77415. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77416. /**
  77417. * Check equality between this matrix and a second one
  77418. * @param value defines the second matrix to compare
  77419. * @returns true is the current matrix and the given one values are strictly equal
  77420. */
  77421. equals(value: DeepImmutable<Matrix>): boolean;
  77422. /**
  77423. * Clone the current matrix
  77424. * @returns a new matrix from the current matrix
  77425. */
  77426. clone(): Matrix;
  77427. /**
  77428. * Returns the name of the current matrix class
  77429. * @returns the string "Matrix"
  77430. */
  77431. getClassName(): string;
  77432. /**
  77433. * Gets the hash code of the current matrix
  77434. * @returns the hash code
  77435. */
  77436. getHashCode(): number;
  77437. /**
  77438. * Decomposes the current Matrix into a translation, rotation and scaling components
  77439. * @param scale defines the scale vector3 given as a reference to update
  77440. * @param rotation defines the rotation quaternion given as a reference to update
  77441. * @param translation defines the translation vector3 given as a reference to update
  77442. * @returns true if operation was successful
  77443. */
  77444. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77445. /**
  77446. * Gets specific row of the matrix
  77447. * @param index defines the number of the row to get
  77448. * @returns the index-th row of the current matrix as a new Vector4
  77449. */
  77450. getRow(index: number): Nullable<Vector4>;
  77451. /**
  77452. * Sets the index-th row of the current matrix to the vector4 values
  77453. * @param index defines the number of the row to set
  77454. * @param row defines the target vector4
  77455. * @returns the updated current matrix
  77456. */
  77457. setRow(index: number, row: Vector4): Matrix;
  77458. /**
  77459. * Compute the transpose of the matrix
  77460. * @returns the new transposed matrix
  77461. */
  77462. transpose(): Matrix;
  77463. /**
  77464. * Compute the transpose of the matrix and store it in a given matrix
  77465. * @param result defines the target matrix
  77466. * @returns the current matrix
  77467. */
  77468. transposeToRef(result: Matrix): Matrix;
  77469. /**
  77470. * Sets the index-th row of the current matrix with the given 4 x float values
  77471. * @param index defines the row index
  77472. * @param x defines the x component to set
  77473. * @param y defines the y component to set
  77474. * @param z defines the z component to set
  77475. * @param w defines the w component to set
  77476. * @returns the updated current matrix
  77477. */
  77478. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77479. /**
  77480. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77481. * @param scale defines the scale factor
  77482. * @returns a new matrix
  77483. */
  77484. scale(scale: number): Matrix;
  77485. /**
  77486. * Scale the current matrix values by a factor to a given result matrix
  77487. * @param scale defines the scale factor
  77488. * @param result defines the matrix to store the result
  77489. * @returns the current matrix
  77490. */
  77491. scaleToRef(scale: number, result: Matrix): Matrix;
  77492. /**
  77493. * Scale the current matrix values by a factor and add the result to a given matrix
  77494. * @param scale defines the scale factor
  77495. * @param result defines the Matrix to store the result
  77496. * @returns the current matrix
  77497. */
  77498. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77499. /**
  77500. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77501. * @param ref matrix to store the result
  77502. */
  77503. toNormalMatrix(ref: Matrix): void;
  77504. /**
  77505. * Gets only rotation part of the current matrix
  77506. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77507. */
  77508. getRotationMatrix(): Matrix;
  77509. /**
  77510. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77511. * @param result defines the target matrix to store data to
  77512. * @returns the current matrix
  77513. */
  77514. getRotationMatrixToRef(result: Matrix): Matrix;
  77515. /**
  77516. * Toggles model matrix from being right handed to left handed in place and vice versa
  77517. */
  77518. toggleModelMatrixHandInPlace(): void;
  77519. /**
  77520. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77521. */
  77522. toggleProjectionMatrixHandInPlace(): void;
  77523. /**
  77524. * Creates a matrix from an array
  77525. * @param array defines the source array
  77526. * @param offset defines an offset in the source array
  77527. * @returns a new Matrix set from the starting index of the given array
  77528. */
  77529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77530. /**
  77531. * Copy the content of an array into a given matrix
  77532. * @param array defines the source array
  77533. * @param offset defines an offset in the source array
  77534. * @param result defines the target matrix
  77535. */
  77536. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77537. /**
  77538. * Stores an array into a matrix after having multiplied each component by a given factor
  77539. * @param array defines the source array
  77540. * @param offset defines the offset in the source array
  77541. * @param scale defines the scaling factor
  77542. * @param result defines the target matrix
  77543. */
  77544. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77545. /**
  77546. * Gets an identity matrix that must not be updated
  77547. */
  77548. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77549. /**
  77550. * Stores a list of values (16) inside a given matrix
  77551. * @param initialM11 defines 1st value of 1st row
  77552. * @param initialM12 defines 2nd value of 1st row
  77553. * @param initialM13 defines 3rd value of 1st row
  77554. * @param initialM14 defines 4th value of 1st row
  77555. * @param initialM21 defines 1st value of 2nd row
  77556. * @param initialM22 defines 2nd value of 2nd row
  77557. * @param initialM23 defines 3rd value of 2nd row
  77558. * @param initialM24 defines 4th value of 2nd row
  77559. * @param initialM31 defines 1st value of 3rd row
  77560. * @param initialM32 defines 2nd value of 3rd row
  77561. * @param initialM33 defines 3rd value of 3rd row
  77562. * @param initialM34 defines 4th value of 3rd row
  77563. * @param initialM41 defines 1st value of 4th row
  77564. * @param initialM42 defines 2nd value of 4th row
  77565. * @param initialM43 defines 3rd value of 4th row
  77566. * @param initialM44 defines 4th value of 4th row
  77567. * @param result defines the target matrix
  77568. */
  77569. 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;
  77570. /**
  77571. * Creates new matrix from a list of values (16)
  77572. * @param initialM11 defines 1st value of 1st row
  77573. * @param initialM12 defines 2nd value of 1st row
  77574. * @param initialM13 defines 3rd value of 1st row
  77575. * @param initialM14 defines 4th value of 1st row
  77576. * @param initialM21 defines 1st value of 2nd row
  77577. * @param initialM22 defines 2nd value of 2nd row
  77578. * @param initialM23 defines 3rd value of 2nd row
  77579. * @param initialM24 defines 4th value of 2nd row
  77580. * @param initialM31 defines 1st value of 3rd row
  77581. * @param initialM32 defines 2nd value of 3rd row
  77582. * @param initialM33 defines 3rd value of 3rd row
  77583. * @param initialM34 defines 4th value of 3rd row
  77584. * @param initialM41 defines 1st value of 4th row
  77585. * @param initialM42 defines 2nd value of 4th row
  77586. * @param initialM43 defines 3rd value of 4th row
  77587. * @param initialM44 defines 4th value of 4th row
  77588. * @returns the new matrix
  77589. */
  77590. 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;
  77591. /**
  77592. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77593. * @param scale defines the scale vector3
  77594. * @param rotation defines the rotation quaternion
  77595. * @param translation defines the translation vector3
  77596. * @returns a new matrix
  77597. */
  77598. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77599. /**
  77600. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77601. * @param scale defines the scale vector3
  77602. * @param rotation defines the rotation quaternion
  77603. * @param translation defines the translation vector3
  77604. * @param result defines the target matrix
  77605. */
  77606. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77607. /**
  77608. * Creates a new identity matrix
  77609. * @returns a new identity matrix
  77610. */
  77611. static Identity(): Matrix;
  77612. /**
  77613. * Creates a new identity matrix and stores the result in a given matrix
  77614. * @param result defines the target matrix
  77615. */
  77616. static IdentityToRef(result: Matrix): void;
  77617. /**
  77618. * Creates a new zero matrix
  77619. * @returns a new zero matrix
  77620. */
  77621. static Zero(): Matrix;
  77622. /**
  77623. * Creates a new rotation matrix for "angle" radians around the X axis
  77624. * @param angle defines the angle (in radians) to use
  77625. * @return the new matrix
  77626. */
  77627. static RotationX(angle: number): Matrix;
  77628. /**
  77629. * Creates a new matrix as the invert of a given matrix
  77630. * @param source defines the source matrix
  77631. * @returns the new matrix
  77632. */
  77633. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77634. /**
  77635. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77636. * @param angle defines the angle (in radians) to use
  77637. * @param result defines the target matrix
  77638. */
  77639. static RotationXToRef(angle: number, result: Matrix): void;
  77640. /**
  77641. * Creates a new rotation matrix for "angle" radians around the Y axis
  77642. * @param angle defines the angle (in radians) to use
  77643. * @return the new matrix
  77644. */
  77645. static RotationY(angle: number): Matrix;
  77646. /**
  77647. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77648. * @param angle defines the angle (in radians) to use
  77649. * @param result defines the target matrix
  77650. */
  77651. static RotationYToRef(angle: number, result: Matrix): void;
  77652. /**
  77653. * Creates a new rotation matrix for "angle" radians around the Z axis
  77654. * @param angle defines the angle (in radians) to use
  77655. * @return the new matrix
  77656. */
  77657. static RotationZ(angle: number): Matrix;
  77658. /**
  77659. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77660. * @param angle defines the angle (in radians) to use
  77661. * @param result defines the target matrix
  77662. */
  77663. static RotationZToRef(angle: number, result: Matrix): void;
  77664. /**
  77665. * Creates a new rotation matrix for "angle" radians around the given axis
  77666. * @param axis defines the axis to use
  77667. * @param angle defines the angle (in radians) to use
  77668. * @return the new matrix
  77669. */
  77670. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77671. /**
  77672. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77673. * @param axis defines the axis to use
  77674. * @param angle defines the angle (in radians) to use
  77675. * @param result defines the target matrix
  77676. */
  77677. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77678. /**
  77679. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77680. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77681. * @param from defines the vector to align
  77682. * @param to defines the vector to align to
  77683. * @param result defines the target matrix
  77684. */
  77685. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77686. /**
  77687. * Creates a rotation matrix
  77688. * @param yaw defines the yaw angle in radians (Y axis)
  77689. * @param pitch defines the pitch angle in radians (X axis)
  77690. * @param roll defines the roll angle in radians (X axis)
  77691. * @returns the new rotation matrix
  77692. */
  77693. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77694. /**
  77695. * Creates a rotation matrix and stores it in a given matrix
  77696. * @param yaw defines the yaw angle in radians (Y axis)
  77697. * @param pitch defines the pitch angle in radians (X axis)
  77698. * @param roll defines the roll angle in radians (X axis)
  77699. * @param result defines the target matrix
  77700. */
  77701. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77702. /**
  77703. * Creates a scaling matrix
  77704. * @param x defines the scale factor on X axis
  77705. * @param y defines the scale factor on Y axis
  77706. * @param z defines the scale factor on Z axis
  77707. * @returns the new matrix
  77708. */
  77709. static Scaling(x: number, y: number, z: number): Matrix;
  77710. /**
  77711. * Creates a scaling matrix and stores it in a given matrix
  77712. * @param x defines the scale factor on X axis
  77713. * @param y defines the scale factor on Y axis
  77714. * @param z defines the scale factor on Z axis
  77715. * @param result defines the target matrix
  77716. */
  77717. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77718. /**
  77719. * Creates a translation matrix
  77720. * @param x defines the translation on X axis
  77721. * @param y defines the translation on Y axis
  77722. * @param z defines the translationon Z axis
  77723. * @returns the new matrix
  77724. */
  77725. static Translation(x: number, y: number, z: number): Matrix;
  77726. /**
  77727. * Creates a translation matrix and stores it in a given matrix
  77728. * @param x defines the translation on X axis
  77729. * @param y defines the translation on Y axis
  77730. * @param z defines the translationon Z axis
  77731. * @param result defines the target matrix
  77732. */
  77733. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77734. /**
  77735. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77736. * @param startValue defines the start value
  77737. * @param endValue defines the end value
  77738. * @param gradient defines the gradient factor
  77739. * @returns the new matrix
  77740. */
  77741. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77742. /**
  77743. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77744. * @param startValue defines the start value
  77745. * @param endValue defines the end value
  77746. * @param gradient defines the gradient factor
  77747. * @param result defines the Matrix object where to store data
  77748. */
  77749. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77750. /**
  77751. * Builds a new matrix whose values are computed by:
  77752. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77753. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77754. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77755. * @param startValue defines the first matrix
  77756. * @param endValue defines the second matrix
  77757. * @param gradient defines the gradient between the two matrices
  77758. * @returns the new matrix
  77759. */
  77760. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77761. /**
  77762. * Update a matrix to values which are computed by:
  77763. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77764. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77765. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77766. * @param startValue defines the first matrix
  77767. * @param endValue defines the second matrix
  77768. * @param gradient defines the gradient between the two matrices
  77769. * @param result defines the target matrix
  77770. */
  77771. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77772. /**
  77773. * 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"
  77774. * This function works in left handed mode
  77775. * @param eye defines the final position of the entity
  77776. * @param target defines where the entity should look at
  77777. * @param up defines the up vector for the entity
  77778. * @returns the new matrix
  77779. */
  77780. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77781. /**
  77782. * 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".
  77783. * This function works in left handed mode
  77784. * @param eye defines the final position of the entity
  77785. * @param target defines where the entity should look at
  77786. * @param up defines the up vector for the entity
  77787. * @param result defines the target matrix
  77788. */
  77789. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77790. /**
  77791. * 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"
  77792. * This function works in right handed mode
  77793. * @param eye defines the final position of the entity
  77794. * @param target defines where the entity should look at
  77795. * @param up defines the up vector for the entity
  77796. * @returns the new matrix
  77797. */
  77798. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77799. /**
  77800. * 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".
  77801. * This function works in right handed mode
  77802. * @param eye defines the final position of the entity
  77803. * @param target defines where the entity should look at
  77804. * @param up defines the up vector for the entity
  77805. * @param result defines the target matrix
  77806. */
  77807. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77808. /**
  77809. * Create a left-handed orthographic projection matrix
  77810. * @param width defines the viewport width
  77811. * @param height defines the viewport height
  77812. * @param znear defines the near clip plane
  77813. * @param zfar defines the far clip plane
  77814. * @returns a new matrix as a left-handed orthographic projection matrix
  77815. */
  77816. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77817. /**
  77818. * Store a left-handed orthographic projection to a given matrix
  77819. * @param width defines the viewport width
  77820. * @param height defines the viewport height
  77821. * @param znear defines the near clip plane
  77822. * @param zfar defines the far clip plane
  77823. * @param result defines the target matrix
  77824. */
  77825. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77826. /**
  77827. * Create a left-handed orthographic projection matrix
  77828. * @param left defines the viewport left coordinate
  77829. * @param right defines the viewport right coordinate
  77830. * @param bottom defines the viewport bottom coordinate
  77831. * @param top defines the viewport top coordinate
  77832. * @param znear defines the near clip plane
  77833. * @param zfar defines the far clip plane
  77834. * @returns a new matrix as a left-handed orthographic projection matrix
  77835. */
  77836. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77837. /**
  77838. * Stores a left-handed orthographic projection into a given matrix
  77839. * @param left defines the viewport left coordinate
  77840. * @param right defines the viewport right coordinate
  77841. * @param bottom defines the viewport bottom coordinate
  77842. * @param top defines the viewport top coordinate
  77843. * @param znear defines the near clip plane
  77844. * @param zfar defines the far clip plane
  77845. * @param result defines the target matrix
  77846. */
  77847. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77848. /**
  77849. * Creates a right-handed orthographic projection matrix
  77850. * @param left defines the viewport left coordinate
  77851. * @param right defines the viewport right coordinate
  77852. * @param bottom defines the viewport bottom coordinate
  77853. * @param top defines the viewport top coordinate
  77854. * @param znear defines the near clip plane
  77855. * @param zfar defines the far clip plane
  77856. * @returns a new matrix as a right-handed orthographic projection matrix
  77857. */
  77858. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77859. /**
  77860. * Stores a right-handed orthographic projection into a given matrix
  77861. * @param left defines the viewport left coordinate
  77862. * @param right defines the viewport right coordinate
  77863. * @param bottom defines the viewport bottom coordinate
  77864. * @param top defines the viewport top coordinate
  77865. * @param znear defines the near clip plane
  77866. * @param zfar defines the far clip plane
  77867. * @param result defines the target matrix
  77868. */
  77869. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77870. /**
  77871. * Creates a left-handed perspective projection matrix
  77872. * @param width defines the viewport width
  77873. * @param height defines the viewport height
  77874. * @param znear defines the near clip plane
  77875. * @param zfar defines the far clip plane
  77876. * @returns a new matrix as a left-handed perspective projection matrix
  77877. */
  77878. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77879. /**
  77880. * Creates a left-handed perspective projection matrix
  77881. * @param fov defines the horizontal field of view
  77882. * @param aspect defines the aspect ratio
  77883. * @param znear defines the near clip plane
  77884. * @param zfar defines the far clip plane
  77885. * @returns a new matrix as a left-handed perspective projection matrix
  77886. */
  77887. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77888. /**
  77889. * Stores a left-handed perspective projection into a given matrix
  77890. * @param fov defines the horizontal field of view
  77891. * @param aspect defines the aspect ratio
  77892. * @param znear defines the near clip plane
  77893. * @param zfar defines the far clip plane
  77894. * @param result defines the target matrix
  77895. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77896. */
  77897. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77898. /**
  77899. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77900. * @param fov defines the horizontal field of view
  77901. * @param aspect defines the aspect ratio
  77902. * @param znear defines the near clip plane
  77903. * @param zfar not used as infinity is used as far clip
  77904. * @param result defines the target matrix
  77905. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77906. */
  77907. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77908. /**
  77909. * Creates a right-handed perspective projection matrix
  77910. * @param fov defines the horizontal field of view
  77911. * @param aspect defines the aspect ratio
  77912. * @param znear defines the near clip plane
  77913. * @param zfar defines the far clip plane
  77914. * @returns a new matrix as a right-handed perspective projection matrix
  77915. */
  77916. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77917. /**
  77918. * Stores a right-handed perspective projection into a given matrix
  77919. * @param fov defines the horizontal field of view
  77920. * @param aspect defines the aspect ratio
  77921. * @param znear defines the near clip plane
  77922. * @param zfar defines the far clip plane
  77923. * @param result defines the target matrix
  77924. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77925. */
  77926. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77927. /**
  77928. * Stores a right-handed perspective projection into a given matrix
  77929. * @param fov defines the horizontal field of view
  77930. * @param aspect defines the aspect ratio
  77931. * @param znear defines the near clip plane
  77932. * @param zfar not used as infinity is used as far clip
  77933. * @param result defines the target matrix
  77934. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77935. */
  77936. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77937. /**
  77938. * Stores a perspective projection for WebVR info a given matrix
  77939. * @param fov defines the field of view
  77940. * @param znear defines the near clip plane
  77941. * @param zfar defines the far clip plane
  77942. * @param result defines the target matrix
  77943. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77944. */
  77945. static PerspectiveFovWebVRToRef(fov: {
  77946. upDegrees: number;
  77947. downDegrees: number;
  77948. leftDegrees: number;
  77949. rightDegrees: number;
  77950. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77951. /**
  77952. * Computes a complete transformation matrix
  77953. * @param viewport defines the viewport to use
  77954. * @param world defines the world matrix
  77955. * @param view defines the view matrix
  77956. * @param projection defines the projection matrix
  77957. * @param zmin defines the near clip plane
  77958. * @param zmax defines the far clip plane
  77959. * @returns the transformation matrix
  77960. */
  77961. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77962. /**
  77963. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77964. * @param matrix defines the matrix to use
  77965. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77966. */
  77967. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77968. /**
  77969. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77970. * @param matrix defines the matrix to use
  77971. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77972. */
  77973. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77974. /**
  77975. * Compute the transpose of a given matrix
  77976. * @param matrix defines the matrix to transpose
  77977. * @returns the new matrix
  77978. */
  77979. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77980. /**
  77981. * Compute the transpose of a matrix and store it in a target matrix
  77982. * @param matrix defines the matrix to transpose
  77983. * @param result defines the target matrix
  77984. */
  77985. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77986. /**
  77987. * Computes a reflection matrix from a plane
  77988. * @param plane defines the reflection plane
  77989. * @returns a new matrix
  77990. */
  77991. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77992. /**
  77993. * Computes a reflection matrix from a plane
  77994. * @param plane defines the reflection plane
  77995. * @param result defines the target matrix
  77996. */
  77997. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77998. /**
  77999. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78000. * @param xaxis defines the value of the 1st axis
  78001. * @param yaxis defines the value of the 2nd axis
  78002. * @param zaxis defines the value of the 3rd axis
  78003. * @param result defines the target matrix
  78004. */
  78005. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78006. /**
  78007. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78008. * @param quat defines the quaternion to use
  78009. * @param result defines the target matrix
  78010. */
  78011. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78012. }
  78013. /**
  78014. * @hidden
  78015. */
  78016. export class TmpVectors {
  78017. static Vector2: Vector2[];
  78018. static Vector3: Vector3[];
  78019. static Vector4: Vector4[];
  78020. static Quaternion: Quaternion[];
  78021. static Matrix: Matrix[];
  78022. }
  78023. }
  78024. declare module BABYLON {
  78025. /**
  78026. * Defines potential orientation for back face culling
  78027. */
  78028. export enum Orientation {
  78029. /**
  78030. * Clockwise
  78031. */
  78032. CW = 0,
  78033. /** Counter clockwise */
  78034. CCW = 1
  78035. }
  78036. /** Class used to represent a Bezier curve */
  78037. export class BezierCurve {
  78038. /**
  78039. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78040. * @param t defines the time
  78041. * @param x1 defines the left coordinate on X axis
  78042. * @param y1 defines the left coordinate on Y axis
  78043. * @param x2 defines the right coordinate on X axis
  78044. * @param y2 defines the right coordinate on Y axis
  78045. * @returns the interpolated value
  78046. */
  78047. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78048. }
  78049. /**
  78050. * Defines angle representation
  78051. */
  78052. export class Angle {
  78053. private _radians;
  78054. /**
  78055. * Creates an Angle object of "radians" radians (float).
  78056. * @param radians the angle in radians
  78057. */
  78058. constructor(radians: number);
  78059. /**
  78060. * Get value in degrees
  78061. * @returns the Angle value in degrees (float)
  78062. */
  78063. degrees(): number;
  78064. /**
  78065. * Get value in radians
  78066. * @returns the Angle value in radians (float)
  78067. */
  78068. radians(): number;
  78069. /**
  78070. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78071. * @param a defines first vector
  78072. * @param b defines second vector
  78073. * @returns a new Angle
  78074. */
  78075. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78076. /**
  78077. * Gets a new Angle object from the given float in radians
  78078. * @param radians defines the angle value in radians
  78079. * @returns a new Angle
  78080. */
  78081. static FromRadians(radians: number): Angle;
  78082. /**
  78083. * Gets a new Angle object from the given float in degrees
  78084. * @param degrees defines the angle value in degrees
  78085. * @returns a new Angle
  78086. */
  78087. static FromDegrees(degrees: number): Angle;
  78088. }
  78089. /**
  78090. * This represents an arc in a 2d space.
  78091. */
  78092. export class Arc2 {
  78093. /** Defines the start point of the arc */
  78094. startPoint: Vector2;
  78095. /** Defines the mid point of the arc */
  78096. midPoint: Vector2;
  78097. /** Defines the end point of the arc */
  78098. endPoint: Vector2;
  78099. /**
  78100. * Defines the center point of the arc.
  78101. */
  78102. centerPoint: Vector2;
  78103. /**
  78104. * Defines the radius of the arc.
  78105. */
  78106. radius: number;
  78107. /**
  78108. * Defines the angle of the arc (from mid point to end point).
  78109. */
  78110. angle: Angle;
  78111. /**
  78112. * Defines the start angle of the arc (from start point to middle point).
  78113. */
  78114. startAngle: Angle;
  78115. /**
  78116. * Defines the orientation of the arc (clock wise/counter clock wise).
  78117. */
  78118. orientation: Orientation;
  78119. /**
  78120. * Creates an Arc object from the three given points : start, middle and end.
  78121. * @param startPoint Defines the start point of the arc
  78122. * @param midPoint Defines the midlle point of the arc
  78123. * @param endPoint Defines the end point of the arc
  78124. */
  78125. constructor(
  78126. /** Defines the start point of the arc */
  78127. startPoint: Vector2,
  78128. /** Defines the mid point of the arc */
  78129. midPoint: Vector2,
  78130. /** Defines the end point of the arc */
  78131. endPoint: Vector2);
  78132. }
  78133. /**
  78134. * Represents a 2D path made up of multiple 2D points
  78135. */
  78136. export class Path2 {
  78137. private _points;
  78138. private _length;
  78139. /**
  78140. * If the path start and end point are the same
  78141. */
  78142. closed: boolean;
  78143. /**
  78144. * Creates a Path2 object from the starting 2D coordinates x and y.
  78145. * @param x the starting points x value
  78146. * @param y the starting points y value
  78147. */
  78148. constructor(x: number, y: number);
  78149. /**
  78150. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78151. * @param x the added points x value
  78152. * @param y the added points y value
  78153. * @returns the updated Path2.
  78154. */
  78155. addLineTo(x: number, y: number): Path2;
  78156. /**
  78157. * 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.
  78158. * @param midX middle point x value
  78159. * @param midY middle point y value
  78160. * @param endX end point x value
  78161. * @param endY end point y value
  78162. * @param numberOfSegments (default: 36)
  78163. * @returns the updated Path2.
  78164. */
  78165. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78166. /**
  78167. * Closes the Path2.
  78168. * @returns the Path2.
  78169. */
  78170. close(): Path2;
  78171. /**
  78172. * Gets the sum of the distance between each sequential point in the path
  78173. * @returns the Path2 total length (float).
  78174. */
  78175. length(): number;
  78176. /**
  78177. * Gets the points which construct the path
  78178. * @returns the Path2 internal array of points.
  78179. */
  78180. getPoints(): Vector2[];
  78181. /**
  78182. * Retreives the point at the distance aways from the starting point
  78183. * @param normalizedLengthPosition the length along the path to retreive the point from
  78184. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78185. */
  78186. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78187. /**
  78188. * Creates a new path starting from an x and y position
  78189. * @param x starting x value
  78190. * @param y starting y value
  78191. * @returns a new Path2 starting at the coordinates (x, y).
  78192. */
  78193. static StartingAt(x: number, y: number): Path2;
  78194. }
  78195. /**
  78196. * Represents a 3D path made up of multiple 3D points
  78197. */
  78198. export class Path3D {
  78199. /**
  78200. * an array of Vector3, the curve axis of the Path3D
  78201. */
  78202. path: Vector3[];
  78203. private _curve;
  78204. private _distances;
  78205. private _tangents;
  78206. private _normals;
  78207. private _binormals;
  78208. private _raw;
  78209. private _alignTangentsWithPath;
  78210. private readonly _pointAtData;
  78211. /**
  78212. * new Path3D(path, normal, raw)
  78213. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78214. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78215. * @param path an array of Vector3, the curve axis of the Path3D
  78216. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78217. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78218. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78219. */
  78220. constructor(
  78221. /**
  78222. * an array of Vector3, the curve axis of the Path3D
  78223. */
  78224. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78225. /**
  78226. * Returns the Path3D array of successive Vector3 designing its curve.
  78227. * @returns the Path3D array of successive Vector3 designing its curve.
  78228. */
  78229. getCurve(): Vector3[];
  78230. /**
  78231. * Returns the Path3D array of successive Vector3 designing its curve.
  78232. * @returns the Path3D array of successive Vector3 designing its curve.
  78233. */
  78234. getPoints(): Vector3[];
  78235. /**
  78236. * @returns the computed length (float) of the path.
  78237. */
  78238. length(): number;
  78239. /**
  78240. * Returns an array populated with tangent vectors on each Path3D curve point.
  78241. * @returns an array populated with tangent vectors on each Path3D curve point.
  78242. */
  78243. getTangents(): Vector3[];
  78244. /**
  78245. * Returns an array populated with normal vectors on each Path3D curve point.
  78246. * @returns an array populated with normal vectors on each Path3D curve point.
  78247. */
  78248. getNormals(): Vector3[];
  78249. /**
  78250. * Returns an array populated with binormal vectors on each Path3D curve point.
  78251. * @returns an array populated with binormal vectors on each Path3D curve point.
  78252. */
  78253. getBinormals(): Vector3[];
  78254. /**
  78255. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78256. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78257. */
  78258. getDistances(): number[];
  78259. /**
  78260. * Returns an interpolated point along this path
  78261. * @param position the position of the point along this path, from 0.0 to 1.0
  78262. * @returns a new Vector3 as the point
  78263. */
  78264. getPointAt(position: number): Vector3;
  78265. /**
  78266. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78267. * @param position the position of the point along this path, from 0.0 to 1.0
  78268. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78269. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78270. */
  78271. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78272. /**
  78273. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78274. * @param position the position of the point along this path, from 0.0 to 1.0
  78275. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78276. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78277. */
  78278. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78279. /**
  78280. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78281. * @param position the position of the point along this path, from 0.0 to 1.0
  78282. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78283. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78284. */
  78285. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78286. /**
  78287. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78288. * @param position the position of the point along this path, from 0.0 to 1.0
  78289. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78290. */
  78291. getDistanceAt(position: number): number;
  78292. /**
  78293. * Returns the array index of the previous point of an interpolated point along this path
  78294. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78295. * @returns the array index
  78296. */
  78297. getPreviousPointIndexAt(position: number): number;
  78298. /**
  78299. * 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)
  78300. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78301. * @returns the sub position
  78302. */
  78303. getSubPositionAt(position: number): number;
  78304. /**
  78305. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78306. * @param target the vector of which to get the closest position to
  78307. * @returns the position of the closest virtual point on this path to the target vector
  78308. */
  78309. getClosestPositionTo(target: Vector3): number;
  78310. /**
  78311. * Returns a sub path (slice) of this path
  78312. * @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
  78313. * @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
  78314. * @returns a sub path (slice) of this path
  78315. */
  78316. slice(start?: number, end?: number): Path3D;
  78317. /**
  78318. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78319. * @param path path which all values are copied into the curves points
  78320. * @param firstNormal which should be projected onto the curve
  78321. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78322. * @returns the same object updated.
  78323. */
  78324. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78325. private _compute;
  78326. private _getFirstNonNullVector;
  78327. private _getLastNonNullVector;
  78328. private _normalVector;
  78329. /**
  78330. * Updates the point at data for an interpolated point along this curve
  78331. * @param position the position of the point along this curve, from 0.0 to 1.0
  78332. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78333. * @returns the (updated) point at data
  78334. */
  78335. private _updatePointAtData;
  78336. /**
  78337. * Updates the point at data from the specified parameters
  78338. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78339. * @param point the interpolated point
  78340. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78341. */
  78342. private _setPointAtData;
  78343. /**
  78344. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78345. */
  78346. private _updateInterpolationMatrix;
  78347. }
  78348. /**
  78349. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78350. * A Curve3 is designed from a series of successive Vector3.
  78351. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78352. */
  78353. export class Curve3 {
  78354. private _points;
  78355. private _length;
  78356. /**
  78357. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78358. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78359. * @param v1 (Vector3) the control point
  78360. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78361. * @param nbPoints (integer) the wanted number of points in the curve
  78362. * @returns the created Curve3
  78363. */
  78364. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78365. /**
  78366. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78367. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78368. * @param v1 (Vector3) the first control point
  78369. * @param v2 (Vector3) the second control point
  78370. * @param v3 (Vector3) the end point of the Cubic Bezier
  78371. * @param nbPoints (integer) the wanted number of points in the curve
  78372. * @returns the created Curve3
  78373. */
  78374. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78375. /**
  78376. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78377. * @param p1 (Vector3) the origin point of the Hermite Spline
  78378. * @param t1 (Vector3) the tangent vector at the origin point
  78379. * @param p2 (Vector3) the end point of the Hermite Spline
  78380. * @param t2 (Vector3) the tangent vector at the end point
  78381. * @param nbPoints (integer) the wanted number of points in the curve
  78382. * @returns the created Curve3
  78383. */
  78384. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78385. /**
  78386. * Returns a Curve3 object along a CatmullRom Spline curve :
  78387. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78388. * @param nbPoints (integer) the wanted number of points between each curve control points
  78389. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78390. * @returns the created Curve3
  78391. */
  78392. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78393. /**
  78394. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78395. * A Curve3 is designed from a series of successive Vector3.
  78396. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78397. * @param points points which make up the curve
  78398. */
  78399. constructor(points: Vector3[]);
  78400. /**
  78401. * @returns the Curve3 stored array of successive Vector3
  78402. */
  78403. getPoints(): Vector3[];
  78404. /**
  78405. * @returns the computed length (float) of the curve.
  78406. */
  78407. length(): number;
  78408. /**
  78409. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78410. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78411. * curveA and curveB keep unchanged.
  78412. * @param curve the curve to continue from this curve
  78413. * @returns the newly constructed curve
  78414. */
  78415. continue(curve: DeepImmutable<Curve3>): Curve3;
  78416. private _computeLength;
  78417. }
  78418. }
  78419. declare module BABYLON {
  78420. /**
  78421. * This represents the main contract an easing function should follow.
  78422. * Easing functions are used throughout the animation system.
  78423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78424. */
  78425. export interface IEasingFunction {
  78426. /**
  78427. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78428. * of the easing function.
  78429. * The link below provides some of the most common examples of easing functions.
  78430. * @see https://easings.net/
  78431. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78432. * @returns the corresponding value on the curve defined by the easing function
  78433. */
  78434. ease(gradient: number): number;
  78435. }
  78436. /**
  78437. * Base class used for every default easing function.
  78438. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78439. */
  78440. export class EasingFunction implements IEasingFunction {
  78441. /**
  78442. * Interpolation follows the mathematical formula associated with the easing function.
  78443. */
  78444. static readonly EASINGMODE_EASEIN: number;
  78445. /**
  78446. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78447. */
  78448. static readonly EASINGMODE_EASEOUT: number;
  78449. /**
  78450. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78451. */
  78452. static readonly EASINGMODE_EASEINOUT: number;
  78453. private _easingMode;
  78454. /**
  78455. * Sets the easing mode of the current function.
  78456. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78457. */
  78458. setEasingMode(easingMode: number): void;
  78459. /**
  78460. * Gets the current easing mode.
  78461. * @returns the easing mode
  78462. */
  78463. getEasingMode(): number;
  78464. /**
  78465. * @hidden
  78466. */
  78467. easeInCore(gradient: number): number;
  78468. /**
  78469. * Given an input gradient between 0 and 1, this returns the corresponding value
  78470. * of the easing function.
  78471. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78472. * @returns the corresponding value on the curve defined by the easing function
  78473. */
  78474. ease(gradient: number): number;
  78475. }
  78476. /**
  78477. * Easing function with a circle shape (see link below).
  78478. * @see https://easings.net/#easeInCirc
  78479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78480. */
  78481. export class CircleEase extends EasingFunction implements IEasingFunction {
  78482. /** @hidden */
  78483. easeInCore(gradient: number): number;
  78484. }
  78485. /**
  78486. * Easing function with a ease back shape (see link below).
  78487. * @see https://easings.net/#easeInBack
  78488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78489. */
  78490. export class BackEase extends EasingFunction implements IEasingFunction {
  78491. /** Defines the amplitude of the function */
  78492. amplitude: number;
  78493. /**
  78494. * Instantiates a back ease easing
  78495. * @see https://easings.net/#easeInBack
  78496. * @param amplitude Defines the amplitude of the function
  78497. */
  78498. constructor(
  78499. /** Defines the amplitude of the function */
  78500. amplitude?: number);
  78501. /** @hidden */
  78502. easeInCore(gradient: number): number;
  78503. }
  78504. /**
  78505. * Easing function with a bouncing shape (see link below).
  78506. * @see https://easings.net/#easeInBounce
  78507. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78508. */
  78509. export class BounceEase extends EasingFunction implements IEasingFunction {
  78510. /** Defines the number of bounces */
  78511. bounces: number;
  78512. /** Defines the amplitude of the bounce */
  78513. bounciness: number;
  78514. /**
  78515. * Instantiates a bounce easing
  78516. * @see https://easings.net/#easeInBounce
  78517. * @param bounces Defines the number of bounces
  78518. * @param bounciness Defines the amplitude of the bounce
  78519. */
  78520. constructor(
  78521. /** Defines the number of bounces */
  78522. bounces?: number,
  78523. /** Defines the amplitude of the bounce */
  78524. bounciness?: number);
  78525. /** @hidden */
  78526. easeInCore(gradient: number): number;
  78527. }
  78528. /**
  78529. * Easing function with a power of 3 shape (see link below).
  78530. * @see https://easings.net/#easeInCubic
  78531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78532. */
  78533. export class CubicEase extends EasingFunction implements IEasingFunction {
  78534. /** @hidden */
  78535. easeInCore(gradient: number): number;
  78536. }
  78537. /**
  78538. * Easing function with an elastic shape (see link below).
  78539. * @see https://easings.net/#easeInElastic
  78540. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78541. */
  78542. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78543. /** Defines the number of oscillations*/
  78544. oscillations: number;
  78545. /** Defines the amplitude of the oscillations*/
  78546. springiness: number;
  78547. /**
  78548. * Instantiates an elastic easing function
  78549. * @see https://easings.net/#easeInElastic
  78550. * @param oscillations Defines the number of oscillations
  78551. * @param springiness Defines the amplitude of the oscillations
  78552. */
  78553. constructor(
  78554. /** Defines the number of oscillations*/
  78555. oscillations?: number,
  78556. /** Defines the amplitude of the oscillations*/
  78557. springiness?: number);
  78558. /** @hidden */
  78559. easeInCore(gradient: number): number;
  78560. }
  78561. /**
  78562. * Easing function with an exponential shape (see link below).
  78563. * @see https://easings.net/#easeInExpo
  78564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78565. */
  78566. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78567. /** Defines the exponent of the function */
  78568. exponent: number;
  78569. /**
  78570. * Instantiates an exponential easing function
  78571. * @see https://easings.net/#easeInExpo
  78572. * @param exponent Defines the exponent of the function
  78573. */
  78574. constructor(
  78575. /** Defines the exponent of the function */
  78576. exponent?: number);
  78577. /** @hidden */
  78578. easeInCore(gradient: number): number;
  78579. }
  78580. /**
  78581. * Easing function with a power shape (see link below).
  78582. * @see https://easings.net/#easeInQuad
  78583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78584. */
  78585. export class PowerEase extends EasingFunction implements IEasingFunction {
  78586. /** Defines the power of the function */
  78587. power: number;
  78588. /**
  78589. * Instantiates an power base easing function
  78590. * @see https://easings.net/#easeInQuad
  78591. * @param power Defines the power of the function
  78592. */
  78593. constructor(
  78594. /** Defines the power of the function */
  78595. power?: number);
  78596. /** @hidden */
  78597. easeInCore(gradient: number): number;
  78598. }
  78599. /**
  78600. * Easing function with a power of 2 shape (see link below).
  78601. * @see https://easings.net/#easeInQuad
  78602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78603. */
  78604. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78605. /** @hidden */
  78606. easeInCore(gradient: number): number;
  78607. }
  78608. /**
  78609. * Easing function with a power of 4 shape (see link below).
  78610. * @see https://easings.net/#easeInQuart
  78611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78612. */
  78613. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78614. /** @hidden */
  78615. easeInCore(gradient: number): number;
  78616. }
  78617. /**
  78618. * Easing function with a power of 5 shape (see link below).
  78619. * @see https://easings.net/#easeInQuint
  78620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78621. */
  78622. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78623. /** @hidden */
  78624. easeInCore(gradient: number): number;
  78625. }
  78626. /**
  78627. * Easing function with a sin shape (see link below).
  78628. * @see https://easings.net/#easeInSine
  78629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78630. */
  78631. export class SineEase extends EasingFunction implements IEasingFunction {
  78632. /** @hidden */
  78633. easeInCore(gradient: number): number;
  78634. }
  78635. /**
  78636. * Easing function with a bezier shape (see link below).
  78637. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78639. */
  78640. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78641. /** Defines the x component of the start tangent in the bezier curve */
  78642. x1: number;
  78643. /** Defines the y component of the start tangent in the bezier curve */
  78644. y1: number;
  78645. /** Defines the x component of the end tangent in the bezier curve */
  78646. x2: number;
  78647. /** Defines the y component of the end tangent in the bezier curve */
  78648. y2: number;
  78649. /**
  78650. * Instantiates a bezier function
  78651. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78652. * @param x1 Defines the x component of the start tangent in the bezier curve
  78653. * @param y1 Defines the y component of the start tangent in the bezier curve
  78654. * @param x2 Defines the x component of the end tangent in the bezier curve
  78655. * @param y2 Defines the y component of the end tangent in the bezier curve
  78656. */
  78657. constructor(
  78658. /** Defines the x component of the start tangent in the bezier curve */
  78659. x1?: number,
  78660. /** Defines the y component of the start tangent in the bezier curve */
  78661. y1?: number,
  78662. /** Defines the x component of the end tangent in the bezier curve */
  78663. x2?: number,
  78664. /** Defines the y component of the end tangent in the bezier curve */
  78665. y2?: number);
  78666. /** @hidden */
  78667. easeInCore(gradient: number): number;
  78668. }
  78669. }
  78670. declare module BABYLON {
  78671. /**
  78672. * Class used to hold a RBG color
  78673. */
  78674. export class Color3 {
  78675. /**
  78676. * Defines the red component (between 0 and 1, default is 0)
  78677. */
  78678. r: number;
  78679. /**
  78680. * Defines the green component (between 0 and 1, default is 0)
  78681. */
  78682. g: number;
  78683. /**
  78684. * Defines the blue component (between 0 and 1, default is 0)
  78685. */
  78686. b: number;
  78687. /**
  78688. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78689. * @param r defines the red component (between 0 and 1, default is 0)
  78690. * @param g defines the green component (between 0 and 1, default is 0)
  78691. * @param b defines the blue component (between 0 and 1, default is 0)
  78692. */
  78693. constructor(
  78694. /**
  78695. * Defines the red component (between 0 and 1, default is 0)
  78696. */
  78697. r?: number,
  78698. /**
  78699. * Defines the green component (between 0 and 1, default is 0)
  78700. */
  78701. g?: number,
  78702. /**
  78703. * Defines the blue component (between 0 and 1, default is 0)
  78704. */
  78705. b?: number);
  78706. /**
  78707. * Creates a string with the Color3 current values
  78708. * @returns the string representation of the Color3 object
  78709. */
  78710. toString(): string;
  78711. /**
  78712. * Returns the string "Color3"
  78713. * @returns "Color3"
  78714. */
  78715. getClassName(): string;
  78716. /**
  78717. * Compute the Color3 hash code
  78718. * @returns an unique number that can be used to hash Color3 objects
  78719. */
  78720. getHashCode(): number;
  78721. /**
  78722. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78723. * @param array defines the array where to store the r,g,b components
  78724. * @param index defines an optional index in the target array to define where to start storing values
  78725. * @returns the current Color3 object
  78726. */
  78727. toArray(array: FloatArray, index?: number): Color3;
  78728. /**
  78729. * Returns a new Color4 object from the current Color3 and the given alpha
  78730. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78731. * @returns a new Color4 object
  78732. */
  78733. toColor4(alpha?: number): Color4;
  78734. /**
  78735. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78736. * @returns the new array
  78737. */
  78738. asArray(): number[];
  78739. /**
  78740. * Returns the luminance value
  78741. * @returns a float value
  78742. */
  78743. toLuminance(): number;
  78744. /**
  78745. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78746. * @param otherColor defines the second operand
  78747. * @returns the new Color3 object
  78748. */
  78749. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78750. /**
  78751. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78752. * @param otherColor defines the second operand
  78753. * @param result defines the Color3 object where to store the result
  78754. * @returns the current Color3
  78755. */
  78756. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78757. /**
  78758. * Determines equality between Color3 objects
  78759. * @param otherColor defines the second operand
  78760. * @returns true if the rgb values are equal to the given ones
  78761. */
  78762. equals(otherColor: DeepImmutable<Color3>): boolean;
  78763. /**
  78764. * Determines equality between the current Color3 object and a set of r,b,g values
  78765. * @param r defines the red component to check
  78766. * @param g defines the green component to check
  78767. * @param b defines the blue component to check
  78768. * @returns true if the rgb values are equal to the given ones
  78769. */
  78770. equalsFloats(r: number, g: number, b: number): boolean;
  78771. /**
  78772. * Multiplies in place each rgb value by scale
  78773. * @param scale defines the scaling factor
  78774. * @returns the updated Color3
  78775. */
  78776. scale(scale: number): Color3;
  78777. /**
  78778. * Multiplies the rgb values by scale and stores the result into "result"
  78779. * @param scale defines the scaling factor
  78780. * @param result defines the Color3 object where to store the result
  78781. * @returns the unmodified current Color3
  78782. */
  78783. scaleToRef(scale: number, result: Color3): Color3;
  78784. /**
  78785. * Scale the current Color3 values by a factor and add the result to a given Color3
  78786. * @param scale defines the scale factor
  78787. * @param result defines color to store the result into
  78788. * @returns the unmodified current Color3
  78789. */
  78790. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78791. /**
  78792. * Clamps the rgb values by the min and max values and stores the result into "result"
  78793. * @param min defines minimum clamping value (default is 0)
  78794. * @param max defines maximum clamping value (default is 1)
  78795. * @param result defines color to store the result into
  78796. * @returns the original Color3
  78797. */
  78798. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78799. /**
  78800. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78801. * @param otherColor defines the second operand
  78802. * @returns the new Color3
  78803. */
  78804. add(otherColor: DeepImmutable<Color3>): Color3;
  78805. /**
  78806. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78807. * @param otherColor defines the second operand
  78808. * @param result defines Color3 object to store the result into
  78809. * @returns the unmodified current Color3
  78810. */
  78811. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78812. /**
  78813. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78814. * @param otherColor defines the second operand
  78815. * @returns the new Color3
  78816. */
  78817. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78818. /**
  78819. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78820. * @param otherColor defines the second operand
  78821. * @param result defines Color3 object to store the result into
  78822. * @returns the unmodified current Color3
  78823. */
  78824. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78825. /**
  78826. * Copy the current object
  78827. * @returns a new Color3 copied the current one
  78828. */
  78829. clone(): Color3;
  78830. /**
  78831. * Copies the rgb values from the source in the current Color3
  78832. * @param source defines the source Color3 object
  78833. * @returns the updated Color3 object
  78834. */
  78835. copyFrom(source: DeepImmutable<Color3>): Color3;
  78836. /**
  78837. * Updates the Color3 rgb values from the given floats
  78838. * @param r defines the red component to read from
  78839. * @param g defines the green component to read from
  78840. * @param b defines the blue component to read from
  78841. * @returns the current Color3 object
  78842. */
  78843. copyFromFloats(r: number, g: number, b: number): Color3;
  78844. /**
  78845. * Updates the Color3 rgb values from the given floats
  78846. * @param r defines the red component to read from
  78847. * @param g defines the green component to read from
  78848. * @param b defines the blue component to read from
  78849. * @returns the current Color3 object
  78850. */
  78851. set(r: number, g: number, b: number): Color3;
  78852. /**
  78853. * Compute the Color3 hexadecimal code as a string
  78854. * @returns a string containing the hexadecimal representation of the Color3 object
  78855. */
  78856. toHexString(): string;
  78857. /**
  78858. * Computes a new Color3 converted from the current one to linear space
  78859. * @returns a new Color3 object
  78860. */
  78861. toLinearSpace(): Color3;
  78862. /**
  78863. * Converts current color in rgb space to HSV values
  78864. * @returns a new color3 representing the HSV values
  78865. */
  78866. toHSV(): Color3;
  78867. /**
  78868. * Converts current color in rgb space to HSV values
  78869. * @param result defines the Color3 where to store the HSV values
  78870. */
  78871. toHSVToRef(result: Color3): void;
  78872. /**
  78873. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78874. * @param convertedColor defines the Color3 object where to store the linear space version
  78875. * @returns the unmodified Color3
  78876. */
  78877. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78878. /**
  78879. * Computes a new Color3 converted from the current one to gamma space
  78880. * @returns a new Color3 object
  78881. */
  78882. toGammaSpace(): Color3;
  78883. /**
  78884. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78885. * @param convertedColor defines the Color3 object where to store the gamma space version
  78886. * @returns the unmodified Color3
  78887. */
  78888. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78889. private static _BlackReadOnly;
  78890. /**
  78891. * Convert Hue, saturation and value to a Color3 (RGB)
  78892. * @param hue defines the hue
  78893. * @param saturation defines the saturation
  78894. * @param value defines the value
  78895. * @param result defines the Color3 where to store the RGB values
  78896. */
  78897. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78898. /**
  78899. * Creates a new Color3 from the string containing valid hexadecimal values
  78900. * @param hex defines a string containing valid hexadecimal values
  78901. * @returns a new Color3 object
  78902. */
  78903. static FromHexString(hex: string): Color3;
  78904. /**
  78905. * Creates a new Color3 from the starting index of the given array
  78906. * @param array defines the source array
  78907. * @param offset defines an offset in the source array
  78908. * @returns a new Color3 object
  78909. */
  78910. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78911. /**
  78912. * Creates a new Color3 from integer values (< 256)
  78913. * @param r defines the red component to read from (value between 0 and 255)
  78914. * @param g defines the green component to read from (value between 0 and 255)
  78915. * @param b defines the blue component to read from (value between 0 and 255)
  78916. * @returns a new Color3 object
  78917. */
  78918. static FromInts(r: number, g: number, b: number): Color3;
  78919. /**
  78920. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78921. * @param start defines the start Color3 value
  78922. * @param end defines the end Color3 value
  78923. * @param amount defines the gradient value between start and end
  78924. * @returns a new Color3 object
  78925. */
  78926. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78927. /**
  78928. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78929. * @param left defines the start value
  78930. * @param right defines the end value
  78931. * @param amount defines the gradient factor
  78932. * @param result defines the Color3 object where to store the result
  78933. */
  78934. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78935. /**
  78936. * Returns a Color3 value containing a red color
  78937. * @returns a new Color3 object
  78938. */
  78939. static Red(): Color3;
  78940. /**
  78941. * Returns a Color3 value containing a green color
  78942. * @returns a new Color3 object
  78943. */
  78944. static Green(): Color3;
  78945. /**
  78946. * Returns a Color3 value containing a blue color
  78947. * @returns a new Color3 object
  78948. */
  78949. static Blue(): Color3;
  78950. /**
  78951. * Returns a Color3 value containing a black color
  78952. * @returns a new Color3 object
  78953. */
  78954. static Black(): Color3;
  78955. /**
  78956. * Gets a Color3 value containing a black color that must not be updated
  78957. */
  78958. static get BlackReadOnly(): DeepImmutable<Color3>;
  78959. /**
  78960. * Returns a Color3 value containing a white color
  78961. * @returns a new Color3 object
  78962. */
  78963. static White(): Color3;
  78964. /**
  78965. * Returns a Color3 value containing a purple color
  78966. * @returns a new Color3 object
  78967. */
  78968. static Purple(): Color3;
  78969. /**
  78970. * Returns a Color3 value containing a magenta color
  78971. * @returns a new Color3 object
  78972. */
  78973. static Magenta(): Color3;
  78974. /**
  78975. * Returns a Color3 value containing a yellow color
  78976. * @returns a new Color3 object
  78977. */
  78978. static Yellow(): Color3;
  78979. /**
  78980. * Returns a Color3 value containing a gray color
  78981. * @returns a new Color3 object
  78982. */
  78983. static Gray(): Color3;
  78984. /**
  78985. * Returns a Color3 value containing a teal color
  78986. * @returns a new Color3 object
  78987. */
  78988. static Teal(): Color3;
  78989. /**
  78990. * Returns a Color3 value containing a random color
  78991. * @returns a new Color3 object
  78992. */
  78993. static Random(): Color3;
  78994. }
  78995. /**
  78996. * Class used to hold a RBGA color
  78997. */
  78998. export class Color4 {
  78999. /**
  79000. * Defines the red component (between 0 and 1, default is 0)
  79001. */
  79002. r: number;
  79003. /**
  79004. * Defines the green component (between 0 and 1, default is 0)
  79005. */
  79006. g: number;
  79007. /**
  79008. * Defines the blue component (between 0 and 1, default is 0)
  79009. */
  79010. b: number;
  79011. /**
  79012. * Defines the alpha component (between 0 and 1, default is 1)
  79013. */
  79014. a: number;
  79015. /**
  79016. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79017. * @param r defines the red component (between 0 and 1, default is 0)
  79018. * @param g defines the green component (between 0 and 1, default is 0)
  79019. * @param b defines the blue component (between 0 and 1, default is 0)
  79020. * @param a defines the alpha component (between 0 and 1, default is 1)
  79021. */
  79022. constructor(
  79023. /**
  79024. * Defines the red component (between 0 and 1, default is 0)
  79025. */
  79026. r?: number,
  79027. /**
  79028. * Defines the green component (between 0 and 1, default is 0)
  79029. */
  79030. g?: number,
  79031. /**
  79032. * Defines the blue component (between 0 and 1, default is 0)
  79033. */
  79034. b?: number,
  79035. /**
  79036. * Defines the alpha component (between 0 and 1, default is 1)
  79037. */
  79038. a?: number);
  79039. /**
  79040. * Adds in place the given Color4 values to the current Color4 object
  79041. * @param right defines the second operand
  79042. * @returns the current updated Color4 object
  79043. */
  79044. addInPlace(right: DeepImmutable<Color4>): Color4;
  79045. /**
  79046. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79047. * @returns the new array
  79048. */
  79049. asArray(): number[];
  79050. /**
  79051. * Stores from the starting index in the given array the Color4 successive values
  79052. * @param array defines the array where to store the r,g,b components
  79053. * @param index defines an optional index in the target array to define where to start storing values
  79054. * @returns the current Color4 object
  79055. */
  79056. toArray(array: number[], index?: number): Color4;
  79057. /**
  79058. * Determines equality between Color4 objects
  79059. * @param otherColor defines the second operand
  79060. * @returns true if the rgba values are equal to the given ones
  79061. */
  79062. equals(otherColor: DeepImmutable<Color4>): boolean;
  79063. /**
  79064. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79065. * @param right defines the second operand
  79066. * @returns a new Color4 object
  79067. */
  79068. add(right: DeepImmutable<Color4>): Color4;
  79069. /**
  79070. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79071. * @param right defines the second operand
  79072. * @returns a new Color4 object
  79073. */
  79074. subtract(right: DeepImmutable<Color4>): Color4;
  79075. /**
  79076. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79077. * @param right defines the second operand
  79078. * @param result defines the Color4 object where to store the result
  79079. * @returns the current Color4 object
  79080. */
  79081. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79082. /**
  79083. * Creates a new Color4 with the current Color4 values multiplied by scale
  79084. * @param scale defines the scaling factor to apply
  79085. * @returns a new Color4 object
  79086. */
  79087. scale(scale: number): Color4;
  79088. /**
  79089. * Multiplies the current Color4 values by scale and stores the result in "result"
  79090. * @param scale defines the scaling factor to apply
  79091. * @param result defines the Color4 object where to store the result
  79092. * @returns the current unmodified Color4
  79093. */
  79094. scaleToRef(scale: number, result: Color4): Color4;
  79095. /**
  79096. * Scale the current Color4 values by a factor and add the result to a given Color4
  79097. * @param scale defines the scale factor
  79098. * @param result defines the Color4 object where to store the result
  79099. * @returns the unmodified current Color4
  79100. */
  79101. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79102. /**
  79103. * Clamps the rgb values by the min and max values and stores the result into "result"
  79104. * @param min defines minimum clamping value (default is 0)
  79105. * @param max defines maximum clamping value (default is 1)
  79106. * @param result defines color to store the result into.
  79107. * @returns the cuurent Color4
  79108. */
  79109. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79110. /**
  79111. * Multipy an Color4 value by another and return a new Color4 object
  79112. * @param color defines the Color4 value to multiply by
  79113. * @returns a new Color4 object
  79114. */
  79115. multiply(color: Color4): Color4;
  79116. /**
  79117. * Multipy a Color4 value by another and push the result in a reference value
  79118. * @param color defines the Color4 value to multiply by
  79119. * @param result defines the Color4 to fill the result in
  79120. * @returns the result Color4
  79121. */
  79122. multiplyToRef(color: Color4, result: Color4): Color4;
  79123. /**
  79124. * Creates a string with the Color4 current values
  79125. * @returns the string representation of the Color4 object
  79126. */
  79127. toString(): string;
  79128. /**
  79129. * Returns the string "Color4"
  79130. * @returns "Color4"
  79131. */
  79132. getClassName(): string;
  79133. /**
  79134. * Compute the Color4 hash code
  79135. * @returns an unique number that can be used to hash Color4 objects
  79136. */
  79137. getHashCode(): number;
  79138. /**
  79139. * Creates a new Color4 copied from the current one
  79140. * @returns a new Color4 object
  79141. */
  79142. clone(): Color4;
  79143. /**
  79144. * Copies the given Color4 values into the current one
  79145. * @param source defines the source Color4 object
  79146. * @returns the current updated Color4 object
  79147. */
  79148. copyFrom(source: Color4): Color4;
  79149. /**
  79150. * Copies the given float values into the current one
  79151. * @param r defines the red component to read from
  79152. * @param g defines the green component to read from
  79153. * @param b defines the blue component to read from
  79154. * @param a defines the alpha component to read from
  79155. * @returns the current updated Color4 object
  79156. */
  79157. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79158. /**
  79159. * Copies the given float values into the current one
  79160. * @param r defines the red component to read from
  79161. * @param g defines the green component to read from
  79162. * @param b defines the blue component to read from
  79163. * @param a defines the alpha component to read from
  79164. * @returns the current updated Color4 object
  79165. */
  79166. set(r: number, g: number, b: number, a: number): Color4;
  79167. /**
  79168. * Compute the Color4 hexadecimal code as a string
  79169. * @returns a string containing the hexadecimal representation of the Color4 object
  79170. */
  79171. toHexString(): string;
  79172. /**
  79173. * Computes a new Color4 converted from the current one to linear space
  79174. * @returns a new Color4 object
  79175. */
  79176. toLinearSpace(): Color4;
  79177. /**
  79178. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79179. * @param convertedColor defines the Color4 object where to store the linear space version
  79180. * @returns the unmodified Color4
  79181. */
  79182. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79183. /**
  79184. * Computes a new Color4 converted from the current one to gamma space
  79185. * @returns a new Color4 object
  79186. */
  79187. toGammaSpace(): Color4;
  79188. /**
  79189. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79190. * @param convertedColor defines the Color4 object where to store the gamma space version
  79191. * @returns the unmodified Color4
  79192. */
  79193. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79194. /**
  79195. * Creates a new Color4 from the string containing valid hexadecimal values
  79196. * @param hex defines a string containing valid hexadecimal values
  79197. * @returns a new Color4 object
  79198. */
  79199. static FromHexString(hex: string): Color4;
  79200. /**
  79201. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79202. * @param left defines the start value
  79203. * @param right defines the end value
  79204. * @param amount defines the gradient factor
  79205. * @returns a new Color4 object
  79206. */
  79207. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79208. /**
  79209. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79210. * @param left defines the start value
  79211. * @param right defines the end value
  79212. * @param amount defines the gradient factor
  79213. * @param result defines the Color4 object where to store data
  79214. */
  79215. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79216. /**
  79217. * Creates a new Color4 from a Color3 and an alpha value
  79218. * @param color3 defines the source Color3 to read from
  79219. * @param alpha defines the alpha component (1.0 by default)
  79220. * @returns a new Color4 object
  79221. */
  79222. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79223. /**
  79224. * Creates a new Color4 from the starting index element of the given array
  79225. * @param array defines the source array to read from
  79226. * @param offset defines the offset in the source array
  79227. * @returns a new Color4 object
  79228. */
  79229. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79230. /**
  79231. * Creates a new Color3 from integer values (< 256)
  79232. * @param r defines the red component to read from (value between 0 and 255)
  79233. * @param g defines the green component to read from (value between 0 and 255)
  79234. * @param b defines the blue component to read from (value between 0 and 255)
  79235. * @param a defines the alpha component to read from (value between 0 and 255)
  79236. * @returns a new Color3 object
  79237. */
  79238. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79239. /**
  79240. * Check the content of a given array and convert it to an array containing RGBA data
  79241. * If the original array was already containing count * 4 values then it is returned directly
  79242. * @param colors defines the array to check
  79243. * @param count defines the number of RGBA data to expect
  79244. * @returns an array containing count * 4 values (RGBA)
  79245. */
  79246. static CheckColors4(colors: number[], count: number): number[];
  79247. }
  79248. /**
  79249. * @hidden
  79250. */
  79251. export class TmpColors {
  79252. static Color3: Color3[];
  79253. static Color4: Color4[];
  79254. }
  79255. }
  79256. declare module BABYLON {
  79257. /**
  79258. * Defines an interface which represents an animation key frame
  79259. */
  79260. export interface IAnimationKey {
  79261. /**
  79262. * Frame of the key frame
  79263. */
  79264. frame: number;
  79265. /**
  79266. * Value at the specifies key frame
  79267. */
  79268. value: any;
  79269. /**
  79270. * The input tangent for the cubic hermite spline
  79271. */
  79272. inTangent?: any;
  79273. /**
  79274. * The output tangent for the cubic hermite spline
  79275. */
  79276. outTangent?: any;
  79277. /**
  79278. * The animation interpolation type
  79279. */
  79280. interpolation?: AnimationKeyInterpolation;
  79281. }
  79282. /**
  79283. * Enum for the animation key frame interpolation type
  79284. */
  79285. export enum AnimationKeyInterpolation {
  79286. /**
  79287. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79288. */
  79289. STEP = 1
  79290. }
  79291. }
  79292. declare module BABYLON {
  79293. /**
  79294. * Represents the range of an animation
  79295. */
  79296. export class AnimationRange {
  79297. /**The name of the animation range**/
  79298. name: string;
  79299. /**The starting frame of the animation */
  79300. from: number;
  79301. /**The ending frame of the animation*/
  79302. to: number;
  79303. /**
  79304. * Initializes the range of an animation
  79305. * @param name The name of the animation range
  79306. * @param from The starting frame of the animation
  79307. * @param to The ending frame of the animation
  79308. */
  79309. constructor(
  79310. /**The name of the animation range**/
  79311. name: string,
  79312. /**The starting frame of the animation */
  79313. from: number,
  79314. /**The ending frame of the animation*/
  79315. to: number);
  79316. /**
  79317. * Makes a copy of the animation range
  79318. * @returns A copy of the animation range
  79319. */
  79320. clone(): AnimationRange;
  79321. }
  79322. }
  79323. declare module BABYLON {
  79324. /**
  79325. * Composed of a frame, and an action function
  79326. */
  79327. export class AnimationEvent {
  79328. /** The frame for which the event is triggered **/
  79329. frame: number;
  79330. /** The event to perform when triggered **/
  79331. action: (currentFrame: number) => void;
  79332. /** Specifies if the event should be triggered only once**/
  79333. onlyOnce?: boolean | undefined;
  79334. /**
  79335. * Specifies if the animation event is done
  79336. */
  79337. isDone: boolean;
  79338. /**
  79339. * Initializes the animation event
  79340. * @param frame The frame for which the event is triggered
  79341. * @param action The event to perform when triggered
  79342. * @param onlyOnce Specifies if the event should be triggered only once
  79343. */
  79344. constructor(
  79345. /** The frame for which the event is triggered **/
  79346. frame: number,
  79347. /** The event to perform when triggered **/
  79348. action: (currentFrame: number) => void,
  79349. /** Specifies if the event should be triggered only once**/
  79350. onlyOnce?: boolean | undefined);
  79351. /** @hidden */
  79352. _clone(): AnimationEvent;
  79353. }
  79354. }
  79355. declare module BABYLON {
  79356. /**
  79357. * Interface used to define a behavior
  79358. */
  79359. export interface Behavior<T> {
  79360. /** gets or sets behavior's name */
  79361. name: string;
  79362. /**
  79363. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79364. */
  79365. init(): void;
  79366. /**
  79367. * Called when the behavior is attached to a target
  79368. * @param target defines the target where the behavior is attached to
  79369. */
  79370. attach(target: T): void;
  79371. /**
  79372. * Called when the behavior is detached from its target
  79373. */
  79374. detach(): void;
  79375. }
  79376. /**
  79377. * Interface implemented by classes supporting behaviors
  79378. */
  79379. export interface IBehaviorAware<T> {
  79380. /**
  79381. * Attach a behavior
  79382. * @param behavior defines the behavior to attach
  79383. * @returns the current host
  79384. */
  79385. addBehavior(behavior: Behavior<T>): T;
  79386. /**
  79387. * Remove a behavior from the current object
  79388. * @param behavior defines the behavior to detach
  79389. * @returns the current host
  79390. */
  79391. removeBehavior(behavior: Behavior<T>): T;
  79392. /**
  79393. * Gets a behavior using its name to search
  79394. * @param name defines the name to search
  79395. * @returns the behavior or null if not found
  79396. */
  79397. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79398. }
  79399. }
  79400. declare module BABYLON {
  79401. /**
  79402. * Defines an array and its length.
  79403. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79404. */
  79405. export interface ISmartArrayLike<T> {
  79406. /**
  79407. * The data of the array.
  79408. */
  79409. data: Array<T>;
  79410. /**
  79411. * The active length of the array.
  79412. */
  79413. length: number;
  79414. }
  79415. /**
  79416. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79417. */
  79418. export class SmartArray<T> implements ISmartArrayLike<T> {
  79419. /**
  79420. * The full set of data from the array.
  79421. */
  79422. data: Array<T>;
  79423. /**
  79424. * The active length of the array.
  79425. */
  79426. length: number;
  79427. protected _id: number;
  79428. /**
  79429. * Instantiates a Smart Array.
  79430. * @param capacity defines the default capacity of the array.
  79431. */
  79432. constructor(capacity: number);
  79433. /**
  79434. * Pushes a value at the end of the active data.
  79435. * @param value defines the object to push in the array.
  79436. */
  79437. push(value: T): void;
  79438. /**
  79439. * Iterates over the active data and apply the lambda to them.
  79440. * @param func defines the action to apply on each value.
  79441. */
  79442. forEach(func: (content: T) => void): void;
  79443. /**
  79444. * Sorts the full sets of data.
  79445. * @param compareFn defines the comparison function to apply.
  79446. */
  79447. sort(compareFn: (a: T, b: T) => number): void;
  79448. /**
  79449. * Resets the active data to an empty array.
  79450. */
  79451. reset(): void;
  79452. /**
  79453. * Releases all the data from the array as well as the array.
  79454. */
  79455. dispose(): void;
  79456. /**
  79457. * Concats the active data with a given array.
  79458. * @param array defines the data to concatenate with.
  79459. */
  79460. concat(array: any): void;
  79461. /**
  79462. * Returns the position of a value in the active data.
  79463. * @param value defines the value to find the index for
  79464. * @returns the index if found in the active data otherwise -1
  79465. */
  79466. indexOf(value: T): number;
  79467. /**
  79468. * Returns whether an element is part of the active data.
  79469. * @param value defines the value to look for
  79470. * @returns true if found in the active data otherwise false
  79471. */
  79472. contains(value: T): boolean;
  79473. private static _GlobalId;
  79474. }
  79475. /**
  79476. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79477. * The data in this array can only be present once
  79478. */
  79479. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79480. private _duplicateId;
  79481. /**
  79482. * Pushes a value at the end of the active data.
  79483. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79484. * @param value defines the object to push in the array.
  79485. */
  79486. push(value: T): void;
  79487. /**
  79488. * Pushes a value at the end of the active data.
  79489. * If the data is already present, it won t be added again
  79490. * @param value defines the object to push in the array.
  79491. * @returns true if added false if it was already present
  79492. */
  79493. pushNoDuplicate(value: T): boolean;
  79494. /**
  79495. * Resets the active data to an empty array.
  79496. */
  79497. reset(): void;
  79498. /**
  79499. * Concats the active data with a given array.
  79500. * This ensures no dupplicate will be present in the result.
  79501. * @param array defines the data to concatenate with.
  79502. */
  79503. concatWithNoDuplicate(array: any): void;
  79504. }
  79505. }
  79506. declare module BABYLON {
  79507. /**
  79508. * @ignore
  79509. * This is a list of all the different input types that are available in the application.
  79510. * Fo instance: ArcRotateCameraGamepadInput...
  79511. */
  79512. export var CameraInputTypes: {};
  79513. /**
  79514. * This is the contract to implement in order to create a new input class.
  79515. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79516. */
  79517. export interface ICameraInput<TCamera extends Camera> {
  79518. /**
  79519. * Defines the camera the input is attached to.
  79520. */
  79521. camera: Nullable<TCamera>;
  79522. /**
  79523. * Gets the class name of the current intput.
  79524. * @returns the class name
  79525. */
  79526. getClassName(): string;
  79527. /**
  79528. * Get the friendly name associated with the input class.
  79529. * @returns the input friendly name
  79530. */
  79531. getSimpleName(): string;
  79532. /**
  79533. * Attach the input controls to a specific dom element to get the input from.
  79534. * @param element Defines the element the controls should be listened from
  79535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79536. */
  79537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79538. /**
  79539. * Detach the current controls from the specified dom element.
  79540. * @param element Defines the element to stop listening the inputs from
  79541. */
  79542. detachControl(element: Nullable<HTMLElement>): void;
  79543. /**
  79544. * Update the current camera state depending on the inputs that have been used this frame.
  79545. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79546. */
  79547. checkInputs?: () => void;
  79548. }
  79549. /**
  79550. * Represents a map of input types to input instance or input index to input instance.
  79551. */
  79552. export interface CameraInputsMap<TCamera extends Camera> {
  79553. /**
  79554. * Accessor to the input by input type.
  79555. */
  79556. [name: string]: ICameraInput<TCamera>;
  79557. /**
  79558. * Accessor to the input by input index.
  79559. */
  79560. [idx: number]: ICameraInput<TCamera>;
  79561. }
  79562. /**
  79563. * This represents the input manager used within a camera.
  79564. * It helps dealing with all the different kind of input attached to a camera.
  79565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79566. */
  79567. export class CameraInputsManager<TCamera extends Camera> {
  79568. /**
  79569. * Defines the list of inputs attahed to the camera.
  79570. */
  79571. attached: CameraInputsMap<TCamera>;
  79572. /**
  79573. * Defines the dom element the camera is collecting inputs from.
  79574. * This is null if the controls have not been attached.
  79575. */
  79576. attachedElement: Nullable<HTMLElement>;
  79577. /**
  79578. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79579. */
  79580. noPreventDefault: boolean;
  79581. /**
  79582. * Defined the camera the input manager belongs to.
  79583. */
  79584. camera: TCamera;
  79585. /**
  79586. * Update the current camera state depending on the inputs that have been used this frame.
  79587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79588. */
  79589. checkInputs: () => void;
  79590. /**
  79591. * Instantiate a new Camera Input Manager.
  79592. * @param camera Defines the camera the input manager blongs to
  79593. */
  79594. constructor(camera: TCamera);
  79595. /**
  79596. * Add an input method to a camera
  79597. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79598. * @param input camera input method
  79599. */
  79600. add(input: ICameraInput<TCamera>): void;
  79601. /**
  79602. * Remove a specific input method from a camera
  79603. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79604. * @param inputToRemove camera input method
  79605. */
  79606. remove(inputToRemove: ICameraInput<TCamera>): void;
  79607. /**
  79608. * Remove a specific input type from a camera
  79609. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79610. * @param inputType the type of the input to remove
  79611. */
  79612. removeByType(inputType: string): void;
  79613. private _addCheckInputs;
  79614. /**
  79615. * Attach the input controls to the currently attached dom element to listen the events from.
  79616. * @param input Defines the input to attach
  79617. */
  79618. attachInput(input: ICameraInput<TCamera>): void;
  79619. /**
  79620. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79621. * @param element Defines the dom element to collect the events from
  79622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79623. */
  79624. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79625. /**
  79626. * Detach the current manager inputs controls from a specific dom element.
  79627. * @param element Defines the dom element to collect the events from
  79628. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79629. */
  79630. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79631. /**
  79632. * Rebuild the dynamic inputCheck function from the current list of
  79633. * defined inputs in the manager.
  79634. */
  79635. rebuildInputCheck(): void;
  79636. /**
  79637. * Remove all attached input methods from a camera
  79638. */
  79639. clear(): void;
  79640. /**
  79641. * Serialize the current input manager attached to a camera.
  79642. * This ensures than once parsed,
  79643. * the input associated to the camera will be identical to the current ones
  79644. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79645. */
  79646. serialize(serializedCamera: any): void;
  79647. /**
  79648. * Parses an input manager serialized JSON to restore the previous list of inputs
  79649. * and states associated to a camera.
  79650. * @param parsedCamera Defines the JSON to parse
  79651. */
  79652. parse(parsedCamera: any): void;
  79653. }
  79654. }
  79655. declare module BABYLON {
  79656. /**
  79657. * Class used to store data that will be store in GPU memory
  79658. */
  79659. export class Buffer {
  79660. private _engine;
  79661. private _buffer;
  79662. /** @hidden */
  79663. _data: Nullable<DataArray>;
  79664. private _updatable;
  79665. private _instanced;
  79666. private _divisor;
  79667. /**
  79668. * Gets the byte stride.
  79669. */
  79670. readonly byteStride: number;
  79671. /**
  79672. * Constructor
  79673. * @param engine the engine
  79674. * @param data the data to use for this buffer
  79675. * @param updatable whether the data is updatable
  79676. * @param stride the stride (optional)
  79677. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79678. * @param instanced whether the buffer is instanced (optional)
  79679. * @param useBytes set to true if the stride in in bytes (optional)
  79680. * @param divisor sets an optional divisor for instances (1 by default)
  79681. */
  79682. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79683. /**
  79684. * Create a new VertexBuffer based on the current buffer
  79685. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79686. * @param offset defines offset in the buffer (0 by default)
  79687. * @param size defines the size in floats of attributes (position is 3 for instance)
  79688. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79689. * @param instanced defines if the vertex buffer contains indexed data
  79690. * @param useBytes defines if the offset and stride are in bytes *
  79691. * @param divisor sets an optional divisor for instances (1 by default)
  79692. * @returns the new vertex buffer
  79693. */
  79694. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79695. /**
  79696. * Gets a boolean indicating if the Buffer is updatable?
  79697. * @returns true if the buffer is updatable
  79698. */
  79699. isUpdatable(): boolean;
  79700. /**
  79701. * Gets current buffer's data
  79702. * @returns a DataArray or null
  79703. */
  79704. getData(): Nullable<DataArray>;
  79705. /**
  79706. * Gets underlying native buffer
  79707. * @returns underlying native buffer
  79708. */
  79709. getBuffer(): Nullable<DataBuffer>;
  79710. /**
  79711. * Gets the stride in float32 units (i.e. byte stride / 4).
  79712. * May not be an integer if the byte stride is not divisible by 4.
  79713. * @returns the stride in float32 units
  79714. * @deprecated Please use byteStride instead.
  79715. */
  79716. getStrideSize(): number;
  79717. /**
  79718. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79719. * @param data defines the data to store
  79720. */
  79721. create(data?: Nullable<DataArray>): void;
  79722. /** @hidden */
  79723. _rebuild(): void;
  79724. /**
  79725. * Update current buffer data
  79726. * @param data defines the data to store
  79727. */
  79728. update(data: DataArray): void;
  79729. /**
  79730. * Updates the data directly.
  79731. * @param data the new data
  79732. * @param offset the new offset
  79733. * @param vertexCount the vertex count (optional)
  79734. * @param useBytes set to true if the offset is in bytes
  79735. */
  79736. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79737. /**
  79738. * Release all resources
  79739. */
  79740. dispose(): void;
  79741. }
  79742. /**
  79743. * Specialized buffer used to store vertex data
  79744. */
  79745. export class VertexBuffer {
  79746. /** @hidden */
  79747. _buffer: Buffer;
  79748. private _kind;
  79749. private _size;
  79750. private _ownsBuffer;
  79751. private _instanced;
  79752. private _instanceDivisor;
  79753. /**
  79754. * The byte type.
  79755. */
  79756. static readonly BYTE: number;
  79757. /**
  79758. * The unsigned byte type.
  79759. */
  79760. static readonly UNSIGNED_BYTE: number;
  79761. /**
  79762. * The short type.
  79763. */
  79764. static readonly SHORT: number;
  79765. /**
  79766. * The unsigned short type.
  79767. */
  79768. static readonly UNSIGNED_SHORT: number;
  79769. /**
  79770. * The integer type.
  79771. */
  79772. static readonly INT: number;
  79773. /**
  79774. * The unsigned integer type.
  79775. */
  79776. static readonly UNSIGNED_INT: number;
  79777. /**
  79778. * The float type.
  79779. */
  79780. static readonly FLOAT: number;
  79781. /**
  79782. * Gets or sets the instance divisor when in instanced mode
  79783. */
  79784. get instanceDivisor(): number;
  79785. set instanceDivisor(value: number);
  79786. /**
  79787. * Gets the byte stride.
  79788. */
  79789. readonly byteStride: number;
  79790. /**
  79791. * Gets the byte offset.
  79792. */
  79793. readonly byteOffset: number;
  79794. /**
  79795. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79796. */
  79797. readonly normalized: boolean;
  79798. /**
  79799. * Gets the data type of each component in the array.
  79800. */
  79801. readonly type: number;
  79802. /**
  79803. * Constructor
  79804. * @param engine the engine
  79805. * @param data the data to use for this vertex buffer
  79806. * @param kind the vertex buffer kind
  79807. * @param updatable whether the data is updatable
  79808. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79809. * @param stride the stride (optional)
  79810. * @param instanced whether the buffer is instanced (optional)
  79811. * @param offset the offset of the data (optional)
  79812. * @param size the number of components (optional)
  79813. * @param type the type of the component (optional)
  79814. * @param normalized whether the data contains normalized data (optional)
  79815. * @param useBytes set to true if stride and offset are in bytes (optional)
  79816. * @param divisor defines the instance divisor to use (1 by default)
  79817. */
  79818. 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);
  79819. /** @hidden */
  79820. _rebuild(): void;
  79821. /**
  79822. * Returns the kind of the VertexBuffer (string)
  79823. * @returns a string
  79824. */
  79825. getKind(): string;
  79826. /**
  79827. * Gets a boolean indicating if the VertexBuffer is updatable?
  79828. * @returns true if the buffer is updatable
  79829. */
  79830. isUpdatable(): boolean;
  79831. /**
  79832. * Gets current buffer's data
  79833. * @returns a DataArray or null
  79834. */
  79835. getData(): Nullable<DataArray>;
  79836. /**
  79837. * Gets underlying native buffer
  79838. * @returns underlying native buffer
  79839. */
  79840. getBuffer(): Nullable<DataBuffer>;
  79841. /**
  79842. * Gets the stride in float32 units (i.e. byte stride / 4).
  79843. * May not be an integer if the byte stride is not divisible by 4.
  79844. * @returns the stride in float32 units
  79845. * @deprecated Please use byteStride instead.
  79846. */
  79847. getStrideSize(): number;
  79848. /**
  79849. * Returns the offset as a multiple of the type byte length.
  79850. * @returns the offset in bytes
  79851. * @deprecated Please use byteOffset instead.
  79852. */
  79853. getOffset(): number;
  79854. /**
  79855. * Returns the number of components per vertex attribute (integer)
  79856. * @returns the size in float
  79857. */
  79858. getSize(): number;
  79859. /**
  79860. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79861. * @returns true if this buffer is instanced
  79862. */
  79863. getIsInstanced(): boolean;
  79864. /**
  79865. * Returns the instancing divisor, zero for non-instanced (integer).
  79866. * @returns a number
  79867. */
  79868. getInstanceDivisor(): number;
  79869. /**
  79870. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79871. * @param data defines the data to store
  79872. */
  79873. create(data?: DataArray): void;
  79874. /**
  79875. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79876. * This function will create a new buffer if the current one is not updatable
  79877. * @param data defines the data to store
  79878. */
  79879. update(data: DataArray): void;
  79880. /**
  79881. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79882. * Returns the directly updated WebGLBuffer.
  79883. * @param data the new data
  79884. * @param offset the new offset
  79885. * @param useBytes set to true if the offset is in bytes
  79886. */
  79887. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79888. /**
  79889. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79890. */
  79891. dispose(): void;
  79892. /**
  79893. * Enumerates each value of this vertex buffer as numbers.
  79894. * @param count the number of values to enumerate
  79895. * @param callback the callback function called for each value
  79896. */
  79897. forEach(count: number, callback: (value: number, index: number) => void): void;
  79898. /**
  79899. * Positions
  79900. */
  79901. static readonly PositionKind: string;
  79902. /**
  79903. * Normals
  79904. */
  79905. static readonly NormalKind: string;
  79906. /**
  79907. * Tangents
  79908. */
  79909. static readonly TangentKind: string;
  79910. /**
  79911. * Texture coordinates
  79912. */
  79913. static readonly UVKind: string;
  79914. /**
  79915. * Texture coordinates 2
  79916. */
  79917. static readonly UV2Kind: string;
  79918. /**
  79919. * Texture coordinates 3
  79920. */
  79921. static readonly UV3Kind: string;
  79922. /**
  79923. * Texture coordinates 4
  79924. */
  79925. static readonly UV4Kind: string;
  79926. /**
  79927. * Texture coordinates 5
  79928. */
  79929. static readonly UV5Kind: string;
  79930. /**
  79931. * Texture coordinates 6
  79932. */
  79933. static readonly UV6Kind: string;
  79934. /**
  79935. * Colors
  79936. */
  79937. static readonly ColorKind: string;
  79938. /**
  79939. * Matrix indices (for bones)
  79940. */
  79941. static readonly MatricesIndicesKind: string;
  79942. /**
  79943. * Matrix weights (for bones)
  79944. */
  79945. static readonly MatricesWeightsKind: string;
  79946. /**
  79947. * Additional matrix indices (for bones)
  79948. */
  79949. static readonly MatricesIndicesExtraKind: string;
  79950. /**
  79951. * Additional matrix weights (for bones)
  79952. */
  79953. static readonly MatricesWeightsExtraKind: string;
  79954. /**
  79955. * Deduces the stride given a kind.
  79956. * @param kind The kind string to deduce
  79957. * @returns The deduced stride
  79958. */
  79959. static DeduceStride(kind: string): number;
  79960. /**
  79961. * Gets the byte length of the given type.
  79962. * @param type the type
  79963. * @returns the number of bytes
  79964. */
  79965. static GetTypeByteLength(type: number): number;
  79966. /**
  79967. * Enumerates each value of the given parameters as numbers.
  79968. * @param data the data to enumerate
  79969. * @param byteOffset the byte offset of the data
  79970. * @param byteStride the byte stride of the data
  79971. * @param componentCount the number of components per element
  79972. * @param componentType the type of the component
  79973. * @param count the number of values to enumerate
  79974. * @param normalized whether the data is normalized
  79975. * @param callback the callback function called for each value
  79976. */
  79977. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79978. private static _GetFloatValue;
  79979. }
  79980. }
  79981. declare module BABYLON {
  79982. /**
  79983. * @hidden
  79984. */
  79985. export class IntersectionInfo {
  79986. bu: Nullable<number>;
  79987. bv: Nullable<number>;
  79988. distance: number;
  79989. faceId: number;
  79990. subMeshId: number;
  79991. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79992. }
  79993. }
  79994. declare module BABYLON {
  79995. /**
  79996. * Represens a plane by the equation ax + by + cz + d = 0
  79997. */
  79998. export class Plane {
  79999. private static _TmpMatrix;
  80000. /**
  80001. * Normal of the plane (a,b,c)
  80002. */
  80003. normal: Vector3;
  80004. /**
  80005. * d component of the plane
  80006. */
  80007. d: number;
  80008. /**
  80009. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80010. * @param a a component of the plane
  80011. * @param b b component of the plane
  80012. * @param c c component of the plane
  80013. * @param d d component of the plane
  80014. */
  80015. constructor(a: number, b: number, c: number, d: number);
  80016. /**
  80017. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80018. */
  80019. asArray(): number[];
  80020. /**
  80021. * @returns a new plane copied from the current Plane.
  80022. */
  80023. clone(): Plane;
  80024. /**
  80025. * @returns the string "Plane".
  80026. */
  80027. getClassName(): string;
  80028. /**
  80029. * @returns the Plane hash code.
  80030. */
  80031. getHashCode(): number;
  80032. /**
  80033. * Normalize the current Plane in place.
  80034. * @returns the updated Plane.
  80035. */
  80036. normalize(): Plane;
  80037. /**
  80038. * Applies a transformation the plane and returns the result
  80039. * @param transformation the transformation matrix to be applied to the plane
  80040. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80041. */
  80042. transform(transformation: DeepImmutable<Matrix>): Plane;
  80043. /**
  80044. * Calcualtte the dot product between the point and the plane normal
  80045. * @param point point to calculate the dot product with
  80046. * @returns the dot product (float) of the point coordinates and the plane normal.
  80047. */
  80048. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80049. /**
  80050. * Updates the current Plane from the plane defined by the three given points.
  80051. * @param point1 one of the points used to contruct the plane
  80052. * @param point2 one of the points used to contruct the plane
  80053. * @param point3 one of the points used to contruct the plane
  80054. * @returns the updated Plane.
  80055. */
  80056. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80057. /**
  80058. * Checks if the plane is facing a given direction
  80059. * @param direction the direction to check if the plane is facing
  80060. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80061. * @returns True is the vector "direction" is the same side than the plane normal.
  80062. */
  80063. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80064. /**
  80065. * Calculates the distance to a point
  80066. * @param point point to calculate distance to
  80067. * @returns the signed distance (float) from the given point to the Plane.
  80068. */
  80069. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80070. /**
  80071. * Creates a plane from an array
  80072. * @param array the array to create a plane from
  80073. * @returns a new Plane from the given array.
  80074. */
  80075. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80076. /**
  80077. * Creates a plane from three points
  80078. * @param point1 point used to create the plane
  80079. * @param point2 point used to create the plane
  80080. * @param point3 point used to create the plane
  80081. * @returns a new Plane defined by the three given points.
  80082. */
  80083. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80084. /**
  80085. * Creates a plane from an origin point and a normal
  80086. * @param origin origin of the plane to be constructed
  80087. * @param normal normal of the plane to be constructed
  80088. * @returns a new Plane the normal vector to this plane at the given origin point.
  80089. * Note : the vector "normal" is updated because normalized.
  80090. */
  80091. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80092. /**
  80093. * Calculates the distance from a plane and a point
  80094. * @param origin origin of the plane to be constructed
  80095. * @param normal normal of the plane to be constructed
  80096. * @param point point to calculate distance to
  80097. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80098. */
  80099. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80100. }
  80101. }
  80102. declare module BABYLON {
  80103. /**
  80104. * Class used to store bounding sphere information
  80105. */
  80106. export class BoundingSphere {
  80107. /**
  80108. * Gets the center of the bounding sphere in local space
  80109. */
  80110. readonly center: Vector3;
  80111. /**
  80112. * Radius of the bounding sphere in local space
  80113. */
  80114. radius: number;
  80115. /**
  80116. * Gets the center of the bounding sphere in world space
  80117. */
  80118. readonly centerWorld: Vector3;
  80119. /**
  80120. * Radius of the bounding sphere in world space
  80121. */
  80122. radiusWorld: number;
  80123. /**
  80124. * Gets the minimum vector in local space
  80125. */
  80126. readonly minimum: Vector3;
  80127. /**
  80128. * Gets the maximum vector in local space
  80129. */
  80130. readonly maximum: Vector3;
  80131. private _worldMatrix;
  80132. private static readonly TmpVector3;
  80133. /**
  80134. * Creates a new bounding sphere
  80135. * @param min defines the minimum vector (in local space)
  80136. * @param max defines the maximum vector (in local space)
  80137. * @param worldMatrix defines the new world matrix
  80138. */
  80139. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80140. /**
  80141. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80142. * @param min defines the new minimum vector (in local space)
  80143. * @param max defines the new maximum vector (in local space)
  80144. * @param worldMatrix defines the new world matrix
  80145. */
  80146. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80147. /**
  80148. * Scale the current bounding sphere by applying a scale factor
  80149. * @param factor defines the scale factor to apply
  80150. * @returns the current bounding box
  80151. */
  80152. scale(factor: number): BoundingSphere;
  80153. /**
  80154. * Gets the world matrix of the bounding box
  80155. * @returns a matrix
  80156. */
  80157. getWorldMatrix(): DeepImmutable<Matrix>;
  80158. /** @hidden */
  80159. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80160. /**
  80161. * Tests if the bounding sphere is intersecting the frustum planes
  80162. * @param frustumPlanes defines the frustum planes to test
  80163. * @returns true if there is an intersection
  80164. */
  80165. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80166. /**
  80167. * Tests if the bounding sphere center is in between the frustum planes.
  80168. * Used for optimistic fast inclusion.
  80169. * @param frustumPlanes defines the frustum planes to test
  80170. * @returns true if the sphere center is in between the frustum planes
  80171. */
  80172. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80173. /**
  80174. * Tests if a point is inside the bounding sphere
  80175. * @param point defines the point to test
  80176. * @returns true if the point is inside the bounding sphere
  80177. */
  80178. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80179. /**
  80180. * Checks if two sphere intersct
  80181. * @param sphere0 sphere 0
  80182. * @param sphere1 sphere 1
  80183. * @returns true if the speres intersect
  80184. */
  80185. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80186. }
  80187. }
  80188. declare module BABYLON {
  80189. /**
  80190. * Class used to store bounding box information
  80191. */
  80192. export class BoundingBox implements ICullable {
  80193. /**
  80194. * Gets the 8 vectors representing the bounding box in local space
  80195. */
  80196. readonly vectors: Vector3[];
  80197. /**
  80198. * Gets the center of the bounding box in local space
  80199. */
  80200. readonly center: Vector3;
  80201. /**
  80202. * Gets the center of the bounding box in world space
  80203. */
  80204. readonly centerWorld: Vector3;
  80205. /**
  80206. * Gets the extend size in local space
  80207. */
  80208. readonly extendSize: Vector3;
  80209. /**
  80210. * Gets the extend size in world space
  80211. */
  80212. readonly extendSizeWorld: Vector3;
  80213. /**
  80214. * Gets the OBB (object bounding box) directions
  80215. */
  80216. readonly directions: Vector3[];
  80217. /**
  80218. * Gets the 8 vectors representing the bounding box in world space
  80219. */
  80220. readonly vectorsWorld: Vector3[];
  80221. /**
  80222. * Gets the minimum vector in world space
  80223. */
  80224. readonly minimumWorld: Vector3;
  80225. /**
  80226. * Gets the maximum vector in world space
  80227. */
  80228. readonly maximumWorld: Vector3;
  80229. /**
  80230. * Gets the minimum vector in local space
  80231. */
  80232. readonly minimum: Vector3;
  80233. /**
  80234. * Gets the maximum vector in local space
  80235. */
  80236. readonly maximum: Vector3;
  80237. private _worldMatrix;
  80238. private static readonly TmpVector3;
  80239. /**
  80240. * @hidden
  80241. */
  80242. _tag: number;
  80243. /**
  80244. * Creates a new bounding box
  80245. * @param min defines the minimum vector (in local space)
  80246. * @param max defines the maximum vector (in local space)
  80247. * @param worldMatrix defines the new world matrix
  80248. */
  80249. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80250. /**
  80251. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80252. * @param min defines the new minimum vector (in local space)
  80253. * @param max defines the new maximum vector (in local space)
  80254. * @param worldMatrix defines the new world matrix
  80255. */
  80256. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80257. /**
  80258. * Scale the current bounding box by applying a scale factor
  80259. * @param factor defines the scale factor to apply
  80260. * @returns the current bounding box
  80261. */
  80262. scale(factor: number): BoundingBox;
  80263. /**
  80264. * Gets the world matrix of the bounding box
  80265. * @returns a matrix
  80266. */
  80267. getWorldMatrix(): DeepImmutable<Matrix>;
  80268. /** @hidden */
  80269. _update(world: DeepImmutable<Matrix>): void;
  80270. /**
  80271. * Tests if the bounding box is intersecting the frustum planes
  80272. * @param frustumPlanes defines the frustum planes to test
  80273. * @returns true if there is an intersection
  80274. */
  80275. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80276. /**
  80277. * Tests if the bounding box is entirely inside the frustum planes
  80278. * @param frustumPlanes defines the frustum planes to test
  80279. * @returns true if there is an inclusion
  80280. */
  80281. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80282. /**
  80283. * Tests if a point is inside the bounding box
  80284. * @param point defines the point to test
  80285. * @returns true if the point is inside the bounding box
  80286. */
  80287. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80288. /**
  80289. * Tests if the bounding box intersects with a bounding sphere
  80290. * @param sphere defines the sphere to test
  80291. * @returns true if there is an intersection
  80292. */
  80293. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80294. /**
  80295. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80296. * @param min defines the min vector to use
  80297. * @param max defines the max vector to use
  80298. * @returns true if there is an intersection
  80299. */
  80300. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80301. /**
  80302. * Tests if two bounding boxes are intersections
  80303. * @param box0 defines the first box to test
  80304. * @param box1 defines the second box to test
  80305. * @returns true if there is an intersection
  80306. */
  80307. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80308. /**
  80309. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80310. * @param minPoint defines the minimum vector of the bounding box
  80311. * @param maxPoint defines the maximum vector of the bounding box
  80312. * @param sphereCenter defines the sphere center
  80313. * @param sphereRadius defines the sphere radius
  80314. * @returns true if there is an intersection
  80315. */
  80316. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80317. /**
  80318. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80319. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80320. * @param frustumPlanes defines the frustum planes to test
  80321. * @return true if there is an inclusion
  80322. */
  80323. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80324. /**
  80325. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80326. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80327. * @param frustumPlanes defines the frustum planes to test
  80328. * @return true if there is an intersection
  80329. */
  80330. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80331. }
  80332. }
  80333. declare module BABYLON {
  80334. /** @hidden */
  80335. export class Collider {
  80336. /** Define if a collision was found */
  80337. collisionFound: boolean;
  80338. /**
  80339. * Define last intersection point in local space
  80340. */
  80341. intersectionPoint: Vector3;
  80342. /**
  80343. * Define last collided mesh
  80344. */
  80345. collidedMesh: Nullable<AbstractMesh>;
  80346. private _collisionPoint;
  80347. private _planeIntersectionPoint;
  80348. private _tempVector;
  80349. private _tempVector2;
  80350. private _tempVector3;
  80351. private _tempVector4;
  80352. private _edge;
  80353. private _baseToVertex;
  80354. private _destinationPoint;
  80355. private _slidePlaneNormal;
  80356. private _displacementVector;
  80357. /** @hidden */
  80358. _radius: Vector3;
  80359. /** @hidden */
  80360. _retry: number;
  80361. private _velocity;
  80362. private _basePoint;
  80363. private _epsilon;
  80364. /** @hidden */
  80365. _velocityWorldLength: number;
  80366. /** @hidden */
  80367. _basePointWorld: Vector3;
  80368. private _velocityWorld;
  80369. private _normalizedVelocity;
  80370. /** @hidden */
  80371. _initialVelocity: Vector3;
  80372. /** @hidden */
  80373. _initialPosition: Vector3;
  80374. private _nearestDistance;
  80375. private _collisionMask;
  80376. get collisionMask(): number;
  80377. set collisionMask(mask: number);
  80378. /**
  80379. * Gets the plane normal used to compute the sliding response (in local space)
  80380. */
  80381. get slidePlaneNormal(): Vector3;
  80382. /** @hidden */
  80383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80384. /** @hidden */
  80385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80386. /** @hidden */
  80387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80388. /** @hidden */
  80389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80390. /** @hidden */
  80391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80392. /** @hidden */
  80393. _getResponse(pos: Vector3, vel: Vector3): void;
  80394. }
  80395. }
  80396. declare module BABYLON {
  80397. /**
  80398. * Interface for cullable objects
  80399. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80400. */
  80401. export interface ICullable {
  80402. /**
  80403. * Checks if the object or part of the object is in the frustum
  80404. * @param frustumPlanes Camera near/planes
  80405. * @returns true if the object is in frustum otherwise false
  80406. */
  80407. isInFrustum(frustumPlanes: Plane[]): boolean;
  80408. /**
  80409. * Checks if a cullable object (mesh...) is in the camera frustum
  80410. * Unlike isInFrustum this cheks the full bounding box
  80411. * @param frustumPlanes Camera near/planes
  80412. * @returns true if the object is in frustum otherwise false
  80413. */
  80414. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80415. }
  80416. /**
  80417. * Info for a bounding data of a mesh
  80418. */
  80419. export class BoundingInfo implements ICullable {
  80420. /**
  80421. * Bounding box for the mesh
  80422. */
  80423. readonly boundingBox: BoundingBox;
  80424. /**
  80425. * Bounding sphere for the mesh
  80426. */
  80427. readonly boundingSphere: BoundingSphere;
  80428. private _isLocked;
  80429. private static readonly TmpVector3;
  80430. /**
  80431. * Constructs bounding info
  80432. * @param minimum min vector of the bounding box/sphere
  80433. * @param maximum max vector of the bounding box/sphere
  80434. * @param worldMatrix defines the new world matrix
  80435. */
  80436. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80437. /**
  80438. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80439. * @param min defines the new minimum vector (in local space)
  80440. * @param max defines the new maximum vector (in local space)
  80441. * @param worldMatrix defines the new world matrix
  80442. */
  80443. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80444. /**
  80445. * min vector of the bounding box/sphere
  80446. */
  80447. get minimum(): Vector3;
  80448. /**
  80449. * max vector of the bounding box/sphere
  80450. */
  80451. get maximum(): Vector3;
  80452. /**
  80453. * If the info is locked and won't be updated to avoid perf overhead
  80454. */
  80455. get isLocked(): boolean;
  80456. set isLocked(value: boolean);
  80457. /**
  80458. * Updates the bounding sphere and box
  80459. * @param world world matrix to be used to update
  80460. */
  80461. update(world: DeepImmutable<Matrix>): void;
  80462. /**
  80463. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80464. * @param center New center of the bounding info
  80465. * @param extend New extend of the bounding info
  80466. * @returns the current bounding info
  80467. */
  80468. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80469. /**
  80470. * Scale the current bounding info by applying a scale factor
  80471. * @param factor defines the scale factor to apply
  80472. * @returns the current bounding info
  80473. */
  80474. scale(factor: number): BoundingInfo;
  80475. /**
  80476. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80477. * @param frustumPlanes defines the frustum to test
  80478. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80479. * @returns true if the bounding info is in the frustum planes
  80480. */
  80481. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80482. /**
  80483. * Gets the world distance between the min and max points of the bounding box
  80484. */
  80485. get diagonalLength(): number;
  80486. /**
  80487. * Checks if a cullable object (mesh...) is in the camera frustum
  80488. * Unlike isInFrustum this cheks the full bounding box
  80489. * @param frustumPlanes Camera near/planes
  80490. * @returns true if the object is in frustum otherwise false
  80491. */
  80492. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80493. /** @hidden */
  80494. _checkCollision(collider: Collider): boolean;
  80495. /**
  80496. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80497. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80498. * @param point the point to check intersection with
  80499. * @returns if the point intersects
  80500. */
  80501. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80502. /**
  80503. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80504. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80505. * @param boundingInfo the bounding info to check intersection with
  80506. * @param precise if the intersection should be done using OBB
  80507. * @returns if the bounding info intersects
  80508. */
  80509. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80510. }
  80511. }
  80512. declare module BABYLON {
  80513. /**
  80514. * Extracts minimum and maximum values from a list of indexed positions
  80515. * @param positions defines the positions to use
  80516. * @param indices defines the indices to the positions
  80517. * @param indexStart defines the start index
  80518. * @param indexCount defines the end index
  80519. * @param bias defines bias value to add to the result
  80520. * @return minimum and maximum values
  80521. */
  80522. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80523. minimum: Vector3;
  80524. maximum: Vector3;
  80525. };
  80526. /**
  80527. * Extracts minimum and maximum values from a list of positions
  80528. * @param positions defines the positions to use
  80529. * @param start defines the start index in the positions array
  80530. * @param count defines the number of positions to handle
  80531. * @param bias defines bias value to add to the result
  80532. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80533. * @return minimum and maximum values
  80534. */
  80535. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80536. minimum: Vector3;
  80537. maximum: Vector3;
  80538. };
  80539. }
  80540. declare module BABYLON {
  80541. /** @hidden */
  80542. export class WebGLDataBuffer extends DataBuffer {
  80543. private _buffer;
  80544. constructor(resource: WebGLBuffer);
  80545. get underlyingResource(): any;
  80546. }
  80547. }
  80548. declare module BABYLON {
  80549. /** @hidden */
  80550. export class WebGLPipelineContext implements IPipelineContext {
  80551. engine: ThinEngine;
  80552. program: Nullable<WebGLProgram>;
  80553. context?: WebGLRenderingContext;
  80554. vertexShader?: WebGLShader;
  80555. fragmentShader?: WebGLShader;
  80556. isParallelCompiled: boolean;
  80557. onCompiled?: () => void;
  80558. transformFeedback?: WebGLTransformFeedback | null;
  80559. vertexCompilationError: Nullable<string>;
  80560. fragmentCompilationError: Nullable<string>;
  80561. programLinkError: Nullable<string>;
  80562. programValidationError: Nullable<string>;
  80563. get isAsync(): boolean;
  80564. get isReady(): boolean;
  80565. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80566. _getVertexShaderCode(): string | null;
  80567. _getFragmentShaderCode(): string | null;
  80568. }
  80569. }
  80570. declare module BABYLON {
  80571. interface ThinEngine {
  80572. /**
  80573. * Create an uniform buffer
  80574. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80575. * @param elements defines the content of the uniform buffer
  80576. * @returns the webGL uniform buffer
  80577. */
  80578. createUniformBuffer(elements: FloatArray): DataBuffer;
  80579. /**
  80580. * Create a dynamic uniform buffer
  80581. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80582. * @param elements defines the content of the uniform buffer
  80583. * @returns the webGL uniform buffer
  80584. */
  80585. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80586. /**
  80587. * Update an existing uniform buffer
  80588. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80589. * @param uniformBuffer defines the target uniform buffer
  80590. * @param elements defines the content to update
  80591. * @param offset defines the offset in the uniform buffer where update should start
  80592. * @param count defines the size of the data to update
  80593. */
  80594. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80595. /**
  80596. * Bind an uniform buffer to the current webGL context
  80597. * @param buffer defines the buffer to bind
  80598. */
  80599. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80600. /**
  80601. * Bind a buffer to the current webGL context at a given location
  80602. * @param buffer defines the buffer to bind
  80603. * @param location defines the index where to bind the buffer
  80604. */
  80605. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80606. /**
  80607. * Bind a specific block at a given index in a specific shader program
  80608. * @param pipelineContext defines the pipeline context to use
  80609. * @param blockName defines the block name
  80610. * @param index defines the index where to bind the block
  80611. */
  80612. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80613. }
  80614. }
  80615. declare module BABYLON {
  80616. /**
  80617. * Uniform buffer objects.
  80618. *
  80619. * Handles blocks of uniform on the GPU.
  80620. *
  80621. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80622. *
  80623. * For more information, please refer to :
  80624. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80625. */
  80626. export class UniformBuffer {
  80627. private _engine;
  80628. private _buffer;
  80629. private _data;
  80630. private _bufferData;
  80631. private _dynamic?;
  80632. private _uniformLocations;
  80633. private _uniformSizes;
  80634. private _uniformLocationPointer;
  80635. private _needSync;
  80636. private _noUBO;
  80637. private _currentEffect;
  80638. /** @hidden */
  80639. _alreadyBound: boolean;
  80640. private static _MAX_UNIFORM_SIZE;
  80641. private static _tempBuffer;
  80642. /**
  80643. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80644. * This is dynamic to allow compat with webgl 1 and 2.
  80645. * You will need to pass the name of the uniform as well as the value.
  80646. */
  80647. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80648. /**
  80649. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80650. * This is dynamic to allow compat with webgl 1 and 2.
  80651. * You will need to pass the name of the uniform as well as the value.
  80652. */
  80653. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80654. /**
  80655. * Lambda to Update a single float in a uniform buffer.
  80656. * This is dynamic to allow compat with webgl 1 and 2.
  80657. * You will need to pass the name of the uniform as well as the value.
  80658. */
  80659. updateFloat: (name: string, x: number) => void;
  80660. /**
  80661. * Lambda to Update a vec2 of float in a uniform buffer.
  80662. * This is dynamic to allow compat with webgl 1 and 2.
  80663. * You will need to pass the name of the uniform as well as the value.
  80664. */
  80665. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80666. /**
  80667. * Lambda to Update a vec3 of float in a uniform buffer.
  80668. * This is dynamic to allow compat with webgl 1 and 2.
  80669. * You will need to pass the name of the uniform as well as the value.
  80670. */
  80671. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80672. /**
  80673. * Lambda to Update a vec4 of float in a uniform buffer.
  80674. * This is dynamic to allow compat with webgl 1 and 2.
  80675. * You will need to pass the name of the uniform as well as the value.
  80676. */
  80677. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80678. /**
  80679. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80680. * This is dynamic to allow compat with webgl 1 and 2.
  80681. * You will need to pass the name of the uniform as well as the value.
  80682. */
  80683. updateMatrix: (name: string, mat: Matrix) => void;
  80684. /**
  80685. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80686. * This is dynamic to allow compat with webgl 1 and 2.
  80687. * You will need to pass the name of the uniform as well as the value.
  80688. */
  80689. updateVector3: (name: string, vector: Vector3) => void;
  80690. /**
  80691. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80692. * This is dynamic to allow compat with webgl 1 and 2.
  80693. * You will need to pass the name of the uniform as well as the value.
  80694. */
  80695. updateVector4: (name: string, vector: Vector4) => void;
  80696. /**
  80697. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80698. * This is dynamic to allow compat with webgl 1 and 2.
  80699. * You will need to pass the name of the uniform as well as the value.
  80700. */
  80701. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80702. /**
  80703. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80704. * This is dynamic to allow compat with webgl 1 and 2.
  80705. * You will need to pass the name of the uniform as well as the value.
  80706. */
  80707. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80708. /**
  80709. * Instantiates a new Uniform buffer objects.
  80710. *
  80711. * Handles blocks of uniform on the GPU.
  80712. *
  80713. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80714. *
  80715. * For more information, please refer to :
  80716. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80717. * @param engine Define the engine the buffer is associated with
  80718. * @param data Define the data contained in the buffer
  80719. * @param dynamic Define if the buffer is updatable
  80720. */
  80721. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80722. /**
  80723. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80724. * or just falling back on setUniformXXX calls.
  80725. */
  80726. get useUbo(): boolean;
  80727. /**
  80728. * Indicates if the WebGL underlying uniform buffer is in sync
  80729. * with the javascript cache data.
  80730. */
  80731. get isSync(): boolean;
  80732. /**
  80733. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80734. * Also, a dynamic UniformBuffer will disable cache verification and always
  80735. * update the underlying WebGL uniform buffer to the GPU.
  80736. * @returns if Dynamic, otherwise false
  80737. */
  80738. isDynamic(): boolean;
  80739. /**
  80740. * The data cache on JS side.
  80741. * @returns the underlying data as a float array
  80742. */
  80743. getData(): Float32Array;
  80744. /**
  80745. * The underlying WebGL Uniform buffer.
  80746. * @returns the webgl buffer
  80747. */
  80748. getBuffer(): Nullable<DataBuffer>;
  80749. /**
  80750. * std140 layout specifies how to align data within an UBO structure.
  80751. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80752. * for specs.
  80753. */
  80754. private _fillAlignment;
  80755. /**
  80756. * Adds an uniform in the buffer.
  80757. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80758. * for the layout to be correct !
  80759. * @param name Name of the uniform, as used in the uniform block in the shader.
  80760. * @param size Data size, or data directly.
  80761. */
  80762. addUniform(name: string, size: number | number[]): void;
  80763. /**
  80764. * Adds a Matrix 4x4 to the uniform buffer.
  80765. * @param name Name of the uniform, as used in the uniform block in the shader.
  80766. * @param mat A 4x4 matrix.
  80767. */
  80768. addMatrix(name: string, mat: Matrix): void;
  80769. /**
  80770. * Adds a vec2 to the uniform buffer.
  80771. * @param name Name of the uniform, as used in the uniform block in the shader.
  80772. * @param x Define the x component value of the vec2
  80773. * @param y Define the y component value of the vec2
  80774. */
  80775. addFloat2(name: string, x: number, y: number): void;
  80776. /**
  80777. * Adds a vec3 to the uniform buffer.
  80778. * @param name Name of the uniform, as used in the uniform block in the shader.
  80779. * @param x Define the x component value of the vec3
  80780. * @param y Define the y component value of the vec3
  80781. * @param z Define the z component value of the vec3
  80782. */
  80783. addFloat3(name: string, x: number, y: number, z: number): void;
  80784. /**
  80785. * Adds a vec3 to the uniform buffer.
  80786. * @param name Name of the uniform, as used in the uniform block in the shader.
  80787. * @param color Define the vec3 from a Color
  80788. */
  80789. addColor3(name: string, color: Color3): void;
  80790. /**
  80791. * Adds a vec4 to the uniform buffer.
  80792. * @param name Name of the uniform, as used in the uniform block in the shader.
  80793. * @param color Define the rgb components from a Color
  80794. * @param alpha Define the a component of the vec4
  80795. */
  80796. addColor4(name: string, color: Color3, alpha: number): void;
  80797. /**
  80798. * Adds a vec3 to the uniform buffer.
  80799. * @param name Name of the uniform, as used in the uniform block in the shader.
  80800. * @param vector Define the vec3 components from a Vector
  80801. */
  80802. addVector3(name: string, vector: Vector3): void;
  80803. /**
  80804. * Adds a Matrix 3x3 to the uniform buffer.
  80805. * @param name Name of the uniform, as used in the uniform block in the shader.
  80806. */
  80807. addMatrix3x3(name: string): void;
  80808. /**
  80809. * Adds a Matrix 2x2 to the uniform buffer.
  80810. * @param name Name of the uniform, as used in the uniform block in the shader.
  80811. */
  80812. addMatrix2x2(name: string): void;
  80813. /**
  80814. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80815. */
  80816. create(): void;
  80817. /** @hidden */
  80818. _rebuild(): void;
  80819. /**
  80820. * Updates the WebGL Uniform Buffer on the GPU.
  80821. * If the `dynamic` flag is set to true, no cache comparison is done.
  80822. * Otherwise, the buffer will be updated only if the cache differs.
  80823. */
  80824. update(): void;
  80825. /**
  80826. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80827. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80828. * @param data Define the flattened data
  80829. * @param size Define the size of the data.
  80830. */
  80831. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80832. private _valueCache;
  80833. private _cacheMatrix;
  80834. private _updateMatrix3x3ForUniform;
  80835. private _updateMatrix3x3ForEffect;
  80836. private _updateMatrix2x2ForEffect;
  80837. private _updateMatrix2x2ForUniform;
  80838. private _updateFloatForEffect;
  80839. private _updateFloatForUniform;
  80840. private _updateFloat2ForEffect;
  80841. private _updateFloat2ForUniform;
  80842. private _updateFloat3ForEffect;
  80843. private _updateFloat3ForUniform;
  80844. private _updateFloat4ForEffect;
  80845. private _updateFloat4ForUniform;
  80846. private _updateMatrixForEffect;
  80847. private _updateMatrixForUniform;
  80848. private _updateVector3ForEffect;
  80849. private _updateVector3ForUniform;
  80850. private _updateVector4ForEffect;
  80851. private _updateVector4ForUniform;
  80852. private _updateColor3ForEffect;
  80853. private _updateColor3ForUniform;
  80854. private _updateColor4ForEffect;
  80855. private _updateColor4ForUniform;
  80856. /**
  80857. * Sets a sampler uniform on the effect.
  80858. * @param name Define the name of the sampler.
  80859. * @param texture Define the texture to set in the sampler
  80860. */
  80861. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80862. /**
  80863. * Directly updates the value of the uniform in the cache AND on the GPU.
  80864. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80865. * @param data Define the flattened data
  80866. */
  80867. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80868. /**
  80869. * Binds this uniform buffer to an effect.
  80870. * @param effect Define the effect to bind the buffer to
  80871. * @param name Name of the uniform block in the shader.
  80872. */
  80873. bindToEffect(effect: Effect, name: string): void;
  80874. /**
  80875. * Disposes the uniform buffer.
  80876. */
  80877. dispose(): void;
  80878. }
  80879. }
  80880. declare module BABYLON {
  80881. /**
  80882. * Enum that determines the text-wrapping mode to use.
  80883. */
  80884. export enum InspectableType {
  80885. /**
  80886. * Checkbox for booleans
  80887. */
  80888. Checkbox = 0,
  80889. /**
  80890. * Sliders for numbers
  80891. */
  80892. Slider = 1,
  80893. /**
  80894. * Vector3
  80895. */
  80896. Vector3 = 2,
  80897. /**
  80898. * Quaternions
  80899. */
  80900. Quaternion = 3,
  80901. /**
  80902. * Color3
  80903. */
  80904. Color3 = 4,
  80905. /**
  80906. * String
  80907. */
  80908. String = 5
  80909. }
  80910. /**
  80911. * Interface used to define custom inspectable properties.
  80912. * This interface is used by the inspector to display custom property grids
  80913. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80914. */
  80915. export interface IInspectable {
  80916. /**
  80917. * Gets the label to display
  80918. */
  80919. label: string;
  80920. /**
  80921. * Gets the name of the property to edit
  80922. */
  80923. propertyName: string;
  80924. /**
  80925. * Gets the type of the editor to use
  80926. */
  80927. type: InspectableType;
  80928. /**
  80929. * Gets the minimum value of the property when using in "slider" mode
  80930. */
  80931. min?: number;
  80932. /**
  80933. * Gets the maximum value of the property when using in "slider" mode
  80934. */
  80935. max?: number;
  80936. /**
  80937. * Gets the setp to use when using in "slider" mode
  80938. */
  80939. step?: number;
  80940. }
  80941. }
  80942. declare module BABYLON {
  80943. /**
  80944. * Class used to provide helper for timing
  80945. */
  80946. export class TimingTools {
  80947. /**
  80948. * Polyfill for setImmediate
  80949. * @param action defines the action to execute after the current execution block
  80950. */
  80951. static SetImmediate(action: () => void): void;
  80952. }
  80953. }
  80954. declare module BABYLON {
  80955. /**
  80956. * Class used to enable instatition of objects by class name
  80957. */
  80958. export class InstantiationTools {
  80959. /**
  80960. * Use this object to register external classes like custom textures or material
  80961. * to allow the laoders to instantiate them
  80962. */
  80963. static RegisteredExternalClasses: {
  80964. [key: string]: Object;
  80965. };
  80966. /**
  80967. * Tries to instantiate a new object from a given class name
  80968. * @param className defines the class name to instantiate
  80969. * @returns the new object or null if the system was not able to do the instantiation
  80970. */
  80971. static Instantiate(className: string): any;
  80972. }
  80973. }
  80974. declare module BABYLON {
  80975. /**
  80976. * Define options used to create a depth texture
  80977. */
  80978. export class DepthTextureCreationOptions {
  80979. /** Specifies whether or not a stencil should be allocated in the texture */
  80980. generateStencil?: boolean;
  80981. /** Specifies whether or not bilinear filtering is enable on the texture */
  80982. bilinearFiltering?: boolean;
  80983. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80984. comparisonFunction?: number;
  80985. /** Specifies if the created texture is a cube texture */
  80986. isCube?: boolean;
  80987. }
  80988. }
  80989. declare module BABYLON {
  80990. interface ThinEngine {
  80991. /**
  80992. * Creates a depth stencil cube texture.
  80993. * This is only available in WebGL 2.
  80994. * @param size The size of face edge in the cube texture.
  80995. * @param options The options defining the cube texture.
  80996. * @returns The cube texture
  80997. */
  80998. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80999. /**
  81000. * Creates a cube texture
  81001. * @param rootUrl defines the url where the files to load is located
  81002. * @param scene defines the current scene
  81003. * @param files defines the list of files to load (1 per face)
  81004. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81005. * @param onLoad defines an optional callback raised when the texture is loaded
  81006. * @param onError defines an optional callback raised if there is an issue to load the texture
  81007. * @param format defines the format of the data
  81008. * @param forcedExtension defines the extension to use to pick the right loader
  81009. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81010. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81011. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81012. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81013. * @returns the cube texture as an InternalTexture
  81014. */
  81015. 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;
  81016. /**
  81017. * Creates a cube texture
  81018. * @param rootUrl defines the url where the files to load is located
  81019. * @param scene defines the current scene
  81020. * @param files defines the list of files to load (1 per face)
  81021. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81022. * @param onLoad defines an optional callback raised when the texture is loaded
  81023. * @param onError defines an optional callback raised if there is an issue to load the texture
  81024. * @param format defines the format of the data
  81025. * @param forcedExtension defines the extension to use to pick the right loader
  81026. * @returns the cube texture as an InternalTexture
  81027. */
  81028. 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;
  81029. /**
  81030. * Creates a cube texture
  81031. * @param rootUrl defines the url where the files to load is located
  81032. * @param scene defines the current scene
  81033. * @param files defines the list of files to load (1 per face)
  81034. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81035. * @param onLoad defines an optional callback raised when the texture is loaded
  81036. * @param onError defines an optional callback raised if there is an issue to load the texture
  81037. * @param format defines the format of the data
  81038. * @param forcedExtension defines the extension to use to pick the right loader
  81039. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81040. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81041. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81042. * @returns the cube texture as an InternalTexture
  81043. */
  81044. 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;
  81045. /** @hidden */
  81046. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81047. /** @hidden */
  81048. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81049. /** @hidden */
  81050. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81051. /** @hidden */
  81052. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81053. /**
  81054. * @hidden
  81055. */
  81056. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81057. }
  81058. }
  81059. declare module BABYLON {
  81060. /**
  81061. * Class for creating a cube texture
  81062. */
  81063. export class CubeTexture extends BaseTexture {
  81064. private _delayedOnLoad;
  81065. /**
  81066. * Observable triggered once the texture has been loaded.
  81067. */
  81068. onLoadObservable: Observable<CubeTexture>;
  81069. /**
  81070. * The url of the texture
  81071. */
  81072. url: string;
  81073. /**
  81074. * Gets or sets the center of the bounding box associated with the cube texture.
  81075. * It must define where the camera used to render the texture was set
  81076. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81077. */
  81078. boundingBoxPosition: Vector3;
  81079. private _boundingBoxSize;
  81080. /**
  81081. * Gets or sets the size of the bounding box associated with the cube texture
  81082. * When defined, the cubemap will switch to local mode
  81083. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81084. * @example https://www.babylonjs-playground.com/#RNASML
  81085. */
  81086. set boundingBoxSize(value: Vector3);
  81087. /**
  81088. * Returns the bounding box size
  81089. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81090. */
  81091. get boundingBoxSize(): Vector3;
  81092. protected _rotationY: number;
  81093. /**
  81094. * Sets texture matrix rotation angle around Y axis in radians.
  81095. */
  81096. set rotationY(value: number);
  81097. /**
  81098. * Gets texture matrix rotation angle around Y axis radians.
  81099. */
  81100. get rotationY(): number;
  81101. /**
  81102. * Are mip maps generated for this texture or not.
  81103. */
  81104. get noMipmap(): boolean;
  81105. private _noMipmap;
  81106. private _files;
  81107. protected _forcedExtension: Nullable<string>;
  81108. private _extensions;
  81109. private _textureMatrix;
  81110. private _format;
  81111. private _createPolynomials;
  81112. /** @hidden */
  81113. _prefiltered: boolean;
  81114. /**
  81115. * Creates a cube texture from an array of image urls
  81116. * @param files defines an array of image urls
  81117. * @param scene defines the hosting scene
  81118. * @param noMipmap specifies if mip maps are not used
  81119. * @returns a cube texture
  81120. */
  81121. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81122. /**
  81123. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81124. * @param url defines the url of the prefiltered texture
  81125. * @param scene defines the scene the texture is attached to
  81126. * @param forcedExtension defines the extension of the file if different from the url
  81127. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81128. * @return the prefiltered texture
  81129. */
  81130. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81131. /**
  81132. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81133. * as prefiltered data.
  81134. * @param rootUrl defines the url of the texture or the root name of the six images
  81135. * @param scene defines the scene the texture is attached to
  81136. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81137. * @param noMipmap defines if mipmaps should be created or not
  81138. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81139. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81140. * @param onError defines a callback triggered in case of error during load
  81141. * @param format defines the internal format to use for the texture once loaded
  81142. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81143. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81144. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81145. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81146. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81147. * @return the cube texture
  81148. */
  81149. 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);
  81150. /**
  81151. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81152. */
  81153. get isPrefiltered(): boolean;
  81154. /**
  81155. * Get the current class name of the texture useful for serialization or dynamic coding.
  81156. * @returns "CubeTexture"
  81157. */
  81158. getClassName(): string;
  81159. /**
  81160. * Update the url (and optional buffer) of this texture if url was null during construction.
  81161. * @param url the url of the texture
  81162. * @param forcedExtension defines the extension to use
  81163. * @param onLoad callback called when the texture is loaded (defaults to null)
  81164. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81165. */
  81166. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81167. /**
  81168. * Delays loading of the cube texture
  81169. * @param forcedExtension defines the extension to use
  81170. */
  81171. delayLoad(forcedExtension?: string): void;
  81172. /**
  81173. * Returns the reflection texture matrix
  81174. * @returns the reflection texture matrix
  81175. */
  81176. getReflectionTextureMatrix(): Matrix;
  81177. /**
  81178. * Sets the reflection texture matrix
  81179. * @param value Reflection texture matrix
  81180. */
  81181. setReflectionTextureMatrix(value: Matrix): void;
  81182. /**
  81183. * Parses text to create a cube texture
  81184. * @param parsedTexture define the serialized text to read from
  81185. * @param scene defines the hosting scene
  81186. * @param rootUrl defines the root url of the cube texture
  81187. * @returns a cube texture
  81188. */
  81189. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81190. /**
  81191. * Makes a clone, or deep copy, of the cube texture
  81192. * @returns a new cube texture
  81193. */
  81194. clone(): CubeTexture;
  81195. }
  81196. }
  81197. declare module BABYLON {
  81198. /**
  81199. * Manages the defines for the Material
  81200. */
  81201. export class MaterialDefines {
  81202. /** @hidden */
  81203. protected _keys: string[];
  81204. private _isDirty;
  81205. /** @hidden */
  81206. _renderId: number;
  81207. /** @hidden */
  81208. _areLightsDirty: boolean;
  81209. /** @hidden */
  81210. _areLightsDisposed: boolean;
  81211. /** @hidden */
  81212. _areAttributesDirty: boolean;
  81213. /** @hidden */
  81214. _areTexturesDirty: boolean;
  81215. /** @hidden */
  81216. _areFresnelDirty: boolean;
  81217. /** @hidden */
  81218. _areMiscDirty: boolean;
  81219. /** @hidden */
  81220. _areImageProcessingDirty: boolean;
  81221. /** @hidden */
  81222. _normals: boolean;
  81223. /** @hidden */
  81224. _uvs: boolean;
  81225. /** @hidden */
  81226. _needNormals: boolean;
  81227. /** @hidden */
  81228. _needUVs: boolean;
  81229. [id: string]: any;
  81230. /**
  81231. * Specifies if the material needs to be re-calculated
  81232. */
  81233. get isDirty(): boolean;
  81234. /**
  81235. * Marks the material to indicate that it has been re-calculated
  81236. */
  81237. markAsProcessed(): void;
  81238. /**
  81239. * Marks the material to indicate that it needs to be re-calculated
  81240. */
  81241. markAsUnprocessed(): void;
  81242. /**
  81243. * Marks the material to indicate all of its defines need to be re-calculated
  81244. */
  81245. markAllAsDirty(): void;
  81246. /**
  81247. * Marks the material to indicate that image processing needs to be re-calculated
  81248. */
  81249. markAsImageProcessingDirty(): void;
  81250. /**
  81251. * Marks the material to indicate the lights need to be re-calculated
  81252. * @param disposed Defines whether the light is dirty due to dispose or not
  81253. */
  81254. markAsLightDirty(disposed?: boolean): void;
  81255. /**
  81256. * Marks the attribute state as changed
  81257. */
  81258. markAsAttributesDirty(): void;
  81259. /**
  81260. * Marks the texture state as changed
  81261. */
  81262. markAsTexturesDirty(): void;
  81263. /**
  81264. * Marks the fresnel state as changed
  81265. */
  81266. markAsFresnelDirty(): void;
  81267. /**
  81268. * Marks the misc state as changed
  81269. */
  81270. markAsMiscDirty(): void;
  81271. /**
  81272. * Rebuilds the material defines
  81273. */
  81274. rebuild(): void;
  81275. /**
  81276. * Specifies if two material defines are equal
  81277. * @param other - A material define instance to compare to
  81278. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81279. */
  81280. isEqual(other: MaterialDefines): boolean;
  81281. /**
  81282. * Clones this instance's defines to another instance
  81283. * @param other - material defines to clone values to
  81284. */
  81285. cloneTo(other: MaterialDefines): void;
  81286. /**
  81287. * Resets the material define values
  81288. */
  81289. reset(): void;
  81290. /**
  81291. * Converts the material define values to a string
  81292. * @returns - String of material define information
  81293. */
  81294. toString(): string;
  81295. }
  81296. }
  81297. declare module BABYLON {
  81298. /**
  81299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81301. * 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;
  81302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81303. */
  81304. export class ColorCurves {
  81305. private _dirty;
  81306. private _tempColor;
  81307. private _globalCurve;
  81308. private _highlightsCurve;
  81309. private _midtonesCurve;
  81310. private _shadowsCurve;
  81311. private _positiveCurve;
  81312. private _negativeCurve;
  81313. private _globalHue;
  81314. private _globalDensity;
  81315. private _globalSaturation;
  81316. private _globalExposure;
  81317. /**
  81318. * Gets the global Hue value.
  81319. * 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).
  81320. */
  81321. get globalHue(): number;
  81322. /**
  81323. * Sets the global Hue value.
  81324. * 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).
  81325. */
  81326. set globalHue(value: number);
  81327. /**
  81328. * Gets the global Density value.
  81329. * 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.
  81330. * Values less than zero provide a filter of opposite hue.
  81331. */
  81332. get globalDensity(): number;
  81333. /**
  81334. * Sets the global Density value.
  81335. * 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.
  81336. * Values less than zero provide a filter of opposite hue.
  81337. */
  81338. set globalDensity(value: number);
  81339. /**
  81340. * Gets the global Saturation value.
  81341. * 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.
  81342. */
  81343. get globalSaturation(): number;
  81344. /**
  81345. * Sets the global Saturation value.
  81346. * 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.
  81347. */
  81348. set globalSaturation(value: number);
  81349. /**
  81350. * Gets the global Exposure value.
  81351. * 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.
  81352. */
  81353. get globalExposure(): number;
  81354. /**
  81355. * Sets the global Exposure value.
  81356. * 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.
  81357. */
  81358. set globalExposure(value: number);
  81359. private _highlightsHue;
  81360. private _highlightsDensity;
  81361. private _highlightsSaturation;
  81362. private _highlightsExposure;
  81363. /**
  81364. * Gets the highlights Hue value.
  81365. * 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).
  81366. */
  81367. get highlightsHue(): number;
  81368. /**
  81369. * Sets the highlights Hue value.
  81370. * 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).
  81371. */
  81372. set highlightsHue(value: number);
  81373. /**
  81374. * Gets the highlights Density value.
  81375. * 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.
  81376. * Values less than zero provide a filter of opposite hue.
  81377. */
  81378. get highlightsDensity(): number;
  81379. /**
  81380. * Sets the highlights Density value.
  81381. * 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.
  81382. * Values less than zero provide a filter of opposite hue.
  81383. */
  81384. set highlightsDensity(value: number);
  81385. /**
  81386. * Gets the highlights Saturation value.
  81387. * 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.
  81388. */
  81389. get highlightsSaturation(): number;
  81390. /**
  81391. * Sets the highlights Saturation value.
  81392. * 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.
  81393. */
  81394. set highlightsSaturation(value: number);
  81395. /**
  81396. * Gets the highlights Exposure value.
  81397. * 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.
  81398. */
  81399. get highlightsExposure(): number;
  81400. /**
  81401. * Sets the highlights Exposure value.
  81402. * 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.
  81403. */
  81404. set highlightsExposure(value: number);
  81405. private _midtonesHue;
  81406. private _midtonesDensity;
  81407. private _midtonesSaturation;
  81408. private _midtonesExposure;
  81409. /**
  81410. * Gets the midtones Hue value.
  81411. * 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).
  81412. */
  81413. get midtonesHue(): number;
  81414. /**
  81415. * Sets the midtones Hue value.
  81416. * 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).
  81417. */
  81418. set midtonesHue(value: number);
  81419. /**
  81420. * Gets the midtones Density value.
  81421. * 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.
  81422. * Values less than zero provide a filter of opposite hue.
  81423. */
  81424. get midtonesDensity(): number;
  81425. /**
  81426. * Sets the midtones Density value.
  81427. * 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.
  81428. * Values less than zero provide a filter of opposite hue.
  81429. */
  81430. set midtonesDensity(value: number);
  81431. /**
  81432. * Gets the midtones Saturation value.
  81433. * 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.
  81434. */
  81435. get midtonesSaturation(): number;
  81436. /**
  81437. * Sets the midtones Saturation value.
  81438. * 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.
  81439. */
  81440. set midtonesSaturation(value: number);
  81441. /**
  81442. * Gets the midtones Exposure value.
  81443. * 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.
  81444. */
  81445. get midtonesExposure(): number;
  81446. /**
  81447. * Sets the midtones Exposure value.
  81448. * 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.
  81449. */
  81450. set midtonesExposure(value: number);
  81451. private _shadowsHue;
  81452. private _shadowsDensity;
  81453. private _shadowsSaturation;
  81454. private _shadowsExposure;
  81455. /**
  81456. * Gets the shadows Hue value.
  81457. * 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).
  81458. */
  81459. get shadowsHue(): number;
  81460. /**
  81461. * Sets the shadows Hue value.
  81462. * 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).
  81463. */
  81464. set shadowsHue(value: number);
  81465. /**
  81466. * Gets the shadows Density value.
  81467. * 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.
  81468. * Values less than zero provide a filter of opposite hue.
  81469. */
  81470. get shadowsDensity(): number;
  81471. /**
  81472. * Sets the shadows Density value.
  81473. * 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.
  81474. * Values less than zero provide a filter of opposite hue.
  81475. */
  81476. set shadowsDensity(value: number);
  81477. /**
  81478. * Gets the shadows Saturation value.
  81479. * 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.
  81480. */
  81481. get shadowsSaturation(): number;
  81482. /**
  81483. * Sets the shadows Saturation value.
  81484. * 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.
  81485. */
  81486. set shadowsSaturation(value: number);
  81487. /**
  81488. * Gets the shadows Exposure value.
  81489. * 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.
  81490. */
  81491. get shadowsExposure(): number;
  81492. /**
  81493. * Sets the shadows Exposure value.
  81494. * 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.
  81495. */
  81496. set shadowsExposure(value: number);
  81497. /**
  81498. * Returns the class name
  81499. * @returns The class name
  81500. */
  81501. getClassName(): string;
  81502. /**
  81503. * Binds the color curves to the shader.
  81504. * @param colorCurves The color curve to bind
  81505. * @param effect The effect to bind to
  81506. * @param positiveUniform The positive uniform shader parameter
  81507. * @param neutralUniform The neutral uniform shader parameter
  81508. * @param negativeUniform The negative uniform shader parameter
  81509. */
  81510. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81511. /**
  81512. * Prepare the list of uniforms associated with the ColorCurves effects.
  81513. * @param uniformsList The list of uniforms used in the effect
  81514. */
  81515. static PrepareUniforms(uniformsList: string[]): void;
  81516. /**
  81517. * Returns color grading data based on a hue, density, saturation and exposure value.
  81518. * @param filterHue The hue of the color filter.
  81519. * @param filterDensity The density of the color filter.
  81520. * @param saturation The saturation.
  81521. * @param exposure The exposure.
  81522. * @param result The result data container.
  81523. */
  81524. private getColorGradingDataToRef;
  81525. /**
  81526. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81527. * @param value The input slider value in range [-100,100].
  81528. * @returns Adjusted value.
  81529. */
  81530. private static applyColorGradingSliderNonlinear;
  81531. /**
  81532. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81533. * @param hue The hue (H) input.
  81534. * @param saturation The saturation (S) input.
  81535. * @param brightness The brightness (B) input.
  81536. * @result An RGBA color represented as Vector4.
  81537. */
  81538. private static fromHSBToRef;
  81539. /**
  81540. * Returns a value clamped between min and max
  81541. * @param value The value to clamp
  81542. * @param min The minimum of value
  81543. * @param max The maximum of value
  81544. * @returns The clamped value.
  81545. */
  81546. private static clamp;
  81547. /**
  81548. * Clones the current color curve instance.
  81549. * @return The cloned curves
  81550. */
  81551. clone(): ColorCurves;
  81552. /**
  81553. * Serializes the current color curve instance to a json representation.
  81554. * @return a JSON representation
  81555. */
  81556. serialize(): any;
  81557. /**
  81558. * Parses the color curve from a json representation.
  81559. * @param source the JSON source to parse
  81560. * @return The parsed curves
  81561. */
  81562. static Parse(source: any): ColorCurves;
  81563. }
  81564. }
  81565. declare module BABYLON {
  81566. /**
  81567. * Interface to follow in your material defines to integrate easily the
  81568. * Image proccessing functions.
  81569. * @hidden
  81570. */
  81571. export interface IImageProcessingConfigurationDefines {
  81572. IMAGEPROCESSING: boolean;
  81573. VIGNETTE: boolean;
  81574. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81575. VIGNETTEBLENDMODEOPAQUE: boolean;
  81576. TONEMAPPING: boolean;
  81577. TONEMAPPING_ACES: boolean;
  81578. CONTRAST: boolean;
  81579. EXPOSURE: boolean;
  81580. COLORCURVES: boolean;
  81581. COLORGRADING: boolean;
  81582. COLORGRADING3D: boolean;
  81583. SAMPLER3DGREENDEPTH: boolean;
  81584. SAMPLER3DBGRMAP: boolean;
  81585. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81586. }
  81587. /**
  81588. * @hidden
  81589. */
  81590. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81591. IMAGEPROCESSING: boolean;
  81592. VIGNETTE: boolean;
  81593. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81594. VIGNETTEBLENDMODEOPAQUE: boolean;
  81595. TONEMAPPING: boolean;
  81596. TONEMAPPING_ACES: boolean;
  81597. CONTRAST: boolean;
  81598. COLORCURVES: boolean;
  81599. COLORGRADING: boolean;
  81600. COLORGRADING3D: boolean;
  81601. SAMPLER3DGREENDEPTH: boolean;
  81602. SAMPLER3DBGRMAP: boolean;
  81603. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81604. EXPOSURE: boolean;
  81605. constructor();
  81606. }
  81607. /**
  81608. * This groups together the common properties used for image processing either in direct forward pass
  81609. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81610. * or not.
  81611. */
  81612. export class ImageProcessingConfiguration {
  81613. /**
  81614. * Default tone mapping applied in BabylonJS.
  81615. */
  81616. static readonly TONEMAPPING_STANDARD: number;
  81617. /**
  81618. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81619. * to other engines rendering to increase portability.
  81620. */
  81621. static readonly TONEMAPPING_ACES: number;
  81622. /**
  81623. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81624. */
  81625. colorCurves: Nullable<ColorCurves>;
  81626. private _colorCurvesEnabled;
  81627. /**
  81628. * Gets wether the color curves effect is enabled.
  81629. */
  81630. get colorCurvesEnabled(): boolean;
  81631. /**
  81632. * Sets wether the color curves effect is enabled.
  81633. */
  81634. set colorCurvesEnabled(value: boolean);
  81635. private _colorGradingTexture;
  81636. /**
  81637. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81638. */
  81639. get colorGradingTexture(): Nullable<BaseTexture>;
  81640. /**
  81641. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81642. */
  81643. set colorGradingTexture(value: Nullable<BaseTexture>);
  81644. private _colorGradingEnabled;
  81645. /**
  81646. * Gets wether the color grading effect is enabled.
  81647. */
  81648. get colorGradingEnabled(): boolean;
  81649. /**
  81650. * Sets wether the color grading effect is enabled.
  81651. */
  81652. set colorGradingEnabled(value: boolean);
  81653. private _colorGradingWithGreenDepth;
  81654. /**
  81655. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81656. */
  81657. get colorGradingWithGreenDepth(): boolean;
  81658. /**
  81659. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81660. */
  81661. set colorGradingWithGreenDepth(value: boolean);
  81662. private _colorGradingBGR;
  81663. /**
  81664. * Gets wether the color grading texture contains BGR values.
  81665. */
  81666. get colorGradingBGR(): boolean;
  81667. /**
  81668. * Sets wether the color grading texture contains BGR values.
  81669. */
  81670. set colorGradingBGR(value: boolean);
  81671. /** @hidden */
  81672. _exposure: number;
  81673. /**
  81674. * Gets the Exposure used in the effect.
  81675. */
  81676. get exposure(): number;
  81677. /**
  81678. * Sets the Exposure used in the effect.
  81679. */
  81680. set exposure(value: number);
  81681. private _toneMappingEnabled;
  81682. /**
  81683. * Gets wether the tone mapping effect is enabled.
  81684. */
  81685. get toneMappingEnabled(): boolean;
  81686. /**
  81687. * Sets wether the tone mapping effect is enabled.
  81688. */
  81689. set toneMappingEnabled(value: boolean);
  81690. private _toneMappingType;
  81691. /**
  81692. * Gets the type of tone mapping effect.
  81693. */
  81694. get toneMappingType(): number;
  81695. /**
  81696. * Sets the type of tone mapping effect used in BabylonJS.
  81697. */
  81698. set toneMappingType(value: number);
  81699. protected _contrast: number;
  81700. /**
  81701. * Gets the contrast used in the effect.
  81702. */
  81703. get contrast(): number;
  81704. /**
  81705. * Sets the contrast used in the effect.
  81706. */
  81707. set contrast(value: number);
  81708. /**
  81709. * Vignette stretch size.
  81710. */
  81711. vignetteStretch: number;
  81712. /**
  81713. * Vignette centre X Offset.
  81714. */
  81715. vignetteCentreX: number;
  81716. /**
  81717. * Vignette centre Y Offset.
  81718. */
  81719. vignetteCentreY: number;
  81720. /**
  81721. * Vignette weight or intensity of the vignette effect.
  81722. */
  81723. vignetteWeight: number;
  81724. /**
  81725. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81726. * if vignetteEnabled is set to true.
  81727. */
  81728. vignetteColor: Color4;
  81729. /**
  81730. * Camera field of view used by the Vignette effect.
  81731. */
  81732. vignetteCameraFov: number;
  81733. private _vignetteBlendMode;
  81734. /**
  81735. * Gets the vignette blend mode allowing different kind of effect.
  81736. */
  81737. get vignetteBlendMode(): number;
  81738. /**
  81739. * Sets the vignette blend mode allowing different kind of effect.
  81740. */
  81741. set vignetteBlendMode(value: number);
  81742. private _vignetteEnabled;
  81743. /**
  81744. * Gets wether the vignette effect is enabled.
  81745. */
  81746. get vignetteEnabled(): boolean;
  81747. /**
  81748. * Sets wether the vignette effect is enabled.
  81749. */
  81750. set vignetteEnabled(value: boolean);
  81751. private _applyByPostProcess;
  81752. /**
  81753. * Gets wether the image processing is applied through a post process or not.
  81754. */
  81755. get applyByPostProcess(): boolean;
  81756. /**
  81757. * Sets wether the image processing is applied through a post process or not.
  81758. */
  81759. set applyByPostProcess(value: boolean);
  81760. private _isEnabled;
  81761. /**
  81762. * Gets wether the image processing is enabled or not.
  81763. */
  81764. get isEnabled(): boolean;
  81765. /**
  81766. * Sets wether the image processing is enabled or not.
  81767. */
  81768. set isEnabled(value: boolean);
  81769. /**
  81770. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81771. */
  81772. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81773. /**
  81774. * Method called each time the image processing information changes requires to recompile the effect.
  81775. */
  81776. protected _updateParameters(): void;
  81777. /**
  81778. * Gets the current class name.
  81779. * @return "ImageProcessingConfiguration"
  81780. */
  81781. getClassName(): string;
  81782. /**
  81783. * Prepare the list of uniforms associated with the Image Processing effects.
  81784. * @param uniforms The list of uniforms used in the effect
  81785. * @param defines the list of defines currently in use
  81786. */
  81787. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81788. /**
  81789. * Prepare the list of samplers associated with the Image Processing effects.
  81790. * @param samplersList The list of uniforms used in the effect
  81791. * @param defines the list of defines currently in use
  81792. */
  81793. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81794. /**
  81795. * Prepare the list of defines associated to the shader.
  81796. * @param defines the list of defines to complete
  81797. * @param forPostProcess Define if we are currently in post process mode or not
  81798. */
  81799. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81800. /**
  81801. * Returns true if all the image processing information are ready.
  81802. * @returns True if ready, otherwise, false
  81803. */
  81804. isReady(): boolean;
  81805. /**
  81806. * Binds the image processing to the shader.
  81807. * @param effect The effect to bind to
  81808. * @param overrideAspectRatio Override the aspect ratio of the effect
  81809. */
  81810. bind(effect: Effect, overrideAspectRatio?: number): void;
  81811. /**
  81812. * Clones the current image processing instance.
  81813. * @return The cloned image processing
  81814. */
  81815. clone(): ImageProcessingConfiguration;
  81816. /**
  81817. * Serializes the current image processing instance to a json representation.
  81818. * @return a JSON representation
  81819. */
  81820. serialize(): any;
  81821. /**
  81822. * Parses the image processing from a json representation.
  81823. * @param source the JSON source to parse
  81824. * @return The parsed image processing
  81825. */
  81826. static Parse(source: any): ImageProcessingConfiguration;
  81827. private static _VIGNETTEMODE_MULTIPLY;
  81828. private static _VIGNETTEMODE_OPAQUE;
  81829. /**
  81830. * Used to apply the vignette as a mix with the pixel color.
  81831. */
  81832. static get VIGNETTEMODE_MULTIPLY(): number;
  81833. /**
  81834. * Used to apply the vignette as a replacement of the pixel color.
  81835. */
  81836. static get VIGNETTEMODE_OPAQUE(): number;
  81837. }
  81838. }
  81839. declare module BABYLON {
  81840. /** @hidden */
  81841. export var postprocessVertexShader: {
  81842. name: string;
  81843. shader: string;
  81844. };
  81845. }
  81846. declare module BABYLON {
  81847. interface ThinEngine {
  81848. /**
  81849. * Creates a new render target texture
  81850. * @param size defines the size of the texture
  81851. * @param options defines the options used to create the texture
  81852. * @returns a new render target texture stored in an InternalTexture
  81853. */
  81854. createRenderTargetTexture(size: number | {
  81855. width: number;
  81856. height: number;
  81857. layers?: number;
  81858. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81859. /**
  81860. * Creates a depth stencil texture.
  81861. * This is only available in WebGL 2 or with the depth texture extension available.
  81862. * @param size The size of face edge in the texture.
  81863. * @param options The options defining the texture.
  81864. * @returns The texture
  81865. */
  81866. createDepthStencilTexture(size: number | {
  81867. width: number;
  81868. height: number;
  81869. layers?: number;
  81870. }, options: DepthTextureCreationOptions): InternalTexture;
  81871. /** @hidden */
  81872. _createDepthStencilTexture(size: number | {
  81873. width: number;
  81874. height: number;
  81875. layers?: number;
  81876. }, options: DepthTextureCreationOptions): InternalTexture;
  81877. }
  81878. }
  81879. declare module BABYLON {
  81880. /** Defines supported spaces */
  81881. export enum Space {
  81882. /** Local (object) space */
  81883. LOCAL = 0,
  81884. /** World space */
  81885. WORLD = 1,
  81886. /** Bone space */
  81887. BONE = 2
  81888. }
  81889. /** Defines the 3 main axes */
  81890. export class Axis {
  81891. /** X axis */
  81892. static X: Vector3;
  81893. /** Y axis */
  81894. static Y: Vector3;
  81895. /** Z axis */
  81896. static Z: Vector3;
  81897. }
  81898. }
  81899. declare module BABYLON {
  81900. /**
  81901. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81902. * This is the base of the follow, arc rotate cameras and Free camera
  81903. * @see http://doc.babylonjs.com/features/cameras
  81904. */
  81905. export class TargetCamera extends Camera {
  81906. private static _RigCamTransformMatrix;
  81907. private static _TargetTransformMatrix;
  81908. private static _TargetFocalPoint;
  81909. /**
  81910. * Define the current direction the camera is moving to
  81911. */
  81912. cameraDirection: Vector3;
  81913. /**
  81914. * Define the current rotation the camera is rotating to
  81915. */
  81916. cameraRotation: Vector2;
  81917. /**
  81918. * When set, the up vector of the camera will be updated by the rotation of the camera
  81919. */
  81920. updateUpVectorFromRotation: boolean;
  81921. private _tmpQuaternion;
  81922. /**
  81923. * Define the current rotation of the camera
  81924. */
  81925. rotation: Vector3;
  81926. /**
  81927. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81928. */
  81929. rotationQuaternion: Quaternion;
  81930. /**
  81931. * Define the current speed of the camera
  81932. */
  81933. speed: number;
  81934. /**
  81935. * Add constraint to the camera to prevent it to move freely in all directions and
  81936. * around all axis.
  81937. */
  81938. noRotationConstraint: boolean;
  81939. /**
  81940. * Define the current target of the camera as an object or a position.
  81941. */
  81942. lockedTarget: any;
  81943. /** @hidden */
  81944. _currentTarget: Vector3;
  81945. /** @hidden */
  81946. _initialFocalDistance: number;
  81947. /** @hidden */
  81948. _viewMatrix: Matrix;
  81949. /** @hidden */
  81950. _camMatrix: Matrix;
  81951. /** @hidden */
  81952. _cameraTransformMatrix: Matrix;
  81953. /** @hidden */
  81954. _cameraRotationMatrix: Matrix;
  81955. /** @hidden */
  81956. _referencePoint: Vector3;
  81957. /** @hidden */
  81958. _transformedReferencePoint: Vector3;
  81959. protected _globalCurrentTarget: Vector3;
  81960. protected _globalCurrentUpVector: Vector3;
  81961. /** @hidden */
  81962. _reset: () => void;
  81963. private _defaultUp;
  81964. /**
  81965. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81966. * This is the base of the follow, arc rotate cameras and Free camera
  81967. * @see http://doc.babylonjs.com/features/cameras
  81968. * @param name Defines the name of the camera in the scene
  81969. * @param position Defines the start position of the camera in the scene
  81970. * @param scene Defines the scene the camera belongs to
  81971. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81972. */
  81973. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81974. /**
  81975. * Gets the position in front of the camera at a given distance.
  81976. * @param distance The distance from the camera we want the position to be
  81977. * @returns the position
  81978. */
  81979. getFrontPosition(distance: number): Vector3;
  81980. /** @hidden */
  81981. _getLockedTargetPosition(): Nullable<Vector3>;
  81982. private _storedPosition;
  81983. private _storedRotation;
  81984. private _storedRotationQuaternion;
  81985. /**
  81986. * Store current camera state of the camera (fov, position, rotation, etc..)
  81987. * @returns the camera
  81988. */
  81989. storeState(): Camera;
  81990. /**
  81991. * Restored camera state. You must call storeState() first
  81992. * @returns whether it was successful or not
  81993. * @hidden
  81994. */
  81995. _restoreStateValues(): boolean;
  81996. /** @hidden */
  81997. _initCache(): void;
  81998. /** @hidden */
  81999. _updateCache(ignoreParentClass?: boolean): void;
  82000. /** @hidden */
  82001. _isSynchronizedViewMatrix(): boolean;
  82002. /** @hidden */
  82003. _computeLocalCameraSpeed(): number;
  82004. /**
  82005. * Defines the target the camera should look at.
  82006. * @param target Defines the new target as a Vector or a mesh
  82007. */
  82008. setTarget(target: Vector3): void;
  82009. /**
  82010. * Return the current target position of the camera. This value is expressed in local space.
  82011. * @returns the target position
  82012. */
  82013. getTarget(): Vector3;
  82014. /** @hidden */
  82015. _decideIfNeedsToMove(): boolean;
  82016. /** @hidden */
  82017. _updatePosition(): void;
  82018. /** @hidden */
  82019. _checkInputs(): void;
  82020. protected _updateCameraRotationMatrix(): void;
  82021. /**
  82022. * 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)
  82023. * @returns the current camera
  82024. */
  82025. private _rotateUpVectorWithCameraRotationMatrix;
  82026. private _cachedRotationZ;
  82027. private _cachedQuaternionRotationZ;
  82028. /** @hidden */
  82029. _getViewMatrix(): Matrix;
  82030. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82031. /**
  82032. * @hidden
  82033. */
  82034. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82035. /**
  82036. * @hidden
  82037. */
  82038. _updateRigCameras(): void;
  82039. private _getRigCamPositionAndTarget;
  82040. /**
  82041. * Gets the current object class name.
  82042. * @return the class name
  82043. */
  82044. getClassName(): string;
  82045. }
  82046. }
  82047. declare module BABYLON {
  82048. /**
  82049. * Gather the list of keyboard event types as constants.
  82050. */
  82051. export class KeyboardEventTypes {
  82052. /**
  82053. * The keydown event is fired when a key becomes active (pressed).
  82054. */
  82055. static readonly KEYDOWN: number;
  82056. /**
  82057. * The keyup event is fired when a key has been released.
  82058. */
  82059. static readonly KEYUP: number;
  82060. }
  82061. /**
  82062. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82063. */
  82064. export class KeyboardInfo {
  82065. /**
  82066. * Defines the type of event (KeyboardEventTypes)
  82067. */
  82068. type: number;
  82069. /**
  82070. * Defines the related dom event
  82071. */
  82072. event: KeyboardEvent;
  82073. /**
  82074. * Instantiates a new keyboard info.
  82075. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82076. * @param type Defines the type of event (KeyboardEventTypes)
  82077. * @param event Defines the related dom event
  82078. */
  82079. constructor(
  82080. /**
  82081. * Defines the type of event (KeyboardEventTypes)
  82082. */
  82083. type: number,
  82084. /**
  82085. * Defines the related dom event
  82086. */
  82087. event: KeyboardEvent);
  82088. }
  82089. /**
  82090. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82091. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82092. */
  82093. export class KeyboardInfoPre extends KeyboardInfo {
  82094. /**
  82095. * Defines the type of event (KeyboardEventTypes)
  82096. */
  82097. type: number;
  82098. /**
  82099. * Defines the related dom event
  82100. */
  82101. event: KeyboardEvent;
  82102. /**
  82103. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82104. */
  82105. skipOnPointerObservable: boolean;
  82106. /**
  82107. * Instantiates a new keyboard pre info.
  82108. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82109. * @param type Defines the type of event (KeyboardEventTypes)
  82110. * @param event Defines the related dom event
  82111. */
  82112. constructor(
  82113. /**
  82114. * Defines the type of event (KeyboardEventTypes)
  82115. */
  82116. type: number,
  82117. /**
  82118. * Defines the related dom event
  82119. */
  82120. event: KeyboardEvent);
  82121. }
  82122. }
  82123. declare module BABYLON {
  82124. /**
  82125. * Manage the keyboard inputs to control the movement of a free camera.
  82126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82127. */
  82128. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82129. /**
  82130. * Defines the camera the input is attached to.
  82131. */
  82132. camera: FreeCamera;
  82133. /**
  82134. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82135. */
  82136. keysUp: number[];
  82137. /**
  82138. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82139. */
  82140. keysDown: number[];
  82141. /**
  82142. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82143. */
  82144. keysLeft: number[];
  82145. /**
  82146. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82147. */
  82148. keysRight: number[];
  82149. private _keys;
  82150. private _onCanvasBlurObserver;
  82151. private _onKeyboardObserver;
  82152. private _engine;
  82153. private _scene;
  82154. /**
  82155. * Attach the input controls to a specific dom element to get the input from.
  82156. * @param element Defines the element the controls should be listened from
  82157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82158. */
  82159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82160. /**
  82161. * Detach the current controls from the specified dom element.
  82162. * @param element Defines the element to stop listening the inputs from
  82163. */
  82164. detachControl(element: Nullable<HTMLElement>): void;
  82165. /**
  82166. * Update the current camera state depending on the inputs that have been used this frame.
  82167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82168. */
  82169. checkInputs(): void;
  82170. /**
  82171. * Gets the class name of the current intput.
  82172. * @returns the class name
  82173. */
  82174. getClassName(): string;
  82175. /** @hidden */
  82176. _onLostFocus(): void;
  82177. /**
  82178. * Get the friendly name associated with the input class.
  82179. * @returns the input friendly name
  82180. */
  82181. getSimpleName(): string;
  82182. }
  82183. }
  82184. declare module BABYLON {
  82185. /**
  82186. * Interface describing all the common properties and methods a shadow light needs to implement.
  82187. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82188. * as well as binding the different shadow properties to the effects.
  82189. */
  82190. export interface IShadowLight extends Light {
  82191. /**
  82192. * The light id in the scene (used in scene.findLighById for instance)
  82193. */
  82194. id: string;
  82195. /**
  82196. * The position the shdow will be casted from.
  82197. */
  82198. position: Vector3;
  82199. /**
  82200. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82201. */
  82202. direction: Vector3;
  82203. /**
  82204. * The transformed position. Position of the light in world space taking parenting in account.
  82205. */
  82206. transformedPosition: Vector3;
  82207. /**
  82208. * The transformed direction. Direction of the light in world space taking parenting in account.
  82209. */
  82210. transformedDirection: Vector3;
  82211. /**
  82212. * The friendly name of the light in the scene.
  82213. */
  82214. name: string;
  82215. /**
  82216. * Defines the shadow projection clipping minimum z value.
  82217. */
  82218. shadowMinZ: number;
  82219. /**
  82220. * Defines the shadow projection clipping maximum z value.
  82221. */
  82222. shadowMaxZ: number;
  82223. /**
  82224. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82225. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82226. */
  82227. computeTransformedInformation(): boolean;
  82228. /**
  82229. * Gets the scene the light belongs to.
  82230. * @returns The scene
  82231. */
  82232. getScene(): Scene;
  82233. /**
  82234. * Callback defining a custom Projection Matrix Builder.
  82235. * This can be used to override the default projection matrix computation.
  82236. */
  82237. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82238. /**
  82239. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82240. * @param matrix The materix to updated with the projection information
  82241. * @param viewMatrix The transform matrix of the light
  82242. * @param renderList The list of mesh to render in the map
  82243. * @returns The current light
  82244. */
  82245. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82246. /**
  82247. * Gets the current depth scale used in ESM.
  82248. * @returns The scale
  82249. */
  82250. getDepthScale(): number;
  82251. /**
  82252. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82253. * @returns true if a cube texture needs to be use
  82254. */
  82255. needCube(): boolean;
  82256. /**
  82257. * Detects if the projection matrix requires to be recomputed this frame.
  82258. * @returns true if it requires to be recomputed otherwise, false.
  82259. */
  82260. needProjectionMatrixCompute(): boolean;
  82261. /**
  82262. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82263. */
  82264. forceProjectionMatrixCompute(): void;
  82265. /**
  82266. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82267. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82268. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82269. */
  82270. getShadowDirection(faceIndex?: number): Vector3;
  82271. /**
  82272. * Gets the minZ used for shadow according to both the scene and the light.
  82273. * @param activeCamera The camera we are returning the min for
  82274. * @returns the depth min z
  82275. */
  82276. getDepthMinZ(activeCamera: Camera): number;
  82277. /**
  82278. * Gets the maxZ used for shadow according to both the scene and the light.
  82279. * @param activeCamera The camera we are returning the max for
  82280. * @returns the depth max z
  82281. */
  82282. getDepthMaxZ(activeCamera: Camera): number;
  82283. }
  82284. /**
  82285. * Base implementation IShadowLight
  82286. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82287. */
  82288. export abstract class ShadowLight extends Light implements IShadowLight {
  82289. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82290. protected _position: Vector3;
  82291. protected _setPosition(value: Vector3): void;
  82292. /**
  82293. * Sets the position the shadow will be casted from. Also use as the light position for both
  82294. * point and spot lights.
  82295. */
  82296. get position(): Vector3;
  82297. /**
  82298. * Sets the position the shadow will be casted from. Also use as the light position for both
  82299. * point and spot lights.
  82300. */
  82301. set position(value: Vector3);
  82302. protected _direction: Vector3;
  82303. protected _setDirection(value: Vector3): void;
  82304. /**
  82305. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82306. * Also use as the light direction on spot and directional lights.
  82307. */
  82308. get direction(): Vector3;
  82309. /**
  82310. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82311. * Also use as the light direction on spot and directional lights.
  82312. */
  82313. set direction(value: Vector3);
  82314. protected _shadowMinZ: number;
  82315. /**
  82316. * Gets the shadow projection clipping minimum z value.
  82317. */
  82318. get shadowMinZ(): number;
  82319. /**
  82320. * Sets the shadow projection clipping minimum z value.
  82321. */
  82322. set shadowMinZ(value: number);
  82323. protected _shadowMaxZ: number;
  82324. /**
  82325. * Sets the shadow projection clipping maximum z value.
  82326. */
  82327. get shadowMaxZ(): number;
  82328. /**
  82329. * Gets the shadow projection clipping maximum z value.
  82330. */
  82331. set shadowMaxZ(value: number);
  82332. /**
  82333. * Callback defining a custom Projection Matrix Builder.
  82334. * This can be used to override the default projection matrix computation.
  82335. */
  82336. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82337. /**
  82338. * The transformed position. Position of the light in world space taking parenting in account.
  82339. */
  82340. transformedPosition: Vector3;
  82341. /**
  82342. * The transformed direction. Direction of the light in world space taking parenting in account.
  82343. */
  82344. transformedDirection: Vector3;
  82345. private _needProjectionMatrixCompute;
  82346. /**
  82347. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82348. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82349. */
  82350. computeTransformedInformation(): boolean;
  82351. /**
  82352. * Return the depth scale used for the shadow map.
  82353. * @returns the depth scale.
  82354. */
  82355. getDepthScale(): number;
  82356. /**
  82357. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82360. */
  82361. getShadowDirection(faceIndex?: number): Vector3;
  82362. /**
  82363. * Returns the ShadowLight absolute position in the World.
  82364. * @returns the position vector in world space
  82365. */
  82366. getAbsolutePosition(): Vector3;
  82367. /**
  82368. * Sets the ShadowLight direction toward the passed target.
  82369. * @param target The point to target in local space
  82370. * @returns the updated ShadowLight direction
  82371. */
  82372. setDirectionToTarget(target: Vector3): Vector3;
  82373. /**
  82374. * Returns the light rotation in euler definition.
  82375. * @returns the x y z rotation in local space.
  82376. */
  82377. getRotation(): Vector3;
  82378. /**
  82379. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82380. * @returns true if a cube texture needs to be use
  82381. */
  82382. needCube(): boolean;
  82383. /**
  82384. * Detects if the projection matrix requires to be recomputed this frame.
  82385. * @returns true if it requires to be recomputed otherwise, false.
  82386. */
  82387. needProjectionMatrixCompute(): boolean;
  82388. /**
  82389. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82390. */
  82391. forceProjectionMatrixCompute(): void;
  82392. /** @hidden */
  82393. _initCache(): void;
  82394. /** @hidden */
  82395. _isSynchronized(): boolean;
  82396. /**
  82397. * Computes the world matrix of the node
  82398. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82399. * @returns the world matrix
  82400. */
  82401. computeWorldMatrix(force?: boolean): Matrix;
  82402. /**
  82403. * Gets the minZ used for shadow according to both the scene and the light.
  82404. * @param activeCamera The camera we are returning the min for
  82405. * @returns the depth min z
  82406. */
  82407. getDepthMinZ(activeCamera: Camera): number;
  82408. /**
  82409. * Gets the maxZ used for shadow according to both the scene and the light.
  82410. * @param activeCamera The camera we are returning the max for
  82411. * @returns the depth max z
  82412. */
  82413. getDepthMaxZ(activeCamera: Camera): number;
  82414. /**
  82415. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82416. * @param matrix The materix to updated with the projection information
  82417. * @param viewMatrix The transform matrix of the light
  82418. * @param renderList The list of mesh to render in the map
  82419. * @returns The current light
  82420. */
  82421. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82422. }
  82423. }
  82424. declare module BABYLON {
  82425. /**
  82426. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82427. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82428. */
  82429. export class EffectFallbacks implements IEffectFallbacks {
  82430. private _defines;
  82431. private _currentRank;
  82432. private _maxRank;
  82433. private _mesh;
  82434. /**
  82435. * Removes the fallback from the bound mesh.
  82436. */
  82437. unBindMesh(): void;
  82438. /**
  82439. * Adds a fallback on the specified property.
  82440. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82441. * @param define The name of the define in the shader
  82442. */
  82443. addFallback(rank: number, define: string): void;
  82444. /**
  82445. * Sets the mesh to use CPU skinning when needing to fallback.
  82446. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82447. * @param mesh The mesh to use the fallbacks.
  82448. */
  82449. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82450. /**
  82451. * Checks to see if more fallbacks are still availible.
  82452. */
  82453. get hasMoreFallbacks(): boolean;
  82454. /**
  82455. * Removes the defines that should be removed when falling back.
  82456. * @param currentDefines defines the current define statements for the shader.
  82457. * @param effect defines the current effect we try to compile
  82458. * @returns The resulting defines with defines of the current rank removed.
  82459. */
  82460. reduce(currentDefines: string, effect: Effect): string;
  82461. }
  82462. }
  82463. declare module BABYLON {
  82464. /**
  82465. * "Static Class" containing the most commonly used helper while dealing with material for
  82466. * rendering purpose.
  82467. *
  82468. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82469. *
  82470. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82471. */
  82472. export class MaterialHelper {
  82473. /**
  82474. * Bind the current view position to an effect.
  82475. * @param effect The effect to be bound
  82476. * @param scene The scene the eyes position is used from
  82477. */
  82478. static BindEyePosition(effect: Effect, scene: Scene): void;
  82479. /**
  82480. * Helps preparing the defines values about the UVs in used in the effect.
  82481. * UVs are shared as much as we can accross channels in the shaders.
  82482. * @param texture The texture we are preparing the UVs for
  82483. * @param defines The defines to update
  82484. * @param key The channel key "diffuse", "specular"... used in the shader
  82485. */
  82486. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82487. /**
  82488. * Binds a texture matrix value to its corrsponding uniform
  82489. * @param texture The texture to bind the matrix for
  82490. * @param uniformBuffer The uniform buffer receivin the data
  82491. * @param key The channel key "diffuse", "specular"... used in the shader
  82492. */
  82493. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82494. /**
  82495. * Gets the current status of the fog (should it be enabled?)
  82496. * @param mesh defines the mesh to evaluate for fog support
  82497. * @param scene defines the hosting scene
  82498. * @returns true if fog must be enabled
  82499. */
  82500. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82501. /**
  82502. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82503. * @param mesh defines the current mesh
  82504. * @param scene defines the current scene
  82505. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82506. * @param pointsCloud defines if point cloud rendering has to be turned on
  82507. * @param fogEnabled defines if fog has to be turned on
  82508. * @param alphaTest defines if alpha testing has to be turned on
  82509. * @param defines defines the current list of defines
  82510. */
  82511. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82512. /**
  82513. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82514. * @param scene defines the current scene
  82515. * @param engine defines the current engine
  82516. * @param defines specifies the list of active defines
  82517. * @param useInstances defines if instances have to be turned on
  82518. * @param useClipPlane defines if clip plane have to be turned on
  82519. */
  82520. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82521. /**
  82522. * Prepares the defines for bones
  82523. * @param mesh The mesh containing the geometry data we will draw
  82524. * @param defines The defines to update
  82525. */
  82526. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82527. /**
  82528. * Prepares the defines for morph targets
  82529. * @param mesh The mesh containing the geometry data we will draw
  82530. * @param defines The defines to update
  82531. */
  82532. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82533. /**
  82534. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82535. * @param mesh The mesh containing the geometry data we will draw
  82536. * @param defines The defines to update
  82537. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82538. * @param useBones Precise whether bones should be used or not (override mesh info)
  82539. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82540. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82541. * @returns false if defines are considered not dirty and have not been checked
  82542. */
  82543. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82544. /**
  82545. * Prepares the defines related to multiview
  82546. * @param scene The scene we are intending to draw
  82547. * @param defines The defines to update
  82548. */
  82549. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82550. /**
  82551. * Prepares the defines related to the light information passed in parameter
  82552. * @param scene The scene we are intending to draw
  82553. * @param mesh The mesh the effect is compiling for
  82554. * @param light The light the effect is compiling for
  82555. * @param lightIndex The index of the light
  82556. * @param defines The defines to update
  82557. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82558. * @param state Defines the current state regarding what is needed (normals, etc...)
  82559. */
  82560. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82561. needNormals: boolean;
  82562. needRebuild: boolean;
  82563. shadowEnabled: boolean;
  82564. specularEnabled: boolean;
  82565. lightmapMode: boolean;
  82566. }): void;
  82567. /**
  82568. * Prepares the defines related to the light information passed in parameter
  82569. * @param scene The scene we are intending to draw
  82570. * @param mesh The mesh the effect is compiling for
  82571. * @param defines The defines to update
  82572. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82573. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82574. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82575. * @returns true if normals will be required for the rest of the effect
  82576. */
  82577. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82578. /**
  82579. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82580. * @param lightIndex defines the light index
  82581. * @param uniformsList The uniform list
  82582. * @param samplersList The sampler list
  82583. * @param projectedLightTexture defines if projected texture must be used
  82584. * @param uniformBuffersList defines an optional list of uniform buffers
  82585. */
  82586. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82587. /**
  82588. * Prepares the uniforms and samplers list to be used in the effect
  82589. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82590. * @param samplersList The sampler list
  82591. * @param defines The defines helping in the list generation
  82592. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82593. */
  82594. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82595. /**
  82596. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82597. * @param defines The defines to update while falling back
  82598. * @param fallbacks The authorized effect fallbacks
  82599. * @param maxSimultaneousLights The maximum number of lights allowed
  82600. * @param rank the current rank of the Effect
  82601. * @returns The newly affected rank
  82602. */
  82603. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82604. private static _TmpMorphInfluencers;
  82605. /**
  82606. * Prepares the list of attributes required for morph targets according to the effect defines.
  82607. * @param attribs The current list of supported attribs
  82608. * @param mesh The mesh to prepare the morph targets attributes for
  82609. * @param influencers The number of influencers
  82610. */
  82611. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82612. /**
  82613. * Prepares the list of attributes required for morph targets according to the effect defines.
  82614. * @param attribs The current list of supported attribs
  82615. * @param mesh The mesh to prepare the morph targets attributes for
  82616. * @param defines The current Defines of the effect
  82617. */
  82618. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82619. /**
  82620. * Prepares the list of attributes required for bones according to the effect defines.
  82621. * @param attribs The current list of supported attribs
  82622. * @param mesh The mesh to prepare the bones attributes for
  82623. * @param defines The current Defines of the effect
  82624. * @param fallbacks The current efffect fallback strategy
  82625. */
  82626. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82627. /**
  82628. * Check and prepare the list of attributes required for instances according to the effect defines.
  82629. * @param attribs The current list of supported attribs
  82630. * @param defines The current MaterialDefines of the effect
  82631. */
  82632. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82633. /**
  82634. * Add the list of attributes required for instances to the attribs array.
  82635. * @param attribs The current list of supported attribs
  82636. */
  82637. static PushAttributesForInstances(attribs: string[]): void;
  82638. /**
  82639. * Binds the light information to the effect.
  82640. * @param light The light containing the generator
  82641. * @param effect The effect we are binding the data to
  82642. * @param lightIndex The light index in the effect used to render
  82643. */
  82644. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82645. /**
  82646. * Binds the lights information from the scene to the effect for the given mesh.
  82647. * @param light Light to bind
  82648. * @param lightIndex Light index
  82649. * @param scene The scene where the light belongs to
  82650. * @param effect The effect we are binding the data to
  82651. * @param useSpecular Defines if specular is supported
  82652. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82653. */
  82654. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82655. /**
  82656. * Binds the lights information from the scene to the effect for the given mesh.
  82657. * @param scene The scene the lights belongs to
  82658. * @param mesh The mesh we are binding the information to render
  82659. * @param effect The effect we are binding the data to
  82660. * @param defines The generated defines for the effect
  82661. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82662. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82663. */
  82664. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82665. private static _tempFogColor;
  82666. /**
  82667. * Binds the fog information from the scene to the effect for the given mesh.
  82668. * @param scene The scene the lights belongs to
  82669. * @param mesh The mesh we are binding the information to render
  82670. * @param effect The effect we are binding the data to
  82671. * @param linearSpace Defines if the fog effect is applied in linear space
  82672. */
  82673. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82674. /**
  82675. * Binds the bones information from the mesh to the effect.
  82676. * @param mesh The mesh we are binding the information to render
  82677. * @param effect The effect we are binding the data to
  82678. */
  82679. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82680. /**
  82681. * Binds the morph targets information from the mesh to the effect.
  82682. * @param abstractMesh The mesh we are binding the information to render
  82683. * @param effect The effect we are binding the data to
  82684. */
  82685. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82686. /**
  82687. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82688. * @param defines The generated defines used in the effect
  82689. * @param effect The effect we are binding the data to
  82690. * @param scene The scene we are willing to render with logarithmic scale for
  82691. */
  82692. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82693. /**
  82694. * Binds the clip plane information from the scene to the effect.
  82695. * @param scene The scene the clip plane information are extracted from
  82696. * @param effect The effect we are binding the data to
  82697. */
  82698. static BindClipPlane(effect: Effect, scene: Scene): void;
  82699. }
  82700. }
  82701. declare module BABYLON {
  82702. /** @hidden */
  82703. export var packingFunctions: {
  82704. name: string;
  82705. shader: string;
  82706. };
  82707. }
  82708. declare module BABYLON {
  82709. /** @hidden */
  82710. export var clipPlaneFragmentDeclaration: {
  82711. name: string;
  82712. shader: string;
  82713. };
  82714. }
  82715. declare module BABYLON {
  82716. /** @hidden */
  82717. export var clipPlaneFragment: {
  82718. name: string;
  82719. shader: string;
  82720. };
  82721. }
  82722. declare module BABYLON {
  82723. /** @hidden */
  82724. export var shadowMapPixelShader: {
  82725. name: string;
  82726. shader: string;
  82727. };
  82728. }
  82729. declare module BABYLON {
  82730. /** @hidden */
  82731. export var bonesDeclaration: {
  82732. name: string;
  82733. shader: string;
  82734. };
  82735. }
  82736. declare module BABYLON {
  82737. /** @hidden */
  82738. export var morphTargetsVertexGlobalDeclaration: {
  82739. name: string;
  82740. shader: string;
  82741. };
  82742. }
  82743. declare module BABYLON {
  82744. /** @hidden */
  82745. export var morphTargetsVertexDeclaration: {
  82746. name: string;
  82747. shader: string;
  82748. };
  82749. }
  82750. declare module BABYLON {
  82751. /** @hidden */
  82752. export var instancesDeclaration: {
  82753. name: string;
  82754. shader: string;
  82755. };
  82756. }
  82757. declare module BABYLON {
  82758. /** @hidden */
  82759. export var helperFunctions: {
  82760. name: string;
  82761. shader: string;
  82762. };
  82763. }
  82764. declare module BABYLON {
  82765. /** @hidden */
  82766. export var clipPlaneVertexDeclaration: {
  82767. name: string;
  82768. shader: string;
  82769. };
  82770. }
  82771. declare module BABYLON {
  82772. /** @hidden */
  82773. export var morphTargetsVertex: {
  82774. name: string;
  82775. shader: string;
  82776. };
  82777. }
  82778. declare module BABYLON {
  82779. /** @hidden */
  82780. export var instancesVertex: {
  82781. name: string;
  82782. shader: string;
  82783. };
  82784. }
  82785. declare module BABYLON {
  82786. /** @hidden */
  82787. export var bonesVertex: {
  82788. name: string;
  82789. shader: string;
  82790. };
  82791. }
  82792. declare module BABYLON {
  82793. /** @hidden */
  82794. export var clipPlaneVertex: {
  82795. name: string;
  82796. shader: string;
  82797. };
  82798. }
  82799. declare module BABYLON {
  82800. /** @hidden */
  82801. export var shadowMapVertexShader: {
  82802. name: string;
  82803. shader: string;
  82804. };
  82805. }
  82806. declare module BABYLON {
  82807. /** @hidden */
  82808. export var depthBoxBlurPixelShader: {
  82809. name: string;
  82810. shader: string;
  82811. };
  82812. }
  82813. declare module BABYLON {
  82814. /**
  82815. * Class representing a ray with position and direction
  82816. */
  82817. export class Ray {
  82818. /** origin point */
  82819. origin: Vector3;
  82820. /** direction */
  82821. direction: Vector3;
  82822. /** length of the ray */
  82823. length: number;
  82824. private static readonly TmpVector3;
  82825. private _tmpRay;
  82826. /**
  82827. * Creates a new ray
  82828. * @param origin origin point
  82829. * @param direction direction
  82830. * @param length length of the ray
  82831. */
  82832. constructor(
  82833. /** origin point */
  82834. origin: Vector3,
  82835. /** direction */
  82836. direction: Vector3,
  82837. /** length of the ray */
  82838. length?: number);
  82839. /**
  82840. * Checks if the ray intersects a box
  82841. * @param minimum bound of the box
  82842. * @param maximum bound of the box
  82843. * @param intersectionTreshold extra extend to be added to the box in all direction
  82844. * @returns if the box was hit
  82845. */
  82846. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82847. /**
  82848. * Checks if the ray intersects a box
  82849. * @param box the bounding box to check
  82850. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82851. * @returns if the box was hit
  82852. */
  82853. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82854. /**
  82855. * If the ray hits a sphere
  82856. * @param sphere the bounding sphere to check
  82857. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82858. * @returns true if it hits the sphere
  82859. */
  82860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82861. /**
  82862. * If the ray hits a triange
  82863. * @param vertex0 triangle vertex
  82864. * @param vertex1 triangle vertex
  82865. * @param vertex2 triangle vertex
  82866. * @returns intersection information if hit
  82867. */
  82868. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82869. /**
  82870. * Checks if ray intersects a plane
  82871. * @param plane the plane to check
  82872. * @returns the distance away it was hit
  82873. */
  82874. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82875. /**
  82876. * Calculate the intercept of a ray on a given axis
  82877. * @param axis to check 'x' | 'y' | 'z'
  82878. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82879. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82880. */
  82881. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82882. /**
  82883. * Checks if ray intersects a mesh
  82884. * @param mesh the mesh to check
  82885. * @param fastCheck if only the bounding box should checked
  82886. * @returns picking info of the intersecton
  82887. */
  82888. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82889. /**
  82890. * Checks if ray intersects a mesh
  82891. * @param meshes the meshes to check
  82892. * @param fastCheck if only the bounding box should checked
  82893. * @param results array to store result in
  82894. * @returns Array of picking infos
  82895. */
  82896. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82897. private _comparePickingInfo;
  82898. private static smallnum;
  82899. private static rayl;
  82900. /**
  82901. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82902. * @param sega the first point of the segment to test the intersection against
  82903. * @param segb the second point of the segment to test the intersection against
  82904. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82905. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82906. */
  82907. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82908. /**
  82909. * Update the ray from viewport position
  82910. * @param x position
  82911. * @param y y position
  82912. * @param viewportWidth viewport width
  82913. * @param viewportHeight viewport height
  82914. * @param world world matrix
  82915. * @param view view matrix
  82916. * @param projection projection matrix
  82917. * @returns this ray updated
  82918. */
  82919. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82920. /**
  82921. * Creates a ray with origin and direction of 0,0,0
  82922. * @returns the new ray
  82923. */
  82924. static Zero(): Ray;
  82925. /**
  82926. * Creates a new ray from screen space and viewport
  82927. * @param x position
  82928. * @param y y position
  82929. * @param viewportWidth viewport width
  82930. * @param viewportHeight viewport height
  82931. * @param world world matrix
  82932. * @param view view matrix
  82933. * @param projection projection matrix
  82934. * @returns new ray
  82935. */
  82936. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82937. /**
  82938. * 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
  82939. * transformed to the given world matrix.
  82940. * @param origin The origin point
  82941. * @param end The end point
  82942. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82943. * @returns the new ray
  82944. */
  82945. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82946. /**
  82947. * Transforms a ray by a matrix
  82948. * @param ray ray to transform
  82949. * @param matrix matrix to apply
  82950. * @returns the resulting new ray
  82951. */
  82952. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82953. /**
  82954. * Transforms a ray by a matrix
  82955. * @param ray ray to transform
  82956. * @param matrix matrix to apply
  82957. * @param result ray to store result in
  82958. */
  82959. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82960. /**
  82961. * Unproject a ray from screen space to object space
  82962. * @param sourceX defines the screen space x coordinate to use
  82963. * @param sourceY defines the screen space y coordinate to use
  82964. * @param viewportWidth defines the current width of the viewport
  82965. * @param viewportHeight defines the current height of the viewport
  82966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82967. * @param view defines the view matrix to use
  82968. * @param projection defines the projection matrix to use
  82969. */
  82970. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82971. }
  82972. /**
  82973. * Type used to define predicate used to select faces when a mesh intersection is detected
  82974. */
  82975. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82976. interface Scene {
  82977. /** @hidden */
  82978. _tempPickingRay: Nullable<Ray>;
  82979. /** @hidden */
  82980. _cachedRayForTransform: Ray;
  82981. /** @hidden */
  82982. _pickWithRayInverseMatrix: Matrix;
  82983. /** @hidden */
  82984. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82985. /** @hidden */
  82986. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82987. }
  82988. }
  82989. declare module BABYLON {
  82990. /**
  82991. * Groups all the scene component constants in one place to ease maintenance.
  82992. * @hidden
  82993. */
  82994. export class SceneComponentConstants {
  82995. static readonly NAME_EFFECTLAYER: string;
  82996. static readonly NAME_LAYER: string;
  82997. static readonly NAME_LENSFLARESYSTEM: string;
  82998. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82999. static readonly NAME_PARTICLESYSTEM: string;
  83000. static readonly NAME_GAMEPAD: string;
  83001. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83002. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83003. static readonly NAME_DEPTHRENDERER: string;
  83004. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83005. static readonly NAME_SPRITE: string;
  83006. static readonly NAME_OUTLINERENDERER: string;
  83007. static readonly NAME_PROCEDURALTEXTURE: string;
  83008. static readonly NAME_SHADOWGENERATOR: string;
  83009. static readonly NAME_OCTREE: string;
  83010. static readonly NAME_PHYSICSENGINE: string;
  83011. static readonly NAME_AUDIO: string;
  83012. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83013. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83014. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83015. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83016. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83017. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83018. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83019. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83020. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83021. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83022. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83023. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83024. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83025. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83026. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83027. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83028. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83029. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83031. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83032. static readonly STEP_AFTERRENDER_AUDIO: number;
  83033. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83034. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83035. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83036. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83037. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83038. static readonly STEP_POINTERMOVE_SPRITE: number;
  83039. static readonly STEP_POINTERDOWN_SPRITE: number;
  83040. static readonly STEP_POINTERUP_SPRITE: number;
  83041. }
  83042. /**
  83043. * This represents a scene component.
  83044. *
  83045. * This is used to decouple the dependency the scene is having on the different workloads like
  83046. * layers, post processes...
  83047. */
  83048. export interface ISceneComponent {
  83049. /**
  83050. * The name of the component. Each component must have a unique name.
  83051. */
  83052. name: string;
  83053. /**
  83054. * The scene the component belongs to.
  83055. */
  83056. scene: Scene;
  83057. /**
  83058. * Register the component to one instance of a scene.
  83059. */
  83060. register(): void;
  83061. /**
  83062. * Rebuilds the elements related to this component in case of
  83063. * context lost for instance.
  83064. */
  83065. rebuild(): void;
  83066. /**
  83067. * Disposes the component and the associated ressources.
  83068. */
  83069. dispose(): void;
  83070. }
  83071. /**
  83072. * This represents a SERIALIZABLE scene component.
  83073. *
  83074. * This extends Scene Component to add Serialization methods on top.
  83075. */
  83076. export interface ISceneSerializableComponent extends ISceneComponent {
  83077. /**
  83078. * Adds all the elements from the container to the scene
  83079. * @param container the container holding the elements
  83080. */
  83081. addFromContainer(container: AbstractScene): void;
  83082. /**
  83083. * Removes all the elements in the container from the scene
  83084. * @param container contains the elements to remove
  83085. * @param dispose if the removed element should be disposed (default: false)
  83086. */
  83087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83088. /**
  83089. * Serializes the component data to the specified json object
  83090. * @param serializationObject The object to serialize to
  83091. */
  83092. serialize(serializationObject: any): void;
  83093. }
  83094. /**
  83095. * Strong typing of a Mesh related stage step action
  83096. */
  83097. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83098. /**
  83099. * Strong typing of a Evaluate Sub Mesh related stage step action
  83100. */
  83101. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83102. /**
  83103. * Strong typing of a Active Mesh related stage step action
  83104. */
  83105. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83106. /**
  83107. * Strong typing of a Camera related stage step action
  83108. */
  83109. export type CameraStageAction = (camera: Camera) => void;
  83110. /**
  83111. * Strong typing of a Camera Frame buffer related stage step action
  83112. */
  83113. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83114. /**
  83115. * Strong typing of a Render Target related stage step action
  83116. */
  83117. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83118. /**
  83119. * Strong typing of a RenderingGroup related stage step action
  83120. */
  83121. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83122. /**
  83123. * Strong typing of a Mesh Render related stage step action
  83124. */
  83125. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83126. /**
  83127. * Strong typing of a simple stage step action
  83128. */
  83129. export type SimpleStageAction = () => void;
  83130. /**
  83131. * Strong typing of a render target action.
  83132. */
  83133. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83134. /**
  83135. * Strong typing of a pointer move action.
  83136. */
  83137. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83138. /**
  83139. * Strong typing of a pointer up/down action.
  83140. */
  83141. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83142. /**
  83143. * Representation of a stage in the scene (Basically a list of ordered steps)
  83144. * @hidden
  83145. */
  83146. export class Stage<T extends Function> extends Array<{
  83147. index: number;
  83148. component: ISceneComponent;
  83149. action: T;
  83150. }> {
  83151. /**
  83152. * Hide ctor from the rest of the world.
  83153. * @param items The items to add.
  83154. */
  83155. private constructor();
  83156. /**
  83157. * Creates a new Stage.
  83158. * @returns A new instance of a Stage
  83159. */
  83160. static Create<T extends Function>(): Stage<T>;
  83161. /**
  83162. * Registers a step in an ordered way in the targeted stage.
  83163. * @param index Defines the position to register the step in
  83164. * @param component Defines the component attached to the step
  83165. * @param action Defines the action to launch during the step
  83166. */
  83167. registerStep(index: number, component: ISceneComponent, action: T): void;
  83168. /**
  83169. * Clears all the steps from the stage.
  83170. */
  83171. clear(): void;
  83172. }
  83173. }
  83174. declare module BABYLON {
  83175. interface Scene {
  83176. /** @hidden */
  83177. _pointerOverSprite: Nullable<Sprite>;
  83178. /** @hidden */
  83179. _pickedDownSprite: Nullable<Sprite>;
  83180. /** @hidden */
  83181. _tempSpritePickingRay: Nullable<Ray>;
  83182. /**
  83183. * All of the sprite managers added to this scene
  83184. * @see http://doc.babylonjs.com/babylon101/sprites
  83185. */
  83186. spriteManagers: Array<ISpriteManager>;
  83187. /**
  83188. * An event triggered when sprites rendering is about to start
  83189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83190. */
  83191. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83192. /**
  83193. * An event triggered when sprites rendering is done
  83194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83195. */
  83196. onAfterSpritesRenderingObservable: Observable<Scene>;
  83197. /** @hidden */
  83198. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83199. /** Launch a ray to try to pick a sprite in the scene
  83200. * @param x position on screen
  83201. * @param y position on screen
  83202. * @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
  83203. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83205. * @returns a PickingInfo
  83206. */
  83207. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83208. /** Use the given ray to pick a sprite in the scene
  83209. * @param ray The ray (in world space) to use to pick meshes
  83210. * @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
  83211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83213. * @returns a PickingInfo
  83214. */
  83215. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83216. /** @hidden */
  83217. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83218. /** Launch a ray to try to pick sprites in the scene
  83219. * @param x position on screen
  83220. * @param y position on screen
  83221. * @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
  83222. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83223. * @returns a PickingInfo array
  83224. */
  83225. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83226. /** Use the given ray to pick sprites in the scene
  83227. * @param ray The ray (in world space) to use to pick meshes
  83228. * @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
  83229. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83230. * @returns a PickingInfo array
  83231. */
  83232. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83233. /**
  83234. * Force the sprite under the pointer
  83235. * @param sprite defines the sprite to use
  83236. */
  83237. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83238. /**
  83239. * Gets the sprite under the pointer
  83240. * @returns a Sprite or null if no sprite is under the pointer
  83241. */
  83242. getPointerOverSprite(): Nullable<Sprite>;
  83243. }
  83244. /**
  83245. * Defines the sprite scene component responsible to manage sprites
  83246. * in a given scene.
  83247. */
  83248. export class SpriteSceneComponent implements ISceneComponent {
  83249. /**
  83250. * The component name helpfull to identify the component in the list of scene components.
  83251. */
  83252. readonly name: string;
  83253. /**
  83254. * The scene the component belongs to.
  83255. */
  83256. scene: Scene;
  83257. /** @hidden */
  83258. private _spritePredicate;
  83259. /**
  83260. * Creates a new instance of the component for the given scene
  83261. * @param scene Defines the scene to register the component in
  83262. */
  83263. constructor(scene: Scene);
  83264. /**
  83265. * Registers the component in a given scene
  83266. */
  83267. register(): void;
  83268. /**
  83269. * Rebuilds the elements related to this component in case of
  83270. * context lost for instance.
  83271. */
  83272. rebuild(): void;
  83273. /**
  83274. * Disposes the component and the associated ressources.
  83275. */
  83276. dispose(): void;
  83277. private _pickSpriteButKeepRay;
  83278. private _pointerMove;
  83279. private _pointerDown;
  83280. private _pointerUp;
  83281. }
  83282. }
  83283. declare module BABYLON {
  83284. /** @hidden */
  83285. export var fogFragmentDeclaration: {
  83286. name: string;
  83287. shader: string;
  83288. };
  83289. }
  83290. declare module BABYLON {
  83291. /** @hidden */
  83292. export var fogFragment: {
  83293. name: string;
  83294. shader: string;
  83295. };
  83296. }
  83297. declare module BABYLON {
  83298. /** @hidden */
  83299. export var spritesPixelShader: {
  83300. name: string;
  83301. shader: string;
  83302. };
  83303. }
  83304. declare module BABYLON {
  83305. /** @hidden */
  83306. export var fogVertexDeclaration: {
  83307. name: string;
  83308. shader: string;
  83309. };
  83310. }
  83311. declare module BABYLON {
  83312. /** @hidden */
  83313. export var spritesVertexShader: {
  83314. name: string;
  83315. shader: string;
  83316. };
  83317. }
  83318. declare module BABYLON {
  83319. /**
  83320. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83321. */
  83322. export interface ISpriteManager extends IDisposable {
  83323. /**
  83324. * Restricts the camera to viewing objects with the same layerMask.
  83325. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83326. */
  83327. layerMask: number;
  83328. /**
  83329. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83330. */
  83331. isPickable: boolean;
  83332. /**
  83333. * Specifies the rendering group id for this mesh (0 by default)
  83334. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83335. */
  83336. renderingGroupId: number;
  83337. /**
  83338. * Defines the list of sprites managed by the manager.
  83339. */
  83340. sprites: Array<Sprite>;
  83341. /**
  83342. * Tests the intersection of a sprite with a specific ray.
  83343. * @param ray The ray we are sending to test the collision
  83344. * @param camera The camera space we are sending rays in
  83345. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83346. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83347. * @returns picking info or null.
  83348. */
  83349. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83350. /**
  83351. * Intersects the sprites with a ray
  83352. * @param ray defines the ray to intersect with
  83353. * @param camera defines the current active camera
  83354. * @param predicate defines a predicate used to select candidate sprites
  83355. * @returns null if no hit or a PickingInfo array
  83356. */
  83357. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83358. /**
  83359. * Renders the list of sprites on screen.
  83360. */
  83361. render(): void;
  83362. }
  83363. /**
  83364. * Class used to manage multiple sprites on the same spritesheet
  83365. * @see http://doc.babylonjs.com/babylon101/sprites
  83366. */
  83367. export class SpriteManager implements ISpriteManager {
  83368. /** defines the manager's name */
  83369. name: string;
  83370. /** Gets the list of sprites */
  83371. sprites: Sprite[];
  83372. /** Gets or sets the rendering group id (0 by default) */
  83373. renderingGroupId: number;
  83374. /** Gets or sets camera layer mask */
  83375. layerMask: number;
  83376. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83377. fogEnabled: boolean;
  83378. /** Gets or sets a boolean indicating if the sprites are pickable */
  83379. isPickable: boolean;
  83380. /** Defines the default width of a cell in the spritesheet */
  83381. cellWidth: number;
  83382. /** Defines the default height of a cell in the spritesheet */
  83383. cellHeight: number;
  83384. /** Associative array from JSON sprite data file */
  83385. private _cellData;
  83386. /** Array of sprite names from JSON sprite data file */
  83387. private _spriteMap;
  83388. /** True when packed cell data from JSON file is ready*/
  83389. private _packedAndReady;
  83390. /**
  83391. * An event triggered when the manager is disposed.
  83392. */
  83393. onDisposeObservable: Observable<SpriteManager>;
  83394. private _onDisposeObserver;
  83395. /**
  83396. * Callback called when the manager is disposed
  83397. */
  83398. set onDispose(callback: () => void);
  83399. private _capacity;
  83400. private _fromPacked;
  83401. private _spriteTexture;
  83402. private _epsilon;
  83403. private _scene;
  83404. private _vertexData;
  83405. private _buffer;
  83406. private _vertexBuffers;
  83407. private _indexBuffer;
  83408. private _effectBase;
  83409. private _effectFog;
  83410. /**
  83411. * Gets or sets the spritesheet texture
  83412. */
  83413. get texture(): Texture;
  83414. set texture(value: Texture);
  83415. private _blendMode;
  83416. /**
  83417. * Blend mode use to render the particle, it can be any of
  83418. * the static Constants.ALPHA_x properties provided in this class.
  83419. * Default value is Constants.ALPHA_COMBINE
  83420. */
  83421. get blendMode(): number;
  83422. set blendMode(blendMode: number);
  83423. /** Disables writing to the depth buffer when rendering the sprites.
  83424. * It can be handy to disable depth writing when using textures without alpha channel
  83425. * and setting some specific blend modes.
  83426. */
  83427. disableDepthWrite: boolean;
  83428. /**
  83429. * Creates a new sprite manager
  83430. * @param name defines the manager's name
  83431. * @param imgUrl defines the sprite sheet url
  83432. * @param capacity defines the maximum allowed number of sprites
  83433. * @param cellSize defines the size of a sprite cell
  83434. * @param scene defines the hosting scene
  83435. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83436. * @param samplingMode defines the smapling mode to use with spritesheet
  83437. * @param fromPacked set to false; do not alter
  83438. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83439. */
  83440. constructor(
  83441. /** defines the manager's name */
  83442. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83443. private _makePacked;
  83444. private _appendSpriteVertex;
  83445. /**
  83446. * Intersects the sprites with a ray
  83447. * @param ray defines the ray to intersect with
  83448. * @param camera defines the current active camera
  83449. * @param predicate defines a predicate used to select candidate sprites
  83450. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83451. * @returns null if no hit or a PickingInfo
  83452. */
  83453. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83454. /**
  83455. * Intersects the sprites with a ray
  83456. * @param ray defines the ray to intersect with
  83457. * @param camera defines the current active camera
  83458. * @param predicate defines a predicate used to select candidate sprites
  83459. * @returns null if no hit or a PickingInfo array
  83460. */
  83461. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83462. /**
  83463. * Render all child sprites
  83464. */
  83465. render(): void;
  83466. /**
  83467. * Release associated resources
  83468. */
  83469. dispose(): void;
  83470. }
  83471. }
  83472. declare module BABYLON {
  83473. /** Interface used by value gradients (color, factor, ...) */
  83474. export interface IValueGradient {
  83475. /**
  83476. * Gets or sets the gradient value (between 0 and 1)
  83477. */
  83478. gradient: number;
  83479. }
  83480. /** Class used to store color4 gradient */
  83481. export class ColorGradient implements IValueGradient {
  83482. /**
  83483. * Gets or sets the gradient value (between 0 and 1)
  83484. */
  83485. gradient: number;
  83486. /**
  83487. * Gets or sets first associated color
  83488. */
  83489. color1: Color4;
  83490. /**
  83491. * Gets or sets second associated color
  83492. */
  83493. color2?: Color4;
  83494. /**
  83495. * Will get a color picked randomly between color1 and color2.
  83496. * If color2 is undefined then color1 will be used
  83497. * @param result defines the target Color4 to store the result in
  83498. */
  83499. getColorToRef(result: Color4): void;
  83500. }
  83501. /** Class used to store color 3 gradient */
  83502. export class Color3Gradient implements IValueGradient {
  83503. /**
  83504. * Gets or sets the gradient value (between 0 and 1)
  83505. */
  83506. gradient: number;
  83507. /**
  83508. * Gets or sets the associated color
  83509. */
  83510. color: Color3;
  83511. }
  83512. /** Class used to store factor gradient */
  83513. export class FactorGradient implements IValueGradient {
  83514. /**
  83515. * Gets or sets the gradient value (between 0 and 1)
  83516. */
  83517. gradient: number;
  83518. /**
  83519. * Gets or sets first associated factor
  83520. */
  83521. factor1: number;
  83522. /**
  83523. * Gets or sets second associated factor
  83524. */
  83525. factor2?: number;
  83526. /**
  83527. * Will get a number picked randomly between factor1 and factor2.
  83528. * If factor2 is undefined then factor1 will be used
  83529. * @returns the picked number
  83530. */
  83531. getFactor(): number;
  83532. }
  83533. /**
  83534. * Helper used to simplify some generic gradient tasks
  83535. */
  83536. export class GradientHelper {
  83537. /**
  83538. * Gets the current gradient from an array of IValueGradient
  83539. * @param ratio defines the current ratio to get
  83540. * @param gradients defines the array of IValueGradient
  83541. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83542. */
  83543. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83544. }
  83545. }
  83546. declare module BABYLON {
  83547. /**
  83548. * Interface for the size containing width and height
  83549. */
  83550. export interface ISize {
  83551. /**
  83552. * Width
  83553. */
  83554. width: number;
  83555. /**
  83556. * Heighht
  83557. */
  83558. height: number;
  83559. }
  83560. /**
  83561. * Size containing widht and height
  83562. */
  83563. export class Size implements ISize {
  83564. /**
  83565. * Width
  83566. */
  83567. width: number;
  83568. /**
  83569. * Height
  83570. */
  83571. height: number;
  83572. /**
  83573. * Creates a Size object from the given width and height (floats).
  83574. * @param width width of the new size
  83575. * @param height height of the new size
  83576. */
  83577. constructor(width: number, height: number);
  83578. /**
  83579. * Returns a string with the Size width and height
  83580. * @returns a string with the Size width and height
  83581. */
  83582. toString(): string;
  83583. /**
  83584. * "Size"
  83585. * @returns the string "Size"
  83586. */
  83587. getClassName(): string;
  83588. /**
  83589. * Returns the Size hash code.
  83590. * @returns a hash code for a unique width and height
  83591. */
  83592. getHashCode(): number;
  83593. /**
  83594. * Updates the current size from the given one.
  83595. * @param src the given size
  83596. */
  83597. copyFrom(src: Size): void;
  83598. /**
  83599. * Updates in place the current Size from the given floats.
  83600. * @param width width of the new size
  83601. * @param height height of the new size
  83602. * @returns the updated Size.
  83603. */
  83604. copyFromFloats(width: number, height: number): Size;
  83605. /**
  83606. * Updates in place the current Size from the given floats.
  83607. * @param width width to set
  83608. * @param height height to set
  83609. * @returns the updated Size.
  83610. */
  83611. set(width: number, height: number): Size;
  83612. /**
  83613. * Multiplies the width and height by numbers
  83614. * @param w factor to multiple the width by
  83615. * @param h factor to multiple the height by
  83616. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83617. */
  83618. multiplyByFloats(w: number, h: number): Size;
  83619. /**
  83620. * Clones the size
  83621. * @returns a new Size copied from the given one.
  83622. */
  83623. clone(): Size;
  83624. /**
  83625. * True if the current Size and the given one width and height are strictly equal.
  83626. * @param other the other size to compare against
  83627. * @returns True if the current Size and the given one width and height are strictly equal.
  83628. */
  83629. equals(other: Size): boolean;
  83630. /**
  83631. * The surface of the Size : width * height (float).
  83632. */
  83633. get surface(): number;
  83634. /**
  83635. * Create a new size of zero
  83636. * @returns a new Size set to (0.0, 0.0)
  83637. */
  83638. static Zero(): Size;
  83639. /**
  83640. * Sums the width and height of two sizes
  83641. * @param otherSize size to add to this size
  83642. * @returns a new Size set as the addition result of the current Size and the given one.
  83643. */
  83644. add(otherSize: Size): Size;
  83645. /**
  83646. * Subtracts the width and height of two
  83647. * @param otherSize size to subtract to this size
  83648. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83649. */
  83650. subtract(otherSize: Size): Size;
  83651. /**
  83652. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83653. * @param start starting size to lerp between
  83654. * @param end end size to lerp between
  83655. * @param amount amount to lerp between the start and end values
  83656. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83657. */
  83658. static Lerp(start: Size, end: Size, amount: number): Size;
  83659. }
  83660. }
  83661. declare module BABYLON {
  83662. interface ThinEngine {
  83663. /**
  83664. * Creates a dynamic texture
  83665. * @param width defines the width of the texture
  83666. * @param height defines the height of the texture
  83667. * @param generateMipMaps defines if the engine should generate the mip levels
  83668. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83669. * @returns the dynamic texture inside an InternalTexture
  83670. */
  83671. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83672. /**
  83673. * Update the content of a dynamic texture
  83674. * @param texture defines the texture to update
  83675. * @param canvas defines the canvas containing the source
  83676. * @param invertY defines if data must be stored with Y axis inverted
  83677. * @param premulAlpha defines if alpha is stored as premultiplied
  83678. * @param format defines the format of the data
  83679. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83680. */
  83681. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83682. }
  83683. }
  83684. declare module BABYLON {
  83685. /**
  83686. * Helper class used to generate a canvas to manipulate images
  83687. */
  83688. export class CanvasGenerator {
  83689. /**
  83690. * Create a new canvas (or offscreen canvas depending on the context)
  83691. * @param width defines the expected width
  83692. * @param height defines the expected height
  83693. * @return a new canvas or offscreen canvas
  83694. */
  83695. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83696. }
  83697. }
  83698. declare module BABYLON {
  83699. /**
  83700. * A class extending Texture allowing drawing on a texture
  83701. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83702. */
  83703. export class DynamicTexture extends Texture {
  83704. private _generateMipMaps;
  83705. private _canvas;
  83706. private _context;
  83707. private _engine;
  83708. /**
  83709. * Creates a DynamicTexture
  83710. * @param name defines the name of the texture
  83711. * @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
  83712. * @param scene defines the scene where you want the texture
  83713. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83714. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83715. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83716. */
  83717. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83718. /**
  83719. * Get the current class name of the texture useful for serialization or dynamic coding.
  83720. * @returns "DynamicTexture"
  83721. */
  83722. getClassName(): string;
  83723. /**
  83724. * Gets the current state of canRescale
  83725. */
  83726. get canRescale(): boolean;
  83727. private _recreate;
  83728. /**
  83729. * Scales the texture
  83730. * @param ratio the scale factor to apply to both width and height
  83731. */
  83732. scale(ratio: number): void;
  83733. /**
  83734. * Resizes the texture
  83735. * @param width the new width
  83736. * @param height the new height
  83737. */
  83738. scaleTo(width: number, height: number): void;
  83739. /**
  83740. * Gets the context of the canvas used by the texture
  83741. * @returns the canvas context of the dynamic texture
  83742. */
  83743. getContext(): CanvasRenderingContext2D;
  83744. /**
  83745. * Clears the texture
  83746. */
  83747. clear(): void;
  83748. /**
  83749. * Updates the texture
  83750. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83751. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83752. */
  83753. update(invertY?: boolean, premulAlpha?: boolean): void;
  83754. /**
  83755. * Draws text onto the texture
  83756. * @param text defines the text to be drawn
  83757. * @param x defines the placement of the text from the left
  83758. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83759. * @param font defines the font to be used with font-style, font-size, font-name
  83760. * @param color defines the color used for the text
  83761. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83762. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83763. * @param update defines whether texture is immediately update (default is true)
  83764. */
  83765. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83766. /**
  83767. * Clones the texture
  83768. * @returns the clone of the texture.
  83769. */
  83770. clone(): DynamicTexture;
  83771. /**
  83772. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83773. * @returns a serialized dynamic texture object
  83774. */
  83775. serialize(): any;
  83776. /** @hidden */
  83777. _rebuild(): void;
  83778. }
  83779. }
  83780. declare module BABYLON {
  83781. interface Engine {
  83782. /**
  83783. * Creates a raw texture
  83784. * @param data defines the data to store in the texture
  83785. * @param width defines the width of the texture
  83786. * @param height defines the height of the texture
  83787. * @param format defines the format of the data
  83788. * @param generateMipMaps defines if the engine should generate the mip levels
  83789. * @param invertY defines if data must be stored with Y axis inverted
  83790. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83791. * @param compression defines the compression used (null by default)
  83792. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83793. * @returns the raw texture inside an InternalTexture
  83794. */
  83795. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83796. /**
  83797. * Update a raw texture
  83798. * @param texture defines the texture to update
  83799. * @param data defines the data to store in the texture
  83800. * @param format defines the format of the data
  83801. * @param invertY defines if data must be stored with Y axis inverted
  83802. */
  83803. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83804. /**
  83805. * Update a raw texture
  83806. * @param texture defines the texture to update
  83807. * @param data defines the data to store in the texture
  83808. * @param format defines the format of the data
  83809. * @param invertY defines if data must be stored with Y axis inverted
  83810. * @param compression defines the compression used (null by default)
  83811. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83812. */
  83813. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83814. /**
  83815. * Creates a new raw cube texture
  83816. * @param data defines the array of data to use to create each face
  83817. * @param size defines the size of the textures
  83818. * @param format defines the format of the data
  83819. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83820. * @param generateMipMaps defines if the engine should generate the mip levels
  83821. * @param invertY defines if data must be stored with Y axis inverted
  83822. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83823. * @param compression defines the compression used (null by default)
  83824. * @returns the cube texture as an InternalTexture
  83825. */
  83826. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83827. /**
  83828. * Update a raw cube texture
  83829. * @param texture defines the texture to udpdate
  83830. * @param data defines the data to store
  83831. * @param format defines the data format
  83832. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83833. * @param invertY defines if data must be stored with Y axis inverted
  83834. */
  83835. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83836. /**
  83837. * Update a raw cube texture
  83838. * @param texture defines the texture to udpdate
  83839. * @param data defines the data to store
  83840. * @param format defines the data format
  83841. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83842. * @param invertY defines if data must be stored with Y axis inverted
  83843. * @param compression defines the compression used (null by default)
  83844. */
  83845. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83846. /**
  83847. * Update a raw cube texture
  83848. * @param texture defines the texture to udpdate
  83849. * @param data defines the data to store
  83850. * @param format defines the data format
  83851. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83852. * @param invertY defines if data must be stored with Y axis inverted
  83853. * @param compression defines the compression used (null by default)
  83854. * @param level defines which level of the texture to update
  83855. */
  83856. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83857. /**
  83858. * Creates a new raw cube texture from a specified url
  83859. * @param url defines the url where the data is located
  83860. * @param scene defines the current scene
  83861. * @param size defines the size of the textures
  83862. * @param format defines the format of the data
  83863. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83864. * @param noMipmap defines if the engine should avoid generating the mip levels
  83865. * @param callback defines a callback used to extract texture data from loaded data
  83866. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83867. * @param onLoad defines a callback called when texture is loaded
  83868. * @param onError defines a callback called if there is an error
  83869. * @returns the cube texture as an InternalTexture
  83870. */
  83871. 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;
  83872. /**
  83873. * Creates a new raw cube texture from a specified url
  83874. * @param url defines the url where the data is located
  83875. * @param scene defines the current scene
  83876. * @param size defines the size of the textures
  83877. * @param format defines the format of the data
  83878. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83879. * @param noMipmap defines if the engine should avoid generating the mip levels
  83880. * @param callback defines a callback used to extract texture data from loaded data
  83881. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83882. * @param onLoad defines a callback called when texture is loaded
  83883. * @param onError defines a callback called if there is an error
  83884. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83885. * @param invertY defines if data must be stored with Y axis inverted
  83886. * @returns the cube texture as an InternalTexture
  83887. */
  83888. 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;
  83889. /**
  83890. * Creates a new raw 3D texture
  83891. * @param data defines the data used to create the texture
  83892. * @param width defines the width of the texture
  83893. * @param height defines the height of the texture
  83894. * @param depth defines the depth of the texture
  83895. * @param format defines the format of the texture
  83896. * @param generateMipMaps defines if the engine must generate mip levels
  83897. * @param invertY defines if data must be stored with Y axis inverted
  83898. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83899. * @param compression defines the compressed used (can be null)
  83900. * @param textureType defines the compressed used (can be null)
  83901. * @returns a new raw 3D texture (stored in an InternalTexture)
  83902. */
  83903. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83904. /**
  83905. * Update a raw 3D texture
  83906. * @param texture defines the texture to update
  83907. * @param data defines the data to store
  83908. * @param format defines the data format
  83909. * @param invertY defines if data must be stored with Y axis inverted
  83910. */
  83911. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83912. /**
  83913. * Update a raw 3D texture
  83914. * @param texture defines the texture to update
  83915. * @param data defines the data to store
  83916. * @param format defines the data format
  83917. * @param invertY defines if data must be stored with Y axis inverted
  83918. * @param compression defines the used compression (can be null)
  83919. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83920. */
  83921. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83922. /**
  83923. * Creates a new raw 2D array texture
  83924. * @param data defines the data used to create the texture
  83925. * @param width defines the width of the texture
  83926. * @param height defines the height of the texture
  83927. * @param depth defines the number of layers of the texture
  83928. * @param format defines the format of the texture
  83929. * @param generateMipMaps defines if the engine must generate mip levels
  83930. * @param invertY defines if data must be stored with Y axis inverted
  83931. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83932. * @param compression defines the compressed used (can be null)
  83933. * @param textureType defines the compressed used (can be null)
  83934. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83935. */
  83936. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83937. /**
  83938. * Update a raw 2D array texture
  83939. * @param texture defines the texture to update
  83940. * @param data defines the data to store
  83941. * @param format defines the data format
  83942. * @param invertY defines if data must be stored with Y axis inverted
  83943. */
  83944. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83945. /**
  83946. * Update a raw 2D array texture
  83947. * @param texture defines the texture to update
  83948. * @param data defines the data to store
  83949. * @param format defines the data format
  83950. * @param invertY defines if data must be stored with Y axis inverted
  83951. * @param compression defines the used compression (can be null)
  83952. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83953. */
  83954. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83955. }
  83956. }
  83957. declare module BABYLON {
  83958. /**
  83959. * Raw texture can help creating a texture directly from an array of data.
  83960. * This can be super useful if you either get the data from an uncompressed source or
  83961. * if you wish to create your texture pixel by pixel.
  83962. */
  83963. export class RawTexture extends Texture {
  83964. /**
  83965. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83966. */
  83967. format: number;
  83968. private _engine;
  83969. /**
  83970. * Instantiates a new RawTexture.
  83971. * Raw texture can help creating a texture directly from an array of data.
  83972. * This can be super useful if you either get the data from an uncompressed source or
  83973. * if you wish to create your texture pixel by pixel.
  83974. * @param data define the array of data to use to create the texture
  83975. * @param width define the width of the texture
  83976. * @param height define the height of the texture
  83977. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83978. * @param scene define the scene the texture belongs to
  83979. * @param generateMipMaps define whether mip maps should be generated or not
  83980. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83981. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83982. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83983. */
  83984. constructor(data: ArrayBufferView, width: number, height: number,
  83985. /**
  83986. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83987. */
  83988. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83989. /**
  83990. * Updates the texture underlying data.
  83991. * @param data Define the new data of the texture
  83992. */
  83993. update(data: ArrayBufferView): void;
  83994. /**
  83995. * Creates a luminance texture from some data.
  83996. * @param data Define the texture data
  83997. * @param width Define the width of the texture
  83998. * @param height Define the height of the texture
  83999. * @param scene Define the scene the texture belongs to
  84000. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84001. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84002. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84003. * @returns the luminance texture
  84004. */
  84005. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84006. /**
  84007. * Creates a luminance alpha texture from some data.
  84008. * @param data Define the texture data
  84009. * @param width Define the width of the texture
  84010. * @param height Define the height of the texture
  84011. * @param scene Define the scene the texture belongs to
  84012. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84013. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84014. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84015. * @returns the luminance alpha texture
  84016. */
  84017. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84018. /**
  84019. * Creates an alpha texture from some data.
  84020. * @param data Define the texture data
  84021. * @param width Define the width of the texture
  84022. * @param height Define the height of the texture
  84023. * @param scene Define the scene the texture belongs to
  84024. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84025. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84026. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84027. * @returns the alpha texture
  84028. */
  84029. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84030. /**
  84031. * Creates a RGB texture from some data.
  84032. * @param data Define the texture data
  84033. * @param width Define the width of the texture
  84034. * @param height Define the height of the texture
  84035. * @param scene Define the scene the texture belongs to
  84036. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84037. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84038. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84039. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84040. * @returns the RGB alpha texture
  84041. */
  84042. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84043. /**
  84044. * Creates a RGBA texture from some data.
  84045. * @param data Define the texture data
  84046. * @param width Define the width of the texture
  84047. * @param height Define the height of the texture
  84048. * @param scene Define the scene the texture belongs to
  84049. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84050. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84051. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84052. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84053. * @returns the RGBA texture
  84054. */
  84055. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84056. /**
  84057. * Creates a R texture from some data.
  84058. * @param data Define the texture data
  84059. * @param width Define the width of the texture
  84060. * @param height Define the height of the texture
  84061. * @param scene Define the scene the texture belongs to
  84062. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84063. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84064. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84065. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84066. * @returns the R texture
  84067. */
  84068. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84069. }
  84070. }
  84071. declare module BABYLON {
  84072. interface AbstractScene {
  84073. /**
  84074. * The list of procedural textures added to the scene
  84075. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84076. */
  84077. proceduralTextures: Array<ProceduralTexture>;
  84078. }
  84079. /**
  84080. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84081. * in a given scene.
  84082. */
  84083. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84084. /**
  84085. * The component name helpfull to identify the component in the list of scene components.
  84086. */
  84087. readonly name: string;
  84088. /**
  84089. * The scene the component belongs to.
  84090. */
  84091. scene: Scene;
  84092. /**
  84093. * Creates a new instance of the component for the given scene
  84094. * @param scene Defines the scene to register the component in
  84095. */
  84096. constructor(scene: Scene);
  84097. /**
  84098. * Registers the component in a given scene
  84099. */
  84100. register(): void;
  84101. /**
  84102. * Rebuilds the elements related to this component in case of
  84103. * context lost for instance.
  84104. */
  84105. rebuild(): void;
  84106. /**
  84107. * Disposes the component and the associated ressources.
  84108. */
  84109. dispose(): void;
  84110. private _beforeClear;
  84111. }
  84112. }
  84113. declare module BABYLON {
  84114. interface ThinEngine {
  84115. /**
  84116. * Creates a new render target cube texture
  84117. * @param size defines the size of the texture
  84118. * @param options defines the options used to create the texture
  84119. * @returns a new render target cube texture stored in an InternalTexture
  84120. */
  84121. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84122. }
  84123. }
  84124. declare module BABYLON {
  84125. /** @hidden */
  84126. export var proceduralVertexShader: {
  84127. name: string;
  84128. shader: string;
  84129. };
  84130. }
  84131. declare module BABYLON {
  84132. /**
  84133. * 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.
  84134. * This is the base class of any Procedural texture and contains most of the shareable code.
  84135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84136. */
  84137. export class ProceduralTexture extends Texture {
  84138. isCube: boolean;
  84139. /**
  84140. * Define if the texture is enabled or not (disabled texture will not render)
  84141. */
  84142. isEnabled: boolean;
  84143. /**
  84144. * Define if the texture must be cleared before rendering (default is true)
  84145. */
  84146. autoClear: boolean;
  84147. /**
  84148. * Callback called when the texture is generated
  84149. */
  84150. onGenerated: () => void;
  84151. /**
  84152. * Event raised when the texture is generated
  84153. */
  84154. onGeneratedObservable: Observable<ProceduralTexture>;
  84155. /** @hidden */
  84156. _generateMipMaps: boolean;
  84157. /** @hidden **/
  84158. _effect: Effect;
  84159. /** @hidden */
  84160. _textures: {
  84161. [key: string]: Texture;
  84162. };
  84163. private _size;
  84164. private _currentRefreshId;
  84165. private _frameId;
  84166. private _refreshRate;
  84167. private _vertexBuffers;
  84168. private _indexBuffer;
  84169. private _uniforms;
  84170. private _samplers;
  84171. private _fragment;
  84172. private _floats;
  84173. private _ints;
  84174. private _floatsArrays;
  84175. private _colors3;
  84176. private _colors4;
  84177. private _vectors2;
  84178. private _vectors3;
  84179. private _matrices;
  84180. private _fallbackTexture;
  84181. private _fallbackTextureUsed;
  84182. private _engine;
  84183. private _cachedDefines;
  84184. private _contentUpdateId;
  84185. private _contentData;
  84186. /**
  84187. * Instantiates a new procedural texture.
  84188. * 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.
  84189. * This is the base class of any Procedural texture and contains most of the shareable code.
  84190. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84191. * @param name Define the name of the texture
  84192. * @param size Define the size of the texture to create
  84193. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84194. * @param scene Define the scene the texture belongs to
  84195. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84196. * @param generateMipMaps Define if the texture should creates mip maps or not
  84197. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84198. */
  84199. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84200. /**
  84201. * The effect that is created when initializing the post process.
  84202. * @returns The created effect corresponding the the postprocess.
  84203. */
  84204. getEffect(): Effect;
  84205. /**
  84206. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84207. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84208. */
  84209. getContent(): Nullable<ArrayBufferView>;
  84210. private _createIndexBuffer;
  84211. /** @hidden */
  84212. _rebuild(): void;
  84213. /**
  84214. * Resets the texture in order to recreate its associated resources.
  84215. * This can be called in case of context loss
  84216. */
  84217. reset(): void;
  84218. protected _getDefines(): string;
  84219. /**
  84220. * Is the texture ready to be used ? (rendered at least once)
  84221. * @returns true if ready, otherwise, false.
  84222. */
  84223. isReady(): boolean;
  84224. /**
  84225. * Resets the refresh counter of the texture and start bak from scratch.
  84226. * Could be useful to regenerate the texture if it is setup to render only once.
  84227. */
  84228. resetRefreshCounter(): void;
  84229. /**
  84230. * Set the fragment shader to use in order to render the texture.
  84231. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84232. */
  84233. setFragment(fragment: any): void;
  84234. /**
  84235. * Define the refresh rate of the texture or the rendering frequency.
  84236. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84237. */
  84238. get refreshRate(): number;
  84239. set refreshRate(value: number);
  84240. /** @hidden */
  84241. _shouldRender(): boolean;
  84242. /**
  84243. * Get the size the texture is rendering at.
  84244. * @returns the size (texture is always squared)
  84245. */
  84246. getRenderSize(): number;
  84247. /**
  84248. * Resize the texture to new value.
  84249. * @param size Define the new size the texture should have
  84250. * @param generateMipMaps Define whether the new texture should create mip maps
  84251. */
  84252. resize(size: number, generateMipMaps: boolean): void;
  84253. private _checkUniform;
  84254. /**
  84255. * Set a texture in the shader program used to render.
  84256. * @param name Define the name of the uniform samplers as defined in the shader
  84257. * @param texture Define the texture to bind to this sampler
  84258. * @return the texture itself allowing "fluent" like uniform updates
  84259. */
  84260. setTexture(name: string, texture: Texture): ProceduralTexture;
  84261. /**
  84262. * Set a float in the shader.
  84263. * @param name Define the name of the uniform as defined in the shader
  84264. * @param value Define the value to give to the uniform
  84265. * @return the texture itself allowing "fluent" like uniform updates
  84266. */
  84267. setFloat(name: string, value: number): ProceduralTexture;
  84268. /**
  84269. * Set a int in the shader.
  84270. * @param name Define the name of the uniform as defined in the shader
  84271. * @param value Define the value to give to the uniform
  84272. * @return the texture itself allowing "fluent" like uniform updates
  84273. */
  84274. setInt(name: string, value: number): ProceduralTexture;
  84275. /**
  84276. * Set an array of floats in the shader.
  84277. * @param name Define the name of the uniform as defined in the shader
  84278. * @param value Define the value to give to the uniform
  84279. * @return the texture itself allowing "fluent" like uniform updates
  84280. */
  84281. setFloats(name: string, value: number[]): ProceduralTexture;
  84282. /**
  84283. * Set a vec3 in the shader from a Color3.
  84284. * @param name Define the name of the uniform as defined in the shader
  84285. * @param value Define the value to give to the uniform
  84286. * @return the texture itself allowing "fluent" like uniform updates
  84287. */
  84288. setColor3(name: string, value: Color3): ProceduralTexture;
  84289. /**
  84290. * Set a vec4 in the shader from a Color4.
  84291. * @param name Define the name of the uniform as defined in the shader
  84292. * @param value Define the value to give to the uniform
  84293. * @return the texture itself allowing "fluent" like uniform updates
  84294. */
  84295. setColor4(name: string, value: Color4): ProceduralTexture;
  84296. /**
  84297. * Set a vec2 in the shader from a Vector2.
  84298. * @param name Define the name of the uniform as defined in the shader
  84299. * @param value Define the value to give to the uniform
  84300. * @return the texture itself allowing "fluent" like uniform updates
  84301. */
  84302. setVector2(name: string, value: Vector2): ProceduralTexture;
  84303. /**
  84304. * Set a vec3 in the shader from a Vector3.
  84305. * @param name Define the name of the uniform as defined in the shader
  84306. * @param value Define the value to give to the uniform
  84307. * @return the texture itself allowing "fluent" like uniform updates
  84308. */
  84309. setVector3(name: string, value: Vector3): ProceduralTexture;
  84310. /**
  84311. * Set a mat4 in the shader from a MAtrix.
  84312. * @param name Define the name of the uniform as defined in the shader
  84313. * @param value Define the value to give to the uniform
  84314. * @return the texture itself allowing "fluent" like uniform updates
  84315. */
  84316. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84317. /**
  84318. * Render the texture to its associated render target.
  84319. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84320. */
  84321. render(useCameraPostProcess?: boolean): void;
  84322. /**
  84323. * Clone the texture.
  84324. * @returns the cloned texture
  84325. */
  84326. clone(): ProceduralTexture;
  84327. /**
  84328. * Dispose the texture and release its asoociated resources.
  84329. */
  84330. dispose(): void;
  84331. }
  84332. }
  84333. declare module BABYLON {
  84334. /**
  84335. * This represents the base class for particle system in Babylon.
  84336. * 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.
  84337. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84338. * @example https://doc.babylonjs.com/babylon101/particles
  84339. */
  84340. export class BaseParticleSystem {
  84341. /**
  84342. * Source color is added to the destination color without alpha affecting the result
  84343. */
  84344. static BLENDMODE_ONEONE: number;
  84345. /**
  84346. * Blend current color and particle color using particle’s alpha
  84347. */
  84348. static BLENDMODE_STANDARD: number;
  84349. /**
  84350. * Add current color and particle color multiplied by particle’s alpha
  84351. */
  84352. static BLENDMODE_ADD: number;
  84353. /**
  84354. * Multiply current color with particle color
  84355. */
  84356. static BLENDMODE_MULTIPLY: number;
  84357. /**
  84358. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84359. */
  84360. static BLENDMODE_MULTIPLYADD: number;
  84361. /**
  84362. * List of animations used by the particle system.
  84363. */
  84364. animations: Animation[];
  84365. /**
  84366. * The id of the Particle system.
  84367. */
  84368. id: string;
  84369. /**
  84370. * The friendly name of the Particle system.
  84371. */
  84372. name: string;
  84373. /**
  84374. * The rendering group used by the Particle system to chose when to render.
  84375. */
  84376. renderingGroupId: number;
  84377. /**
  84378. * The emitter represents the Mesh or position we are attaching the particle system to.
  84379. */
  84380. emitter: Nullable<AbstractMesh | Vector3>;
  84381. /**
  84382. * The maximum number of particles to emit per frame
  84383. */
  84384. emitRate: number;
  84385. /**
  84386. * If you want to launch only a few particles at once, that can be done, as well.
  84387. */
  84388. manualEmitCount: number;
  84389. /**
  84390. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84391. */
  84392. updateSpeed: number;
  84393. /**
  84394. * The amount of time the particle system is running (depends of the overall update speed).
  84395. */
  84396. targetStopDuration: number;
  84397. /**
  84398. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84399. */
  84400. disposeOnStop: boolean;
  84401. /**
  84402. * Minimum power of emitting particles.
  84403. */
  84404. minEmitPower: number;
  84405. /**
  84406. * Maximum power of emitting particles.
  84407. */
  84408. maxEmitPower: number;
  84409. /**
  84410. * Minimum life time of emitting particles.
  84411. */
  84412. minLifeTime: number;
  84413. /**
  84414. * Maximum life time of emitting particles.
  84415. */
  84416. maxLifeTime: number;
  84417. /**
  84418. * Minimum Size of emitting particles.
  84419. */
  84420. minSize: number;
  84421. /**
  84422. * Maximum Size of emitting particles.
  84423. */
  84424. maxSize: number;
  84425. /**
  84426. * Minimum scale of emitting particles on X axis.
  84427. */
  84428. minScaleX: number;
  84429. /**
  84430. * Maximum scale of emitting particles on X axis.
  84431. */
  84432. maxScaleX: number;
  84433. /**
  84434. * Minimum scale of emitting particles on Y axis.
  84435. */
  84436. minScaleY: number;
  84437. /**
  84438. * Maximum scale of emitting particles on Y axis.
  84439. */
  84440. maxScaleY: number;
  84441. /**
  84442. * Gets or sets the minimal initial rotation in radians.
  84443. */
  84444. minInitialRotation: number;
  84445. /**
  84446. * Gets or sets the maximal initial rotation in radians.
  84447. */
  84448. maxInitialRotation: number;
  84449. /**
  84450. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84451. */
  84452. minAngularSpeed: number;
  84453. /**
  84454. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84455. */
  84456. maxAngularSpeed: number;
  84457. /**
  84458. * The texture used to render each particle. (this can be a spritesheet)
  84459. */
  84460. particleTexture: Nullable<Texture>;
  84461. /**
  84462. * The layer mask we are rendering the particles through.
  84463. */
  84464. layerMask: number;
  84465. /**
  84466. * This can help using your own shader to render the particle system.
  84467. * The according effect will be created
  84468. */
  84469. customShader: any;
  84470. /**
  84471. * By default particle system starts as soon as they are created. This prevents the
  84472. * automatic start to happen and let you decide when to start emitting particles.
  84473. */
  84474. preventAutoStart: boolean;
  84475. private _noiseTexture;
  84476. /**
  84477. * Gets or sets a texture used to add random noise to particle positions
  84478. */
  84479. get noiseTexture(): Nullable<ProceduralTexture>;
  84480. set noiseTexture(value: Nullable<ProceduralTexture>);
  84481. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84482. noiseStrength: Vector3;
  84483. /**
  84484. * Callback triggered when the particle animation is ending.
  84485. */
  84486. onAnimationEnd: Nullable<() => void>;
  84487. /**
  84488. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84489. */
  84490. blendMode: number;
  84491. /**
  84492. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84493. * to override the particles.
  84494. */
  84495. forceDepthWrite: boolean;
  84496. /** 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 */
  84497. preWarmCycles: number;
  84498. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84499. preWarmStepOffset: number;
  84500. /**
  84501. * 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)
  84502. */
  84503. spriteCellChangeSpeed: number;
  84504. /**
  84505. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84506. */
  84507. startSpriteCellID: number;
  84508. /**
  84509. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84510. */
  84511. endSpriteCellID: number;
  84512. /**
  84513. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84514. */
  84515. spriteCellWidth: number;
  84516. /**
  84517. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84518. */
  84519. spriteCellHeight: number;
  84520. /**
  84521. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84522. */
  84523. spriteRandomStartCell: boolean;
  84524. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84525. translationPivot: Vector2;
  84526. /** @hidden */
  84527. protected _isAnimationSheetEnabled: boolean;
  84528. /**
  84529. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84530. */
  84531. beginAnimationOnStart: boolean;
  84532. /**
  84533. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84534. */
  84535. beginAnimationFrom: number;
  84536. /**
  84537. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84538. */
  84539. beginAnimationTo: number;
  84540. /**
  84541. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84542. */
  84543. beginAnimationLoop: boolean;
  84544. /**
  84545. * Gets or sets a world offset applied to all particles
  84546. */
  84547. worldOffset: Vector3;
  84548. /**
  84549. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84550. */
  84551. get isAnimationSheetEnabled(): boolean;
  84552. set isAnimationSheetEnabled(value: boolean);
  84553. /**
  84554. * Get hosting scene
  84555. * @returns the scene
  84556. */
  84557. getScene(): Scene;
  84558. /**
  84559. * You can use gravity if you want to give an orientation to your particles.
  84560. */
  84561. gravity: Vector3;
  84562. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84563. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84564. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84565. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84566. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84567. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84568. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84569. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84570. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84571. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84572. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84573. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84574. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84575. /**
  84576. * Defines the delay in milliseconds before starting the system (0 by default)
  84577. */
  84578. startDelay: number;
  84579. /**
  84580. * Gets the current list of drag gradients.
  84581. * You must use addDragGradient and removeDragGradient to udpate this list
  84582. * @returns the list of drag gradients
  84583. */
  84584. getDragGradients(): Nullable<Array<FactorGradient>>;
  84585. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84586. limitVelocityDamping: number;
  84587. /**
  84588. * Gets the current list of limit velocity gradients.
  84589. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84590. * @returns the list of limit velocity gradients
  84591. */
  84592. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84593. /**
  84594. * Gets the current list of color gradients.
  84595. * You must use addColorGradient and removeColorGradient to udpate this list
  84596. * @returns the list of color gradients
  84597. */
  84598. getColorGradients(): Nullable<Array<ColorGradient>>;
  84599. /**
  84600. * Gets the current list of size gradients.
  84601. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84602. * @returns the list of size gradients
  84603. */
  84604. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84605. /**
  84606. * Gets the current list of color remap gradients.
  84607. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84608. * @returns the list of color remap gradients
  84609. */
  84610. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84611. /**
  84612. * Gets the current list of alpha remap gradients.
  84613. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84614. * @returns the list of alpha remap gradients
  84615. */
  84616. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84617. /**
  84618. * Gets the current list of life time gradients.
  84619. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84620. * @returns the list of life time gradients
  84621. */
  84622. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84623. /**
  84624. * Gets the current list of angular speed gradients.
  84625. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84626. * @returns the list of angular speed gradients
  84627. */
  84628. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84629. /**
  84630. * Gets the current list of velocity gradients.
  84631. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84632. * @returns the list of velocity gradients
  84633. */
  84634. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84635. /**
  84636. * Gets the current list of start size gradients.
  84637. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84638. * @returns the list of start size gradients
  84639. */
  84640. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84641. /**
  84642. * Gets the current list of emit rate gradients.
  84643. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84644. * @returns the list of emit rate gradients
  84645. */
  84646. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84647. /**
  84648. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84649. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84650. */
  84651. get direction1(): Vector3;
  84652. set direction1(value: Vector3);
  84653. /**
  84654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84655. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84656. */
  84657. get direction2(): Vector3;
  84658. set direction2(value: Vector3);
  84659. /**
  84660. * 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.
  84661. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84662. */
  84663. get minEmitBox(): Vector3;
  84664. set minEmitBox(value: Vector3);
  84665. /**
  84666. * 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.
  84667. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84668. */
  84669. get maxEmitBox(): Vector3;
  84670. set maxEmitBox(value: Vector3);
  84671. /**
  84672. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84673. */
  84674. color1: Color4;
  84675. /**
  84676. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84677. */
  84678. color2: Color4;
  84679. /**
  84680. * Color the particle will have at the end of its lifetime
  84681. */
  84682. colorDead: Color4;
  84683. /**
  84684. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84685. */
  84686. textureMask: Color4;
  84687. /**
  84688. * The particle emitter type defines the emitter used by the particle system.
  84689. * It can be for example box, sphere, or cone...
  84690. */
  84691. particleEmitterType: IParticleEmitterType;
  84692. /** @hidden */
  84693. _isSubEmitter: boolean;
  84694. /**
  84695. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84696. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84697. */
  84698. billboardMode: number;
  84699. protected _isBillboardBased: boolean;
  84700. /**
  84701. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84702. */
  84703. get isBillboardBased(): boolean;
  84704. set isBillboardBased(value: boolean);
  84705. /**
  84706. * The scene the particle system belongs to.
  84707. */
  84708. protected _scene: Scene;
  84709. /**
  84710. * Local cache of defines for image processing.
  84711. */
  84712. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84713. /**
  84714. * Default configuration related to image processing available in the standard Material.
  84715. */
  84716. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84717. /**
  84718. * Gets the image processing configuration used either in this material.
  84719. */
  84720. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84721. /**
  84722. * Sets the Default image processing configuration used either in the this material.
  84723. *
  84724. * If sets to null, the scene one is in use.
  84725. */
  84726. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84727. /**
  84728. * Attaches a new image processing configuration to the Standard Material.
  84729. * @param configuration
  84730. */
  84731. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84732. /** @hidden */
  84733. protected _reset(): void;
  84734. /** @hidden */
  84735. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84736. /**
  84737. * Instantiates a particle system.
  84738. * 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.
  84739. * @param name The name of the particle system
  84740. */
  84741. constructor(name: string);
  84742. /**
  84743. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84744. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84745. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84746. * @returns the emitter
  84747. */
  84748. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84749. /**
  84750. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84751. * @param radius The radius of the hemisphere to emit from
  84752. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84753. * @returns the emitter
  84754. */
  84755. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84756. /**
  84757. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84758. * @param radius The radius of the sphere to emit from
  84759. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84760. * @returns the emitter
  84761. */
  84762. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84763. /**
  84764. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84765. * @param radius The radius of the sphere to emit from
  84766. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84767. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84768. * @returns the emitter
  84769. */
  84770. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84771. /**
  84772. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84773. * @param radius The radius of the emission cylinder
  84774. * @param height The height of the emission cylinder
  84775. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84776. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84777. * @returns the emitter
  84778. */
  84779. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84780. /**
  84781. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84782. * @param radius The radius of the cylinder to emit from
  84783. * @param height The height of the emission cylinder
  84784. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84787. * @returns the emitter
  84788. */
  84789. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84790. /**
  84791. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84792. * @param radius The radius of the cone to emit from
  84793. * @param angle The base angle of the cone
  84794. * @returns the emitter
  84795. */
  84796. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84797. /**
  84798. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84801. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84802. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84803. * @returns the emitter
  84804. */
  84805. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84806. }
  84807. }
  84808. declare module BABYLON {
  84809. /**
  84810. * Type of sub emitter
  84811. */
  84812. export enum SubEmitterType {
  84813. /**
  84814. * Attached to the particle over it's lifetime
  84815. */
  84816. ATTACHED = 0,
  84817. /**
  84818. * Created when the particle dies
  84819. */
  84820. END = 1
  84821. }
  84822. /**
  84823. * Sub emitter class used to emit particles from an existing particle
  84824. */
  84825. export class SubEmitter {
  84826. /**
  84827. * the particle system to be used by the sub emitter
  84828. */
  84829. particleSystem: ParticleSystem;
  84830. /**
  84831. * Type of the submitter (Default: END)
  84832. */
  84833. type: SubEmitterType;
  84834. /**
  84835. * 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)
  84836. * Note: This only is supported when using an emitter of type Mesh
  84837. */
  84838. inheritDirection: boolean;
  84839. /**
  84840. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84841. */
  84842. inheritedVelocityAmount: number;
  84843. /**
  84844. * Creates a sub emitter
  84845. * @param particleSystem the particle system to be used by the sub emitter
  84846. */
  84847. constructor(
  84848. /**
  84849. * the particle system to be used by the sub emitter
  84850. */
  84851. particleSystem: ParticleSystem);
  84852. /**
  84853. * Clones the sub emitter
  84854. * @returns the cloned sub emitter
  84855. */
  84856. clone(): SubEmitter;
  84857. /**
  84858. * Serialize current object to a JSON object
  84859. * @returns the serialized object
  84860. */
  84861. serialize(): any;
  84862. /** @hidden */
  84863. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84864. /**
  84865. * Creates a new SubEmitter from a serialized JSON version
  84866. * @param serializationObject defines the JSON object to read from
  84867. * @param scene defines the hosting scene
  84868. * @param rootUrl defines the rootUrl for data loading
  84869. * @returns a new SubEmitter
  84870. */
  84871. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84872. /** Release associated resources */
  84873. dispose(): void;
  84874. }
  84875. }
  84876. declare module BABYLON {
  84877. /** @hidden */
  84878. export var imageProcessingDeclaration: {
  84879. name: string;
  84880. shader: string;
  84881. };
  84882. }
  84883. declare module BABYLON {
  84884. /** @hidden */
  84885. export var imageProcessingFunctions: {
  84886. name: string;
  84887. shader: string;
  84888. };
  84889. }
  84890. declare module BABYLON {
  84891. /** @hidden */
  84892. export var particlesPixelShader: {
  84893. name: string;
  84894. shader: string;
  84895. };
  84896. }
  84897. declare module BABYLON {
  84898. /** @hidden */
  84899. export var particlesVertexShader: {
  84900. name: string;
  84901. shader: string;
  84902. };
  84903. }
  84904. declare module BABYLON {
  84905. /**
  84906. * This represents a particle system in Babylon.
  84907. * 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.
  84908. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84909. * @example https://doc.babylonjs.com/babylon101/particles
  84910. */
  84911. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84912. /**
  84913. * Billboard mode will only apply to Y axis
  84914. */
  84915. static readonly BILLBOARDMODE_Y: number;
  84916. /**
  84917. * Billboard mode will apply to all axes
  84918. */
  84919. static readonly BILLBOARDMODE_ALL: number;
  84920. /**
  84921. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84922. */
  84923. static readonly BILLBOARDMODE_STRETCHED: number;
  84924. /**
  84925. * This function can be defined to provide custom update for active particles.
  84926. * This function will be called instead of regular update (age, position, color, etc.).
  84927. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84928. */
  84929. updateFunction: (particles: Particle[]) => void;
  84930. private _emitterWorldMatrix;
  84931. /**
  84932. * This function can be defined to specify initial direction for every new particle.
  84933. * It by default use the emitterType defined function
  84934. */
  84935. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84936. /**
  84937. * This function can be defined to specify initial position for every new particle.
  84938. * It by default use the emitterType defined function
  84939. */
  84940. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84941. /**
  84942. * @hidden
  84943. */
  84944. _inheritedVelocityOffset: Vector3;
  84945. /**
  84946. * An event triggered when the system is disposed
  84947. */
  84948. onDisposeObservable: Observable<ParticleSystem>;
  84949. private _onDisposeObserver;
  84950. /**
  84951. * Sets a callback that will be triggered when the system is disposed
  84952. */
  84953. set onDispose(callback: () => void);
  84954. private _particles;
  84955. private _epsilon;
  84956. private _capacity;
  84957. private _stockParticles;
  84958. private _newPartsExcess;
  84959. private _vertexData;
  84960. private _vertexBuffer;
  84961. private _vertexBuffers;
  84962. private _spriteBuffer;
  84963. private _indexBuffer;
  84964. private _effect;
  84965. private _customEffect;
  84966. private _cachedDefines;
  84967. private _scaledColorStep;
  84968. private _colorDiff;
  84969. private _scaledDirection;
  84970. private _scaledGravity;
  84971. private _currentRenderId;
  84972. private _alive;
  84973. private _useInstancing;
  84974. private _started;
  84975. private _stopped;
  84976. private _actualFrame;
  84977. private _scaledUpdateSpeed;
  84978. private _vertexBufferSize;
  84979. /** @hidden */
  84980. _currentEmitRateGradient: Nullable<FactorGradient>;
  84981. /** @hidden */
  84982. _currentEmitRate1: number;
  84983. /** @hidden */
  84984. _currentEmitRate2: number;
  84985. /** @hidden */
  84986. _currentStartSizeGradient: Nullable<FactorGradient>;
  84987. /** @hidden */
  84988. _currentStartSize1: number;
  84989. /** @hidden */
  84990. _currentStartSize2: number;
  84991. private readonly _rawTextureWidth;
  84992. private _rampGradientsTexture;
  84993. private _useRampGradients;
  84994. /** Gets or sets a boolean indicating that ramp gradients must be used
  84995. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84996. */
  84997. get useRampGradients(): boolean;
  84998. set useRampGradients(value: boolean);
  84999. /**
  85000. * 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.
  85001. * 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: [])
  85002. */
  85003. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85004. private _subEmitters;
  85005. /**
  85006. * @hidden
  85007. * If the particle systems emitter should be disposed when the particle system is disposed
  85008. */
  85009. _disposeEmitterOnDispose: boolean;
  85010. /**
  85011. * The current active Sub-systems, this property is used by the root particle system only.
  85012. */
  85013. activeSubSystems: Array<ParticleSystem>;
  85014. /**
  85015. * Specifies if the particles are updated in emitter local space or world space
  85016. */
  85017. isLocal: boolean;
  85018. private _rootParticleSystem;
  85019. /**
  85020. * Gets the current list of active particles
  85021. */
  85022. get particles(): Particle[];
  85023. /**
  85024. * Returns the string "ParticleSystem"
  85025. * @returns a string containing the class name
  85026. */
  85027. getClassName(): string;
  85028. /**
  85029. * Instantiates a particle system.
  85030. * 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.
  85031. * @param name The name of the particle system
  85032. * @param capacity The max number of particles alive at the same time
  85033. * @param scene The scene the particle system belongs to
  85034. * @param customEffect a custom effect used to change the way particles are rendered by default
  85035. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85036. * @param epsilon Offset used to render the particles
  85037. */
  85038. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85039. private _addFactorGradient;
  85040. private _removeFactorGradient;
  85041. /**
  85042. * Adds a new life time gradient
  85043. * @param gradient defines the gradient to use (between 0 and 1)
  85044. * @param factor defines the life time factor to affect to the specified gradient
  85045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85046. * @returns the current particle system
  85047. */
  85048. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85049. /**
  85050. * Remove a specific life time gradient
  85051. * @param gradient defines the gradient to remove
  85052. * @returns the current particle system
  85053. */
  85054. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85055. /**
  85056. * Adds a new size gradient
  85057. * @param gradient defines the gradient to use (between 0 and 1)
  85058. * @param factor defines the size factor to affect to the specified gradient
  85059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85060. * @returns the current particle system
  85061. */
  85062. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85063. /**
  85064. * Remove a specific size gradient
  85065. * @param gradient defines the gradient to remove
  85066. * @returns the current particle system
  85067. */
  85068. removeSizeGradient(gradient: number): IParticleSystem;
  85069. /**
  85070. * Adds a new color remap gradient
  85071. * @param gradient defines the gradient to use (between 0 and 1)
  85072. * @param min defines the color remap minimal range
  85073. * @param max defines the color remap maximal range
  85074. * @returns the current particle system
  85075. */
  85076. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85077. /**
  85078. * Remove a specific color remap gradient
  85079. * @param gradient defines the gradient to remove
  85080. * @returns the current particle system
  85081. */
  85082. removeColorRemapGradient(gradient: number): IParticleSystem;
  85083. /**
  85084. * Adds a new alpha remap gradient
  85085. * @param gradient defines the gradient to use (between 0 and 1)
  85086. * @param min defines the alpha remap minimal range
  85087. * @param max defines the alpha remap maximal range
  85088. * @returns the current particle system
  85089. */
  85090. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85091. /**
  85092. * Remove a specific alpha remap gradient
  85093. * @param gradient defines the gradient to remove
  85094. * @returns the current particle system
  85095. */
  85096. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85097. /**
  85098. * Adds a new angular speed gradient
  85099. * @param gradient defines the gradient to use (between 0 and 1)
  85100. * @param factor defines the angular speed to affect to the specified gradient
  85101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85102. * @returns the current particle system
  85103. */
  85104. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85105. /**
  85106. * Remove a specific angular speed gradient
  85107. * @param gradient defines the gradient to remove
  85108. * @returns the current particle system
  85109. */
  85110. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85111. /**
  85112. * Adds a new velocity gradient
  85113. * @param gradient defines the gradient to use (between 0 and 1)
  85114. * @param factor defines the velocity to affect to the specified gradient
  85115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85116. * @returns the current particle system
  85117. */
  85118. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85119. /**
  85120. * Remove a specific velocity gradient
  85121. * @param gradient defines the gradient to remove
  85122. * @returns the current particle system
  85123. */
  85124. removeVelocityGradient(gradient: number): IParticleSystem;
  85125. /**
  85126. * Adds a new limit velocity gradient
  85127. * @param gradient defines the gradient to use (between 0 and 1)
  85128. * @param factor defines the limit velocity value to affect to the specified gradient
  85129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85130. * @returns the current particle system
  85131. */
  85132. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85133. /**
  85134. * Remove a specific limit velocity gradient
  85135. * @param gradient defines the gradient to remove
  85136. * @returns the current particle system
  85137. */
  85138. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85139. /**
  85140. * Adds a new drag gradient
  85141. * @param gradient defines the gradient to use (between 0 and 1)
  85142. * @param factor defines the drag value to affect to the specified gradient
  85143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85144. * @returns the current particle system
  85145. */
  85146. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85147. /**
  85148. * Remove a specific drag gradient
  85149. * @param gradient defines the gradient to remove
  85150. * @returns the current particle system
  85151. */
  85152. removeDragGradient(gradient: number): IParticleSystem;
  85153. /**
  85154. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85155. * @param gradient defines the gradient to use (between 0 and 1)
  85156. * @param factor defines the emit rate value to affect to the specified gradient
  85157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85158. * @returns the current particle system
  85159. */
  85160. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85161. /**
  85162. * Remove a specific emit rate gradient
  85163. * @param gradient defines the gradient to remove
  85164. * @returns the current particle system
  85165. */
  85166. removeEmitRateGradient(gradient: number): IParticleSystem;
  85167. /**
  85168. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85169. * @param gradient defines the gradient to use (between 0 and 1)
  85170. * @param factor defines the start size value to affect to the specified gradient
  85171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85172. * @returns the current particle system
  85173. */
  85174. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85175. /**
  85176. * Remove a specific start size gradient
  85177. * @param gradient defines the gradient to remove
  85178. * @returns the current particle system
  85179. */
  85180. removeStartSizeGradient(gradient: number): IParticleSystem;
  85181. private _createRampGradientTexture;
  85182. /**
  85183. * Gets the current list of ramp gradients.
  85184. * You must use addRampGradient and removeRampGradient to udpate this list
  85185. * @returns the list of ramp gradients
  85186. */
  85187. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85188. /**
  85189. * Adds a new ramp gradient used to remap particle colors
  85190. * @param gradient defines the gradient to use (between 0 and 1)
  85191. * @param color defines the color to affect to the specified gradient
  85192. * @returns the current particle system
  85193. */
  85194. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85195. /**
  85196. * Remove a specific ramp gradient
  85197. * @param gradient defines the gradient to remove
  85198. * @returns the current particle system
  85199. */
  85200. removeRampGradient(gradient: number): ParticleSystem;
  85201. /**
  85202. * Adds a new color gradient
  85203. * @param gradient defines the gradient to use (between 0 and 1)
  85204. * @param color1 defines the color to affect to the specified gradient
  85205. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85206. * @returns this particle system
  85207. */
  85208. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85209. /**
  85210. * Remove a specific color gradient
  85211. * @param gradient defines the gradient to remove
  85212. * @returns this particle system
  85213. */
  85214. removeColorGradient(gradient: number): IParticleSystem;
  85215. private _fetchR;
  85216. protected _reset(): void;
  85217. private _resetEffect;
  85218. private _createVertexBuffers;
  85219. private _createIndexBuffer;
  85220. /**
  85221. * Gets the maximum number of particles active at the same time.
  85222. * @returns The max number of active particles.
  85223. */
  85224. getCapacity(): number;
  85225. /**
  85226. * Gets whether there are still active particles in the system.
  85227. * @returns True if it is alive, otherwise false.
  85228. */
  85229. isAlive(): boolean;
  85230. /**
  85231. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85232. * @returns True if it has been started, otherwise false.
  85233. */
  85234. isStarted(): boolean;
  85235. private _prepareSubEmitterInternalArray;
  85236. /**
  85237. * Starts the particle system and begins to emit
  85238. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85239. */
  85240. start(delay?: number): void;
  85241. /**
  85242. * Stops the particle system.
  85243. * @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.
  85244. */
  85245. stop(stopSubEmitters?: boolean): void;
  85246. /**
  85247. * Remove all active particles
  85248. */
  85249. reset(): void;
  85250. /**
  85251. * @hidden (for internal use only)
  85252. */
  85253. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85254. /**
  85255. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85256. * Its lifetime will start back at 0.
  85257. */
  85258. recycleParticle: (particle: Particle) => void;
  85259. private _stopSubEmitters;
  85260. private _createParticle;
  85261. private _removeFromRoot;
  85262. private _emitFromParticle;
  85263. private _update;
  85264. /** @hidden */
  85265. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85266. /** @hidden */
  85267. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85268. /** @hidden */
  85269. private _getEffect;
  85270. /**
  85271. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85272. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85273. */
  85274. animate(preWarmOnly?: boolean): void;
  85275. private _appendParticleVertices;
  85276. /**
  85277. * Rebuilds the particle system.
  85278. */
  85279. rebuild(): void;
  85280. /**
  85281. * Is this system ready to be used/rendered
  85282. * @return true if the system is ready
  85283. */
  85284. isReady(): boolean;
  85285. private _render;
  85286. /**
  85287. * Renders the particle system in its current state.
  85288. * @returns the current number of particles
  85289. */
  85290. render(): number;
  85291. /**
  85292. * Disposes the particle system and free the associated resources
  85293. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85294. */
  85295. dispose(disposeTexture?: boolean): void;
  85296. /**
  85297. * Clones the particle system.
  85298. * @param name The name of the cloned object
  85299. * @param newEmitter The new emitter to use
  85300. * @returns the cloned particle system
  85301. */
  85302. clone(name: string, newEmitter: any): ParticleSystem;
  85303. /**
  85304. * Serializes the particle system to a JSON object.
  85305. * @returns the JSON object
  85306. */
  85307. serialize(): any;
  85308. /** @hidden */
  85309. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85310. /** @hidden */
  85311. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85312. /**
  85313. * Parses a JSON object to create a particle system.
  85314. * @param parsedParticleSystem The JSON object to parse
  85315. * @param scene The scene to create the particle system in
  85316. * @param rootUrl The root url to use to load external dependencies like texture
  85317. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85318. * @returns the Parsed particle system
  85319. */
  85320. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85321. }
  85322. }
  85323. declare module BABYLON {
  85324. /**
  85325. * A particle represents one of the element emitted by a particle system.
  85326. * This is mainly define by its coordinates, direction, velocity and age.
  85327. */
  85328. export class Particle {
  85329. /**
  85330. * The particle system the particle belongs to.
  85331. */
  85332. particleSystem: ParticleSystem;
  85333. private static _Count;
  85334. /**
  85335. * Unique ID of the particle
  85336. */
  85337. id: number;
  85338. /**
  85339. * The world position of the particle in the scene.
  85340. */
  85341. position: Vector3;
  85342. /**
  85343. * The world direction of the particle in the scene.
  85344. */
  85345. direction: Vector3;
  85346. /**
  85347. * The color of the particle.
  85348. */
  85349. color: Color4;
  85350. /**
  85351. * The color change of the particle per step.
  85352. */
  85353. colorStep: Color4;
  85354. /**
  85355. * Defines how long will the life of the particle be.
  85356. */
  85357. lifeTime: number;
  85358. /**
  85359. * The current age of the particle.
  85360. */
  85361. age: number;
  85362. /**
  85363. * The current size of the particle.
  85364. */
  85365. size: number;
  85366. /**
  85367. * The current scale of the particle.
  85368. */
  85369. scale: Vector2;
  85370. /**
  85371. * The current angle of the particle.
  85372. */
  85373. angle: number;
  85374. /**
  85375. * Defines how fast is the angle changing.
  85376. */
  85377. angularSpeed: number;
  85378. /**
  85379. * Defines the cell index used by the particle to be rendered from a sprite.
  85380. */
  85381. cellIndex: number;
  85382. /**
  85383. * The information required to support color remapping
  85384. */
  85385. remapData: Vector4;
  85386. /** @hidden */
  85387. _randomCellOffset?: number;
  85388. /** @hidden */
  85389. _initialDirection: Nullable<Vector3>;
  85390. /** @hidden */
  85391. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85392. /** @hidden */
  85393. _initialStartSpriteCellID: number;
  85394. /** @hidden */
  85395. _initialEndSpriteCellID: number;
  85396. /** @hidden */
  85397. _currentColorGradient: Nullable<ColorGradient>;
  85398. /** @hidden */
  85399. _currentColor1: Color4;
  85400. /** @hidden */
  85401. _currentColor2: Color4;
  85402. /** @hidden */
  85403. _currentSizeGradient: Nullable<FactorGradient>;
  85404. /** @hidden */
  85405. _currentSize1: number;
  85406. /** @hidden */
  85407. _currentSize2: number;
  85408. /** @hidden */
  85409. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85410. /** @hidden */
  85411. _currentAngularSpeed1: number;
  85412. /** @hidden */
  85413. _currentAngularSpeed2: number;
  85414. /** @hidden */
  85415. _currentVelocityGradient: Nullable<FactorGradient>;
  85416. /** @hidden */
  85417. _currentVelocity1: number;
  85418. /** @hidden */
  85419. _currentVelocity2: number;
  85420. /** @hidden */
  85421. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85422. /** @hidden */
  85423. _currentLimitVelocity1: number;
  85424. /** @hidden */
  85425. _currentLimitVelocity2: number;
  85426. /** @hidden */
  85427. _currentDragGradient: Nullable<FactorGradient>;
  85428. /** @hidden */
  85429. _currentDrag1: number;
  85430. /** @hidden */
  85431. _currentDrag2: number;
  85432. /** @hidden */
  85433. _randomNoiseCoordinates1: Vector3;
  85434. /** @hidden */
  85435. _randomNoiseCoordinates2: Vector3;
  85436. /** @hidden */
  85437. _localPosition?: Vector3;
  85438. /**
  85439. * Creates a new instance Particle
  85440. * @param particleSystem the particle system the particle belongs to
  85441. */
  85442. constructor(
  85443. /**
  85444. * The particle system the particle belongs to.
  85445. */
  85446. particleSystem: ParticleSystem);
  85447. private updateCellInfoFromSystem;
  85448. /**
  85449. * Defines how the sprite cell index is updated for the particle
  85450. */
  85451. updateCellIndex(): void;
  85452. /** @hidden */
  85453. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85454. /** @hidden */
  85455. _inheritParticleInfoToSubEmitters(): void;
  85456. /** @hidden */
  85457. _reset(): void;
  85458. /**
  85459. * Copy the properties of particle to another one.
  85460. * @param other the particle to copy the information to.
  85461. */
  85462. copyTo(other: Particle): void;
  85463. }
  85464. }
  85465. declare module BABYLON {
  85466. /**
  85467. * Particle emitter represents a volume emitting particles.
  85468. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85469. */
  85470. export interface IParticleEmitterType {
  85471. /**
  85472. * Called by the particle System when the direction is computed for the created particle.
  85473. * @param worldMatrix is the world matrix of the particle system
  85474. * @param directionToUpdate is the direction vector to update with the result
  85475. * @param particle is the particle we are computed the direction for
  85476. * @param isLocal defines if the direction should be set in local space
  85477. */
  85478. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85479. /**
  85480. * Called by the particle System when the position is computed for the created particle.
  85481. * @param worldMatrix is the world matrix of the particle system
  85482. * @param positionToUpdate is the position vector to update with the result
  85483. * @param particle is the particle we are computed the position for
  85484. * @param isLocal defines if the position should be set in local space
  85485. */
  85486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85487. /**
  85488. * Clones the current emitter and returns a copy of it
  85489. * @returns the new emitter
  85490. */
  85491. clone(): IParticleEmitterType;
  85492. /**
  85493. * Called by the GPUParticleSystem to setup the update shader
  85494. * @param effect defines the update shader
  85495. */
  85496. applyToShader(effect: Effect): void;
  85497. /**
  85498. * Returns a string to use to update the GPU particles update shader
  85499. * @returns the effect defines string
  85500. */
  85501. getEffectDefines(): string;
  85502. /**
  85503. * Returns a string representing the class name
  85504. * @returns a string containing the class name
  85505. */
  85506. getClassName(): string;
  85507. /**
  85508. * Serializes the particle system to a JSON object.
  85509. * @returns the JSON object
  85510. */
  85511. serialize(): any;
  85512. /**
  85513. * Parse properties from a JSON object
  85514. * @param serializationObject defines the JSON object
  85515. * @param scene defines the hosting scene
  85516. */
  85517. parse(serializationObject: any, scene: Scene): void;
  85518. }
  85519. }
  85520. declare module BABYLON {
  85521. /**
  85522. * Particle emitter emitting particles from the inside of a box.
  85523. * It emits the particles randomly between 2 given directions.
  85524. */
  85525. export class BoxParticleEmitter implements IParticleEmitterType {
  85526. /**
  85527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85528. */
  85529. direction1: Vector3;
  85530. /**
  85531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85532. */
  85533. direction2: Vector3;
  85534. /**
  85535. * 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.
  85536. */
  85537. minEmitBox: Vector3;
  85538. /**
  85539. * 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.
  85540. */
  85541. maxEmitBox: Vector3;
  85542. /**
  85543. * Creates a new instance BoxParticleEmitter
  85544. */
  85545. constructor();
  85546. /**
  85547. * Called by the particle System when the direction is computed for the created particle.
  85548. * @param worldMatrix is the world matrix of the particle system
  85549. * @param directionToUpdate is the direction vector to update with the result
  85550. * @param particle is the particle we are computed the direction for
  85551. * @param isLocal defines if the direction should be set in local space
  85552. */
  85553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85554. /**
  85555. * Called by the particle System when the position is computed for the created particle.
  85556. * @param worldMatrix is the world matrix of the particle system
  85557. * @param positionToUpdate is the position vector to update with the result
  85558. * @param particle is the particle we are computed the position for
  85559. * @param isLocal defines if the position should be set in local space
  85560. */
  85561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85562. /**
  85563. * Clones the current emitter and returns a copy of it
  85564. * @returns the new emitter
  85565. */
  85566. clone(): BoxParticleEmitter;
  85567. /**
  85568. * Called by the GPUParticleSystem to setup the update shader
  85569. * @param effect defines the update shader
  85570. */
  85571. applyToShader(effect: Effect): void;
  85572. /**
  85573. * Returns a string to use to update the GPU particles update shader
  85574. * @returns a string containng the defines string
  85575. */
  85576. getEffectDefines(): string;
  85577. /**
  85578. * Returns the string "BoxParticleEmitter"
  85579. * @returns a string containing the class name
  85580. */
  85581. getClassName(): string;
  85582. /**
  85583. * Serializes the particle system to a JSON object.
  85584. * @returns the JSON object
  85585. */
  85586. serialize(): any;
  85587. /**
  85588. * Parse properties from a JSON object
  85589. * @param serializationObject defines the JSON object
  85590. */
  85591. parse(serializationObject: any): void;
  85592. }
  85593. }
  85594. declare module BABYLON {
  85595. /**
  85596. * Particle emitter emitting particles from the inside of a cone.
  85597. * It emits the particles alongside the cone volume from the base to the particle.
  85598. * The emission direction might be randomized.
  85599. */
  85600. export class ConeParticleEmitter implements IParticleEmitterType {
  85601. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85602. directionRandomizer: number;
  85603. private _radius;
  85604. private _angle;
  85605. private _height;
  85606. /**
  85607. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85608. */
  85609. radiusRange: number;
  85610. /**
  85611. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85612. */
  85613. heightRange: number;
  85614. /**
  85615. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85616. */
  85617. emitFromSpawnPointOnly: boolean;
  85618. /**
  85619. * Gets or sets the radius of the emission cone
  85620. */
  85621. get radius(): number;
  85622. set radius(value: number);
  85623. /**
  85624. * Gets or sets the angle of the emission cone
  85625. */
  85626. get angle(): number;
  85627. set angle(value: number);
  85628. private _buildHeight;
  85629. /**
  85630. * Creates a new instance ConeParticleEmitter
  85631. * @param radius the radius of the emission cone (1 by default)
  85632. * @param angle the cone base angle (PI by default)
  85633. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85634. */
  85635. constructor(radius?: number, angle?: number,
  85636. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85637. directionRandomizer?: number);
  85638. /**
  85639. * Called by the particle System when the direction is computed for the created particle.
  85640. * @param worldMatrix is the world matrix of the particle system
  85641. * @param directionToUpdate is the direction vector to update with the result
  85642. * @param particle is the particle we are computed the direction for
  85643. * @param isLocal defines if the direction should be set in local space
  85644. */
  85645. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85646. /**
  85647. * Called by the particle System when the position is computed for the created particle.
  85648. * @param worldMatrix is the world matrix of the particle system
  85649. * @param positionToUpdate is the position vector to update with the result
  85650. * @param particle is the particle we are computed the position for
  85651. * @param isLocal defines if the position should be set in local space
  85652. */
  85653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85654. /**
  85655. * Clones the current emitter and returns a copy of it
  85656. * @returns the new emitter
  85657. */
  85658. clone(): ConeParticleEmitter;
  85659. /**
  85660. * Called by the GPUParticleSystem to setup the update shader
  85661. * @param effect defines the update shader
  85662. */
  85663. applyToShader(effect: Effect): void;
  85664. /**
  85665. * Returns a string to use to update the GPU particles update shader
  85666. * @returns a string containng the defines string
  85667. */
  85668. getEffectDefines(): string;
  85669. /**
  85670. * Returns the string "ConeParticleEmitter"
  85671. * @returns a string containing the class name
  85672. */
  85673. getClassName(): string;
  85674. /**
  85675. * Serializes the particle system to a JSON object.
  85676. * @returns the JSON object
  85677. */
  85678. serialize(): any;
  85679. /**
  85680. * Parse properties from a JSON object
  85681. * @param serializationObject defines the JSON object
  85682. */
  85683. parse(serializationObject: any): void;
  85684. }
  85685. }
  85686. declare module BABYLON {
  85687. /**
  85688. * Particle emitter emitting particles from the inside of a cylinder.
  85689. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85690. */
  85691. export class CylinderParticleEmitter implements IParticleEmitterType {
  85692. /**
  85693. * The radius of the emission cylinder.
  85694. */
  85695. radius: number;
  85696. /**
  85697. * The height of the emission cylinder.
  85698. */
  85699. height: number;
  85700. /**
  85701. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85702. */
  85703. radiusRange: number;
  85704. /**
  85705. * How much to randomize the particle direction [0-1].
  85706. */
  85707. directionRandomizer: number;
  85708. /**
  85709. * Creates a new instance CylinderParticleEmitter
  85710. * @param radius the radius of the emission cylinder (1 by default)
  85711. * @param height the height of the emission cylinder (1 by default)
  85712. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85713. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85714. */
  85715. constructor(
  85716. /**
  85717. * The radius of the emission cylinder.
  85718. */
  85719. radius?: number,
  85720. /**
  85721. * The height of the emission cylinder.
  85722. */
  85723. height?: number,
  85724. /**
  85725. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85726. */
  85727. radiusRange?: number,
  85728. /**
  85729. * How much to randomize the particle direction [0-1].
  85730. */
  85731. directionRandomizer?: number);
  85732. /**
  85733. * Called by the particle System when the direction is computed for the created particle.
  85734. * @param worldMatrix is the world matrix of the particle system
  85735. * @param directionToUpdate is the direction vector to update with the result
  85736. * @param particle is the particle we are computed the direction for
  85737. * @param isLocal defines if the direction should be set in local space
  85738. */
  85739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85740. /**
  85741. * Called by the particle System when the position is computed for the created particle.
  85742. * @param worldMatrix is the world matrix of the particle system
  85743. * @param positionToUpdate is the position vector to update with the result
  85744. * @param particle is the particle we are computed the position for
  85745. * @param isLocal defines if the position should be set in local space
  85746. */
  85747. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85748. /**
  85749. * Clones the current emitter and returns a copy of it
  85750. * @returns the new emitter
  85751. */
  85752. clone(): CylinderParticleEmitter;
  85753. /**
  85754. * Called by the GPUParticleSystem to setup the update shader
  85755. * @param effect defines the update shader
  85756. */
  85757. applyToShader(effect: Effect): void;
  85758. /**
  85759. * Returns a string to use to update the GPU particles update shader
  85760. * @returns a string containng the defines string
  85761. */
  85762. getEffectDefines(): string;
  85763. /**
  85764. * Returns the string "CylinderParticleEmitter"
  85765. * @returns a string containing the class name
  85766. */
  85767. getClassName(): string;
  85768. /**
  85769. * Serializes the particle system to a JSON object.
  85770. * @returns the JSON object
  85771. */
  85772. serialize(): any;
  85773. /**
  85774. * Parse properties from a JSON object
  85775. * @param serializationObject defines the JSON object
  85776. */
  85777. parse(serializationObject: any): void;
  85778. }
  85779. /**
  85780. * Particle emitter emitting particles from the inside of a cylinder.
  85781. * It emits the particles randomly between two vectors.
  85782. */
  85783. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85784. /**
  85785. * The min limit of the emission direction.
  85786. */
  85787. direction1: Vector3;
  85788. /**
  85789. * The max limit of the emission direction.
  85790. */
  85791. direction2: Vector3;
  85792. /**
  85793. * Creates a new instance CylinderDirectedParticleEmitter
  85794. * @param radius the radius of the emission cylinder (1 by default)
  85795. * @param height the height of the emission cylinder (1 by default)
  85796. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85797. * @param direction1 the min limit of the emission direction (up vector by default)
  85798. * @param direction2 the max limit of the emission direction (up vector by default)
  85799. */
  85800. constructor(radius?: number, height?: number, radiusRange?: number,
  85801. /**
  85802. * The min limit of the emission direction.
  85803. */
  85804. direction1?: Vector3,
  85805. /**
  85806. * The max limit of the emission direction.
  85807. */
  85808. direction2?: Vector3);
  85809. /**
  85810. * Called by the particle System when the direction is computed for the created particle.
  85811. * @param worldMatrix is the world matrix of the particle system
  85812. * @param directionToUpdate is the direction vector to update with the result
  85813. * @param particle is the particle we are computed the direction for
  85814. */
  85815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85816. /**
  85817. * Clones the current emitter and returns a copy of it
  85818. * @returns the new emitter
  85819. */
  85820. clone(): CylinderDirectedParticleEmitter;
  85821. /**
  85822. * Called by the GPUParticleSystem to setup the update shader
  85823. * @param effect defines the update shader
  85824. */
  85825. applyToShader(effect: Effect): void;
  85826. /**
  85827. * Returns a string to use to update the GPU particles update shader
  85828. * @returns a string containng the defines string
  85829. */
  85830. getEffectDefines(): string;
  85831. /**
  85832. * Returns the string "CylinderDirectedParticleEmitter"
  85833. * @returns a string containing the class name
  85834. */
  85835. getClassName(): string;
  85836. /**
  85837. * Serializes the particle system to a JSON object.
  85838. * @returns the JSON object
  85839. */
  85840. serialize(): any;
  85841. /**
  85842. * Parse properties from a JSON object
  85843. * @param serializationObject defines the JSON object
  85844. */
  85845. parse(serializationObject: any): void;
  85846. }
  85847. }
  85848. declare module BABYLON {
  85849. /**
  85850. * Particle emitter emitting particles from the inside of a hemisphere.
  85851. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85852. */
  85853. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85854. /**
  85855. * The radius of the emission hemisphere.
  85856. */
  85857. radius: number;
  85858. /**
  85859. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85860. */
  85861. radiusRange: number;
  85862. /**
  85863. * How much to randomize the particle direction [0-1].
  85864. */
  85865. directionRandomizer: number;
  85866. /**
  85867. * Creates a new instance HemisphericParticleEmitter
  85868. * @param radius the radius of the emission hemisphere (1 by default)
  85869. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85870. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85871. */
  85872. constructor(
  85873. /**
  85874. * The radius of the emission hemisphere.
  85875. */
  85876. radius?: number,
  85877. /**
  85878. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85879. */
  85880. radiusRange?: number,
  85881. /**
  85882. * How much to randomize the particle direction [0-1].
  85883. */
  85884. directionRandomizer?: number);
  85885. /**
  85886. * Called by the particle System when the direction is computed for the created particle.
  85887. * @param worldMatrix is the world matrix of the particle system
  85888. * @param directionToUpdate is the direction vector to update with the result
  85889. * @param particle is the particle we are computed the direction for
  85890. * @param isLocal defines if the direction should be set in local space
  85891. */
  85892. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85893. /**
  85894. * Called by the particle System when the position is computed for the created particle.
  85895. * @param worldMatrix is the world matrix of the particle system
  85896. * @param positionToUpdate is the position vector to update with the result
  85897. * @param particle is the particle we are computed the position for
  85898. * @param isLocal defines if the position should be set in local space
  85899. */
  85900. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85901. /**
  85902. * Clones the current emitter and returns a copy of it
  85903. * @returns the new emitter
  85904. */
  85905. clone(): HemisphericParticleEmitter;
  85906. /**
  85907. * Called by the GPUParticleSystem to setup the update shader
  85908. * @param effect defines the update shader
  85909. */
  85910. applyToShader(effect: Effect): void;
  85911. /**
  85912. * Returns a string to use to update the GPU particles update shader
  85913. * @returns a string containng the defines string
  85914. */
  85915. getEffectDefines(): string;
  85916. /**
  85917. * Returns the string "HemisphericParticleEmitter"
  85918. * @returns a string containing the class name
  85919. */
  85920. getClassName(): string;
  85921. /**
  85922. * Serializes the particle system to a JSON object.
  85923. * @returns the JSON object
  85924. */
  85925. serialize(): any;
  85926. /**
  85927. * Parse properties from a JSON object
  85928. * @param serializationObject defines the JSON object
  85929. */
  85930. parse(serializationObject: any): void;
  85931. }
  85932. }
  85933. declare module BABYLON {
  85934. /**
  85935. * Particle emitter emitting particles from a point.
  85936. * It emits the particles randomly between 2 given directions.
  85937. */
  85938. export class PointParticleEmitter implements IParticleEmitterType {
  85939. /**
  85940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85941. */
  85942. direction1: Vector3;
  85943. /**
  85944. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85945. */
  85946. direction2: Vector3;
  85947. /**
  85948. * Creates a new instance PointParticleEmitter
  85949. */
  85950. constructor();
  85951. /**
  85952. * Called by the particle System when the direction is computed for the created particle.
  85953. * @param worldMatrix is the world matrix of the particle system
  85954. * @param directionToUpdate is the direction vector to update with the result
  85955. * @param particle is the particle we are computed the direction for
  85956. * @param isLocal defines if the direction should be set in local space
  85957. */
  85958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85959. /**
  85960. * Called by the particle System when the position is computed for the created particle.
  85961. * @param worldMatrix is the world matrix of the particle system
  85962. * @param positionToUpdate is the position vector to update with the result
  85963. * @param particle is the particle we are computed the position for
  85964. * @param isLocal defines if the position should be set in local space
  85965. */
  85966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85967. /**
  85968. * Clones the current emitter and returns a copy of it
  85969. * @returns the new emitter
  85970. */
  85971. clone(): PointParticleEmitter;
  85972. /**
  85973. * Called by the GPUParticleSystem to setup the update shader
  85974. * @param effect defines the update shader
  85975. */
  85976. applyToShader(effect: Effect): void;
  85977. /**
  85978. * Returns a string to use to update the GPU particles update shader
  85979. * @returns a string containng the defines string
  85980. */
  85981. getEffectDefines(): string;
  85982. /**
  85983. * Returns the string "PointParticleEmitter"
  85984. * @returns a string containing the class name
  85985. */
  85986. getClassName(): string;
  85987. /**
  85988. * Serializes the particle system to a JSON object.
  85989. * @returns the JSON object
  85990. */
  85991. serialize(): any;
  85992. /**
  85993. * Parse properties from a JSON object
  85994. * @param serializationObject defines the JSON object
  85995. */
  85996. parse(serializationObject: any): void;
  85997. }
  85998. }
  85999. declare module BABYLON {
  86000. /**
  86001. * Particle emitter emitting particles from the inside of a sphere.
  86002. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86003. */
  86004. export class SphereParticleEmitter implements IParticleEmitterType {
  86005. /**
  86006. * The radius of the emission sphere.
  86007. */
  86008. radius: number;
  86009. /**
  86010. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86011. */
  86012. radiusRange: number;
  86013. /**
  86014. * How much to randomize the particle direction [0-1].
  86015. */
  86016. directionRandomizer: number;
  86017. /**
  86018. * Creates a new instance SphereParticleEmitter
  86019. * @param radius the radius of the emission sphere (1 by default)
  86020. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86021. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86022. */
  86023. constructor(
  86024. /**
  86025. * The radius of the emission sphere.
  86026. */
  86027. radius?: number,
  86028. /**
  86029. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86030. */
  86031. radiusRange?: number,
  86032. /**
  86033. * How much to randomize the particle direction [0-1].
  86034. */
  86035. directionRandomizer?: number);
  86036. /**
  86037. * Called by the particle System when the direction is computed for the created particle.
  86038. * @param worldMatrix is the world matrix of the particle system
  86039. * @param directionToUpdate is the direction vector to update with the result
  86040. * @param particle is the particle we are computed the direction for
  86041. * @param isLocal defines if the direction should be set in local space
  86042. */
  86043. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86044. /**
  86045. * Called by the particle System when the position is computed for the created particle.
  86046. * @param worldMatrix is the world matrix of the particle system
  86047. * @param positionToUpdate is the position vector to update with the result
  86048. * @param particle is the particle we are computed the position for
  86049. * @param isLocal defines if the position should be set in local space
  86050. */
  86051. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86052. /**
  86053. * Clones the current emitter and returns a copy of it
  86054. * @returns the new emitter
  86055. */
  86056. clone(): SphereParticleEmitter;
  86057. /**
  86058. * Called by the GPUParticleSystem to setup the update shader
  86059. * @param effect defines the update shader
  86060. */
  86061. applyToShader(effect: Effect): void;
  86062. /**
  86063. * Returns a string to use to update the GPU particles update shader
  86064. * @returns a string containng the defines string
  86065. */
  86066. getEffectDefines(): string;
  86067. /**
  86068. * Returns the string "SphereParticleEmitter"
  86069. * @returns a string containing the class name
  86070. */
  86071. getClassName(): string;
  86072. /**
  86073. * Serializes the particle system to a JSON object.
  86074. * @returns the JSON object
  86075. */
  86076. serialize(): any;
  86077. /**
  86078. * Parse properties from a JSON object
  86079. * @param serializationObject defines the JSON object
  86080. */
  86081. parse(serializationObject: any): void;
  86082. }
  86083. /**
  86084. * Particle emitter emitting particles from the inside of a sphere.
  86085. * It emits the particles randomly between two vectors.
  86086. */
  86087. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86088. /**
  86089. * The min limit of the emission direction.
  86090. */
  86091. direction1: Vector3;
  86092. /**
  86093. * The max limit of the emission direction.
  86094. */
  86095. direction2: Vector3;
  86096. /**
  86097. * Creates a new instance SphereDirectedParticleEmitter
  86098. * @param radius the radius of the emission sphere (1 by default)
  86099. * @param direction1 the min limit of the emission direction (up vector by default)
  86100. * @param direction2 the max limit of the emission direction (up vector by default)
  86101. */
  86102. constructor(radius?: number,
  86103. /**
  86104. * The min limit of the emission direction.
  86105. */
  86106. direction1?: Vector3,
  86107. /**
  86108. * The max limit of the emission direction.
  86109. */
  86110. direction2?: Vector3);
  86111. /**
  86112. * Called by the particle System when the direction is computed for the created particle.
  86113. * @param worldMatrix is the world matrix of the particle system
  86114. * @param directionToUpdate is the direction vector to update with the result
  86115. * @param particle is the particle we are computed the direction for
  86116. */
  86117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86118. /**
  86119. * Clones the current emitter and returns a copy of it
  86120. * @returns the new emitter
  86121. */
  86122. clone(): SphereDirectedParticleEmitter;
  86123. /**
  86124. * Called by the GPUParticleSystem to setup the update shader
  86125. * @param effect defines the update shader
  86126. */
  86127. applyToShader(effect: Effect): void;
  86128. /**
  86129. * Returns a string to use to update the GPU particles update shader
  86130. * @returns a string containng the defines string
  86131. */
  86132. getEffectDefines(): string;
  86133. /**
  86134. * Returns the string "SphereDirectedParticleEmitter"
  86135. * @returns a string containing the class name
  86136. */
  86137. getClassName(): string;
  86138. /**
  86139. * Serializes the particle system to a JSON object.
  86140. * @returns the JSON object
  86141. */
  86142. serialize(): any;
  86143. /**
  86144. * Parse properties from a JSON object
  86145. * @param serializationObject defines the JSON object
  86146. */
  86147. parse(serializationObject: any): void;
  86148. }
  86149. }
  86150. declare module BABYLON {
  86151. /**
  86152. * Particle emitter emitting particles from a custom list of positions.
  86153. */
  86154. export class CustomParticleEmitter implements IParticleEmitterType {
  86155. /**
  86156. * Gets or sets the position generator that will create the inital position of each particle.
  86157. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86158. */
  86159. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86160. /**
  86161. * Gets or sets the destination generator that will create the final destination of each particle.
  86162. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86163. */
  86164. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86165. /**
  86166. * Creates a new instance CustomParticleEmitter
  86167. */
  86168. constructor();
  86169. /**
  86170. * Called by the particle System when the direction is computed for the created particle.
  86171. * @param worldMatrix is the world matrix of the particle system
  86172. * @param directionToUpdate is the direction vector to update with the result
  86173. * @param particle is the particle we are computed the direction for
  86174. * @param isLocal defines if the direction should be set in local space
  86175. */
  86176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86177. /**
  86178. * Called by the particle System when the position is computed for the created particle.
  86179. * @param worldMatrix is the world matrix of the particle system
  86180. * @param positionToUpdate is the position vector to update with the result
  86181. * @param particle is the particle we are computed the position for
  86182. * @param isLocal defines if the position should be set in local space
  86183. */
  86184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86185. /**
  86186. * Clones the current emitter and returns a copy of it
  86187. * @returns the new emitter
  86188. */
  86189. clone(): CustomParticleEmitter;
  86190. /**
  86191. * Called by the GPUParticleSystem to setup the update shader
  86192. * @param effect defines the update shader
  86193. */
  86194. applyToShader(effect: Effect): void;
  86195. /**
  86196. * Returns a string to use to update the GPU particles update shader
  86197. * @returns a string containng the defines string
  86198. */
  86199. getEffectDefines(): string;
  86200. /**
  86201. * Returns the string "PointParticleEmitter"
  86202. * @returns a string containing the class name
  86203. */
  86204. getClassName(): string;
  86205. /**
  86206. * Serializes the particle system to a JSON object.
  86207. * @returns the JSON object
  86208. */
  86209. serialize(): any;
  86210. /**
  86211. * Parse properties from a JSON object
  86212. * @param serializationObject defines the JSON object
  86213. */
  86214. parse(serializationObject: any): void;
  86215. }
  86216. }
  86217. declare module BABYLON {
  86218. /**
  86219. * Particle emitter emitting particles from the inside of a box.
  86220. * It emits the particles randomly between 2 given directions.
  86221. */
  86222. export class MeshParticleEmitter implements IParticleEmitterType {
  86223. /** Defines the mesh to use as source */
  86224. mesh?: AbstractMesh | undefined;
  86225. private _indices;
  86226. private _positions;
  86227. private _normals;
  86228. private _storedNormal;
  86229. /**
  86230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86231. */
  86232. direction1: Vector3;
  86233. /**
  86234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86235. */
  86236. direction2: Vector3;
  86237. /**
  86238. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86239. */
  86240. useMeshNormalsForDirection: boolean;
  86241. /**
  86242. * Creates a new instance MeshParticleEmitter
  86243. * @param mesh defines the mesh to use as source
  86244. */
  86245. constructor(
  86246. /** Defines the mesh to use as source */
  86247. mesh?: AbstractMesh | undefined);
  86248. /**
  86249. * Called by the particle System when the direction is computed for the created particle.
  86250. * @param worldMatrix is the world matrix of the particle system
  86251. * @param directionToUpdate is the direction vector to update with the result
  86252. * @param particle is the particle we are computed the direction for
  86253. * @param isLocal defines if the direction should be set in local space
  86254. */
  86255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86256. /**
  86257. * Called by the particle System when the position is computed for the created particle.
  86258. * @param worldMatrix is the world matrix of the particle system
  86259. * @param positionToUpdate is the position vector to update with the result
  86260. * @param particle is the particle we are computed the position for
  86261. * @param isLocal defines if the position should be set in local space
  86262. */
  86263. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86264. /**
  86265. * Clones the current emitter and returns a copy of it
  86266. * @returns the new emitter
  86267. */
  86268. clone(): MeshParticleEmitter;
  86269. /**
  86270. * Called by the GPUParticleSystem to setup the update shader
  86271. * @param effect defines the update shader
  86272. */
  86273. applyToShader(effect: Effect): void;
  86274. /**
  86275. * Returns a string to use to update the GPU particles update shader
  86276. * @returns a string containng the defines string
  86277. */
  86278. getEffectDefines(): string;
  86279. /**
  86280. * Returns the string "BoxParticleEmitter"
  86281. * @returns a string containing the class name
  86282. */
  86283. getClassName(): string;
  86284. /**
  86285. * Serializes the particle system to a JSON object.
  86286. * @returns the JSON object
  86287. */
  86288. serialize(): any;
  86289. /**
  86290. * Parse properties from a JSON object
  86291. * @param serializationObject defines the JSON object
  86292. * @param scene defines the hosting scene
  86293. */
  86294. parse(serializationObject: any, scene: Scene): void;
  86295. }
  86296. }
  86297. declare module BABYLON {
  86298. /**
  86299. * Interface representing a particle system in Babylon.js.
  86300. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86301. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86302. */
  86303. export interface IParticleSystem {
  86304. /**
  86305. * List of animations used by the particle system.
  86306. */
  86307. animations: Animation[];
  86308. /**
  86309. * The id of the Particle system.
  86310. */
  86311. id: string;
  86312. /**
  86313. * The name of the Particle system.
  86314. */
  86315. name: string;
  86316. /**
  86317. * The emitter represents the Mesh or position we are attaching the particle system to.
  86318. */
  86319. emitter: Nullable<AbstractMesh | Vector3>;
  86320. /**
  86321. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86322. */
  86323. isBillboardBased: boolean;
  86324. /**
  86325. * The rendering group used by the Particle system to chose when to render.
  86326. */
  86327. renderingGroupId: number;
  86328. /**
  86329. * The layer mask we are rendering the particles through.
  86330. */
  86331. layerMask: number;
  86332. /**
  86333. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86334. */
  86335. updateSpeed: number;
  86336. /**
  86337. * The amount of time the particle system is running (depends of the overall update speed).
  86338. */
  86339. targetStopDuration: number;
  86340. /**
  86341. * The texture used to render each particle. (this can be a spritesheet)
  86342. */
  86343. particleTexture: Nullable<Texture>;
  86344. /**
  86345. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86346. */
  86347. blendMode: number;
  86348. /**
  86349. * Minimum life time of emitting particles.
  86350. */
  86351. minLifeTime: number;
  86352. /**
  86353. * Maximum life time of emitting particles.
  86354. */
  86355. maxLifeTime: number;
  86356. /**
  86357. * Minimum Size of emitting particles.
  86358. */
  86359. minSize: number;
  86360. /**
  86361. * Maximum Size of emitting particles.
  86362. */
  86363. maxSize: number;
  86364. /**
  86365. * Minimum scale of emitting particles on X axis.
  86366. */
  86367. minScaleX: number;
  86368. /**
  86369. * Maximum scale of emitting particles on X axis.
  86370. */
  86371. maxScaleX: number;
  86372. /**
  86373. * Minimum scale of emitting particles on Y axis.
  86374. */
  86375. minScaleY: number;
  86376. /**
  86377. * Maximum scale of emitting particles on Y axis.
  86378. */
  86379. maxScaleY: number;
  86380. /**
  86381. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86382. */
  86383. color1: Color4;
  86384. /**
  86385. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86386. */
  86387. color2: Color4;
  86388. /**
  86389. * Color the particle will have at the end of its lifetime.
  86390. */
  86391. colorDead: Color4;
  86392. /**
  86393. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86394. */
  86395. emitRate: number;
  86396. /**
  86397. * You can use gravity if you want to give an orientation to your particles.
  86398. */
  86399. gravity: Vector3;
  86400. /**
  86401. * Minimum power of emitting particles.
  86402. */
  86403. minEmitPower: number;
  86404. /**
  86405. * Maximum power of emitting particles.
  86406. */
  86407. maxEmitPower: number;
  86408. /**
  86409. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86410. */
  86411. minAngularSpeed: number;
  86412. /**
  86413. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86414. */
  86415. maxAngularSpeed: number;
  86416. /**
  86417. * Gets or sets the minimal initial rotation in radians.
  86418. */
  86419. minInitialRotation: number;
  86420. /**
  86421. * Gets or sets the maximal initial rotation in radians.
  86422. */
  86423. maxInitialRotation: number;
  86424. /**
  86425. * The particle emitter type defines the emitter used by the particle system.
  86426. * It can be for example box, sphere, or cone...
  86427. */
  86428. particleEmitterType: Nullable<IParticleEmitterType>;
  86429. /**
  86430. * Defines the delay in milliseconds before starting the system (0 by default)
  86431. */
  86432. startDelay: number;
  86433. /**
  86434. * 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
  86435. */
  86436. preWarmCycles: number;
  86437. /**
  86438. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86439. */
  86440. preWarmStepOffset: number;
  86441. /**
  86442. * 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)
  86443. */
  86444. spriteCellChangeSpeed: number;
  86445. /**
  86446. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86447. */
  86448. startSpriteCellID: number;
  86449. /**
  86450. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86451. */
  86452. endSpriteCellID: number;
  86453. /**
  86454. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86455. */
  86456. spriteCellWidth: number;
  86457. /**
  86458. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86459. */
  86460. spriteCellHeight: number;
  86461. /**
  86462. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86463. */
  86464. spriteRandomStartCell: boolean;
  86465. /**
  86466. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86467. */
  86468. isAnimationSheetEnabled: boolean;
  86469. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86470. translationPivot: Vector2;
  86471. /**
  86472. * Gets or sets a texture used to add random noise to particle positions
  86473. */
  86474. noiseTexture: Nullable<BaseTexture>;
  86475. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86476. noiseStrength: Vector3;
  86477. /**
  86478. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86479. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86480. */
  86481. billboardMode: number;
  86482. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86483. limitVelocityDamping: number;
  86484. /**
  86485. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86486. */
  86487. beginAnimationOnStart: boolean;
  86488. /**
  86489. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86490. */
  86491. beginAnimationFrom: number;
  86492. /**
  86493. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86494. */
  86495. beginAnimationTo: number;
  86496. /**
  86497. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86498. */
  86499. beginAnimationLoop: boolean;
  86500. /**
  86501. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86502. */
  86503. disposeOnStop: boolean;
  86504. /**
  86505. * Specifies if the particles are updated in emitter local space or world space
  86506. */
  86507. isLocal: boolean;
  86508. /**
  86509. * Gets the maximum number of particles active at the same time.
  86510. * @returns The max number of active particles.
  86511. */
  86512. getCapacity(): number;
  86513. /**
  86514. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86515. * @returns True if it has been started, otherwise false.
  86516. */
  86517. isStarted(): boolean;
  86518. /**
  86519. * Animates the particle system for this frame.
  86520. */
  86521. animate(): void;
  86522. /**
  86523. * Renders the particle system in its current state.
  86524. * @returns the current number of particles
  86525. */
  86526. render(): number;
  86527. /**
  86528. * Dispose the particle system and frees its associated resources.
  86529. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86530. */
  86531. dispose(disposeTexture?: boolean): void;
  86532. /**
  86533. * Clones the particle system.
  86534. * @param name The name of the cloned object
  86535. * @param newEmitter The new emitter to use
  86536. * @returns the cloned particle system
  86537. */
  86538. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86539. /**
  86540. * Serializes the particle system to a JSON object.
  86541. * @returns the JSON object
  86542. */
  86543. serialize(): any;
  86544. /**
  86545. * Rebuild the particle system
  86546. */
  86547. rebuild(): void;
  86548. /**
  86549. * Starts the particle system and begins to emit
  86550. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86551. */
  86552. start(delay?: number): void;
  86553. /**
  86554. * Stops the particle system.
  86555. */
  86556. stop(): void;
  86557. /**
  86558. * Remove all active particles
  86559. */
  86560. reset(): void;
  86561. /**
  86562. * Is this system ready to be used/rendered
  86563. * @return true if the system is ready
  86564. */
  86565. isReady(): boolean;
  86566. /**
  86567. * Adds a new color gradient
  86568. * @param gradient defines the gradient to use (between 0 and 1)
  86569. * @param color1 defines the color to affect to the specified gradient
  86570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86571. * @returns the current particle system
  86572. */
  86573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86574. /**
  86575. * Remove a specific color gradient
  86576. * @param gradient defines the gradient to remove
  86577. * @returns the current particle system
  86578. */
  86579. removeColorGradient(gradient: number): IParticleSystem;
  86580. /**
  86581. * Adds a new size gradient
  86582. * @param gradient defines the gradient to use (between 0 and 1)
  86583. * @param factor defines the size factor to affect to the specified gradient
  86584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86585. * @returns the current particle system
  86586. */
  86587. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86588. /**
  86589. * Remove a specific size gradient
  86590. * @param gradient defines the gradient to remove
  86591. * @returns the current particle system
  86592. */
  86593. removeSizeGradient(gradient: number): IParticleSystem;
  86594. /**
  86595. * Gets the current list of color gradients.
  86596. * You must use addColorGradient and removeColorGradient to udpate this list
  86597. * @returns the list of color gradients
  86598. */
  86599. getColorGradients(): Nullable<Array<ColorGradient>>;
  86600. /**
  86601. * Gets the current list of size gradients.
  86602. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86603. * @returns the list of size gradients
  86604. */
  86605. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86606. /**
  86607. * Gets the current list of angular speed gradients.
  86608. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86609. * @returns the list of angular speed gradients
  86610. */
  86611. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86612. /**
  86613. * Adds a new angular speed gradient
  86614. * @param gradient defines the gradient to use (between 0 and 1)
  86615. * @param factor defines the angular speed to affect to the specified gradient
  86616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86617. * @returns the current particle system
  86618. */
  86619. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86620. /**
  86621. * Remove a specific angular speed gradient
  86622. * @param gradient defines the gradient to remove
  86623. * @returns the current particle system
  86624. */
  86625. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86626. /**
  86627. * Gets the current list of velocity gradients.
  86628. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86629. * @returns the list of velocity gradients
  86630. */
  86631. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86632. /**
  86633. * Adds a new velocity gradient
  86634. * @param gradient defines the gradient to use (between 0 and 1)
  86635. * @param factor defines the velocity to affect to the specified gradient
  86636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86637. * @returns the current particle system
  86638. */
  86639. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86640. /**
  86641. * Remove a specific velocity gradient
  86642. * @param gradient defines the gradient to remove
  86643. * @returns the current particle system
  86644. */
  86645. removeVelocityGradient(gradient: number): IParticleSystem;
  86646. /**
  86647. * Gets the current list of limit velocity gradients.
  86648. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86649. * @returns the list of limit velocity gradients
  86650. */
  86651. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86652. /**
  86653. * Adds a new limit velocity gradient
  86654. * @param gradient defines the gradient to use (between 0 and 1)
  86655. * @param factor defines the limit velocity to affect to the specified gradient
  86656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86657. * @returns the current particle system
  86658. */
  86659. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86660. /**
  86661. * Remove a specific limit velocity gradient
  86662. * @param gradient defines the gradient to remove
  86663. * @returns the current particle system
  86664. */
  86665. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86666. /**
  86667. * Adds a new drag gradient
  86668. * @param gradient defines the gradient to use (between 0 and 1)
  86669. * @param factor defines the drag to affect to the specified gradient
  86670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86671. * @returns the current particle system
  86672. */
  86673. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86674. /**
  86675. * Remove a specific drag gradient
  86676. * @param gradient defines the gradient to remove
  86677. * @returns the current particle system
  86678. */
  86679. removeDragGradient(gradient: number): IParticleSystem;
  86680. /**
  86681. * Gets the current list of drag gradients.
  86682. * You must use addDragGradient and removeDragGradient to udpate this list
  86683. * @returns the list of drag gradients
  86684. */
  86685. getDragGradients(): Nullable<Array<FactorGradient>>;
  86686. /**
  86687. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86688. * @param gradient defines the gradient to use (between 0 and 1)
  86689. * @param factor defines the emit rate to affect to the specified gradient
  86690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86691. * @returns the current particle system
  86692. */
  86693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86694. /**
  86695. * Remove a specific emit rate gradient
  86696. * @param gradient defines the gradient to remove
  86697. * @returns the current particle system
  86698. */
  86699. removeEmitRateGradient(gradient: number): IParticleSystem;
  86700. /**
  86701. * Gets the current list of emit rate gradients.
  86702. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86703. * @returns the list of emit rate gradients
  86704. */
  86705. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86706. /**
  86707. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86708. * @param gradient defines the gradient to use (between 0 and 1)
  86709. * @param factor defines the start size to affect to the specified gradient
  86710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86711. * @returns the current particle system
  86712. */
  86713. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86714. /**
  86715. * Remove a specific start size gradient
  86716. * @param gradient defines the gradient to remove
  86717. * @returns the current particle system
  86718. */
  86719. removeStartSizeGradient(gradient: number): IParticleSystem;
  86720. /**
  86721. * Gets the current list of start size gradients.
  86722. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86723. * @returns the list of start size gradients
  86724. */
  86725. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86726. /**
  86727. * Adds a new life time gradient
  86728. * @param gradient defines the gradient to use (between 0 and 1)
  86729. * @param factor defines the life time factor to affect to the specified gradient
  86730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86731. * @returns the current particle system
  86732. */
  86733. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86734. /**
  86735. * Remove a specific life time gradient
  86736. * @param gradient defines the gradient to remove
  86737. * @returns the current particle system
  86738. */
  86739. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86740. /**
  86741. * Gets the current list of life time gradients.
  86742. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86743. * @returns the list of life time gradients
  86744. */
  86745. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86746. /**
  86747. * Gets the current list of color gradients.
  86748. * You must use addColorGradient and removeColorGradient to udpate this list
  86749. * @returns the list of color gradients
  86750. */
  86751. getColorGradients(): Nullable<Array<ColorGradient>>;
  86752. /**
  86753. * Adds a new ramp gradient used to remap particle colors
  86754. * @param gradient defines the gradient to use (between 0 and 1)
  86755. * @param color defines the color to affect to the specified gradient
  86756. * @returns the current particle system
  86757. */
  86758. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86759. /**
  86760. * Gets the current list of ramp gradients.
  86761. * You must use addRampGradient and removeRampGradient to udpate this list
  86762. * @returns the list of ramp gradients
  86763. */
  86764. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86765. /** Gets or sets a boolean indicating that ramp gradients must be used
  86766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86767. */
  86768. useRampGradients: boolean;
  86769. /**
  86770. * Adds a new color remap gradient
  86771. * @param gradient defines the gradient to use (between 0 and 1)
  86772. * @param min defines the color remap minimal range
  86773. * @param max defines the color remap maximal range
  86774. * @returns the current particle system
  86775. */
  86776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86777. /**
  86778. * Gets the current list of color remap gradients.
  86779. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86780. * @returns the list of color remap gradients
  86781. */
  86782. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86783. /**
  86784. * Adds a new alpha remap gradient
  86785. * @param gradient defines the gradient to use (between 0 and 1)
  86786. * @param min defines the alpha remap minimal range
  86787. * @param max defines the alpha remap maximal range
  86788. * @returns the current particle system
  86789. */
  86790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86791. /**
  86792. * Gets the current list of alpha remap gradients.
  86793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86794. * @returns the list of alpha remap gradients
  86795. */
  86796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86797. /**
  86798. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86801. * @returns the emitter
  86802. */
  86803. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86804. /**
  86805. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86806. * @param radius The radius of the hemisphere to emit from
  86807. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86808. * @returns the emitter
  86809. */
  86810. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86811. /**
  86812. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86813. * @param radius The radius of the sphere to emit from
  86814. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86815. * @returns the emitter
  86816. */
  86817. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86818. /**
  86819. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86820. * @param radius The radius of the sphere to emit from
  86821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86823. * @returns the emitter
  86824. */
  86825. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86826. /**
  86827. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86828. * @param radius The radius of the emission cylinder
  86829. * @param height The height of the emission cylinder
  86830. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86831. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86832. * @returns the emitter
  86833. */
  86834. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86835. /**
  86836. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86837. * @param radius The radius of the cylinder to emit from
  86838. * @param height The height of the emission cylinder
  86839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86842. * @returns the emitter
  86843. */
  86844. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86845. /**
  86846. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86847. * @param radius The radius of the cone to emit from
  86848. * @param angle The base angle of the cone
  86849. * @returns the emitter
  86850. */
  86851. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86852. /**
  86853. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86856. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86857. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86858. * @returns the emitter
  86859. */
  86860. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86861. /**
  86862. * Get hosting scene
  86863. * @returns the scene
  86864. */
  86865. getScene(): Scene;
  86866. }
  86867. }
  86868. declare module BABYLON {
  86869. /**
  86870. * 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.
  86871. * @see https://doc.babylonjs.com/how_to/transformnode
  86872. */
  86873. export class TransformNode extends Node {
  86874. /**
  86875. * Object will not rotate to face the camera
  86876. */
  86877. static BILLBOARDMODE_NONE: number;
  86878. /**
  86879. * Object will rotate to face the camera but only on the x axis
  86880. */
  86881. static BILLBOARDMODE_X: number;
  86882. /**
  86883. * Object will rotate to face the camera but only on the y axis
  86884. */
  86885. static BILLBOARDMODE_Y: number;
  86886. /**
  86887. * Object will rotate to face the camera but only on the z axis
  86888. */
  86889. static BILLBOARDMODE_Z: number;
  86890. /**
  86891. * Object will rotate to face the camera
  86892. */
  86893. static BILLBOARDMODE_ALL: number;
  86894. /**
  86895. * Object will rotate to face the camera's position instead of orientation
  86896. */
  86897. static BILLBOARDMODE_USE_POSITION: number;
  86898. private _forward;
  86899. private _forwardInverted;
  86900. private _up;
  86901. private _right;
  86902. private _rightInverted;
  86903. private _position;
  86904. private _rotation;
  86905. private _rotationQuaternion;
  86906. protected _scaling: Vector3;
  86907. protected _isDirty: boolean;
  86908. private _transformToBoneReferal;
  86909. private _isAbsoluteSynced;
  86910. private _billboardMode;
  86911. /**
  86912. * Gets or sets the billboard mode. Default is 0.
  86913. *
  86914. * | Value | Type | Description |
  86915. * | --- | --- | --- |
  86916. * | 0 | BILLBOARDMODE_NONE | |
  86917. * | 1 | BILLBOARDMODE_X | |
  86918. * | 2 | BILLBOARDMODE_Y | |
  86919. * | 4 | BILLBOARDMODE_Z | |
  86920. * | 7 | BILLBOARDMODE_ALL | |
  86921. *
  86922. */
  86923. get billboardMode(): number;
  86924. set billboardMode(value: number);
  86925. private _preserveParentRotationForBillboard;
  86926. /**
  86927. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86928. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86929. */
  86930. get preserveParentRotationForBillboard(): boolean;
  86931. set preserveParentRotationForBillboard(value: boolean);
  86932. /**
  86933. * 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
  86934. */
  86935. scalingDeterminant: number;
  86936. private _infiniteDistance;
  86937. /**
  86938. * Gets or sets the distance of the object to max, often used by skybox
  86939. */
  86940. get infiniteDistance(): boolean;
  86941. set infiniteDistance(value: boolean);
  86942. /**
  86943. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86944. * By default the system will update normals to compensate
  86945. */
  86946. ignoreNonUniformScaling: boolean;
  86947. /**
  86948. * 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
  86949. */
  86950. reIntegrateRotationIntoRotationQuaternion: boolean;
  86951. /** @hidden */
  86952. _poseMatrix: Nullable<Matrix>;
  86953. /** @hidden */
  86954. _localMatrix: Matrix;
  86955. private _usePivotMatrix;
  86956. private _absolutePosition;
  86957. private _absoluteScaling;
  86958. private _absoluteRotationQuaternion;
  86959. private _pivotMatrix;
  86960. private _pivotMatrixInverse;
  86961. protected _postMultiplyPivotMatrix: boolean;
  86962. protected _isWorldMatrixFrozen: boolean;
  86963. /** @hidden */
  86964. _indexInSceneTransformNodesArray: number;
  86965. /**
  86966. * An event triggered after the world matrix is updated
  86967. */
  86968. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86969. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86970. /**
  86971. * Gets a string identifying the name of the class
  86972. * @returns "TransformNode" string
  86973. */
  86974. getClassName(): string;
  86975. /**
  86976. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86977. */
  86978. get position(): Vector3;
  86979. set position(newPosition: Vector3);
  86980. /**
  86981. * 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)).
  86982. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86983. */
  86984. get rotation(): Vector3;
  86985. set rotation(newRotation: Vector3);
  86986. /**
  86987. * 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)).
  86988. */
  86989. get scaling(): Vector3;
  86990. set scaling(newScaling: Vector3);
  86991. /**
  86992. * 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).
  86993. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86994. */
  86995. get rotationQuaternion(): Nullable<Quaternion>;
  86996. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86997. /**
  86998. * The forward direction of that transform in world space.
  86999. */
  87000. get forward(): Vector3;
  87001. /**
  87002. * The up direction of that transform in world space.
  87003. */
  87004. get up(): Vector3;
  87005. /**
  87006. * The right direction of that transform in world space.
  87007. */
  87008. get right(): Vector3;
  87009. /**
  87010. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87011. * @param matrix the matrix to copy the pose from
  87012. * @returns this TransformNode.
  87013. */
  87014. updatePoseMatrix(matrix: Matrix): TransformNode;
  87015. /**
  87016. * Returns the mesh Pose matrix.
  87017. * @returns the pose matrix
  87018. */
  87019. getPoseMatrix(): Matrix;
  87020. /** @hidden */
  87021. _isSynchronized(): boolean;
  87022. /** @hidden */
  87023. _initCache(): void;
  87024. /**
  87025. * Flag the transform node as dirty (Forcing it to update everything)
  87026. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87027. * @returns this transform node
  87028. */
  87029. markAsDirty(property: string): TransformNode;
  87030. /**
  87031. * Returns the current mesh absolute position.
  87032. * Returns a Vector3.
  87033. */
  87034. get absolutePosition(): Vector3;
  87035. /**
  87036. * Returns the current mesh absolute scaling.
  87037. * Returns a Vector3.
  87038. */
  87039. get absoluteScaling(): Vector3;
  87040. /**
  87041. * Returns the current mesh absolute rotation.
  87042. * Returns a Quaternion.
  87043. */
  87044. get absoluteRotationQuaternion(): Quaternion;
  87045. /**
  87046. * Sets a new matrix to apply before all other transformation
  87047. * @param matrix defines the transform matrix
  87048. * @returns the current TransformNode
  87049. */
  87050. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87051. /**
  87052. * Sets a new pivot matrix to the current node
  87053. * @param matrix defines the new pivot matrix to use
  87054. * @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
  87055. * @returns the current TransformNode
  87056. */
  87057. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87058. /**
  87059. * Returns the mesh pivot matrix.
  87060. * Default : Identity.
  87061. * @returns the matrix
  87062. */
  87063. getPivotMatrix(): Matrix;
  87064. /**
  87065. * Instantiate (when possible) or clone that node with its hierarchy
  87066. * @param newParent defines the new parent to use for the instance (or clone)
  87067. * @param options defines options to configure how copy is done
  87068. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87069. * @returns an instance (or a clone) of the current node with its hiearchy
  87070. */
  87071. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87072. doNotInstantiate: boolean;
  87073. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87074. /**
  87075. * Prevents the World matrix to be computed any longer
  87076. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87077. * @returns the TransformNode.
  87078. */
  87079. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87080. /**
  87081. * Allows back the World matrix computation.
  87082. * @returns the TransformNode.
  87083. */
  87084. unfreezeWorldMatrix(): this;
  87085. /**
  87086. * True if the World matrix has been frozen.
  87087. */
  87088. get isWorldMatrixFrozen(): boolean;
  87089. /**
  87090. * Retuns the mesh absolute position in the World.
  87091. * @returns a Vector3.
  87092. */
  87093. getAbsolutePosition(): Vector3;
  87094. /**
  87095. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87096. * @param absolutePosition the absolute position to set
  87097. * @returns the TransformNode.
  87098. */
  87099. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87100. /**
  87101. * Sets the mesh position in its local space.
  87102. * @param vector3 the position to set in localspace
  87103. * @returns the TransformNode.
  87104. */
  87105. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87106. /**
  87107. * Returns the mesh position in the local space from the current World matrix values.
  87108. * @returns a new Vector3.
  87109. */
  87110. getPositionExpressedInLocalSpace(): Vector3;
  87111. /**
  87112. * Translates the mesh along the passed Vector3 in its local space.
  87113. * @param vector3 the distance to translate in localspace
  87114. * @returns the TransformNode.
  87115. */
  87116. locallyTranslate(vector3: Vector3): TransformNode;
  87117. private static _lookAtVectorCache;
  87118. /**
  87119. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87120. * @param targetPoint the position (must be in same space as current mesh) to look at
  87121. * @param yawCor optional yaw (y-axis) correction in radians
  87122. * @param pitchCor optional pitch (x-axis) correction in radians
  87123. * @param rollCor optional roll (z-axis) correction in radians
  87124. * @param space the choosen space of the target
  87125. * @returns the TransformNode.
  87126. */
  87127. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87128. /**
  87129. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87130. * This Vector3 is expressed in the World space.
  87131. * @param localAxis axis to rotate
  87132. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87133. */
  87134. getDirection(localAxis: Vector3): Vector3;
  87135. /**
  87136. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87137. * localAxis is expressed in the mesh local space.
  87138. * result is computed in the Wordl space from the mesh World matrix.
  87139. * @param localAxis axis to rotate
  87140. * @param result the resulting transformnode
  87141. * @returns this TransformNode.
  87142. */
  87143. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87144. /**
  87145. * Sets this transform node rotation to the given local axis.
  87146. * @param localAxis the axis in local space
  87147. * @param yawCor optional yaw (y-axis) correction in radians
  87148. * @param pitchCor optional pitch (x-axis) correction in radians
  87149. * @param rollCor optional roll (z-axis) correction in radians
  87150. * @returns this TransformNode
  87151. */
  87152. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87153. /**
  87154. * Sets a new pivot point to the current node
  87155. * @param point defines the new pivot point to use
  87156. * @param space defines if the point is in world or local space (local by default)
  87157. * @returns the current TransformNode
  87158. */
  87159. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87160. /**
  87161. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87162. * @returns the pivot point
  87163. */
  87164. getPivotPoint(): Vector3;
  87165. /**
  87166. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87167. * @param result the vector3 to store the result
  87168. * @returns this TransformNode.
  87169. */
  87170. getPivotPointToRef(result: Vector3): TransformNode;
  87171. /**
  87172. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87173. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87174. */
  87175. getAbsolutePivotPoint(): Vector3;
  87176. /**
  87177. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87178. * @param result vector3 to store the result
  87179. * @returns this TransformNode.
  87180. */
  87181. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87182. /**
  87183. * Defines the passed node as the parent of the current node.
  87184. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87185. * @see https://doc.babylonjs.com/how_to/parenting
  87186. * @param node the node ot set as the parent
  87187. * @returns this TransformNode.
  87188. */
  87189. setParent(node: Nullable<Node>): TransformNode;
  87190. private _nonUniformScaling;
  87191. /**
  87192. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87193. */
  87194. get nonUniformScaling(): boolean;
  87195. /** @hidden */
  87196. _updateNonUniformScalingState(value: boolean): boolean;
  87197. /**
  87198. * Attach the current TransformNode to another TransformNode associated with a bone
  87199. * @param bone Bone affecting the TransformNode
  87200. * @param affectedTransformNode TransformNode associated with the bone
  87201. * @returns this object
  87202. */
  87203. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87204. /**
  87205. * Detach the transform node if its associated with a bone
  87206. * @returns this object
  87207. */
  87208. detachFromBone(): TransformNode;
  87209. private static _rotationAxisCache;
  87210. /**
  87211. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87212. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87213. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87214. * The passed axis is also normalized.
  87215. * @param axis the axis to rotate around
  87216. * @param amount the amount to rotate in radians
  87217. * @param space Space to rotate in (Default: local)
  87218. * @returns the TransformNode.
  87219. */
  87220. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87221. /**
  87222. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87223. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87224. * The passed axis is also normalized. .
  87225. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87226. * @param point the point to rotate around
  87227. * @param axis the axis to rotate around
  87228. * @param amount the amount to rotate in radians
  87229. * @returns the TransformNode
  87230. */
  87231. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87232. /**
  87233. * Translates the mesh along the axis vector for the passed distance in the given space.
  87234. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87235. * @param axis the axis to translate in
  87236. * @param distance the distance to translate
  87237. * @param space Space to rotate in (Default: local)
  87238. * @returns the TransformNode.
  87239. */
  87240. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87241. /**
  87242. * Adds a rotation step to the mesh current rotation.
  87243. * x, y, z are Euler angles expressed in radians.
  87244. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87245. * This means this rotation is made in the mesh local space only.
  87246. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87247. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87248. * ```javascript
  87249. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87250. * ```
  87251. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87252. * 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.
  87253. * @param x Rotation to add
  87254. * @param y Rotation to add
  87255. * @param z Rotation to add
  87256. * @returns the TransformNode.
  87257. */
  87258. addRotation(x: number, y: number, z: number): TransformNode;
  87259. /**
  87260. * @hidden
  87261. */
  87262. protected _getEffectiveParent(): Nullable<Node>;
  87263. /**
  87264. * Computes the world matrix of the node
  87265. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87266. * @returns the world matrix
  87267. */
  87268. computeWorldMatrix(force?: boolean): Matrix;
  87269. /**
  87270. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87271. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87272. */
  87273. resetLocalMatrix(independentOfChildren?: boolean): void;
  87274. protected _afterComputeWorldMatrix(): void;
  87275. /**
  87276. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87277. * @param func callback function to add
  87278. *
  87279. * @returns the TransformNode.
  87280. */
  87281. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87282. /**
  87283. * Removes a registered callback function.
  87284. * @param func callback function to remove
  87285. * @returns the TransformNode.
  87286. */
  87287. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87288. /**
  87289. * Gets the position of the current mesh in camera space
  87290. * @param camera defines the camera to use
  87291. * @returns a position
  87292. */
  87293. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87294. /**
  87295. * Returns the distance from the mesh to the active camera
  87296. * @param camera defines the camera to use
  87297. * @returns the distance
  87298. */
  87299. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87300. /**
  87301. * Clone the current transform node
  87302. * @param name Name of the new clone
  87303. * @param newParent New parent for the clone
  87304. * @param doNotCloneChildren Do not clone children hierarchy
  87305. * @returns the new transform node
  87306. */
  87307. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87308. /**
  87309. * Serializes the objects information.
  87310. * @param currentSerializationObject defines the object to serialize in
  87311. * @returns the serialized object
  87312. */
  87313. serialize(currentSerializationObject?: any): any;
  87314. /**
  87315. * Returns a new TransformNode object parsed from the source provided.
  87316. * @param parsedTransformNode is the source.
  87317. * @param scene the scne the object belongs to
  87318. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87319. * @returns a new TransformNode object parsed from the source provided.
  87320. */
  87321. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87322. /**
  87323. * Get all child-transformNodes of this node
  87324. * @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
  87325. * @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
  87326. * @returns an array of TransformNode
  87327. */
  87328. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87329. /**
  87330. * Releases resources associated with this transform node.
  87331. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87332. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87333. */
  87334. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87335. /**
  87336. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87337. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87338. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87339. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87340. * @returns the current mesh
  87341. */
  87342. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87343. private _syncAbsoluteScalingAndRotation;
  87344. }
  87345. }
  87346. declare module BABYLON {
  87347. /**
  87348. * Class used to override all child animations of a given target
  87349. */
  87350. export class AnimationPropertiesOverride {
  87351. /**
  87352. * Gets or sets a value indicating if animation blending must be used
  87353. */
  87354. enableBlending: boolean;
  87355. /**
  87356. * Gets or sets the blending speed to use when enableBlending is true
  87357. */
  87358. blendingSpeed: number;
  87359. /**
  87360. * Gets or sets the default loop mode to use
  87361. */
  87362. loopMode: number;
  87363. }
  87364. }
  87365. declare module BABYLON {
  87366. /**
  87367. * Class used to store bone information
  87368. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87369. */
  87370. export class Bone extends Node {
  87371. /**
  87372. * defines the bone name
  87373. */
  87374. name: string;
  87375. private static _tmpVecs;
  87376. private static _tmpQuat;
  87377. private static _tmpMats;
  87378. /**
  87379. * Gets the list of child bones
  87380. */
  87381. children: Bone[];
  87382. /** Gets the animations associated with this bone */
  87383. animations: Animation[];
  87384. /**
  87385. * Gets or sets bone length
  87386. */
  87387. length: number;
  87388. /**
  87389. * @hidden Internal only
  87390. * Set this value to map this bone to a different index in the transform matrices
  87391. * Set this value to -1 to exclude the bone from the transform matrices
  87392. */
  87393. _index: Nullable<number>;
  87394. private _skeleton;
  87395. private _localMatrix;
  87396. private _restPose;
  87397. private _baseMatrix;
  87398. private _absoluteTransform;
  87399. private _invertedAbsoluteTransform;
  87400. private _parent;
  87401. private _scalingDeterminant;
  87402. private _worldTransform;
  87403. private _localScaling;
  87404. private _localRotation;
  87405. private _localPosition;
  87406. private _needToDecompose;
  87407. private _needToCompose;
  87408. /** @hidden */
  87409. _linkedTransformNode: Nullable<TransformNode>;
  87410. /** @hidden */
  87411. _waitingTransformNodeId: Nullable<string>;
  87412. /** @hidden */
  87413. get _matrix(): Matrix;
  87414. /** @hidden */
  87415. set _matrix(value: Matrix);
  87416. /**
  87417. * Create a new bone
  87418. * @param name defines the bone name
  87419. * @param skeleton defines the parent skeleton
  87420. * @param parentBone defines the parent (can be null if the bone is the root)
  87421. * @param localMatrix defines the local matrix
  87422. * @param restPose defines the rest pose matrix
  87423. * @param baseMatrix defines the base matrix
  87424. * @param index defines index of the bone in the hiearchy
  87425. */
  87426. constructor(
  87427. /**
  87428. * defines the bone name
  87429. */
  87430. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87431. /**
  87432. * Gets the current object class name.
  87433. * @return the class name
  87434. */
  87435. getClassName(): string;
  87436. /**
  87437. * Gets the parent skeleton
  87438. * @returns a skeleton
  87439. */
  87440. getSkeleton(): Skeleton;
  87441. /**
  87442. * Gets parent bone
  87443. * @returns a bone or null if the bone is the root of the bone hierarchy
  87444. */
  87445. getParent(): Nullable<Bone>;
  87446. /**
  87447. * Returns an array containing the root bones
  87448. * @returns an array containing the root bones
  87449. */
  87450. getChildren(): Array<Bone>;
  87451. /**
  87452. * Gets the node index in matrix array generated for rendering
  87453. * @returns the node index
  87454. */
  87455. getIndex(): number;
  87456. /**
  87457. * Sets the parent bone
  87458. * @param parent defines the parent (can be null if the bone is the root)
  87459. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87460. */
  87461. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87462. /**
  87463. * Gets the local matrix
  87464. * @returns a matrix
  87465. */
  87466. getLocalMatrix(): Matrix;
  87467. /**
  87468. * Gets the base matrix (initial matrix which remains unchanged)
  87469. * @returns a matrix
  87470. */
  87471. getBaseMatrix(): Matrix;
  87472. /**
  87473. * Gets the rest pose matrix
  87474. * @returns a matrix
  87475. */
  87476. getRestPose(): Matrix;
  87477. /**
  87478. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87479. */
  87480. getWorldMatrix(): Matrix;
  87481. /**
  87482. * Sets the local matrix to rest pose matrix
  87483. */
  87484. returnToRest(): void;
  87485. /**
  87486. * Gets the inverse of the absolute transform matrix.
  87487. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87488. * @returns a matrix
  87489. */
  87490. getInvertedAbsoluteTransform(): Matrix;
  87491. /**
  87492. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87493. * @returns a matrix
  87494. */
  87495. getAbsoluteTransform(): Matrix;
  87496. /**
  87497. * Links with the given transform node.
  87498. * The local matrix of this bone is copied from the transform node every frame.
  87499. * @param transformNode defines the transform node to link to
  87500. */
  87501. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87502. /**
  87503. * Gets the node used to drive the bone's transformation
  87504. * @returns a transform node or null
  87505. */
  87506. getTransformNode(): Nullable<TransformNode>;
  87507. /** Gets or sets current position (in local space) */
  87508. get position(): Vector3;
  87509. set position(newPosition: Vector3);
  87510. /** Gets or sets current rotation (in local space) */
  87511. get rotation(): Vector3;
  87512. set rotation(newRotation: Vector3);
  87513. /** Gets or sets current rotation quaternion (in local space) */
  87514. get rotationQuaternion(): Quaternion;
  87515. set rotationQuaternion(newRotation: Quaternion);
  87516. /** Gets or sets current scaling (in local space) */
  87517. get scaling(): Vector3;
  87518. set scaling(newScaling: Vector3);
  87519. /**
  87520. * Gets the animation properties override
  87521. */
  87522. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87523. private _decompose;
  87524. private _compose;
  87525. /**
  87526. * Update the base and local matrices
  87527. * @param matrix defines the new base or local matrix
  87528. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87529. * @param updateLocalMatrix defines if the local matrix should be updated
  87530. */
  87531. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87532. /** @hidden */
  87533. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87534. /**
  87535. * Flag the bone as dirty (Forcing it to update everything)
  87536. */
  87537. markAsDirty(): void;
  87538. /** @hidden */
  87539. _markAsDirtyAndCompose(): void;
  87540. private _markAsDirtyAndDecompose;
  87541. /**
  87542. * Translate the bone in local or world space
  87543. * @param vec The amount to translate the bone
  87544. * @param space The space that the translation is in
  87545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87546. */
  87547. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87548. /**
  87549. * Set the postion of the bone in local or world space
  87550. * @param position The position to set the bone
  87551. * @param space The space that the position is in
  87552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87553. */
  87554. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87555. /**
  87556. * Set the absolute position of the bone (world space)
  87557. * @param position The position to set the bone
  87558. * @param mesh The mesh that this bone is attached to
  87559. */
  87560. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87561. /**
  87562. * Scale the bone on the x, y and z axes (in local space)
  87563. * @param x The amount to scale the bone on the x axis
  87564. * @param y The amount to scale the bone on the y axis
  87565. * @param z The amount to scale the bone on the z axis
  87566. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87567. */
  87568. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87569. /**
  87570. * Set the bone scaling in local space
  87571. * @param scale defines the scaling vector
  87572. */
  87573. setScale(scale: Vector3): void;
  87574. /**
  87575. * Gets the current scaling in local space
  87576. * @returns the current scaling vector
  87577. */
  87578. getScale(): Vector3;
  87579. /**
  87580. * Gets the current scaling in local space and stores it in a target vector
  87581. * @param result defines the target vector
  87582. */
  87583. getScaleToRef(result: Vector3): void;
  87584. /**
  87585. * Set the yaw, pitch, and roll of the bone in local or world space
  87586. * @param yaw The rotation of the bone on the y axis
  87587. * @param pitch The rotation of the bone on the x axis
  87588. * @param roll The rotation of the bone on the z axis
  87589. * @param space The space that the axes of rotation are in
  87590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87591. */
  87592. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87593. /**
  87594. * Add a rotation to the bone on an axis in local or world space
  87595. * @param axis The axis to rotate the bone on
  87596. * @param amount The amount to rotate the bone
  87597. * @param space The space that the axis is in
  87598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87599. */
  87600. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87601. /**
  87602. * Set the rotation of the bone to a particular axis angle in local or world space
  87603. * @param axis The axis to rotate the bone on
  87604. * @param angle The angle that the bone should be rotated to
  87605. * @param space The space that the axis is in
  87606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87607. */
  87608. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87609. /**
  87610. * Set the euler rotation of the bone in local of world space
  87611. * @param rotation The euler rotation that the bone should be set to
  87612. * @param space The space that the rotation is in
  87613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87614. */
  87615. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87616. /**
  87617. * Set the quaternion rotation of the bone in local of world space
  87618. * @param quat The quaternion rotation that the bone should be set to
  87619. * @param space The space that the rotation is in
  87620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87621. */
  87622. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87623. /**
  87624. * Set the rotation matrix of the bone in local of world space
  87625. * @param rotMat The rotation matrix that the bone should be set to
  87626. * @param space The space that the rotation is in
  87627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87628. */
  87629. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87630. private _rotateWithMatrix;
  87631. private _getNegativeRotationToRef;
  87632. /**
  87633. * Get the position of the bone in local or world space
  87634. * @param space The space that the returned position is in
  87635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87636. * @returns The position of the bone
  87637. */
  87638. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87639. /**
  87640. * Copy the position of the bone to a vector3 in local or world space
  87641. * @param space The space that the returned position is in
  87642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87643. * @param result The vector3 to copy the position to
  87644. */
  87645. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87646. /**
  87647. * Get the absolute position of the bone (world space)
  87648. * @param mesh The mesh that this bone is attached to
  87649. * @returns The absolute position of the bone
  87650. */
  87651. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87652. /**
  87653. * Copy the absolute position of the bone (world space) to the result param
  87654. * @param mesh The mesh that this bone is attached to
  87655. * @param result The vector3 to copy the absolute position to
  87656. */
  87657. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87658. /**
  87659. * Compute the absolute transforms of this bone and its children
  87660. */
  87661. computeAbsoluteTransforms(): void;
  87662. /**
  87663. * Get the world direction from an axis that is in the local space of the bone
  87664. * @param localAxis The local direction that is used to compute the world direction
  87665. * @param mesh The mesh that this bone is attached to
  87666. * @returns The world direction
  87667. */
  87668. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87669. /**
  87670. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87671. * @param localAxis The local direction that is used to compute the world direction
  87672. * @param mesh The mesh that this bone is attached to
  87673. * @param result The vector3 that the world direction will be copied to
  87674. */
  87675. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87676. /**
  87677. * Get the euler rotation of the bone in local or world space
  87678. * @param space The space that the rotation should be in
  87679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87680. * @returns The euler rotation
  87681. */
  87682. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87683. /**
  87684. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87685. * @param space The space that the rotation should be in
  87686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87687. * @param result The vector3 that the rotation should be copied to
  87688. */
  87689. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87690. /**
  87691. * Get the quaternion rotation of the bone in either local or world space
  87692. * @param space The space that the rotation should be in
  87693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87694. * @returns The quaternion rotation
  87695. */
  87696. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87697. /**
  87698. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87699. * @param space The space that the rotation should be in
  87700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87701. * @param result The quaternion that the rotation should be copied to
  87702. */
  87703. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87704. /**
  87705. * Get the rotation matrix of the bone in local or world space
  87706. * @param space The space that the rotation should be in
  87707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87708. * @returns The rotation matrix
  87709. */
  87710. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87711. /**
  87712. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87713. * @param space The space that the rotation should be in
  87714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87715. * @param result The quaternion that the rotation should be copied to
  87716. */
  87717. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87718. /**
  87719. * Get the world position of a point that is in the local space of the bone
  87720. * @param position The local position
  87721. * @param mesh The mesh that this bone is attached to
  87722. * @returns The world position
  87723. */
  87724. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87725. /**
  87726. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87727. * @param position The local position
  87728. * @param mesh The mesh that this bone is attached to
  87729. * @param result The vector3 that the world position should be copied to
  87730. */
  87731. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87732. /**
  87733. * Get the local position of a point that is in world space
  87734. * @param position The world position
  87735. * @param mesh The mesh that this bone is attached to
  87736. * @returns The local position
  87737. */
  87738. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87739. /**
  87740. * Get the local position of a point that is in world space and copy it to the result param
  87741. * @param position The world position
  87742. * @param mesh The mesh that this bone is attached to
  87743. * @param result The vector3 that the local position should be copied to
  87744. */
  87745. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87746. }
  87747. }
  87748. declare module BABYLON {
  87749. /**
  87750. * Defines a runtime animation
  87751. */
  87752. export class RuntimeAnimation {
  87753. private _events;
  87754. /**
  87755. * The current frame of the runtime animation
  87756. */
  87757. private _currentFrame;
  87758. /**
  87759. * The animation used by the runtime animation
  87760. */
  87761. private _animation;
  87762. /**
  87763. * The target of the runtime animation
  87764. */
  87765. private _target;
  87766. /**
  87767. * The initiating animatable
  87768. */
  87769. private _host;
  87770. /**
  87771. * The original value of the runtime animation
  87772. */
  87773. private _originalValue;
  87774. /**
  87775. * The original blend value of the runtime animation
  87776. */
  87777. private _originalBlendValue;
  87778. /**
  87779. * The offsets cache of the runtime animation
  87780. */
  87781. private _offsetsCache;
  87782. /**
  87783. * The high limits cache of the runtime animation
  87784. */
  87785. private _highLimitsCache;
  87786. /**
  87787. * Specifies if the runtime animation has been stopped
  87788. */
  87789. private _stopped;
  87790. /**
  87791. * The blending factor of the runtime animation
  87792. */
  87793. private _blendingFactor;
  87794. /**
  87795. * The BabylonJS scene
  87796. */
  87797. private _scene;
  87798. /**
  87799. * The current value of the runtime animation
  87800. */
  87801. private _currentValue;
  87802. /** @hidden */
  87803. _animationState: _IAnimationState;
  87804. /**
  87805. * The active target of the runtime animation
  87806. */
  87807. private _activeTargets;
  87808. private _currentActiveTarget;
  87809. private _directTarget;
  87810. /**
  87811. * The target path of the runtime animation
  87812. */
  87813. private _targetPath;
  87814. /**
  87815. * The weight of the runtime animation
  87816. */
  87817. private _weight;
  87818. /**
  87819. * The ratio offset of the runtime animation
  87820. */
  87821. private _ratioOffset;
  87822. /**
  87823. * The previous delay of the runtime animation
  87824. */
  87825. private _previousDelay;
  87826. /**
  87827. * The previous ratio of the runtime animation
  87828. */
  87829. private _previousRatio;
  87830. private _enableBlending;
  87831. private _keys;
  87832. private _minFrame;
  87833. private _maxFrame;
  87834. private _minValue;
  87835. private _maxValue;
  87836. private _targetIsArray;
  87837. /**
  87838. * Gets the current frame of the runtime animation
  87839. */
  87840. get currentFrame(): number;
  87841. /**
  87842. * Gets the weight of the runtime animation
  87843. */
  87844. get weight(): number;
  87845. /**
  87846. * Gets the current value of the runtime animation
  87847. */
  87848. get currentValue(): any;
  87849. /**
  87850. * Gets the target path of the runtime animation
  87851. */
  87852. get targetPath(): string;
  87853. /**
  87854. * Gets the actual target of the runtime animation
  87855. */
  87856. get target(): any;
  87857. /** @hidden */
  87858. _onLoop: () => void;
  87859. /**
  87860. * Create a new RuntimeAnimation object
  87861. * @param target defines the target of the animation
  87862. * @param animation defines the source animation object
  87863. * @param scene defines the hosting scene
  87864. * @param host defines the initiating Animatable
  87865. */
  87866. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87867. private _preparePath;
  87868. /**
  87869. * Gets the animation from the runtime animation
  87870. */
  87871. get animation(): Animation;
  87872. /**
  87873. * Resets the runtime animation to the beginning
  87874. * @param restoreOriginal defines whether to restore the target property to the original value
  87875. */
  87876. reset(restoreOriginal?: boolean): void;
  87877. /**
  87878. * Specifies if the runtime animation is stopped
  87879. * @returns Boolean specifying if the runtime animation is stopped
  87880. */
  87881. isStopped(): boolean;
  87882. /**
  87883. * Disposes of the runtime animation
  87884. */
  87885. dispose(): void;
  87886. /**
  87887. * Apply the interpolated value to the target
  87888. * @param currentValue defines the value computed by the animation
  87889. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87890. */
  87891. setValue(currentValue: any, weight: number): void;
  87892. private _getOriginalValues;
  87893. private _setValue;
  87894. /**
  87895. * Gets the loop pmode of the runtime animation
  87896. * @returns Loop Mode
  87897. */
  87898. private _getCorrectLoopMode;
  87899. /**
  87900. * Move the current animation to a given frame
  87901. * @param frame defines the frame to move to
  87902. */
  87903. goToFrame(frame: number): void;
  87904. /**
  87905. * @hidden Internal use only
  87906. */
  87907. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87908. /**
  87909. * Execute the current animation
  87910. * @param delay defines the delay to add to the current frame
  87911. * @param from defines the lower bound of the animation range
  87912. * @param to defines the upper bound of the animation range
  87913. * @param loop defines if the current animation must loop
  87914. * @param speedRatio defines the current speed ratio
  87915. * @param weight defines the weight of the animation (default is -1 so no weight)
  87916. * @param onLoop optional callback called when animation loops
  87917. * @returns a boolean indicating if the animation is running
  87918. */
  87919. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87920. }
  87921. }
  87922. declare module BABYLON {
  87923. /**
  87924. * Class used to store an actual running animation
  87925. */
  87926. export class Animatable {
  87927. /** defines the target object */
  87928. target: any;
  87929. /** defines the starting frame number (default is 0) */
  87930. fromFrame: number;
  87931. /** defines the ending frame number (default is 100) */
  87932. toFrame: number;
  87933. /** defines if the animation must loop (default is false) */
  87934. loopAnimation: boolean;
  87935. /** defines a callback to call when animation ends if it is not looping */
  87936. onAnimationEnd?: (() => void) | null | undefined;
  87937. /** defines a callback to call when animation loops */
  87938. onAnimationLoop?: (() => void) | null | undefined;
  87939. private _localDelayOffset;
  87940. private _pausedDelay;
  87941. private _runtimeAnimations;
  87942. private _paused;
  87943. private _scene;
  87944. private _speedRatio;
  87945. private _weight;
  87946. private _syncRoot;
  87947. /**
  87948. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87949. * This will only apply for non looping animation (default is true)
  87950. */
  87951. disposeOnEnd: boolean;
  87952. /**
  87953. * Gets a boolean indicating if the animation has started
  87954. */
  87955. animationStarted: boolean;
  87956. /**
  87957. * Observer raised when the animation ends
  87958. */
  87959. onAnimationEndObservable: Observable<Animatable>;
  87960. /**
  87961. * Observer raised when the animation loops
  87962. */
  87963. onAnimationLoopObservable: Observable<Animatable>;
  87964. /**
  87965. * Gets the root Animatable used to synchronize and normalize animations
  87966. */
  87967. get syncRoot(): Nullable<Animatable>;
  87968. /**
  87969. * Gets the current frame of the first RuntimeAnimation
  87970. * Used to synchronize Animatables
  87971. */
  87972. get masterFrame(): number;
  87973. /**
  87974. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87975. */
  87976. get weight(): number;
  87977. set weight(value: number);
  87978. /**
  87979. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87980. */
  87981. get speedRatio(): number;
  87982. set speedRatio(value: number);
  87983. /**
  87984. * Creates a new Animatable
  87985. * @param scene defines the hosting scene
  87986. * @param target defines the target object
  87987. * @param fromFrame defines the starting frame number (default is 0)
  87988. * @param toFrame defines the ending frame number (default is 100)
  87989. * @param loopAnimation defines if the animation must loop (default is false)
  87990. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87991. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87992. * @param animations defines a group of animation to add to the new Animatable
  87993. * @param onAnimationLoop defines a callback to call when animation loops
  87994. */
  87995. constructor(scene: Scene,
  87996. /** defines the target object */
  87997. target: any,
  87998. /** defines the starting frame number (default is 0) */
  87999. fromFrame?: number,
  88000. /** defines the ending frame number (default is 100) */
  88001. toFrame?: number,
  88002. /** defines if the animation must loop (default is false) */
  88003. loopAnimation?: boolean, speedRatio?: number,
  88004. /** defines a callback to call when animation ends if it is not looping */
  88005. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88006. /** defines a callback to call when animation loops */
  88007. onAnimationLoop?: (() => void) | null | undefined);
  88008. /**
  88009. * Synchronize and normalize current Animatable with a source Animatable
  88010. * This is useful when using animation weights and when animations are not of the same length
  88011. * @param root defines the root Animatable to synchronize with
  88012. * @returns the current Animatable
  88013. */
  88014. syncWith(root: Animatable): Animatable;
  88015. /**
  88016. * Gets the list of runtime animations
  88017. * @returns an array of RuntimeAnimation
  88018. */
  88019. getAnimations(): RuntimeAnimation[];
  88020. /**
  88021. * Adds more animations to the current animatable
  88022. * @param target defines the target of the animations
  88023. * @param animations defines the new animations to add
  88024. */
  88025. appendAnimations(target: any, animations: Animation[]): void;
  88026. /**
  88027. * Gets the source animation for a specific property
  88028. * @param property defines the propertyu to look for
  88029. * @returns null or the source animation for the given property
  88030. */
  88031. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88032. /**
  88033. * Gets the runtime animation for a specific property
  88034. * @param property defines the propertyu to look for
  88035. * @returns null or the runtime animation for the given property
  88036. */
  88037. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88038. /**
  88039. * Resets the animatable to its original state
  88040. */
  88041. reset(): void;
  88042. /**
  88043. * Allows the animatable to blend with current running animations
  88044. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88045. * @param blendingSpeed defines the blending speed to use
  88046. */
  88047. enableBlending(blendingSpeed: number): void;
  88048. /**
  88049. * Disable animation blending
  88050. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88051. */
  88052. disableBlending(): void;
  88053. /**
  88054. * Jump directly to a given frame
  88055. * @param frame defines the frame to jump to
  88056. */
  88057. goToFrame(frame: number): void;
  88058. /**
  88059. * Pause the animation
  88060. */
  88061. pause(): void;
  88062. /**
  88063. * Restart the animation
  88064. */
  88065. restart(): void;
  88066. private _raiseOnAnimationEnd;
  88067. /**
  88068. * Stop and delete the current animation
  88069. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88070. * @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)
  88071. */
  88072. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88073. /**
  88074. * Wait asynchronously for the animation to end
  88075. * @returns a promise which will be fullfilled when the animation ends
  88076. */
  88077. waitAsync(): Promise<Animatable>;
  88078. /** @hidden */
  88079. _animate(delay: number): boolean;
  88080. }
  88081. interface Scene {
  88082. /** @hidden */
  88083. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88084. /** @hidden */
  88085. _processLateAnimationBindingsForMatrices(holder: {
  88086. totalWeight: number;
  88087. animations: RuntimeAnimation[];
  88088. originalValue: Matrix;
  88089. }): any;
  88090. /** @hidden */
  88091. _processLateAnimationBindingsForQuaternions(holder: {
  88092. totalWeight: number;
  88093. animations: RuntimeAnimation[];
  88094. originalValue: Quaternion;
  88095. }, refQuaternion: Quaternion): Quaternion;
  88096. /** @hidden */
  88097. _processLateAnimationBindings(): void;
  88098. /**
  88099. * Will start the animation sequence of a given target
  88100. * @param target defines the target
  88101. * @param from defines from which frame should animation start
  88102. * @param to defines until which frame should animation run.
  88103. * @param weight defines the weight to apply to the animation (1.0 by default)
  88104. * @param loop defines if the animation loops
  88105. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88106. * @param onAnimationEnd defines the function to be executed when the animation ends
  88107. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88108. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88109. * @param onAnimationLoop defines the callback to call when an animation loops
  88110. * @returns the animatable object created for this animation
  88111. */
  88112. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88113. /**
  88114. * Will start the animation sequence of a given target
  88115. * @param target defines the target
  88116. * @param from defines from which frame should animation start
  88117. * @param to defines until which frame should animation run.
  88118. * @param loop defines if the animation loops
  88119. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88120. * @param onAnimationEnd defines the function to be executed when the animation ends
  88121. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88122. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88123. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88124. * @param onAnimationLoop defines the callback to call when an animation loops
  88125. * @returns the animatable object created for this animation
  88126. */
  88127. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88128. /**
  88129. * Will start the animation sequence of a given target and its hierarchy
  88130. * @param target defines the target
  88131. * @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.
  88132. * @param from defines from which frame should animation start
  88133. * @param to defines until which frame should animation run.
  88134. * @param loop defines if the animation loops
  88135. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88136. * @param onAnimationEnd defines the function to be executed when the animation ends
  88137. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88138. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88139. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88140. * @param onAnimationLoop defines the callback to call when an animation loops
  88141. * @returns the list of created animatables
  88142. */
  88143. 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[];
  88144. /**
  88145. * Begin a new animation on a given node
  88146. * @param target defines the target where the animation will take place
  88147. * @param animations defines the list of animations to start
  88148. * @param from defines the initial value
  88149. * @param to defines the final value
  88150. * @param loop defines if you want animation to loop (off by default)
  88151. * @param speedRatio defines the speed ratio to apply to all animations
  88152. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88153. * @param onAnimationLoop defines the callback to call when an animation loops
  88154. * @returns the list of created animatables
  88155. */
  88156. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88157. /**
  88158. * Begin a new animation on a given node and its hierarchy
  88159. * @param target defines the root node where the animation will take place
  88160. * @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.
  88161. * @param animations defines the list of animations to start
  88162. * @param from defines the initial value
  88163. * @param to defines the final value
  88164. * @param loop defines if you want animation to loop (off by default)
  88165. * @param speedRatio defines the speed ratio to apply to all animations
  88166. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88167. * @param onAnimationLoop defines the callback to call when an animation loops
  88168. * @returns the list of animatables created for all nodes
  88169. */
  88170. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88171. /**
  88172. * Gets the animatable associated with a specific target
  88173. * @param target defines the target of the animatable
  88174. * @returns the required animatable if found
  88175. */
  88176. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88177. /**
  88178. * Gets all animatables associated with a given target
  88179. * @param target defines the target to look animatables for
  88180. * @returns an array of Animatables
  88181. */
  88182. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88183. /**
  88184. * Stops and removes all animations that have been applied to the scene
  88185. */
  88186. stopAllAnimations(): void;
  88187. /**
  88188. * Gets the current delta time used by animation engine
  88189. */
  88190. deltaTime: number;
  88191. }
  88192. interface Bone {
  88193. /**
  88194. * Copy an animation range from another bone
  88195. * @param source defines the source bone
  88196. * @param rangeName defines the range name to copy
  88197. * @param frameOffset defines the frame offset
  88198. * @param rescaleAsRequired defines if rescaling must be applied if required
  88199. * @param skelDimensionsRatio defines the scaling ratio
  88200. * @returns true if operation was successful
  88201. */
  88202. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88203. }
  88204. }
  88205. declare module BABYLON {
  88206. /**
  88207. * Class used to handle skinning animations
  88208. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88209. */
  88210. export class Skeleton implements IAnimatable {
  88211. /** defines the skeleton name */
  88212. name: string;
  88213. /** defines the skeleton Id */
  88214. id: string;
  88215. /**
  88216. * Defines the list of child bones
  88217. */
  88218. bones: Bone[];
  88219. /**
  88220. * Defines an estimate of the dimension of the skeleton at rest
  88221. */
  88222. dimensionsAtRest: Vector3;
  88223. /**
  88224. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88225. */
  88226. needInitialSkinMatrix: boolean;
  88227. /**
  88228. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88229. */
  88230. overrideMesh: Nullable<AbstractMesh>;
  88231. /**
  88232. * Gets the list of animations attached to this skeleton
  88233. */
  88234. animations: Array<Animation>;
  88235. private _scene;
  88236. private _isDirty;
  88237. private _transformMatrices;
  88238. private _transformMatrixTexture;
  88239. private _meshesWithPoseMatrix;
  88240. private _animatables;
  88241. private _identity;
  88242. private _synchronizedWithMesh;
  88243. private _ranges;
  88244. private _lastAbsoluteTransformsUpdateId;
  88245. private _canUseTextureForBones;
  88246. private _uniqueId;
  88247. /** @hidden */
  88248. _numBonesWithLinkedTransformNode: number;
  88249. /** @hidden */
  88250. _hasWaitingData: Nullable<boolean>;
  88251. /**
  88252. * Specifies if the skeleton should be serialized
  88253. */
  88254. doNotSerialize: boolean;
  88255. private _useTextureToStoreBoneMatrices;
  88256. /**
  88257. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88258. * Please note that this option is not available if the hardware does not support it
  88259. */
  88260. get useTextureToStoreBoneMatrices(): boolean;
  88261. set useTextureToStoreBoneMatrices(value: boolean);
  88262. private _animationPropertiesOverride;
  88263. /**
  88264. * Gets or sets the animation properties override
  88265. */
  88266. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88267. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88268. /**
  88269. * List of inspectable custom properties (used by the Inspector)
  88270. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88271. */
  88272. inspectableCustomProperties: IInspectable[];
  88273. /**
  88274. * An observable triggered before computing the skeleton's matrices
  88275. */
  88276. onBeforeComputeObservable: Observable<Skeleton>;
  88277. /**
  88278. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88279. */
  88280. get isUsingTextureForMatrices(): boolean;
  88281. /**
  88282. * Gets the unique ID of this skeleton
  88283. */
  88284. get uniqueId(): number;
  88285. /**
  88286. * Creates a new skeleton
  88287. * @param name defines the skeleton name
  88288. * @param id defines the skeleton Id
  88289. * @param scene defines the hosting scene
  88290. */
  88291. constructor(
  88292. /** defines the skeleton name */
  88293. name: string,
  88294. /** defines the skeleton Id */
  88295. id: string, scene: Scene);
  88296. /**
  88297. * Gets the current object class name.
  88298. * @return the class name
  88299. */
  88300. getClassName(): string;
  88301. /**
  88302. * Returns an array containing the root bones
  88303. * @returns an array containing the root bones
  88304. */
  88305. getChildren(): Array<Bone>;
  88306. /**
  88307. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88308. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88309. * @returns a Float32Array containing matrices data
  88310. */
  88311. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88312. /**
  88313. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88314. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88315. * @returns a raw texture containing the data
  88316. */
  88317. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88318. /**
  88319. * Gets the current hosting scene
  88320. * @returns a scene object
  88321. */
  88322. getScene(): Scene;
  88323. /**
  88324. * Gets a string representing the current skeleton data
  88325. * @param fullDetails defines a boolean indicating if we want a verbose version
  88326. * @returns a string representing the current skeleton data
  88327. */
  88328. toString(fullDetails?: boolean): string;
  88329. /**
  88330. * Get bone's index searching by name
  88331. * @param name defines bone's name to search for
  88332. * @return the indice of the bone. Returns -1 if not found
  88333. */
  88334. getBoneIndexByName(name: string): number;
  88335. /**
  88336. * Creater a new animation range
  88337. * @param name defines the name of the range
  88338. * @param from defines the start key
  88339. * @param to defines the end key
  88340. */
  88341. createAnimationRange(name: string, from: number, to: number): void;
  88342. /**
  88343. * Delete a specific animation range
  88344. * @param name defines the name of the range
  88345. * @param deleteFrames defines if frames must be removed as well
  88346. */
  88347. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88348. /**
  88349. * Gets a specific animation range
  88350. * @param name defines the name of the range to look for
  88351. * @returns the requested animation range or null if not found
  88352. */
  88353. getAnimationRange(name: string): Nullable<AnimationRange>;
  88354. /**
  88355. * Gets the list of all animation ranges defined on this skeleton
  88356. * @returns an array
  88357. */
  88358. getAnimationRanges(): Nullable<AnimationRange>[];
  88359. /**
  88360. * Copy animation range from a source skeleton.
  88361. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88362. * @param source defines the source skeleton
  88363. * @param name defines the name of the range to copy
  88364. * @param rescaleAsRequired defines if rescaling must be applied if required
  88365. * @returns true if operation was successful
  88366. */
  88367. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88368. /**
  88369. * Forces the skeleton to go to rest pose
  88370. */
  88371. returnToRest(): void;
  88372. private _getHighestAnimationFrame;
  88373. /**
  88374. * Begin a specific animation range
  88375. * @param name defines the name of the range to start
  88376. * @param loop defines if looping must be turned on (false by default)
  88377. * @param speedRatio defines the speed ratio to apply (1 by default)
  88378. * @param onAnimationEnd defines a callback which will be called when animation will end
  88379. * @returns a new animatable
  88380. */
  88381. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88382. /** @hidden */
  88383. _markAsDirty(): void;
  88384. /** @hidden */
  88385. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88386. /** @hidden */
  88387. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88388. private _computeTransformMatrices;
  88389. /**
  88390. * Build all resources required to render a skeleton
  88391. */
  88392. prepare(): void;
  88393. /**
  88394. * Gets the list of animatables currently running for this skeleton
  88395. * @returns an array of animatables
  88396. */
  88397. getAnimatables(): IAnimatable[];
  88398. /**
  88399. * Clone the current skeleton
  88400. * @param name defines the name of the new skeleton
  88401. * @param id defines the id of the new skeleton
  88402. * @returns the new skeleton
  88403. */
  88404. clone(name: string, id?: string): Skeleton;
  88405. /**
  88406. * Enable animation blending for this skeleton
  88407. * @param blendingSpeed defines the blending speed to apply
  88408. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88409. */
  88410. enableBlending(blendingSpeed?: number): void;
  88411. /**
  88412. * Releases all resources associated with the current skeleton
  88413. */
  88414. dispose(): void;
  88415. /**
  88416. * Serialize the skeleton in a JSON object
  88417. * @returns a JSON object
  88418. */
  88419. serialize(): any;
  88420. /**
  88421. * Creates a new skeleton from serialized data
  88422. * @param parsedSkeleton defines the serialized data
  88423. * @param scene defines the hosting scene
  88424. * @returns a new skeleton
  88425. */
  88426. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88427. /**
  88428. * Compute all node absolute transforms
  88429. * @param forceUpdate defines if computation must be done even if cache is up to date
  88430. */
  88431. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88432. /**
  88433. * Gets the root pose matrix
  88434. * @returns a matrix
  88435. */
  88436. getPoseMatrix(): Nullable<Matrix>;
  88437. /**
  88438. * Sorts bones per internal index
  88439. */
  88440. sortBones(): void;
  88441. private _sortBones;
  88442. }
  88443. }
  88444. declare module BABYLON {
  88445. /**
  88446. * Creates an instance based on a source mesh.
  88447. */
  88448. export class InstancedMesh extends AbstractMesh {
  88449. private _sourceMesh;
  88450. private _currentLOD;
  88451. /** @hidden */
  88452. _indexInSourceMeshInstanceArray: number;
  88453. constructor(name: string, source: Mesh);
  88454. /**
  88455. * Returns the string "InstancedMesh".
  88456. */
  88457. getClassName(): string;
  88458. /** Gets the list of lights affecting that mesh */
  88459. get lightSources(): Light[];
  88460. _resyncLightSources(): void;
  88461. _resyncLightSource(light: Light): void;
  88462. _removeLightSource(light: Light, dispose: boolean): void;
  88463. /**
  88464. * If the source mesh receives shadows
  88465. */
  88466. get receiveShadows(): boolean;
  88467. /**
  88468. * The material of the source mesh
  88469. */
  88470. get material(): Nullable<Material>;
  88471. /**
  88472. * Visibility of the source mesh
  88473. */
  88474. get visibility(): number;
  88475. /**
  88476. * Skeleton of the source mesh
  88477. */
  88478. get skeleton(): Nullable<Skeleton>;
  88479. /**
  88480. * Rendering ground id of the source mesh
  88481. */
  88482. get renderingGroupId(): number;
  88483. set renderingGroupId(value: number);
  88484. /**
  88485. * Returns the total number of vertices (integer).
  88486. */
  88487. getTotalVertices(): number;
  88488. /**
  88489. * Returns a positive integer : the total number of indices in this mesh geometry.
  88490. * @returns the numner of indices or zero if the mesh has no geometry.
  88491. */
  88492. getTotalIndices(): number;
  88493. /**
  88494. * The source mesh of the instance
  88495. */
  88496. get sourceMesh(): Mesh;
  88497. /**
  88498. * Is this node ready to be used/rendered
  88499. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88500. * @return {boolean} is it ready
  88501. */
  88502. isReady(completeCheck?: boolean): boolean;
  88503. /**
  88504. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88505. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88506. * @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.
  88507. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88508. */
  88509. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88510. /**
  88511. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88512. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88513. * The `data` are either a numeric array either a Float32Array.
  88514. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88515. * 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).
  88516. * Note that a new underlying VertexBuffer object is created each call.
  88517. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88518. *
  88519. * Possible `kind` values :
  88520. * - VertexBuffer.PositionKind
  88521. * - VertexBuffer.UVKind
  88522. * - VertexBuffer.UV2Kind
  88523. * - VertexBuffer.UV3Kind
  88524. * - VertexBuffer.UV4Kind
  88525. * - VertexBuffer.UV5Kind
  88526. * - VertexBuffer.UV6Kind
  88527. * - VertexBuffer.ColorKind
  88528. * - VertexBuffer.MatricesIndicesKind
  88529. * - VertexBuffer.MatricesIndicesExtraKind
  88530. * - VertexBuffer.MatricesWeightsKind
  88531. * - VertexBuffer.MatricesWeightsExtraKind
  88532. *
  88533. * Returns the Mesh.
  88534. */
  88535. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88536. /**
  88537. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88538. * If the mesh has no geometry, it is simply returned as it is.
  88539. * The `data` are either a numeric array either a Float32Array.
  88540. * No new underlying VertexBuffer object is created.
  88541. * 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.
  88542. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88543. *
  88544. * Possible `kind` values :
  88545. * - VertexBuffer.PositionKind
  88546. * - VertexBuffer.UVKind
  88547. * - VertexBuffer.UV2Kind
  88548. * - VertexBuffer.UV3Kind
  88549. * - VertexBuffer.UV4Kind
  88550. * - VertexBuffer.UV5Kind
  88551. * - VertexBuffer.UV6Kind
  88552. * - VertexBuffer.ColorKind
  88553. * - VertexBuffer.MatricesIndicesKind
  88554. * - VertexBuffer.MatricesIndicesExtraKind
  88555. * - VertexBuffer.MatricesWeightsKind
  88556. * - VertexBuffer.MatricesWeightsExtraKind
  88557. *
  88558. * Returns the Mesh.
  88559. */
  88560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88561. /**
  88562. * Sets the mesh indices.
  88563. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88564. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88565. * This method creates a new index buffer each call.
  88566. * Returns the Mesh.
  88567. */
  88568. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88569. /**
  88570. * Boolean : True if the mesh owns the requested kind of data.
  88571. */
  88572. isVerticesDataPresent(kind: string): boolean;
  88573. /**
  88574. * Returns an array of indices (IndicesArray).
  88575. */
  88576. getIndices(): Nullable<IndicesArray>;
  88577. get _positions(): Nullable<Vector3[]>;
  88578. /**
  88579. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88580. * This means the mesh underlying bounding box and sphere are recomputed.
  88581. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88582. * @returns the current mesh
  88583. */
  88584. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88585. /** @hidden */
  88586. _preActivate(): InstancedMesh;
  88587. /** @hidden */
  88588. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88589. /** @hidden */
  88590. _postActivate(): void;
  88591. getWorldMatrix(): Matrix;
  88592. get isAnInstance(): boolean;
  88593. /**
  88594. * Returns the current associated LOD AbstractMesh.
  88595. */
  88596. getLOD(camera: Camera): AbstractMesh;
  88597. /** @hidden */
  88598. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88599. /** @hidden */
  88600. _syncSubMeshes(): InstancedMesh;
  88601. /** @hidden */
  88602. _generatePointsArray(): boolean;
  88603. /**
  88604. * Creates a new InstancedMesh from the current mesh.
  88605. * - name (string) : the cloned mesh name
  88606. * - newParent (optional Node) : the optional Node to parent the clone to.
  88607. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88608. *
  88609. * Returns the clone.
  88610. */
  88611. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88612. /**
  88613. * Disposes the InstancedMesh.
  88614. * Returns nothing.
  88615. */
  88616. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88617. }
  88618. interface Mesh {
  88619. /**
  88620. * Register a custom buffer that will be instanced
  88621. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88622. * @param kind defines the buffer kind
  88623. * @param stride defines the stride in floats
  88624. */
  88625. registerInstancedBuffer(kind: string, stride: number): void;
  88626. /** @hidden */
  88627. _userInstancedBuffersStorage: {
  88628. data: {
  88629. [key: string]: Float32Array;
  88630. };
  88631. sizes: {
  88632. [key: string]: number;
  88633. };
  88634. vertexBuffers: {
  88635. [key: string]: Nullable<VertexBuffer>;
  88636. };
  88637. strides: {
  88638. [key: string]: number;
  88639. };
  88640. };
  88641. }
  88642. interface AbstractMesh {
  88643. /**
  88644. * Object used to store instanced buffers defined by user
  88645. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88646. */
  88647. instancedBuffers: {
  88648. [key: string]: any;
  88649. };
  88650. }
  88651. }
  88652. declare module BABYLON {
  88653. /**
  88654. * Defines the options associated with the creation of a shader material.
  88655. */
  88656. export interface IShaderMaterialOptions {
  88657. /**
  88658. * Does the material work in alpha blend mode
  88659. */
  88660. needAlphaBlending: boolean;
  88661. /**
  88662. * Does the material work in alpha test mode
  88663. */
  88664. needAlphaTesting: boolean;
  88665. /**
  88666. * The list of attribute names used in the shader
  88667. */
  88668. attributes: string[];
  88669. /**
  88670. * The list of unifrom names used in the shader
  88671. */
  88672. uniforms: string[];
  88673. /**
  88674. * The list of UBO names used in the shader
  88675. */
  88676. uniformBuffers: string[];
  88677. /**
  88678. * The list of sampler names used in the shader
  88679. */
  88680. samplers: string[];
  88681. /**
  88682. * The list of defines used in the shader
  88683. */
  88684. defines: string[];
  88685. }
  88686. /**
  88687. * 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.
  88688. *
  88689. * This returned material effects how the mesh will look based on the code in the shaders.
  88690. *
  88691. * @see http://doc.babylonjs.com/how_to/shader_material
  88692. */
  88693. export class ShaderMaterial extends Material {
  88694. private _shaderPath;
  88695. private _options;
  88696. private _textures;
  88697. private _textureArrays;
  88698. private _floats;
  88699. private _ints;
  88700. private _floatsArrays;
  88701. private _colors3;
  88702. private _colors3Arrays;
  88703. private _colors4;
  88704. private _colors4Arrays;
  88705. private _vectors2;
  88706. private _vectors3;
  88707. private _vectors4;
  88708. private _matrices;
  88709. private _matrixArrays;
  88710. private _matrices3x3;
  88711. private _matrices2x2;
  88712. private _vectors2Arrays;
  88713. private _vectors3Arrays;
  88714. private _vectors4Arrays;
  88715. private _cachedWorldViewMatrix;
  88716. private _cachedWorldViewProjectionMatrix;
  88717. private _renderId;
  88718. private _multiview;
  88719. /**
  88720. * Instantiate a new shader material.
  88721. * 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.
  88722. * This returned material effects how the mesh will look based on the code in the shaders.
  88723. * @see http://doc.babylonjs.com/how_to/shader_material
  88724. * @param name Define the name of the material in the scene
  88725. * @param scene Define the scene the material belongs to
  88726. * @param shaderPath Defines the route to the shader code in one of three ways:
  88727. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88728. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88729. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88730. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88731. * @param options Define the options used to create the shader
  88732. */
  88733. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88734. /**
  88735. * Gets the shader path used to define the shader code
  88736. * It can be modified to trigger a new compilation
  88737. */
  88738. get shaderPath(): any;
  88739. /**
  88740. * Sets the shader path used to define the shader code
  88741. * It can be modified to trigger a new compilation
  88742. */
  88743. set shaderPath(shaderPath: any);
  88744. /**
  88745. * Gets the options used to compile the shader.
  88746. * They can be modified to trigger a new compilation
  88747. */
  88748. get options(): IShaderMaterialOptions;
  88749. /**
  88750. * Gets the current class name of the material e.g. "ShaderMaterial"
  88751. * Mainly use in serialization.
  88752. * @returns the class name
  88753. */
  88754. getClassName(): string;
  88755. /**
  88756. * Specifies if the material will require alpha blending
  88757. * @returns a boolean specifying if alpha blending is needed
  88758. */
  88759. needAlphaBlending(): boolean;
  88760. /**
  88761. * Specifies if this material should be rendered in alpha test mode
  88762. * @returns a boolean specifying if an alpha test is needed.
  88763. */
  88764. needAlphaTesting(): boolean;
  88765. private _checkUniform;
  88766. /**
  88767. * Set a texture in the shader.
  88768. * @param name Define the name of the uniform samplers as defined in the shader
  88769. * @param texture Define the texture to bind to this sampler
  88770. * @return the material itself allowing "fluent" like uniform updates
  88771. */
  88772. setTexture(name: string, texture: Texture): ShaderMaterial;
  88773. /**
  88774. * Set a texture array in the shader.
  88775. * @param name Define the name of the uniform sampler array as defined in the shader
  88776. * @param textures Define the list of textures to bind to this sampler
  88777. * @return the material itself allowing "fluent" like uniform updates
  88778. */
  88779. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88780. /**
  88781. * Set a float in the shader.
  88782. * @param name Define the name of the uniform as defined in the shader
  88783. * @param value Define the value to give to the uniform
  88784. * @return the material itself allowing "fluent" like uniform updates
  88785. */
  88786. setFloat(name: string, value: number): ShaderMaterial;
  88787. /**
  88788. * Set a int in the shader.
  88789. * @param name Define the name of the uniform as defined in the shader
  88790. * @param value Define the value to give to the uniform
  88791. * @return the material itself allowing "fluent" like uniform updates
  88792. */
  88793. setInt(name: string, value: number): ShaderMaterial;
  88794. /**
  88795. * Set an array of floats in the shader.
  88796. * @param name Define the name of the uniform as defined in the shader
  88797. * @param value Define the value to give to the uniform
  88798. * @return the material itself allowing "fluent" like uniform updates
  88799. */
  88800. setFloats(name: string, value: number[]): ShaderMaterial;
  88801. /**
  88802. * Set a vec3 in the shader from a Color3.
  88803. * @param name Define the name of the uniform as defined in the shader
  88804. * @param value Define the value to give to the uniform
  88805. * @return the material itself allowing "fluent" like uniform updates
  88806. */
  88807. setColor3(name: string, value: Color3): ShaderMaterial;
  88808. /**
  88809. * Set a vec3 array in the shader from a Color3 array.
  88810. * @param name Define the name of the uniform as defined in the shader
  88811. * @param value Define the value to give to the uniform
  88812. * @return the material itself allowing "fluent" like uniform updates
  88813. */
  88814. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88815. /**
  88816. * Set a vec4 in the shader from a Color4.
  88817. * @param name Define the name of the uniform as defined in the shader
  88818. * @param value Define the value to give to the uniform
  88819. * @return the material itself allowing "fluent" like uniform updates
  88820. */
  88821. setColor4(name: string, value: Color4): ShaderMaterial;
  88822. /**
  88823. * Set a vec4 array in the shader from a Color4 array.
  88824. * @param name Define the name of the uniform as defined in the shader
  88825. * @param value Define the value to give to the uniform
  88826. * @return the material itself allowing "fluent" like uniform updates
  88827. */
  88828. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88829. /**
  88830. * Set a vec2 in the shader from a Vector2.
  88831. * @param name Define the name of the uniform as defined in the shader
  88832. * @param value Define the value to give to the uniform
  88833. * @return the material itself allowing "fluent" like uniform updates
  88834. */
  88835. setVector2(name: string, value: Vector2): ShaderMaterial;
  88836. /**
  88837. * Set a vec3 in the shader from a Vector3.
  88838. * @param name Define the name of the uniform as defined in the shader
  88839. * @param value Define the value to give to the uniform
  88840. * @return the material itself allowing "fluent" like uniform updates
  88841. */
  88842. setVector3(name: string, value: Vector3): ShaderMaterial;
  88843. /**
  88844. * Set a vec4 in the shader from a Vector4.
  88845. * @param name Define the name of the uniform as defined in the shader
  88846. * @param value Define the value to give to the uniform
  88847. * @return the material itself allowing "fluent" like uniform updates
  88848. */
  88849. setVector4(name: string, value: Vector4): ShaderMaterial;
  88850. /**
  88851. * Set a mat4 in the shader from a Matrix.
  88852. * @param name Define the name of the uniform as defined in the shader
  88853. * @param value Define the value to give to the uniform
  88854. * @return the material itself allowing "fluent" like uniform updates
  88855. */
  88856. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88857. /**
  88858. * Set a float32Array in the shader from a matrix array.
  88859. * @param name Define the name of the uniform as defined in the shader
  88860. * @param value Define the value to give to the uniform
  88861. * @return the material itself allowing "fluent" like uniform updates
  88862. */
  88863. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88864. /**
  88865. * Set a mat3 in the shader from a Float32Array.
  88866. * @param name Define the name of the uniform as defined in the shader
  88867. * @param value Define the value to give to the uniform
  88868. * @return the material itself allowing "fluent" like uniform updates
  88869. */
  88870. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88871. /**
  88872. * Set a mat2 in the shader from a Float32Array.
  88873. * @param name Define the name of the uniform as defined in the shader
  88874. * @param value Define the value to give to the uniform
  88875. * @return the material itself allowing "fluent" like uniform updates
  88876. */
  88877. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88878. /**
  88879. * Set a vec2 array in the shader from a number array.
  88880. * @param name Define the name of the uniform as defined in the shader
  88881. * @param value Define the value to give to the uniform
  88882. * @return the material itself allowing "fluent" like uniform updates
  88883. */
  88884. setArray2(name: string, value: number[]): ShaderMaterial;
  88885. /**
  88886. * Set a vec3 array in the shader from a number array.
  88887. * @param name Define the name of the uniform as defined in the shader
  88888. * @param value Define the value to give to the uniform
  88889. * @return the material itself allowing "fluent" like uniform updates
  88890. */
  88891. setArray3(name: string, value: number[]): ShaderMaterial;
  88892. /**
  88893. * Set a vec4 array in the shader from a number array.
  88894. * @param name Define the name of the uniform as defined in the shader
  88895. * @param value Define the value to give to the uniform
  88896. * @return the material itself allowing "fluent" like uniform updates
  88897. */
  88898. setArray4(name: string, value: number[]): ShaderMaterial;
  88899. private _checkCache;
  88900. /**
  88901. * Specifies that the submesh is ready to be used
  88902. * @param mesh defines the mesh to check
  88903. * @param subMesh defines which submesh to check
  88904. * @param useInstances specifies that instances should be used
  88905. * @returns a boolean indicating that the submesh is ready or not
  88906. */
  88907. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88908. /**
  88909. * Checks if the material is ready to render the requested mesh
  88910. * @param mesh Define the mesh to render
  88911. * @param useInstances Define whether or not the material is used with instances
  88912. * @returns true if ready, otherwise false
  88913. */
  88914. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88915. /**
  88916. * Binds the world matrix to the material
  88917. * @param world defines the world transformation matrix
  88918. */
  88919. bindOnlyWorldMatrix(world: Matrix): void;
  88920. /**
  88921. * Binds the material to the mesh
  88922. * @param world defines the world transformation matrix
  88923. * @param mesh defines the mesh to bind the material to
  88924. */
  88925. bind(world: Matrix, mesh?: Mesh): void;
  88926. /**
  88927. * Gets the active textures from the material
  88928. * @returns an array of textures
  88929. */
  88930. getActiveTextures(): BaseTexture[];
  88931. /**
  88932. * Specifies if the material uses a texture
  88933. * @param texture defines the texture to check against the material
  88934. * @returns a boolean specifying if the material uses the texture
  88935. */
  88936. hasTexture(texture: BaseTexture): boolean;
  88937. /**
  88938. * Makes a duplicate of the material, and gives it a new name
  88939. * @param name defines the new name for the duplicated material
  88940. * @returns the cloned material
  88941. */
  88942. clone(name: string): ShaderMaterial;
  88943. /**
  88944. * Disposes the material
  88945. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88946. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88947. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88948. */
  88949. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88950. /**
  88951. * Serializes this material in a JSON representation
  88952. * @returns the serialized material object
  88953. */
  88954. serialize(): any;
  88955. /**
  88956. * Creates a shader material from parsed shader material data
  88957. * @param source defines the JSON represnetation of the material
  88958. * @param scene defines the hosting scene
  88959. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88960. * @returns a new material
  88961. */
  88962. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88963. }
  88964. }
  88965. declare module BABYLON {
  88966. /** @hidden */
  88967. export var colorPixelShader: {
  88968. name: string;
  88969. shader: string;
  88970. };
  88971. }
  88972. declare module BABYLON {
  88973. /** @hidden */
  88974. export var colorVertexShader: {
  88975. name: string;
  88976. shader: string;
  88977. };
  88978. }
  88979. declare module BABYLON {
  88980. /**
  88981. * Line mesh
  88982. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88983. */
  88984. export class LinesMesh extends Mesh {
  88985. /**
  88986. * If vertex color should be applied to the mesh
  88987. */
  88988. readonly useVertexColor?: boolean | undefined;
  88989. /**
  88990. * If vertex alpha should be applied to the mesh
  88991. */
  88992. readonly useVertexAlpha?: boolean | undefined;
  88993. /**
  88994. * Color of the line (Default: White)
  88995. */
  88996. color: Color3;
  88997. /**
  88998. * Alpha of the line (Default: 1)
  88999. */
  89000. alpha: number;
  89001. /**
  89002. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89003. * This margin is expressed in world space coordinates, so its value may vary.
  89004. * Default value is 0.1
  89005. */
  89006. intersectionThreshold: number;
  89007. private _colorShader;
  89008. private color4;
  89009. /**
  89010. * Creates a new LinesMesh
  89011. * @param name defines the name
  89012. * @param scene defines the hosting scene
  89013. * @param parent defines the parent mesh if any
  89014. * @param source defines the optional source LinesMesh used to clone data from
  89015. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89016. * When false, achieved by calling a clone(), also passing False.
  89017. * This will make creation of children, recursive.
  89018. * @param useVertexColor defines if this LinesMesh supports vertex color
  89019. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89020. */
  89021. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89022. /**
  89023. * If vertex color should be applied to the mesh
  89024. */
  89025. useVertexColor?: boolean | undefined,
  89026. /**
  89027. * If vertex alpha should be applied to the mesh
  89028. */
  89029. useVertexAlpha?: boolean | undefined);
  89030. private _addClipPlaneDefine;
  89031. private _removeClipPlaneDefine;
  89032. isReady(): boolean;
  89033. /**
  89034. * Returns the string "LineMesh"
  89035. */
  89036. getClassName(): string;
  89037. /**
  89038. * @hidden
  89039. */
  89040. get material(): Material;
  89041. /**
  89042. * @hidden
  89043. */
  89044. set material(value: Material);
  89045. /**
  89046. * @hidden
  89047. */
  89048. get checkCollisions(): boolean;
  89049. /** @hidden */
  89050. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89051. /** @hidden */
  89052. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89053. /**
  89054. * Disposes of the line mesh
  89055. * @param doNotRecurse If children should be disposed
  89056. */
  89057. dispose(doNotRecurse?: boolean): void;
  89058. /**
  89059. * Returns a new LineMesh object cloned from the current one.
  89060. */
  89061. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89062. /**
  89063. * Creates a new InstancedLinesMesh object from the mesh model.
  89064. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89065. * @param name defines the name of the new instance
  89066. * @returns a new InstancedLinesMesh
  89067. */
  89068. createInstance(name: string): InstancedLinesMesh;
  89069. }
  89070. /**
  89071. * Creates an instance based on a source LinesMesh
  89072. */
  89073. export class InstancedLinesMesh extends InstancedMesh {
  89074. /**
  89075. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89076. * This margin is expressed in world space coordinates, so its value may vary.
  89077. * Initilized with the intersectionThreshold value of the source LinesMesh
  89078. */
  89079. intersectionThreshold: number;
  89080. constructor(name: string, source: LinesMesh);
  89081. /**
  89082. * Returns the string "InstancedLinesMesh".
  89083. */
  89084. getClassName(): string;
  89085. }
  89086. }
  89087. declare module BABYLON {
  89088. /** @hidden */
  89089. export var linePixelShader: {
  89090. name: string;
  89091. shader: string;
  89092. };
  89093. }
  89094. declare module BABYLON {
  89095. /** @hidden */
  89096. export var lineVertexShader: {
  89097. name: string;
  89098. shader: string;
  89099. };
  89100. }
  89101. declare module BABYLON {
  89102. interface AbstractMesh {
  89103. /**
  89104. * Gets the edgesRenderer associated with the mesh
  89105. */
  89106. edgesRenderer: Nullable<EdgesRenderer>;
  89107. }
  89108. interface LinesMesh {
  89109. /**
  89110. * Enables the edge rendering mode on the mesh.
  89111. * This mode makes the mesh edges visible
  89112. * @param epsilon defines the maximal distance between two angles to detect a face
  89113. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89114. * @returns the currentAbstractMesh
  89115. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89116. */
  89117. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89118. }
  89119. interface InstancedLinesMesh {
  89120. /**
  89121. * Enables the edge rendering mode on the mesh.
  89122. * This mode makes the mesh edges visible
  89123. * @param epsilon defines the maximal distance between two angles to detect a face
  89124. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89125. * @returns the current InstancedLinesMesh
  89126. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89127. */
  89128. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89129. }
  89130. /**
  89131. * Defines the minimum contract an Edges renderer should follow.
  89132. */
  89133. export interface IEdgesRenderer extends IDisposable {
  89134. /**
  89135. * Gets or sets a boolean indicating if the edgesRenderer is active
  89136. */
  89137. isEnabled: boolean;
  89138. /**
  89139. * Renders the edges of the attached mesh,
  89140. */
  89141. render(): void;
  89142. /**
  89143. * Checks wether or not the edges renderer is ready to render.
  89144. * @return true if ready, otherwise false.
  89145. */
  89146. isReady(): boolean;
  89147. }
  89148. /**
  89149. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89150. */
  89151. export class EdgesRenderer implements IEdgesRenderer {
  89152. /**
  89153. * Define the size of the edges with an orthographic camera
  89154. */
  89155. edgesWidthScalerForOrthographic: number;
  89156. /**
  89157. * Define the size of the edges with a perspective camera
  89158. */
  89159. edgesWidthScalerForPerspective: number;
  89160. protected _source: AbstractMesh;
  89161. protected _linesPositions: number[];
  89162. protected _linesNormals: number[];
  89163. protected _linesIndices: number[];
  89164. protected _epsilon: number;
  89165. protected _indicesCount: number;
  89166. protected _lineShader: ShaderMaterial;
  89167. protected _ib: DataBuffer;
  89168. protected _buffers: {
  89169. [key: string]: Nullable<VertexBuffer>;
  89170. };
  89171. protected _checkVerticesInsteadOfIndices: boolean;
  89172. private _meshRebuildObserver;
  89173. private _meshDisposeObserver;
  89174. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89175. isEnabled: boolean;
  89176. /**
  89177. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89178. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89179. * @param source Mesh used to create edges
  89180. * @param epsilon sum of angles in adjacency to check for edge
  89181. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89182. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89183. */
  89184. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89185. protected _prepareRessources(): void;
  89186. /** @hidden */
  89187. _rebuild(): void;
  89188. /**
  89189. * Releases the required resources for the edges renderer
  89190. */
  89191. dispose(): void;
  89192. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89193. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89194. /**
  89195. * Checks if the pair of p0 and p1 is en edge
  89196. * @param faceIndex
  89197. * @param edge
  89198. * @param faceNormals
  89199. * @param p0
  89200. * @param p1
  89201. * @private
  89202. */
  89203. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89204. /**
  89205. * push line into the position, normal and index buffer
  89206. * @protected
  89207. */
  89208. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89209. /**
  89210. * Generates lines edges from adjacencjes
  89211. * @private
  89212. */
  89213. _generateEdgesLines(): void;
  89214. /**
  89215. * Checks wether or not the edges renderer is ready to render.
  89216. * @return true if ready, otherwise false.
  89217. */
  89218. isReady(): boolean;
  89219. /**
  89220. * Renders the edges of the attached mesh,
  89221. */
  89222. render(): void;
  89223. }
  89224. /**
  89225. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89226. */
  89227. export class LineEdgesRenderer extends EdgesRenderer {
  89228. /**
  89229. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89230. * @param source LineMesh used to generate edges
  89231. * @param epsilon not important (specified angle for edge detection)
  89232. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89233. */
  89234. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89235. /**
  89236. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89237. */
  89238. _generateEdgesLines(): void;
  89239. }
  89240. }
  89241. declare module BABYLON {
  89242. /**
  89243. * This represents the object necessary to create a rendering group.
  89244. * This is exclusively used and created by the rendering manager.
  89245. * To modify the behavior, you use the available helpers in your scene or meshes.
  89246. * @hidden
  89247. */
  89248. export class RenderingGroup {
  89249. index: number;
  89250. private static _zeroVector;
  89251. private _scene;
  89252. private _opaqueSubMeshes;
  89253. private _transparentSubMeshes;
  89254. private _alphaTestSubMeshes;
  89255. private _depthOnlySubMeshes;
  89256. private _particleSystems;
  89257. private _spriteManagers;
  89258. private _opaqueSortCompareFn;
  89259. private _alphaTestSortCompareFn;
  89260. private _transparentSortCompareFn;
  89261. private _renderOpaque;
  89262. private _renderAlphaTest;
  89263. private _renderTransparent;
  89264. /** @hidden */
  89265. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89266. onBeforeTransparentRendering: () => void;
  89267. /**
  89268. * Set the opaque sort comparison function.
  89269. * If null the sub meshes will be render in the order they were created
  89270. */
  89271. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89272. /**
  89273. * Set the alpha test sort comparison function.
  89274. * If null the sub meshes will be render in the order they were created
  89275. */
  89276. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89277. /**
  89278. * Set the transparent sort comparison function.
  89279. * If null the sub meshes will be render in the order they were created
  89280. */
  89281. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89282. /**
  89283. * Creates a new rendering group.
  89284. * @param index The rendering group index
  89285. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89286. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89287. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89288. */
  89289. 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>);
  89290. /**
  89291. * Render all the sub meshes contained in the group.
  89292. * @param customRenderFunction Used to override the default render behaviour of the group.
  89293. * @returns true if rendered some submeshes.
  89294. */
  89295. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89296. /**
  89297. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89298. * @param subMeshes The submeshes to render
  89299. */
  89300. private renderOpaqueSorted;
  89301. /**
  89302. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89303. * @param subMeshes The submeshes to render
  89304. */
  89305. private renderAlphaTestSorted;
  89306. /**
  89307. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89308. * @param subMeshes The submeshes to render
  89309. */
  89310. private renderTransparentSorted;
  89311. /**
  89312. * Renders the submeshes in a specified order.
  89313. * @param subMeshes The submeshes to sort before render
  89314. * @param sortCompareFn The comparison function use to sort
  89315. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89316. * @param transparent Specifies to activate blending if true
  89317. */
  89318. private static renderSorted;
  89319. /**
  89320. * Renders the submeshes in the order they were dispatched (no sort applied).
  89321. * @param subMeshes The submeshes to render
  89322. */
  89323. private static renderUnsorted;
  89324. /**
  89325. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89326. * are rendered back to front if in the same alpha index.
  89327. *
  89328. * @param a The first submesh
  89329. * @param b The second submesh
  89330. * @returns The result of the comparison
  89331. */
  89332. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89333. /**
  89334. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89335. * are rendered back to front.
  89336. *
  89337. * @param a The first submesh
  89338. * @param b The second submesh
  89339. * @returns The result of the comparison
  89340. */
  89341. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89342. /**
  89343. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89344. * are rendered front to back (prevent overdraw).
  89345. *
  89346. * @param a The first submesh
  89347. * @param b The second submesh
  89348. * @returns The result of the comparison
  89349. */
  89350. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89351. /**
  89352. * Resets the different lists of submeshes to prepare a new frame.
  89353. */
  89354. prepare(): void;
  89355. dispose(): void;
  89356. /**
  89357. * Inserts the submesh in its correct queue depending on its material.
  89358. * @param subMesh The submesh to dispatch
  89359. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89360. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89361. */
  89362. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89363. dispatchSprites(spriteManager: ISpriteManager): void;
  89364. dispatchParticles(particleSystem: IParticleSystem): void;
  89365. private _renderParticles;
  89366. private _renderSprites;
  89367. }
  89368. }
  89369. declare module BABYLON {
  89370. /**
  89371. * Interface describing the different options available in the rendering manager
  89372. * regarding Auto Clear between groups.
  89373. */
  89374. export interface IRenderingManagerAutoClearSetup {
  89375. /**
  89376. * Defines whether or not autoclear is enable.
  89377. */
  89378. autoClear: boolean;
  89379. /**
  89380. * Defines whether or not to autoclear the depth buffer.
  89381. */
  89382. depth: boolean;
  89383. /**
  89384. * Defines whether or not to autoclear the stencil buffer.
  89385. */
  89386. stencil: boolean;
  89387. }
  89388. /**
  89389. * This class is used by the onRenderingGroupObservable
  89390. */
  89391. export class RenderingGroupInfo {
  89392. /**
  89393. * The Scene that being rendered
  89394. */
  89395. scene: Scene;
  89396. /**
  89397. * The camera currently used for the rendering pass
  89398. */
  89399. camera: Nullable<Camera>;
  89400. /**
  89401. * The ID of the renderingGroup being processed
  89402. */
  89403. renderingGroupId: number;
  89404. }
  89405. /**
  89406. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89407. * It is enable to manage the different groups as well as the different necessary sort functions.
  89408. * This should not be used directly aside of the few static configurations
  89409. */
  89410. export class RenderingManager {
  89411. /**
  89412. * The max id used for rendering groups (not included)
  89413. */
  89414. static MAX_RENDERINGGROUPS: number;
  89415. /**
  89416. * The min id used for rendering groups (included)
  89417. */
  89418. static MIN_RENDERINGGROUPS: number;
  89419. /**
  89420. * Used to globally prevent autoclearing scenes.
  89421. */
  89422. static AUTOCLEAR: boolean;
  89423. /**
  89424. * @hidden
  89425. */
  89426. _useSceneAutoClearSetup: boolean;
  89427. private _scene;
  89428. private _renderingGroups;
  89429. private _depthStencilBufferAlreadyCleaned;
  89430. private _autoClearDepthStencil;
  89431. private _customOpaqueSortCompareFn;
  89432. private _customAlphaTestSortCompareFn;
  89433. private _customTransparentSortCompareFn;
  89434. private _renderingGroupInfo;
  89435. /**
  89436. * Instantiates a new rendering group for a particular scene
  89437. * @param scene Defines the scene the groups belongs to
  89438. */
  89439. constructor(scene: Scene);
  89440. private _clearDepthStencilBuffer;
  89441. /**
  89442. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89443. * @hidden
  89444. */
  89445. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89446. /**
  89447. * Resets the different information of the group to prepare a new frame
  89448. * @hidden
  89449. */
  89450. reset(): void;
  89451. /**
  89452. * Dispose and release the group and its associated resources.
  89453. * @hidden
  89454. */
  89455. dispose(): void;
  89456. /**
  89457. * Clear the info related to rendering groups preventing retention points during dispose.
  89458. */
  89459. freeRenderingGroups(): void;
  89460. private _prepareRenderingGroup;
  89461. /**
  89462. * Add a sprite manager to the rendering manager in order to render it this frame.
  89463. * @param spriteManager Define the sprite manager to render
  89464. */
  89465. dispatchSprites(spriteManager: ISpriteManager): void;
  89466. /**
  89467. * Add a particle system to the rendering manager in order to render it this frame.
  89468. * @param particleSystem Define the particle system to render
  89469. */
  89470. dispatchParticles(particleSystem: IParticleSystem): void;
  89471. /**
  89472. * Add a submesh to the manager in order to render it this frame
  89473. * @param subMesh The submesh to dispatch
  89474. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89475. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89476. */
  89477. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89478. /**
  89479. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89480. * This allowed control for front to back rendering or reversly depending of the special needs.
  89481. *
  89482. * @param renderingGroupId The rendering group id corresponding to its index
  89483. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89484. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89485. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89486. */
  89487. 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;
  89488. /**
  89489. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89490. *
  89491. * @param renderingGroupId The rendering group id corresponding to its index
  89492. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89493. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89494. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89495. */
  89496. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89497. /**
  89498. * Gets the current auto clear configuration for one rendering group of the rendering
  89499. * manager.
  89500. * @param index the rendering group index to get the information for
  89501. * @returns The auto clear setup for the requested rendering group
  89502. */
  89503. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89504. }
  89505. }
  89506. declare module BABYLON {
  89507. /**
  89508. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89509. */
  89510. export interface ICustomShaderOptions {
  89511. /**
  89512. * Gets or sets the custom shader name to use
  89513. */
  89514. shaderName: string;
  89515. /**
  89516. * The list of attribute names used in the shader
  89517. */
  89518. attributes?: string[];
  89519. /**
  89520. * The list of unifrom names used in the shader
  89521. */
  89522. uniforms?: string[];
  89523. /**
  89524. * The list of sampler names used in the shader
  89525. */
  89526. samplers?: string[];
  89527. /**
  89528. * The list of defines used in the shader
  89529. */
  89530. defines?: string[];
  89531. }
  89532. /**
  89533. * Interface to implement to create a shadow generator compatible with BJS.
  89534. */
  89535. export interface IShadowGenerator {
  89536. /**
  89537. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89538. * @returns The render target texture if present otherwise, null
  89539. */
  89540. getShadowMap(): Nullable<RenderTargetTexture>;
  89541. /**
  89542. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89543. * @param subMesh The submesh we want to render in the shadow map
  89544. * @param useInstances Defines wether will draw in the map using instances
  89545. * @returns true if ready otherwise, false
  89546. */
  89547. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89548. /**
  89549. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89550. * @param defines Defines of the material we want to update
  89551. * @param lightIndex Index of the light in the enabled light list of the material
  89552. */
  89553. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89554. /**
  89555. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89556. * defined in the generator but impacting the effect).
  89557. * It implies the unifroms available on the materials are the standard BJS ones.
  89558. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89559. * @param effect The effect we are binfing the information for
  89560. */
  89561. bindShadowLight(lightIndex: string, effect: Effect): void;
  89562. /**
  89563. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89564. * (eq to shadow prjection matrix * light transform matrix)
  89565. * @returns The transform matrix used to create the shadow map
  89566. */
  89567. getTransformMatrix(): Matrix;
  89568. /**
  89569. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89570. * Cube and 2D textures for instance.
  89571. */
  89572. recreateShadowMap(): void;
  89573. /**
  89574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89575. * @param onCompiled Callback triggered at the and of the effects compilation
  89576. * @param options Sets of optional options forcing the compilation with different modes
  89577. */
  89578. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89579. useInstances: boolean;
  89580. }>): void;
  89581. /**
  89582. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89583. * @param options Sets of optional options forcing the compilation with different modes
  89584. * @returns A promise that resolves when the compilation completes
  89585. */
  89586. forceCompilationAsync(options?: Partial<{
  89587. useInstances: boolean;
  89588. }>): Promise<void>;
  89589. /**
  89590. * Serializes the shadow generator setup to a json object.
  89591. * @returns The serialized JSON object
  89592. */
  89593. serialize(): any;
  89594. /**
  89595. * Disposes the Shadow map and related Textures and effects.
  89596. */
  89597. dispose(): void;
  89598. }
  89599. /**
  89600. * Default implementation IShadowGenerator.
  89601. * This is the main object responsible of generating shadows in the framework.
  89602. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89603. */
  89604. export class ShadowGenerator implements IShadowGenerator {
  89605. /**
  89606. * Name of the shadow generator class
  89607. */
  89608. static CLASSNAME: string;
  89609. /**
  89610. * Shadow generator mode None: no filtering applied.
  89611. */
  89612. static readonly FILTER_NONE: number;
  89613. /**
  89614. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89615. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89616. */
  89617. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89618. /**
  89619. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89620. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89621. */
  89622. static readonly FILTER_POISSONSAMPLING: number;
  89623. /**
  89624. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89626. */
  89627. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89628. /**
  89629. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89630. * edge artifacts on steep falloff.
  89631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89632. */
  89633. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89634. /**
  89635. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89636. * edge artifacts on steep falloff.
  89637. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89638. */
  89639. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89640. /**
  89641. * Shadow generator mode PCF: Percentage Closer Filtering
  89642. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89643. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89644. */
  89645. static readonly FILTER_PCF: number;
  89646. /**
  89647. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89648. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89649. * Contact Hardening
  89650. */
  89651. static readonly FILTER_PCSS: number;
  89652. /**
  89653. * Reserved for PCF and PCSS
  89654. * Highest Quality.
  89655. *
  89656. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89657. *
  89658. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89659. */
  89660. static readonly QUALITY_HIGH: number;
  89661. /**
  89662. * Reserved for PCF and PCSS
  89663. * Good tradeoff for quality/perf cross devices
  89664. *
  89665. * Execute PCF on a 3*3 kernel.
  89666. *
  89667. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89668. */
  89669. static readonly QUALITY_MEDIUM: number;
  89670. /**
  89671. * Reserved for PCF and PCSS
  89672. * The lowest quality but the fastest.
  89673. *
  89674. * Execute PCF on a 1*1 kernel.
  89675. *
  89676. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89677. */
  89678. static readonly QUALITY_LOW: number;
  89679. /** Gets or sets the custom shader name to use */
  89680. customShaderOptions: ICustomShaderOptions;
  89681. /**
  89682. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89683. */
  89684. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89685. /**
  89686. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89687. */
  89688. onAfterShadowMapRenderObservable: Observable<Effect>;
  89689. /**
  89690. * Observable triggered before a mesh is rendered in the shadow map.
  89691. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89692. */
  89693. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89694. /**
  89695. * Observable triggered after a mesh is rendered in the shadow map.
  89696. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89697. */
  89698. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89699. protected _bias: number;
  89700. /**
  89701. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89702. */
  89703. get bias(): number;
  89704. /**
  89705. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89706. */
  89707. set bias(bias: number);
  89708. protected _normalBias: number;
  89709. /**
  89710. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89711. */
  89712. get normalBias(): number;
  89713. /**
  89714. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89715. */
  89716. set normalBias(normalBias: number);
  89717. protected _blurBoxOffset: number;
  89718. /**
  89719. * Gets the blur box offset: offset applied during the blur pass.
  89720. * Only useful if useKernelBlur = false
  89721. */
  89722. get blurBoxOffset(): number;
  89723. /**
  89724. * Sets the blur box offset: offset applied during the blur pass.
  89725. * Only useful if useKernelBlur = false
  89726. */
  89727. set blurBoxOffset(value: number);
  89728. protected _blurScale: number;
  89729. /**
  89730. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89731. * 2 means half of the size.
  89732. */
  89733. get blurScale(): number;
  89734. /**
  89735. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89736. * 2 means half of the size.
  89737. */
  89738. set blurScale(value: number);
  89739. protected _blurKernel: number;
  89740. /**
  89741. * Gets the blur kernel: kernel size of the blur pass.
  89742. * Only useful if useKernelBlur = true
  89743. */
  89744. get blurKernel(): number;
  89745. /**
  89746. * Sets the blur kernel: kernel size of the blur pass.
  89747. * Only useful if useKernelBlur = true
  89748. */
  89749. set blurKernel(value: number);
  89750. protected _useKernelBlur: boolean;
  89751. /**
  89752. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89753. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89754. */
  89755. get useKernelBlur(): boolean;
  89756. /**
  89757. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89758. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89759. */
  89760. set useKernelBlur(value: boolean);
  89761. protected _depthScale: number;
  89762. /**
  89763. * Gets the depth scale used in ESM mode.
  89764. */
  89765. get depthScale(): number;
  89766. /**
  89767. * Sets the depth scale used in ESM mode.
  89768. * This can override the scale stored on the light.
  89769. */
  89770. set depthScale(value: number);
  89771. protected _validateFilter(filter: number): number;
  89772. protected _filter: number;
  89773. /**
  89774. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89775. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89776. */
  89777. get filter(): number;
  89778. /**
  89779. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89780. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89781. */
  89782. set filter(value: number);
  89783. /**
  89784. * Gets if the current filter is set to Poisson Sampling.
  89785. */
  89786. get usePoissonSampling(): boolean;
  89787. /**
  89788. * Sets the current filter to Poisson Sampling.
  89789. */
  89790. set usePoissonSampling(value: boolean);
  89791. /**
  89792. * Gets if the current filter is set to ESM.
  89793. */
  89794. get useExponentialShadowMap(): boolean;
  89795. /**
  89796. * Sets the current filter is to ESM.
  89797. */
  89798. set useExponentialShadowMap(value: boolean);
  89799. /**
  89800. * Gets if the current filter is set to filtered ESM.
  89801. */
  89802. get useBlurExponentialShadowMap(): boolean;
  89803. /**
  89804. * Gets if the current filter is set to filtered ESM.
  89805. */
  89806. set useBlurExponentialShadowMap(value: boolean);
  89807. /**
  89808. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89809. * exponential to prevent steep falloff artifacts).
  89810. */
  89811. get useCloseExponentialShadowMap(): boolean;
  89812. /**
  89813. * Sets the current filter to "close ESM" (using the inverse of the
  89814. * exponential to prevent steep falloff artifacts).
  89815. */
  89816. set useCloseExponentialShadowMap(value: boolean);
  89817. /**
  89818. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89819. * exponential to prevent steep falloff artifacts).
  89820. */
  89821. get useBlurCloseExponentialShadowMap(): boolean;
  89822. /**
  89823. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89824. * exponential to prevent steep falloff artifacts).
  89825. */
  89826. set useBlurCloseExponentialShadowMap(value: boolean);
  89827. /**
  89828. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89829. */
  89830. get usePercentageCloserFiltering(): boolean;
  89831. /**
  89832. * Sets the current filter to "PCF" (percentage closer filtering).
  89833. */
  89834. set usePercentageCloserFiltering(value: boolean);
  89835. protected _filteringQuality: number;
  89836. /**
  89837. * Gets the PCF or PCSS Quality.
  89838. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89839. */
  89840. get filteringQuality(): number;
  89841. /**
  89842. * Sets the PCF or PCSS Quality.
  89843. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89844. */
  89845. set filteringQuality(filteringQuality: number);
  89846. /**
  89847. * Gets if the current filter is set to "PCSS" (contact hardening).
  89848. */
  89849. get useContactHardeningShadow(): boolean;
  89850. /**
  89851. * Sets the current filter to "PCSS" (contact hardening).
  89852. */
  89853. set useContactHardeningShadow(value: boolean);
  89854. protected _contactHardeningLightSizeUVRatio: number;
  89855. /**
  89856. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89857. * Using a ratio helps keeping shape stability independently of the map size.
  89858. *
  89859. * It does not account for the light projection as it was having too much
  89860. * instability during the light setup or during light position changes.
  89861. *
  89862. * Only valid if useContactHardeningShadow is true.
  89863. */
  89864. get contactHardeningLightSizeUVRatio(): number;
  89865. /**
  89866. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89867. * Using a ratio helps keeping shape stability independently of the map size.
  89868. *
  89869. * It does not account for the light projection as it was having too much
  89870. * instability during the light setup or during light position changes.
  89871. *
  89872. * Only valid if useContactHardeningShadow is true.
  89873. */
  89874. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89875. protected _darkness: number;
  89876. /** Gets or sets the actual darkness of a shadow */
  89877. get darkness(): number;
  89878. set darkness(value: number);
  89879. /**
  89880. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89881. * 0 means strongest and 1 would means no shadow.
  89882. * @returns the darkness.
  89883. */
  89884. getDarkness(): number;
  89885. /**
  89886. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89887. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89888. * @returns the shadow generator allowing fluent coding.
  89889. */
  89890. setDarkness(darkness: number): ShadowGenerator;
  89891. protected _transparencyShadow: boolean;
  89892. /** Gets or sets the ability to have transparent shadow */
  89893. get transparencyShadow(): boolean;
  89894. set transparencyShadow(value: boolean);
  89895. /**
  89896. * Sets the ability to have transparent shadow (boolean).
  89897. * @param transparent True if transparent else False
  89898. * @returns the shadow generator allowing fluent coding
  89899. */
  89900. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89901. protected _shadowMap: Nullable<RenderTargetTexture>;
  89902. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89903. /**
  89904. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89905. * @returns The render target texture if present otherwise, null
  89906. */
  89907. getShadowMap(): Nullable<RenderTargetTexture>;
  89908. /**
  89909. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89910. * @returns The render target texture if the shadow map is present otherwise, null
  89911. */
  89912. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89913. /**
  89914. * Gets the class name of that object
  89915. * @returns "ShadowGenerator"
  89916. */
  89917. getClassName(): string;
  89918. /**
  89919. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89920. * @param mesh Mesh to add
  89921. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89922. * @returns the Shadow Generator itself
  89923. */
  89924. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89925. /**
  89926. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89927. * @param mesh Mesh to remove
  89928. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89929. * @returns the Shadow Generator itself
  89930. */
  89931. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89932. /**
  89933. * Controls the extent to which the shadows fade out at the edge of the frustum
  89934. */
  89935. frustumEdgeFalloff: number;
  89936. protected _light: IShadowLight;
  89937. /**
  89938. * Returns the associated light object.
  89939. * @returns the light generating the shadow
  89940. */
  89941. getLight(): IShadowLight;
  89942. /**
  89943. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89944. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89945. * It might on the other hand introduce peter panning.
  89946. */
  89947. forceBackFacesOnly: boolean;
  89948. protected _scene: Scene;
  89949. protected _lightDirection: Vector3;
  89950. protected _effect: Effect;
  89951. protected _viewMatrix: Matrix;
  89952. protected _projectionMatrix: Matrix;
  89953. protected _transformMatrix: Matrix;
  89954. protected _cachedPosition: Vector3;
  89955. protected _cachedDirection: Vector3;
  89956. protected _cachedDefines: string;
  89957. protected _currentRenderID: number;
  89958. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89959. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89960. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89961. protected _blurPostProcesses: PostProcess[];
  89962. protected _mapSize: number;
  89963. protected _currentFaceIndex: number;
  89964. protected _currentFaceIndexCache: number;
  89965. protected _textureType: number;
  89966. protected _defaultTextureMatrix: Matrix;
  89967. protected _storedUniqueId: Nullable<number>;
  89968. /** @hidden */
  89969. static _SceneComponentInitialization: (scene: Scene) => void;
  89970. /**
  89971. * Creates a ShadowGenerator object.
  89972. * A ShadowGenerator is the required tool to use the shadows.
  89973. * Each light casting shadows needs to use its own ShadowGenerator.
  89974. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89975. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89976. * @param light The light object generating the shadows.
  89977. * @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.
  89978. */
  89979. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89980. protected _initializeGenerator(): void;
  89981. protected _createTargetRenderTexture(): void;
  89982. protected _initializeShadowMap(): void;
  89983. protected _initializeBlurRTTAndPostProcesses(): void;
  89984. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89985. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89986. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89987. protected _applyFilterValues(): void;
  89988. /**
  89989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89990. * @param onCompiled Callback triggered at the and of the effects compilation
  89991. * @param options Sets of optional options forcing the compilation with different modes
  89992. */
  89993. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89994. useInstances: boolean;
  89995. }>): void;
  89996. /**
  89997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89998. * @param options Sets of optional options forcing the compilation with different modes
  89999. * @returns A promise that resolves when the compilation completes
  90000. */
  90001. forceCompilationAsync(options?: Partial<{
  90002. useInstances: boolean;
  90003. }>): Promise<void>;
  90004. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90005. /**
  90006. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90007. * @param subMesh The submesh we want to render in the shadow map
  90008. * @param useInstances Defines wether will draw in the map using instances
  90009. * @returns true if ready otherwise, false
  90010. */
  90011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90012. /**
  90013. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90014. * @param defines Defines of the material we want to update
  90015. * @param lightIndex Index of the light in the enabled light list of the material
  90016. */
  90017. prepareDefines(defines: any, lightIndex: number): void;
  90018. /**
  90019. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90020. * defined in the generator but impacting the effect).
  90021. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90022. * @param effect The effect we are binfing the information for
  90023. */
  90024. bindShadowLight(lightIndex: string, effect: Effect): void;
  90025. /**
  90026. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90027. * (eq to shadow prjection matrix * light transform matrix)
  90028. * @returns The transform matrix used to create the shadow map
  90029. */
  90030. getTransformMatrix(): Matrix;
  90031. /**
  90032. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90033. * Cube and 2D textures for instance.
  90034. */
  90035. recreateShadowMap(): void;
  90036. protected _disposeBlurPostProcesses(): void;
  90037. protected _disposeRTTandPostProcesses(): void;
  90038. /**
  90039. * Disposes the ShadowGenerator.
  90040. * Returns nothing.
  90041. */
  90042. dispose(): void;
  90043. /**
  90044. * Serializes the shadow generator setup to a json object.
  90045. * @returns The serialized JSON object
  90046. */
  90047. serialize(): any;
  90048. /**
  90049. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90050. * @param parsedShadowGenerator The JSON object to parse
  90051. * @param scene The scene to create the shadow map for
  90052. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90053. * @returns The parsed shadow generator
  90054. */
  90055. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90056. }
  90057. }
  90058. declare module BABYLON {
  90059. /**
  90060. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90061. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90062. * 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.
  90063. */
  90064. export abstract class Light extends Node {
  90065. /**
  90066. * Falloff Default: light is falling off following the material specification:
  90067. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90068. */
  90069. static readonly FALLOFF_DEFAULT: number;
  90070. /**
  90071. * Falloff Physical: light is falling off following the inverse squared distance law.
  90072. */
  90073. static readonly FALLOFF_PHYSICAL: number;
  90074. /**
  90075. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90076. * to enhance interoperability with other engines.
  90077. */
  90078. static readonly FALLOFF_GLTF: number;
  90079. /**
  90080. * Falloff Standard: light is falling off like in the standard material
  90081. * to enhance interoperability with other materials.
  90082. */
  90083. static readonly FALLOFF_STANDARD: number;
  90084. /**
  90085. * If every light affecting the material is in this lightmapMode,
  90086. * material.lightmapTexture adds or multiplies
  90087. * (depends on material.useLightmapAsShadowmap)
  90088. * after every other light calculations.
  90089. */
  90090. static readonly LIGHTMAP_DEFAULT: number;
  90091. /**
  90092. * material.lightmapTexture as only diffuse lighting from this light
  90093. * adds only specular lighting from this light
  90094. * adds dynamic shadows
  90095. */
  90096. static readonly LIGHTMAP_SPECULAR: number;
  90097. /**
  90098. * material.lightmapTexture as only lighting
  90099. * no light calculation from this light
  90100. * only adds dynamic shadows from this light
  90101. */
  90102. static readonly LIGHTMAP_SHADOWSONLY: number;
  90103. /**
  90104. * Each light type uses the default quantity according to its type:
  90105. * point/spot lights use luminous intensity
  90106. * directional lights use illuminance
  90107. */
  90108. static readonly INTENSITYMODE_AUTOMATIC: number;
  90109. /**
  90110. * lumen (lm)
  90111. */
  90112. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90113. /**
  90114. * candela (lm/sr)
  90115. */
  90116. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90117. /**
  90118. * lux (lm/m^2)
  90119. */
  90120. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90121. /**
  90122. * nit (cd/m^2)
  90123. */
  90124. static readonly INTENSITYMODE_LUMINANCE: number;
  90125. /**
  90126. * Light type const id of the point light.
  90127. */
  90128. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90129. /**
  90130. * Light type const id of the directional light.
  90131. */
  90132. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90133. /**
  90134. * Light type const id of the spot light.
  90135. */
  90136. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90137. /**
  90138. * Light type const id of the hemispheric light.
  90139. */
  90140. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90141. /**
  90142. * Diffuse gives the basic color to an object.
  90143. */
  90144. diffuse: Color3;
  90145. /**
  90146. * Specular produces a highlight color on an object.
  90147. * Note: This is note affecting PBR materials.
  90148. */
  90149. specular: Color3;
  90150. /**
  90151. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90152. * falling off base on range or angle.
  90153. * This can be set to any values in Light.FALLOFF_x.
  90154. *
  90155. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90156. * other types of materials.
  90157. */
  90158. falloffType: number;
  90159. /**
  90160. * Strength of the light.
  90161. * Note: By default it is define in the framework own unit.
  90162. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90163. */
  90164. intensity: number;
  90165. private _range;
  90166. protected _inverseSquaredRange: number;
  90167. /**
  90168. * Defines how far from the source the light is impacting in scene units.
  90169. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90170. */
  90171. get range(): number;
  90172. /**
  90173. * Defines how far from the source the light is impacting in scene units.
  90174. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90175. */
  90176. set range(value: number);
  90177. /**
  90178. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90179. * of light.
  90180. */
  90181. private _photometricScale;
  90182. private _intensityMode;
  90183. /**
  90184. * Gets the photometric scale used to interpret the intensity.
  90185. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90186. */
  90187. get intensityMode(): number;
  90188. /**
  90189. * Sets the photometric scale used to interpret the intensity.
  90190. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90191. */
  90192. set intensityMode(value: number);
  90193. private _radius;
  90194. /**
  90195. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90196. */
  90197. get radius(): number;
  90198. /**
  90199. * sets the light radius used by PBR Materials to simulate soft area lights.
  90200. */
  90201. set radius(value: number);
  90202. private _renderPriority;
  90203. /**
  90204. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90205. * exceeding the number allowed of the materials.
  90206. */
  90207. renderPriority: number;
  90208. private _shadowEnabled;
  90209. /**
  90210. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90211. * the current shadow generator.
  90212. */
  90213. get shadowEnabled(): boolean;
  90214. /**
  90215. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90216. * the current shadow generator.
  90217. */
  90218. set shadowEnabled(value: boolean);
  90219. private _includedOnlyMeshes;
  90220. /**
  90221. * Gets the only meshes impacted by this light.
  90222. */
  90223. get includedOnlyMeshes(): AbstractMesh[];
  90224. /**
  90225. * Sets the only meshes impacted by this light.
  90226. */
  90227. set includedOnlyMeshes(value: AbstractMesh[]);
  90228. private _excludedMeshes;
  90229. /**
  90230. * Gets the meshes not impacted by this light.
  90231. */
  90232. get excludedMeshes(): AbstractMesh[];
  90233. /**
  90234. * Sets the meshes not impacted by this light.
  90235. */
  90236. set excludedMeshes(value: AbstractMesh[]);
  90237. private _excludeWithLayerMask;
  90238. /**
  90239. * Gets the layer id use to find what meshes are not impacted by the light.
  90240. * Inactive if 0
  90241. */
  90242. get excludeWithLayerMask(): number;
  90243. /**
  90244. * Sets the layer id use to find what meshes are not impacted by the light.
  90245. * Inactive if 0
  90246. */
  90247. set excludeWithLayerMask(value: number);
  90248. private _includeOnlyWithLayerMask;
  90249. /**
  90250. * Gets the layer id use to find what meshes are impacted by the light.
  90251. * Inactive if 0
  90252. */
  90253. get includeOnlyWithLayerMask(): number;
  90254. /**
  90255. * Sets the layer id use to find what meshes are impacted by the light.
  90256. * Inactive if 0
  90257. */
  90258. set includeOnlyWithLayerMask(value: number);
  90259. private _lightmapMode;
  90260. /**
  90261. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90262. */
  90263. get lightmapMode(): number;
  90264. /**
  90265. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90266. */
  90267. set lightmapMode(value: number);
  90268. /**
  90269. * Shadow generator associted to the light.
  90270. * @hidden Internal use only.
  90271. */
  90272. _shadowGenerator: Nullable<IShadowGenerator>;
  90273. /**
  90274. * @hidden Internal use only.
  90275. */
  90276. _excludedMeshesIds: string[];
  90277. /**
  90278. * @hidden Internal use only.
  90279. */
  90280. _includedOnlyMeshesIds: string[];
  90281. /**
  90282. * The current light unifom buffer.
  90283. * @hidden Internal use only.
  90284. */
  90285. _uniformBuffer: UniformBuffer;
  90286. /** @hidden */
  90287. _renderId: number;
  90288. /**
  90289. * Creates a Light object in the scene.
  90290. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90291. * @param name The firendly name of the light
  90292. * @param scene The scene the light belongs too
  90293. */
  90294. constructor(name: string, scene: Scene);
  90295. protected abstract _buildUniformLayout(): void;
  90296. /**
  90297. * Sets the passed Effect "effect" with the Light information.
  90298. * @param effect The effect to update
  90299. * @param lightIndex The index of the light in the effect to update
  90300. * @returns The light
  90301. */
  90302. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90303. /**
  90304. * Sets the passed Effect "effect" with the Light textures.
  90305. * @param effect The effect to update
  90306. * @param lightIndex The index of the light in the effect to update
  90307. * @returns The light
  90308. */
  90309. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90310. /**
  90311. * Binds the lights information from the scene to the effect for the given mesh.
  90312. * @param lightIndex Light index
  90313. * @param scene The scene where the light belongs to
  90314. * @param effect The effect we are binding the data to
  90315. * @param useSpecular Defines if specular is supported
  90316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90317. */
  90318. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90319. /**
  90320. * Sets the passed Effect "effect" with the Light information.
  90321. * @param effect The effect to update
  90322. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90323. * @returns The light
  90324. */
  90325. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90326. /**
  90327. * Returns the string "Light".
  90328. * @returns the class name
  90329. */
  90330. getClassName(): string;
  90331. /** @hidden */
  90332. readonly _isLight: boolean;
  90333. /**
  90334. * Converts the light information to a readable string for debug purpose.
  90335. * @param fullDetails Supports for multiple levels of logging within scene loading
  90336. * @returns the human readable light info
  90337. */
  90338. toString(fullDetails?: boolean): string;
  90339. /** @hidden */
  90340. protected _syncParentEnabledState(): void;
  90341. /**
  90342. * Set the enabled state of this node.
  90343. * @param value - the new enabled state
  90344. */
  90345. setEnabled(value: boolean): void;
  90346. /**
  90347. * Returns the Light associated shadow generator if any.
  90348. * @return the associated shadow generator.
  90349. */
  90350. getShadowGenerator(): Nullable<IShadowGenerator>;
  90351. /**
  90352. * Returns a Vector3, the absolute light position in the World.
  90353. * @returns the world space position of the light
  90354. */
  90355. getAbsolutePosition(): Vector3;
  90356. /**
  90357. * Specifies if the light will affect the passed mesh.
  90358. * @param mesh The mesh to test against the light
  90359. * @return true the mesh is affected otherwise, false.
  90360. */
  90361. canAffectMesh(mesh: AbstractMesh): boolean;
  90362. /**
  90363. * Sort function to order lights for rendering.
  90364. * @param a First Light object to compare to second.
  90365. * @param b Second Light object to compare first.
  90366. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90367. */
  90368. static CompareLightsPriority(a: Light, b: Light): number;
  90369. /**
  90370. * Releases resources associated with this node.
  90371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90373. */
  90374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90375. /**
  90376. * Returns the light type ID (integer).
  90377. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90378. */
  90379. getTypeID(): number;
  90380. /**
  90381. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90382. * @returns the scaled intensity in intensity mode unit
  90383. */
  90384. getScaledIntensity(): number;
  90385. /**
  90386. * Returns a new Light object, named "name", from the current one.
  90387. * @param name The name of the cloned light
  90388. * @returns the new created light
  90389. */
  90390. clone(name: string): Nullable<Light>;
  90391. /**
  90392. * Serializes the current light into a Serialization object.
  90393. * @returns the serialized object.
  90394. */
  90395. serialize(): any;
  90396. /**
  90397. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90398. * This new light is named "name" and added to the passed scene.
  90399. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90400. * @param name The friendly name of the light
  90401. * @param scene The scene the new light will belong to
  90402. * @returns the constructor function
  90403. */
  90404. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90405. /**
  90406. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90407. * @param parsedLight The JSON representation of the light
  90408. * @param scene The scene to create the parsed light in
  90409. * @returns the created light after parsing
  90410. */
  90411. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90412. private _hookArrayForExcluded;
  90413. private _hookArrayForIncludedOnly;
  90414. private _resyncMeshes;
  90415. /**
  90416. * Forces the meshes to update their light related information in their rendering used effects
  90417. * @hidden Internal Use Only
  90418. */
  90419. _markMeshesAsLightDirty(): void;
  90420. /**
  90421. * Recomputes the cached photometric scale if needed.
  90422. */
  90423. private _computePhotometricScale;
  90424. /**
  90425. * Returns the Photometric Scale according to the light type and intensity mode.
  90426. */
  90427. private _getPhotometricScale;
  90428. /**
  90429. * Reorder the light in the scene according to their defined priority.
  90430. * @hidden Internal Use Only
  90431. */
  90432. _reorderLightsInScene(): void;
  90433. /**
  90434. * Prepares the list of defines specific to the light type.
  90435. * @param defines the list of defines
  90436. * @param lightIndex defines the index of the light for the effect
  90437. */
  90438. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90439. }
  90440. }
  90441. declare module BABYLON {
  90442. /**
  90443. * Interface used to define Action
  90444. */
  90445. export interface IAction {
  90446. /**
  90447. * Trigger for the action
  90448. */
  90449. trigger: number;
  90450. /** Options of the trigger */
  90451. triggerOptions: any;
  90452. /**
  90453. * Gets the trigger parameters
  90454. * @returns the trigger parameters
  90455. */
  90456. getTriggerParameter(): any;
  90457. /**
  90458. * Internal only - executes current action event
  90459. * @hidden
  90460. */
  90461. _executeCurrent(evt?: ActionEvent): void;
  90462. /**
  90463. * Serialize placeholder for child classes
  90464. * @param parent of child
  90465. * @returns the serialized object
  90466. */
  90467. serialize(parent: any): any;
  90468. /**
  90469. * Internal only
  90470. * @hidden
  90471. */
  90472. _prepare(): void;
  90473. /**
  90474. * Internal only - manager for action
  90475. * @hidden
  90476. */
  90477. _actionManager: AbstractActionManager;
  90478. /**
  90479. * Adds action to chain of actions, may be a DoNothingAction
  90480. * @param action defines the next action to execute
  90481. * @returns The action passed in
  90482. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90483. */
  90484. then(action: IAction): IAction;
  90485. }
  90486. /**
  90487. * The action to be carried out following a trigger
  90488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90489. */
  90490. export class Action implements IAction {
  90491. /** the trigger, with or without parameters, for the action */
  90492. triggerOptions: any;
  90493. /**
  90494. * Trigger for the action
  90495. */
  90496. trigger: number;
  90497. /**
  90498. * Internal only - manager for action
  90499. * @hidden
  90500. */
  90501. _actionManager: ActionManager;
  90502. private _nextActiveAction;
  90503. private _child;
  90504. private _condition?;
  90505. private _triggerParameter;
  90506. /**
  90507. * An event triggered prior to action being executed.
  90508. */
  90509. onBeforeExecuteObservable: Observable<Action>;
  90510. /**
  90511. * Creates a new Action
  90512. * @param triggerOptions the trigger, with or without parameters, for the action
  90513. * @param condition an optional determinant of action
  90514. */
  90515. constructor(
  90516. /** the trigger, with or without parameters, for the action */
  90517. triggerOptions: any, condition?: Condition);
  90518. /**
  90519. * Internal only
  90520. * @hidden
  90521. */
  90522. _prepare(): void;
  90523. /**
  90524. * Gets the trigger parameters
  90525. * @returns the trigger parameters
  90526. */
  90527. getTriggerParameter(): any;
  90528. /**
  90529. * Internal only - executes current action event
  90530. * @hidden
  90531. */
  90532. _executeCurrent(evt?: ActionEvent): void;
  90533. /**
  90534. * Execute placeholder for child classes
  90535. * @param evt optional action event
  90536. */
  90537. execute(evt?: ActionEvent): void;
  90538. /**
  90539. * Skips to next active action
  90540. */
  90541. skipToNextActiveAction(): void;
  90542. /**
  90543. * Adds action to chain of actions, may be a DoNothingAction
  90544. * @param action defines the next action to execute
  90545. * @returns The action passed in
  90546. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90547. */
  90548. then(action: Action): Action;
  90549. /**
  90550. * Internal only
  90551. * @hidden
  90552. */
  90553. _getProperty(propertyPath: string): string;
  90554. /**
  90555. * Internal only
  90556. * @hidden
  90557. */
  90558. _getEffectiveTarget(target: any, propertyPath: string): any;
  90559. /**
  90560. * Serialize placeholder for child classes
  90561. * @param parent of child
  90562. * @returns the serialized object
  90563. */
  90564. serialize(parent: any): any;
  90565. /**
  90566. * Internal only called by serialize
  90567. * @hidden
  90568. */
  90569. protected _serialize(serializedAction: any, parent?: any): any;
  90570. /**
  90571. * Internal only
  90572. * @hidden
  90573. */
  90574. static _SerializeValueAsString: (value: any) => string;
  90575. /**
  90576. * Internal only
  90577. * @hidden
  90578. */
  90579. static _GetTargetProperty: (target: Node | Scene) => {
  90580. name: string;
  90581. targetType: string;
  90582. value: string;
  90583. };
  90584. }
  90585. }
  90586. declare module BABYLON {
  90587. /**
  90588. * A Condition applied to an Action
  90589. */
  90590. export class Condition {
  90591. /**
  90592. * Internal only - manager for action
  90593. * @hidden
  90594. */
  90595. _actionManager: ActionManager;
  90596. /**
  90597. * Internal only
  90598. * @hidden
  90599. */
  90600. _evaluationId: number;
  90601. /**
  90602. * Internal only
  90603. * @hidden
  90604. */
  90605. _currentResult: boolean;
  90606. /**
  90607. * Creates a new Condition
  90608. * @param actionManager the manager of the action the condition is applied to
  90609. */
  90610. constructor(actionManager: ActionManager);
  90611. /**
  90612. * Check if the current condition is valid
  90613. * @returns a boolean
  90614. */
  90615. isValid(): boolean;
  90616. /**
  90617. * Internal only
  90618. * @hidden
  90619. */
  90620. _getProperty(propertyPath: string): string;
  90621. /**
  90622. * Internal only
  90623. * @hidden
  90624. */
  90625. _getEffectiveTarget(target: any, propertyPath: string): any;
  90626. /**
  90627. * Serialize placeholder for child classes
  90628. * @returns the serialized object
  90629. */
  90630. serialize(): any;
  90631. /**
  90632. * Internal only
  90633. * @hidden
  90634. */
  90635. protected _serialize(serializedCondition: any): any;
  90636. }
  90637. /**
  90638. * Defines specific conditional operators as extensions of Condition
  90639. */
  90640. export class ValueCondition extends Condition {
  90641. /** path to specify the property of the target the conditional operator uses */
  90642. propertyPath: string;
  90643. /** the value compared by the conditional operator against the current value of the property */
  90644. value: any;
  90645. /** the conditional operator, default ValueCondition.IsEqual */
  90646. operator: number;
  90647. /**
  90648. * Internal only
  90649. * @hidden
  90650. */
  90651. private static _IsEqual;
  90652. /**
  90653. * Internal only
  90654. * @hidden
  90655. */
  90656. private static _IsDifferent;
  90657. /**
  90658. * Internal only
  90659. * @hidden
  90660. */
  90661. private static _IsGreater;
  90662. /**
  90663. * Internal only
  90664. * @hidden
  90665. */
  90666. private static _IsLesser;
  90667. /**
  90668. * returns the number for IsEqual
  90669. */
  90670. static get IsEqual(): number;
  90671. /**
  90672. * Returns the number for IsDifferent
  90673. */
  90674. static get IsDifferent(): number;
  90675. /**
  90676. * Returns the number for IsGreater
  90677. */
  90678. static get IsGreater(): number;
  90679. /**
  90680. * Returns the number for IsLesser
  90681. */
  90682. static get IsLesser(): number;
  90683. /**
  90684. * Internal only The action manager for the condition
  90685. * @hidden
  90686. */
  90687. _actionManager: ActionManager;
  90688. /**
  90689. * Internal only
  90690. * @hidden
  90691. */
  90692. private _target;
  90693. /**
  90694. * Internal only
  90695. * @hidden
  90696. */
  90697. private _effectiveTarget;
  90698. /**
  90699. * Internal only
  90700. * @hidden
  90701. */
  90702. private _property;
  90703. /**
  90704. * Creates a new ValueCondition
  90705. * @param actionManager manager for the action the condition applies to
  90706. * @param target for the action
  90707. * @param propertyPath path to specify the property of the target the conditional operator uses
  90708. * @param value the value compared by the conditional operator against the current value of the property
  90709. * @param operator the conditional operator, default ValueCondition.IsEqual
  90710. */
  90711. constructor(actionManager: ActionManager, target: any,
  90712. /** path to specify the property of the target the conditional operator uses */
  90713. propertyPath: string,
  90714. /** the value compared by the conditional operator against the current value of the property */
  90715. value: any,
  90716. /** the conditional operator, default ValueCondition.IsEqual */
  90717. operator?: number);
  90718. /**
  90719. * Compares the given value with the property value for the specified conditional operator
  90720. * @returns the result of the comparison
  90721. */
  90722. isValid(): boolean;
  90723. /**
  90724. * Serialize the ValueCondition into a JSON compatible object
  90725. * @returns serialization object
  90726. */
  90727. serialize(): any;
  90728. /**
  90729. * Gets the name of the conditional operator for the ValueCondition
  90730. * @param operator the conditional operator
  90731. * @returns the name
  90732. */
  90733. static GetOperatorName(operator: number): string;
  90734. }
  90735. /**
  90736. * Defines a predicate condition as an extension of Condition
  90737. */
  90738. export class PredicateCondition extends Condition {
  90739. /** defines the predicate function used to validate the condition */
  90740. predicate: () => boolean;
  90741. /**
  90742. * Internal only - manager for action
  90743. * @hidden
  90744. */
  90745. _actionManager: ActionManager;
  90746. /**
  90747. * Creates a new PredicateCondition
  90748. * @param actionManager manager for the action the condition applies to
  90749. * @param predicate defines the predicate function used to validate the condition
  90750. */
  90751. constructor(actionManager: ActionManager,
  90752. /** defines the predicate function used to validate the condition */
  90753. predicate: () => boolean);
  90754. /**
  90755. * @returns the validity of the predicate condition
  90756. */
  90757. isValid(): boolean;
  90758. }
  90759. /**
  90760. * Defines a state condition as an extension of Condition
  90761. */
  90762. export class StateCondition extends Condition {
  90763. /** Value to compare with target state */
  90764. value: string;
  90765. /**
  90766. * Internal only - manager for action
  90767. * @hidden
  90768. */
  90769. _actionManager: ActionManager;
  90770. /**
  90771. * Internal only
  90772. * @hidden
  90773. */
  90774. private _target;
  90775. /**
  90776. * Creates a new StateCondition
  90777. * @param actionManager manager for the action the condition applies to
  90778. * @param target of the condition
  90779. * @param value to compare with target state
  90780. */
  90781. constructor(actionManager: ActionManager, target: any,
  90782. /** Value to compare with target state */
  90783. value: string);
  90784. /**
  90785. * Gets a boolean indicating if the current condition is met
  90786. * @returns the validity of the state
  90787. */
  90788. isValid(): boolean;
  90789. /**
  90790. * Serialize the StateCondition into a JSON compatible object
  90791. * @returns serialization object
  90792. */
  90793. serialize(): any;
  90794. }
  90795. }
  90796. declare module BABYLON {
  90797. /**
  90798. * This defines an action responsible to toggle a boolean once triggered.
  90799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90800. */
  90801. export class SwitchBooleanAction extends Action {
  90802. /**
  90803. * The path to the boolean property in the target object
  90804. */
  90805. propertyPath: string;
  90806. private _target;
  90807. private _effectiveTarget;
  90808. private _property;
  90809. /**
  90810. * Instantiate the action
  90811. * @param triggerOptions defines the trigger options
  90812. * @param target defines the object containing the boolean
  90813. * @param propertyPath defines the path to the boolean property in the target object
  90814. * @param condition defines the trigger related conditions
  90815. */
  90816. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90817. /** @hidden */
  90818. _prepare(): void;
  90819. /**
  90820. * Execute the action toggle the boolean value.
  90821. */
  90822. execute(): void;
  90823. /**
  90824. * Serializes the actions and its related information.
  90825. * @param parent defines the object to serialize in
  90826. * @returns the serialized object
  90827. */
  90828. serialize(parent: any): any;
  90829. }
  90830. /**
  90831. * This defines an action responsible to set a the state field of the target
  90832. * to a desired value once triggered.
  90833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90834. */
  90835. export class SetStateAction extends Action {
  90836. /**
  90837. * The value to store in the state field.
  90838. */
  90839. value: string;
  90840. private _target;
  90841. /**
  90842. * Instantiate the action
  90843. * @param triggerOptions defines the trigger options
  90844. * @param target defines the object containing the state property
  90845. * @param value defines the value to store in the state field
  90846. * @param condition defines the trigger related conditions
  90847. */
  90848. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90849. /**
  90850. * Execute the action and store the value on the target state property.
  90851. */
  90852. execute(): void;
  90853. /**
  90854. * Serializes the actions and its related information.
  90855. * @param parent defines the object to serialize in
  90856. * @returns the serialized object
  90857. */
  90858. serialize(parent: any): any;
  90859. }
  90860. /**
  90861. * This defines an action responsible to set a property of the target
  90862. * to a desired value once triggered.
  90863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90864. */
  90865. export class SetValueAction extends Action {
  90866. /**
  90867. * The path of the property to set in the target.
  90868. */
  90869. propertyPath: string;
  90870. /**
  90871. * The value to set in the property
  90872. */
  90873. value: any;
  90874. private _target;
  90875. private _effectiveTarget;
  90876. private _property;
  90877. /**
  90878. * Instantiate the action
  90879. * @param triggerOptions defines the trigger options
  90880. * @param target defines the object containing the property
  90881. * @param propertyPath defines the path of the property to set in the target
  90882. * @param value defines the value to set in the property
  90883. * @param condition defines the trigger related conditions
  90884. */
  90885. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90886. /** @hidden */
  90887. _prepare(): void;
  90888. /**
  90889. * Execute the action and set the targetted property to the desired value.
  90890. */
  90891. execute(): void;
  90892. /**
  90893. * Serializes the actions and its related information.
  90894. * @param parent defines the object to serialize in
  90895. * @returns the serialized object
  90896. */
  90897. serialize(parent: any): any;
  90898. }
  90899. /**
  90900. * This defines an action responsible to increment the target value
  90901. * to a desired value once triggered.
  90902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90903. */
  90904. export class IncrementValueAction extends Action {
  90905. /**
  90906. * The path of the property to increment in the target.
  90907. */
  90908. propertyPath: string;
  90909. /**
  90910. * The value we should increment the property by.
  90911. */
  90912. value: any;
  90913. private _target;
  90914. private _effectiveTarget;
  90915. private _property;
  90916. /**
  90917. * Instantiate the action
  90918. * @param triggerOptions defines the trigger options
  90919. * @param target defines the object containing the property
  90920. * @param propertyPath defines the path of the property to increment in the target
  90921. * @param value defines the value value we should increment the property by
  90922. * @param condition defines the trigger related conditions
  90923. */
  90924. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90925. /** @hidden */
  90926. _prepare(): void;
  90927. /**
  90928. * Execute the action and increment the target of the value amount.
  90929. */
  90930. execute(): void;
  90931. /**
  90932. * Serializes the actions and its related information.
  90933. * @param parent defines the object to serialize in
  90934. * @returns the serialized object
  90935. */
  90936. serialize(parent: any): any;
  90937. }
  90938. /**
  90939. * This defines an action responsible to start an animation once triggered.
  90940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90941. */
  90942. export class PlayAnimationAction extends Action {
  90943. /**
  90944. * Where the animation should start (animation frame)
  90945. */
  90946. from: number;
  90947. /**
  90948. * Where the animation should stop (animation frame)
  90949. */
  90950. to: number;
  90951. /**
  90952. * Define if the animation should loop or stop after the first play.
  90953. */
  90954. loop?: boolean;
  90955. private _target;
  90956. /**
  90957. * Instantiate the action
  90958. * @param triggerOptions defines the trigger options
  90959. * @param target defines the target animation or animation name
  90960. * @param from defines from where the animation should start (animation frame)
  90961. * @param end defines where the animation should stop (animation frame)
  90962. * @param loop defines if the animation should loop or stop after the first play
  90963. * @param condition defines the trigger related conditions
  90964. */
  90965. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90966. /** @hidden */
  90967. _prepare(): void;
  90968. /**
  90969. * Execute the action and play the animation.
  90970. */
  90971. execute(): void;
  90972. /**
  90973. * Serializes the actions and its related information.
  90974. * @param parent defines the object to serialize in
  90975. * @returns the serialized object
  90976. */
  90977. serialize(parent: any): any;
  90978. }
  90979. /**
  90980. * This defines an action responsible to stop an animation once triggered.
  90981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90982. */
  90983. export class StopAnimationAction extends Action {
  90984. private _target;
  90985. /**
  90986. * Instantiate the action
  90987. * @param triggerOptions defines the trigger options
  90988. * @param target defines the target animation or animation name
  90989. * @param condition defines the trigger related conditions
  90990. */
  90991. constructor(triggerOptions: any, target: any, condition?: Condition);
  90992. /** @hidden */
  90993. _prepare(): void;
  90994. /**
  90995. * Execute the action and stop the animation.
  90996. */
  90997. execute(): void;
  90998. /**
  90999. * Serializes the actions and its related information.
  91000. * @param parent defines the object to serialize in
  91001. * @returns the serialized object
  91002. */
  91003. serialize(parent: any): any;
  91004. }
  91005. /**
  91006. * This defines an action responsible that does nothing once triggered.
  91007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91008. */
  91009. export class DoNothingAction extends Action {
  91010. /**
  91011. * Instantiate the action
  91012. * @param triggerOptions defines the trigger options
  91013. * @param condition defines the trigger related conditions
  91014. */
  91015. constructor(triggerOptions?: any, condition?: Condition);
  91016. /**
  91017. * Execute the action and do nothing.
  91018. */
  91019. execute(): void;
  91020. /**
  91021. * Serializes the actions and its related information.
  91022. * @param parent defines the object to serialize in
  91023. * @returns the serialized object
  91024. */
  91025. serialize(parent: any): any;
  91026. }
  91027. /**
  91028. * This defines an action responsible to trigger several actions once triggered.
  91029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91030. */
  91031. export class CombineAction extends Action {
  91032. /**
  91033. * The list of aggregated animations to run.
  91034. */
  91035. children: Action[];
  91036. /**
  91037. * Instantiate the action
  91038. * @param triggerOptions defines the trigger options
  91039. * @param children defines the list of aggregated animations to run
  91040. * @param condition defines the trigger related conditions
  91041. */
  91042. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91043. /** @hidden */
  91044. _prepare(): void;
  91045. /**
  91046. * Execute the action and executes all the aggregated actions.
  91047. */
  91048. execute(evt: ActionEvent): void;
  91049. /**
  91050. * Serializes the actions and its related information.
  91051. * @param parent defines the object to serialize in
  91052. * @returns the serialized object
  91053. */
  91054. serialize(parent: any): any;
  91055. }
  91056. /**
  91057. * This defines an action responsible to run code (external event) once triggered.
  91058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91059. */
  91060. export class ExecuteCodeAction extends Action {
  91061. /**
  91062. * The callback function to run.
  91063. */
  91064. func: (evt: ActionEvent) => void;
  91065. /**
  91066. * Instantiate the action
  91067. * @param triggerOptions defines the trigger options
  91068. * @param func defines the callback function to run
  91069. * @param condition defines the trigger related conditions
  91070. */
  91071. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91072. /**
  91073. * Execute the action and run the attached code.
  91074. */
  91075. execute(evt: ActionEvent): void;
  91076. }
  91077. /**
  91078. * This defines an action responsible to set the parent property of the target once triggered.
  91079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91080. */
  91081. export class SetParentAction extends Action {
  91082. private _parent;
  91083. private _target;
  91084. /**
  91085. * Instantiate the action
  91086. * @param triggerOptions defines the trigger options
  91087. * @param target defines the target containing the parent property
  91088. * @param parent defines from where the animation should start (animation frame)
  91089. * @param condition defines the trigger related conditions
  91090. */
  91091. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91092. /** @hidden */
  91093. _prepare(): void;
  91094. /**
  91095. * Execute the action and set the parent property.
  91096. */
  91097. execute(): void;
  91098. /**
  91099. * Serializes the actions and its related information.
  91100. * @param parent defines the object to serialize in
  91101. * @returns the serialized object
  91102. */
  91103. serialize(parent: any): any;
  91104. }
  91105. }
  91106. declare module BABYLON {
  91107. /**
  91108. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91109. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91111. */
  91112. export class ActionManager extends AbstractActionManager {
  91113. /**
  91114. * Nothing
  91115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91116. */
  91117. static readonly NothingTrigger: number;
  91118. /**
  91119. * On pick
  91120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91121. */
  91122. static readonly OnPickTrigger: number;
  91123. /**
  91124. * On left pick
  91125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91126. */
  91127. static readonly OnLeftPickTrigger: number;
  91128. /**
  91129. * On right pick
  91130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91131. */
  91132. static readonly OnRightPickTrigger: number;
  91133. /**
  91134. * On center pick
  91135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91136. */
  91137. static readonly OnCenterPickTrigger: number;
  91138. /**
  91139. * On pick down
  91140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91141. */
  91142. static readonly OnPickDownTrigger: number;
  91143. /**
  91144. * On double pick
  91145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91146. */
  91147. static readonly OnDoublePickTrigger: number;
  91148. /**
  91149. * On pick up
  91150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91151. */
  91152. static readonly OnPickUpTrigger: number;
  91153. /**
  91154. * On pick out.
  91155. * This trigger will only be raised if you also declared a OnPickDown
  91156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91157. */
  91158. static readonly OnPickOutTrigger: number;
  91159. /**
  91160. * On long press
  91161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91162. */
  91163. static readonly OnLongPressTrigger: number;
  91164. /**
  91165. * On pointer over
  91166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91167. */
  91168. static readonly OnPointerOverTrigger: number;
  91169. /**
  91170. * On pointer out
  91171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91172. */
  91173. static readonly OnPointerOutTrigger: number;
  91174. /**
  91175. * On every frame
  91176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91177. */
  91178. static readonly OnEveryFrameTrigger: number;
  91179. /**
  91180. * On intersection enter
  91181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91182. */
  91183. static readonly OnIntersectionEnterTrigger: number;
  91184. /**
  91185. * On intersection exit
  91186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91187. */
  91188. static readonly OnIntersectionExitTrigger: number;
  91189. /**
  91190. * On key down
  91191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91192. */
  91193. static readonly OnKeyDownTrigger: number;
  91194. /**
  91195. * On key up
  91196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91197. */
  91198. static readonly OnKeyUpTrigger: number;
  91199. private _scene;
  91200. /**
  91201. * Creates a new action manager
  91202. * @param scene defines the hosting scene
  91203. */
  91204. constructor(scene: Scene);
  91205. /**
  91206. * Releases all associated resources
  91207. */
  91208. dispose(): void;
  91209. /**
  91210. * Gets hosting scene
  91211. * @returns the hosting scene
  91212. */
  91213. getScene(): Scene;
  91214. /**
  91215. * Does this action manager handles actions of any of the given triggers
  91216. * @param triggers defines the triggers to be tested
  91217. * @return a boolean indicating whether one (or more) of the triggers is handled
  91218. */
  91219. hasSpecificTriggers(triggers: number[]): boolean;
  91220. /**
  91221. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91222. * speed.
  91223. * @param triggerA defines the trigger to be tested
  91224. * @param triggerB defines the trigger to be tested
  91225. * @return a boolean indicating whether one (or more) of the triggers is handled
  91226. */
  91227. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91228. /**
  91229. * Does this action manager handles actions of a given trigger
  91230. * @param trigger defines the trigger to be tested
  91231. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91232. * @return whether the trigger is handled
  91233. */
  91234. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91235. /**
  91236. * Does this action manager has pointer triggers
  91237. */
  91238. get hasPointerTriggers(): boolean;
  91239. /**
  91240. * Does this action manager has pick triggers
  91241. */
  91242. get hasPickTriggers(): boolean;
  91243. /**
  91244. * Registers an action to this action manager
  91245. * @param action defines the action to be registered
  91246. * @return the action amended (prepared) after registration
  91247. */
  91248. registerAction(action: IAction): Nullable<IAction>;
  91249. /**
  91250. * Unregisters an action to this action manager
  91251. * @param action defines the action to be unregistered
  91252. * @return a boolean indicating whether the action has been unregistered
  91253. */
  91254. unregisterAction(action: IAction): Boolean;
  91255. /**
  91256. * Process a specific trigger
  91257. * @param trigger defines the trigger to process
  91258. * @param evt defines the event details to be processed
  91259. */
  91260. processTrigger(trigger: number, evt?: IActionEvent): void;
  91261. /** @hidden */
  91262. _getEffectiveTarget(target: any, propertyPath: string): any;
  91263. /** @hidden */
  91264. _getProperty(propertyPath: string): string;
  91265. /**
  91266. * Serialize this manager to a JSON object
  91267. * @param name defines the property name to store this manager
  91268. * @returns a JSON representation of this manager
  91269. */
  91270. serialize(name: string): any;
  91271. /**
  91272. * Creates a new ActionManager from a JSON data
  91273. * @param parsedActions defines the JSON data to read from
  91274. * @param object defines the hosting mesh
  91275. * @param scene defines the hosting scene
  91276. */
  91277. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91278. /**
  91279. * Get a trigger name by index
  91280. * @param trigger defines the trigger index
  91281. * @returns a trigger name
  91282. */
  91283. static GetTriggerName(trigger: number): string;
  91284. }
  91285. }
  91286. declare module BABYLON {
  91287. /**
  91288. * Class used to represent a sprite
  91289. * @see http://doc.babylonjs.com/babylon101/sprites
  91290. */
  91291. export class Sprite {
  91292. /** defines the name */
  91293. name: string;
  91294. /** Gets or sets the current world position */
  91295. position: Vector3;
  91296. /** Gets or sets the main color */
  91297. color: Color4;
  91298. /** Gets or sets the width */
  91299. width: number;
  91300. /** Gets or sets the height */
  91301. height: number;
  91302. /** Gets or sets rotation angle */
  91303. angle: number;
  91304. /** Gets or sets the cell index in the sprite sheet */
  91305. cellIndex: number;
  91306. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91307. cellRef: string;
  91308. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91309. invertU: number;
  91310. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91311. invertV: number;
  91312. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91313. disposeWhenFinishedAnimating: boolean;
  91314. /** Gets the list of attached animations */
  91315. animations: Animation[];
  91316. /** Gets or sets a boolean indicating if the sprite can be picked */
  91317. isPickable: boolean;
  91318. /**
  91319. * Gets or sets the associated action manager
  91320. */
  91321. actionManager: Nullable<ActionManager>;
  91322. private _animationStarted;
  91323. private _loopAnimation;
  91324. private _fromIndex;
  91325. private _toIndex;
  91326. private _delay;
  91327. private _direction;
  91328. private _manager;
  91329. private _time;
  91330. private _onAnimationEnd;
  91331. /**
  91332. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91333. */
  91334. isVisible: boolean;
  91335. /**
  91336. * Gets or sets the sprite size
  91337. */
  91338. get size(): number;
  91339. set size(value: number);
  91340. /**
  91341. * Creates a new Sprite
  91342. * @param name defines the name
  91343. * @param manager defines the manager
  91344. */
  91345. constructor(
  91346. /** defines the name */
  91347. name: string, manager: ISpriteManager);
  91348. /**
  91349. * Starts an animation
  91350. * @param from defines the initial key
  91351. * @param to defines the end key
  91352. * @param loop defines if the animation must loop
  91353. * @param delay defines the start delay (in ms)
  91354. * @param onAnimationEnd defines a callback to call when animation ends
  91355. */
  91356. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91357. /** Stops current animation (if any) */
  91358. stopAnimation(): void;
  91359. /** @hidden */
  91360. _animate(deltaTime: number): void;
  91361. /** Release associated resources */
  91362. dispose(): void;
  91363. }
  91364. }
  91365. declare module BABYLON {
  91366. /**
  91367. * Information about the result of picking within a scene
  91368. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91369. */
  91370. export class PickingInfo {
  91371. /** @hidden */
  91372. _pickingUnavailable: boolean;
  91373. /**
  91374. * If the pick collided with an object
  91375. */
  91376. hit: boolean;
  91377. /**
  91378. * Distance away where the pick collided
  91379. */
  91380. distance: number;
  91381. /**
  91382. * The location of pick collision
  91383. */
  91384. pickedPoint: Nullable<Vector3>;
  91385. /**
  91386. * The mesh corresponding the the pick collision
  91387. */
  91388. pickedMesh: Nullable<AbstractMesh>;
  91389. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91390. bu: number;
  91391. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91392. bv: number;
  91393. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91394. faceId: number;
  91395. /** Id of the the submesh that was picked */
  91396. subMeshId: number;
  91397. /** If a sprite was picked, this will be the sprite the pick collided with */
  91398. pickedSprite: Nullable<Sprite>;
  91399. /**
  91400. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91401. */
  91402. originMesh: Nullable<AbstractMesh>;
  91403. /**
  91404. * The ray that was used to perform the picking.
  91405. */
  91406. ray: Nullable<Ray>;
  91407. /**
  91408. * Gets the normal correspodning to the face the pick collided with
  91409. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91410. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91411. * @returns The normal correspodning to the face the pick collided with
  91412. */
  91413. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91414. /**
  91415. * Gets the texture coordinates of where the pick occured
  91416. * @returns the vector containing the coordnates of the texture
  91417. */
  91418. getTextureCoordinates(): Nullable<Vector2>;
  91419. }
  91420. }
  91421. declare module BABYLON {
  91422. /**
  91423. * Gather the list of pointer event types as constants.
  91424. */
  91425. export class PointerEventTypes {
  91426. /**
  91427. * 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.
  91428. */
  91429. static readonly POINTERDOWN: number;
  91430. /**
  91431. * The pointerup event is fired when a pointer is no longer active.
  91432. */
  91433. static readonly POINTERUP: number;
  91434. /**
  91435. * The pointermove event is fired when a pointer changes coordinates.
  91436. */
  91437. static readonly POINTERMOVE: number;
  91438. /**
  91439. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91440. */
  91441. static readonly POINTERWHEEL: number;
  91442. /**
  91443. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91444. */
  91445. static readonly POINTERPICK: number;
  91446. /**
  91447. * The pointertap event is fired when a the object has been touched and released without drag.
  91448. */
  91449. static readonly POINTERTAP: number;
  91450. /**
  91451. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91452. */
  91453. static readonly POINTERDOUBLETAP: number;
  91454. }
  91455. /**
  91456. * Base class of pointer info types.
  91457. */
  91458. export class PointerInfoBase {
  91459. /**
  91460. * Defines the type of event (PointerEventTypes)
  91461. */
  91462. type: number;
  91463. /**
  91464. * Defines the related dom event
  91465. */
  91466. event: PointerEvent | MouseWheelEvent;
  91467. /**
  91468. * Instantiates the base class of pointers info.
  91469. * @param type Defines the type of event (PointerEventTypes)
  91470. * @param event Defines the related dom event
  91471. */
  91472. constructor(
  91473. /**
  91474. * Defines the type of event (PointerEventTypes)
  91475. */
  91476. type: number,
  91477. /**
  91478. * Defines the related dom event
  91479. */
  91480. event: PointerEvent | MouseWheelEvent);
  91481. }
  91482. /**
  91483. * This class is used to store pointer related info for the onPrePointerObservable event.
  91484. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91485. */
  91486. export class PointerInfoPre extends PointerInfoBase {
  91487. /**
  91488. * Ray from a pointer if availible (eg. 6dof controller)
  91489. */
  91490. ray: Nullable<Ray>;
  91491. /**
  91492. * Defines the local position of the pointer on the canvas.
  91493. */
  91494. localPosition: Vector2;
  91495. /**
  91496. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91497. */
  91498. skipOnPointerObservable: boolean;
  91499. /**
  91500. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91501. * @param type Defines the type of event (PointerEventTypes)
  91502. * @param event Defines the related dom event
  91503. * @param localX Defines the local x coordinates of the pointer when the event occured
  91504. * @param localY Defines the local y coordinates of the pointer when the event occured
  91505. */
  91506. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91507. }
  91508. /**
  91509. * This type contains all the data related to a pointer event in Babylon.js.
  91510. * 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.
  91511. */
  91512. export class PointerInfo extends PointerInfoBase {
  91513. /**
  91514. * Defines the picking info associated to the info (if any)\
  91515. */
  91516. pickInfo: Nullable<PickingInfo>;
  91517. /**
  91518. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91519. * @param type Defines the type of event (PointerEventTypes)
  91520. * @param event Defines the related dom event
  91521. * @param pickInfo Defines the picking info associated to the info (if any)\
  91522. */
  91523. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91524. /**
  91525. * Defines the picking info associated to the info (if any)\
  91526. */
  91527. pickInfo: Nullable<PickingInfo>);
  91528. }
  91529. /**
  91530. * Data relating to a touch event on the screen.
  91531. */
  91532. export interface PointerTouch {
  91533. /**
  91534. * X coordinate of touch.
  91535. */
  91536. x: number;
  91537. /**
  91538. * Y coordinate of touch.
  91539. */
  91540. y: number;
  91541. /**
  91542. * Id of touch. Unique for each finger.
  91543. */
  91544. pointerId: number;
  91545. /**
  91546. * Event type passed from DOM.
  91547. */
  91548. type: any;
  91549. }
  91550. }
  91551. declare module BABYLON {
  91552. /**
  91553. * Manage the mouse inputs to control the movement of a free camera.
  91554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91555. */
  91556. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91557. /**
  91558. * Define if touch is enabled in the mouse input
  91559. */
  91560. touchEnabled: boolean;
  91561. /**
  91562. * Defines the camera the input is attached to.
  91563. */
  91564. camera: FreeCamera;
  91565. /**
  91566. * Defines the buttons associated with the input to handle camera move.
  91567. */
  91568. buttons: number[];
  91569. /**
  91570. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91571. */
  91572. angularSensibility: number;
  91573. private _pointerInput;
  91574. private _onMouseMove;
  91575. private _observer;
  91576. private previousPosition;
  91577. /**
  91578. * Observable for when a pointer move event occurs containing the move offset
  91579. */
  91580. onPointerMovedObservable: Observable<{
  91581. offsetX: number;
  91582. offsetY: number;
  91583. }>;
  91584. /**
  91585. * @hidden
  91586. * If the camera should be rotated automatically based on pointer movement
  91587. */
  91588. _allowCameraRotation: boolean;
  91589. /**
  91590. * Manage the mouse inputs to control the movement of a free camera.
  91591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91592. * @param touchEnabled Defines if touch is enabled or not
  91593. */
  91594. constructor(
  91595. /**
  91596. * Define if touch is enabled in the mouse input
  91597. */
  91598. touchEnabled?: boolean);
  91599. /**
  91600. * Attach the input controls to a specific dom element to get the input from.
  91601. * @param element Defines the element the controls should be listened from
  91602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91603. */
  91604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91605. /**
  91606. * Called on JS contextmenu event.
  91607. * Override this method to provide functionality.
  91608. */
  91609. protected onContextMenu(evt: PointerEvent): void;
  91610. /**
  91611. * Detach the current controls from the specified dom element.
  91612. * @param element Defines the element to stop listening the inputs from
  91613. */
  91614. detachControl(element: Nullable<HTMLElement>): void;
  91615. /**
  91616. * Gets the class name of the current intput.
  91617. * @returns the class name
  91618. */
  91619. getClassName(): string;
  91620. /**
  91621. * Get the friendly name associated with the input class.
  91622. * @returns the input friendly name
  91623. */
  91624. getSimpleName(): string;
  91625. }
  91626. }
  91627. declare module BABYLON {
  91628. /**
  91629. * Manage the touch inputs to control the movement of a free camera.
  91630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91631. */
  91632. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91633. /**
  91634. * Defines the camera the input is attached to.
  91635. */
  91636. camera: FreeCamera;
  91637. /**
  91638. * Defines the touch sensibility for rotation.
  91639. * The higher the faster.
  91640. */
  91641. touchAngularSensibility: number;
  91642. /**
  91643. * Defines the touch sensibility for move.
  91644. * The higher the faster.
  91645. */
  91646. touchMoveSensibility: number;
  91647. private _offsetX;
  91648. private _offsetY;
  91649. private _pointerPressed;
  91650. private _pointerInput;
  91651. private _observer;
  91652. private _onLostFocus;
  91653. /**
  91654. * Attach the input controls to a specific dom element to get the input from.
  91655. * @param element Defines the element the controls should be listened from
  91656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91657. */
  91658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91659. /**
  91660. * Detach the current controls from the specified dom element.
  91661. * @param element Defines the element to stop listening the inputs from
  91662. */
  91663. detachControl(element: Nullable<HTMLElement>): void;
  91664. /**
  91665. * Update the current camera state depending on the inputs that have been used this frame.
  91666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91667. */
  91668. checkInputs(): void;
  91669. /**
  91670. * Gets the class name of the current intput.
  91671. * @returns the class name
  91672. */
  91673. getClassName(): string;
  91674. /**
  91675. * Get the friendly name associated with the input class.
  91676. * @returns the input friendly name
  91677. */
  91678. getSimpleName(): string;
  91679. }
  91680. }
  91681. declare module BABYLON {
  91682. /**
  91683. * Default Inputs manager for the FreeCamera.
  91684. * It groups all the default supported inputs for ease of use.
  91685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91686. */
  91687. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91688. /**
  91689. * @hidden
  91690. */
  91691. _mouseInput: Nullable<FreeCameraMouseInput>;
  91692. /**
  91693. * Instantiates a new FreeCameraInputsManager.
  91694. * @param camera Defines the camera the inputs belong to
  91695. */
  91696. constructor(camera: FreeCamera);
  91697. /**
  91698. * Add keyboard input support to the input manager.
  91699. * @returns the current input manager
  91700. */
  91701. addKeyboard(): FreeCameraInputsManager;
  91702. /**
  91703. * Add mouse input support to the input manager.
  91704. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91705. * @returns the current input manager
  91706. */
  91707. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91708. /**
  91709. * Removes the mouse input support from the manager
  91710. * @returns the current input manager
  91711. */
  91712. removeMouse(): FreeCameraInputsManager;
  91713. /**
  91714. * Add touch input support to the input manager.
  91715. * @returns the current input manager
  91716. */
  91717. addTouch(): FreeCameraInputsManager;
  91718. /**
  91719. * Remove all attached input methods from a camera
  91720. */
  91721. clear(): void;
  91722. }
  91723. }
  91724. declare module BABYLON {
  91725. /**
  91726. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91727. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91728. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91729. */
  91730. export class FreeCamera extends TargetCamera {
  91731. /**
  91732. * Define the collision ellipsoid of the camera.
  91733. * This is helpful to simulate a camera body like the player body around the camera
  91734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91735. */
  91736. ellipsoid: Vector3;
  91737. /**
  91738. * Define an offset for the position of the ellipsoid around the camera.
  91739. * This can be helpful to determine the center of the body near the gravity center of the body
  91740. * instead of its head.
  91741. */
  91742. ellipsoidOffset: Vector3;
  91743. /**
  91744. * Enable or disable collisions of the camera with the rest of the scene objects.
  91745. */
  91746. checkCollisions: boolean;
  91747. /**
  91748. * Enable or disable gravity on the camera.
  91749. */
  91750. applyGravity: boolean;
  91751. /**
  91752. * Define the input manager associated to the camera.
  91753. */
  91754. inputs: FreeCameraInputsManager;
  91755. /**
  91756. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91757. * Higher values reduce sensitivity.
  91758. */
  91759. get angularSensibility(): number;
  91760. /**
  91761. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91762. * Higher values reduce sensitivity.
  91763. */
  91764. set angularSensibility(value: number);
  91765. /**
  91766. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91767. */
  91768. get keysUp(): number[];
  91769. set keysUp(value: number[]);
  91770. /**
  91771. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91772. */
  91773. get keysDown(): number[];
  91774. set keysDown(value: number[]);
  91775. /**
  91776. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91777. */
  91778. get keysLeft(): number[];
  91779. set keysLeft(value: number[]);
  91780. /**
  91781. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91782. */
  91783. get keysRight(): number[];
  91784. set keysRight(value: number[]);
  91785. /**
  91786. * Event raised when the camera collide with a mesh in the scene.
  91787. */
  91788. onCollide: (collidedMesh: AbstractMesh) => void;
  91789. private _collider;
  91790. private _needMoveForGravity;
  91791. private _oldPosition;
  91792. private _diffPosition;
  91793. private _newPosition;
  91794. /** @hidden */
  91795. _localDirection: Vector3;
  91796. /** @hidden */
  91797. _transformedDirection: Vector3;
  91798. /**
  91799. * Instantiates a Free Camera.
  91800. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91801. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91802. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91803. * @param name Define the name of the camera in the scene
  91804. * @param position Define the start position of the camera in the scene
  91805. * @param scene Define the scene the camera belongs to
  91806. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91807. */
  91808. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91809. /**
  91810. * Attached controls to the current camera.
  91811. * @param element Defines the element the controls should be listened from
  91812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91813. */
  91814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91815. /**
  91816. * Detach the current controls from the camera.
  91817. * The camera will stop reacting to inputs.
  91818. * @param element Defines the element to stop listening the inputs from
  91819. */
  91820. detachControl(element: HTMLElement): void;
  91821. private _collisionMask;
  91822. /**
  91823. * Define a collision mask to limit the list of object the camera can collide with
  91824. */
  91825. get collisionMask(): number;
  91826. set collisionMask(mask: number);
  91827. /** @hidden */
  91828. _collideWithWorld(displacement: Vector3): void;
  91829. private _onCollisionPositionChange;
  91830. /** @hidden */
  91831. _checkInputs(): void;
  91832. /** @hidden */
  91833. _decideIfNeedsToMove(): boolean;
  91834. /** @hidden */
  91835. _updatePosition(): void;
  91836. /**
  91837. * Destroy the camera and release the current resources hold by it.
  91838. */
  91839. dispose(): void;
  91840. /**
  91841. * Gets the current object class name.
  91842. * @return the class name
  91843. */
  91844. getClassName(): string;
  91845. }
  91846. }
  91847. declare module BABYLON {
  91848. /**
  91849. * Represents a gamepad control stick position
  91850. */
  91851. export class StickValues {
  91852. /**
  91853. * The x component of the control stick
  91854. */
  91855. x: number;
  91856. /**
  91857. * The y component of the control stick
  91858. */
  91859. y: number;
  91860. /**
  91861. * Initializes the gamepad x and y control stick values
  91862. * @param x The x component of the gamepad control stick value
  91863. * @param y The y component of the gamepad control stick value
  91864. */
  91865. constructor(
  91866. /**
  91867. * The x component of the control stick
  91868. */
  91869. x: number,
  91870. /**
  91871. * The y component of the control stick
  91872. */
  91873. y: number);
  91874. }
  91875. /**
  91876. * An interface which manages callbacks for gamepad button changes
  91877. */
  91878. export interface GamepadButtonChanges {
  91879. /**
  91880. * Called when a gamepad has been changed
  91881. */
  91882. changed: boolean;
  91883. /**
  91884. * Called when a gamepad press event has been triggered
  91885. */
  91886. pressChanged: boolean;
  91887. /**
  91888. * Called when a touch event has been triggered
  91889. */
  91890. touchChanged: boolean;
  91891. /**
  91892. * Called when a value has changed
  91893. */
  91894. valueChanged: boolean;
  91895. }
  91896. /**
  91897. * Represents a gamepad
  91898. */
  91899. export class Gamepad {
  91900. /**
  91901. * The id of the gamepad
  91902. */
  91903. id: string;
  91904. /**
  91905. * The index of the gamepad
  91906. */
  91907. index: number;
  91908. /**
  91909. * The browser gamepad
  91910. */
  91911. browserGamepad: any;
  91912. /**
  91913. * Specifies what type of gamepad this represents
  91914. */
  91915. type: number;
  91916. private _leftStick;
  91917. private _rightStick;
  91918. /** @hidden */
  91919. _isConnected: boolean;
  91920. private _leftStickAxisX;
  91921. private _leftStickAxisY;
  91922. private _rightStickAxisX;
  91923. private _rightStickAxisY;
  91924. /**
  91925. * Triggered when the left control stick has been changed
  91926. */
  91927. private _onleftstickchanged;
  91928. /**
  91929. * Triggered when the right control stick has been changed
  91930. */
  91931. private _onrightstickchanged;
  91932. /**
  91933. * Represents a gamepad controller
  91934. */
  91935. static GAMEPAD: number;
  91936. /**
  91937. * Represents a generic controller
  91938. */
  91939. static GENERIC: number;
  91940. /**
  91941. * Represents an XBox controller
  91942. */
  91943. static XBOX: number;
  91944. /**
  91945. * Represents a pose-enabled controller
  91946. */
  91947. static POSE_ENABLED: number;
  91948. /**
  91949. * Represents an Dual Shock controller
  91950. */
  91951. static DUALSHOCK: number;
  91952. /**
  91953. * Specifies whether the left control stick should be Y-inverted
  91954. */
  91955. protected _invertLeftStickY: boolean;
  91956. /**
  91957. * Specifies if the gamepad has been connected
  91958. */
  91959. get isConnected(): boolean;
  91960. /**
  91961. * Initializes the gamepad
  91962. * @param id The id of the gamepad
  91963. * @param index The index of the gamepad
  91964. * @param browserGamepad The browser gamepad
  91965. * @param leftStickX The x component of the left joystick
  91966. * @param leftStickY The y component of the left joystick
  91967. * @param rightStickX The x component of the right joystick
  91968. * @param rightStickY The y component of the right joystick
  91969. */
  91970. constructor(
  91971. /**
  91972. * The id of the gamepad
  91973. */
  91974. id: string,
  91975. /**
  91976. * The index of the gamepad
  91977. */
  91978. index: number,
  91979. /**
  91980. * The browser gamepad
  91981. */
  91982. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91983. /**
  91984. * Callback triggered when the left joystick has changed
  91985. * @param callback
  91986. */
  91987. onleftstickchanged(callback: (values: StickValues) => void): void;
  91988. /**
  91989. * Callback triggered when the right joystick has changed
  91990. * @param callback
  91991. */
  91992. onrightstickchanged(callback: (values: StickValues) => void): void;
  91993. /**
  91994. * Gets the left joystick
  91995. */
  91996. get leftStick(): StickValues;
  91997. /**
  91998. * Sets the left joystick values
  91999. */
  92000. set leftStick(newValues: StickValues);
  92001. /**
  92002. * Gets the right joystick
  92003. */
  92004. get rightStick(): StickValues;
  92005. /**
  92006. * Sets the right joystick value
  92007. */
  92008. set rightStick(newValues: StickValues);
  92009. /**
  92010. * Updates the gamepad joystick positions
  92011. */
  92012. update(): void;
  92013. /**
  92014. * Disposes the gamepad
  92015. */
  92016. dispose(): void;
  92017. }
  92018. /**
  92019. * Represents a generic gamepad
  92020. */
  92021. export class GenericPad extends Gamepad {
  92022. private _buttons;
  92023. private _onbuttondown;
  92024. private _onbuttonup;
  92025. /**
  92026. * Observable triggered when a button has been pressed
  92027. */
  92028. onButtonDownObservable: Observable<number>;
  92029. /**
  92030. * Observable triggered when a button has been released
  92031. */
  92032. onButtonUpObservable: Observable<number>;
  92033. /**
  92034. * Callback triggered when a button has been pressed
  92035. * @param callback Called when a button has been pressed
  92036. */
  92037. onbuttondown(callback: (buttonPressed: number) => void): void;
  92038. /**
  92039. * Callback triggered when a button has been released
  92040. * @param callback Called when a button has been released
  92041. */
  92042. onbuttonup(callback: (buttonReleased: number) => void): void;
  92043. /**
  92044. * Initializes the generic gamepad
  92045. * @param id The id of the generic gamepad
  92046. * @param index The index of the generic gamepad
  92047. * @param browserGamepad The browser gamepad
  92048. */
  92049. constructor(id: string, index: number, browserGamepad: any);
  92050. private _setButtonValue;
  92051. /**
  92052. * Updates the generic gamepad
  92053. */
  92054. update(): void;
  92055. /**
  92056. * Disposes the generic gamepad
  92057. */
  92058. dispose(): void;
  92059. }
  92060. }
  92061. declare module BABYLON {
  92062. /**
  92063. * Defines the types of pose enabled controllers that are supported
  92064. */
  92065. export enum PoseEnabledControllerType {
  92066. /**
  92067. * HTC Vive
  92068. */
  92069. VIVE = 0,
  92070. /**
  92071. * Oculus Rift
  92072. */
  92073. OCULUS = 1,
  92074. /**
  92075. * Windows mixed reality
  92076. */
  92077. WINDOWS = 2,
  92078. /**
  92079. * Samsung gear VR
  92080. */
  92081. GEAR_VR = 3,
  92082. /**
  92083. * Google Daydream
  92084. */
  92085. DAYDREAM = 4,
  92086. /**
  92087. * Generic
  92088. */
  92089. GENERIC = 5
  92090. }
  92091. /**
  92092. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92093. */
  92094. export interface MutableGamepadButton {
  92095. /**
  92096. * Value of the button/trigger
  92097. */
  92098. value: number;
  92099. /**
  92100. * If the button/trigger is currently touched
  92101. */
  92102. touched: boolean;
  92103. /**
  92104. * If the button/trigger is currently pressed
  92105. */
  92106. pressed: boolean;
  92107. }
  92108. /**
  92109. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92110. * @hidden
  92111. */
  92112. export interface ExtendedGamepadButton extends GamepadButton {
  92113. /**
  92114. * If the button/trigger is currently pressed
  92115. */
  92116. readonly pressed: boolean;
  92117. /**
  92118. * If the button/trigger is currently touched
  92119. */
  92120. readonly touched: boolean;
  92121. /**
  92122. * Value of the button/trigger
  92123. */
  92124. readonly value: number;
  92125. }
  92126. /** @hidden */
  92127. export interface _GamePadFactory {
  92128. /**
  92129. * Returns whether or not the current gamepad can be created for this type of controller.
  92130. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92131. * @returns true if it can be created, otherwise false
  92132. */
  92133. canCreate(gamepadInfo: any): boolean;
  92134. /**
  92135. * Creates a new instance of the Gamepad.
  92136. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92137. * @returns the new gamepad instance
  92138. */
  92139. create(gamepadInfo: any): Gamepad;
  92140. }
  92141. /**
  92142. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92143. */
  92144. export class PoseEnabledControllerHelper {
  92145. /** @hidden */
  92146. static _ControllerFactories: _GamePadFactory[];
  92147. /** @hidden */
  92148. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92149. /**
  92150. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92151. * @param vrGamepad the gamepad to initialized
  92152. * @returns a vr controller of the type the gamepad identified as
  92153. */
  92154. static InitiateController(vrGamepad: any): Gamepad;
  92155. }
  92156. /**
  92157. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92158. */
  92159. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92160. /**
  92161. * If the controller is used in a webXR session
  92162. */
  92163. isXR: boolean;
  92164. private _deviceRoomPosition;
  92165. private _deviceRoomRotationQuaternion;
  92166. /**
  92167. * The device position in babylon space
  92168. */
  92169. devicePosition: Vector3;
  92170. /**
  92171. * The device rotation in babylon space
  92172. */
  92173. deviceRotationQuaternion: Quaternion;
  92174. /**
  92175. * The scale factor of the device in babylon space
  92176. */
  92177. deviceScaleFactor: number;
  92178. /**
  92179. * (Likely devicePosition should be used instead) The device position in its room space
  92180. */
  92181. position: Vector3;
  92182. /**
  92183. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92184. */
  92185. rotationQuaternion: Quaternion;
  92186. /**
  92187. * The type of controller (Eg. Windows mixed reality)
  92188. */
  92189. controllerType: PoseEnabledControllerType;
  92190. protected _calculatedPosition: Vector3;
  92191. private _calculatedRotation;
  92192. /**
  92193. * The raw pose from the device
  92194. */
  92195. rawPose: DevicePose;
  92196. private _trackPosition;
  92197. private _maxRotationDistFromHeadset;
  92198. private _draggedRoomRotation;
  92199. /**
  92200. * @hidden
  92201. */
  92202. _disableTrackPosition(fixedPosition: Vector3): void;
  92203. /**
  92204. * Internal, the mesh attached to the controller
  92205. * @hidden
  92206. */
  92207. _mesh: Nullable<AbstractMesh>;
  92208. private _poseControlledCamera;
  92209. private _leftHandSystemQuaternion;
  92210. /**
  92211. * Internal, matrix used to convert room space to babylon space
  92212. * @hidden
  92213. */
  92214. _deviceToWorld: Matrix;
  92215. /**
  92216. * Node to be used when casting a ray from the controller
  92217. * @hidden
  92218. */
  92219. _pointingPoseNode: Nullable<TransformNode>;
  92220. /**
  92221. * Name of the child mesh that can be used to cast a ray from the controller
  92222. */
  92223. static readonly POINTING_POSE: string;
  92224. /**
  92225. * Creates a new PoseEnabledController from a gamepad
  92226. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92227. */
  92228. constructor(browserGamepad: any);
  92229. private _workingMatrix;
  92230. /**
  92231. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92232. */
  92233. update(): void;
  92234. /**
  92235. * Updates only the pose device and mesh without doing any button event checking
  92236. */
  92237. protected _updatePoseAndMesh(): void;
  92238. /**
  92239. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92240. * @param poseData raw pose fromthe device
  92241. */
  92242. updateFromDevice(poseData: DevicePose): void;
  92243. /**
  92244. * @hidden
  92245. */
  92246. _meshAttachedObservable: Observable<AbstractMesh>;
  92247. /**
  92248. * Attaches a mesh to the controller
  92249. * @param mesh the mesh to be attached
  92250. */
  92251. attachToMesh(mesh: AbstractMesh): void;
  92252. /**
  92253. * Attaches the controllers mesh to a camera
  92254. * @param camera the camera the mesh should be attached to
  92255. */
  92256. attachToPoseControlledCamera(camera: TargetCamera): void;
  92257. /**
  92258. * Disposes of the controller
  92259. */
  92260. dispose(): void;
  92261. /**
  92262. * The mesh that is attached to the controller
  92263. */
  92264. get mesh(): Nullable<AbstractMesh>;
  92265. /**
  92266. * Gets the ray of the controller in the direction the controller is pointing
  92267. * @param length the length the resulting ray should be
  92268. * @returns a ray in the direction the controller is pointing
  92269. */
  92270. getForwardRay(length?: number): Ray;
  92271. }
  92272. }
  92273. declare module BABYLON {
  92274. /**
  92275. * Defines the WebVRController object that represents controllers tracked in 3D space
  92276. */
  92277. export abstract class WebVRController extends PoseEnabledController {
  92278. /**
  92279. * Internal, the default controller model for the controller
  92280. */
  92281. protected _defaultModel: Nullable<AbstractMesh>;
  92282. /**
  92283. * Fired when the trigger state has changed
  92284. */
  92285. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92286. /**
  92287. * Fired when the main button state has changed
  92288. */
  92289. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92290. /**
  92291. * Fired when the secondary button state has changed
  92292. */
  92293. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92294. /**
  92295. * Fired when the pad state has changed
  92296. */
  92297. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92298. /**
  92299. * Fired when controllers stick values have changed
  92300. */
  92301. onPadValuesChangedObservable: Observable<StickValues>;
  92302. /**
  92303. * Array of button availible on the controller
  92304. */
  92305. protected _buttons: Array<MutableGamepadButton>;
  92306. private _onButtonStateChange;
  92307. /**
  92308. * Fired when a controller button's state has changed
  92309. * @param callback the callback containing the button that was modified
  92310. */
  92311. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92312. /**
  92313. * X and Y axis corresponding to the controllers joystick
  92314. */
  92315. pad: StickValues;
  92316. /**
  92317. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92318. */
  92319. hand: string;
  92320. /**
  92321. * The default controller model for the controller
  92322. */
  92323. get defaultModel(): Nullable<AbstractMesh>;
  92324. /**
  92325. * Creates a new WebVRController from a gamepad
  92326. * @param vrGamepad the gamepad that the WebVRController should be created from
  92327. */
  92328. constructor(vrGamepad: any);
  92329. /**
  92330. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92331. */
  92332. update(): void;
  92333. /**
  92334. * Function to be called when a button is modified
  92335. */
  92336. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92337. /**
  92338. * Loads a mesh and attaches it to the controller
  92339. * @param scene the scene the mesh should be added to
  92340. * @param meshLoaded callback for when the mesh has been loaded
  92341. */
  92342. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92343. private _setButtonValue;
  92344. private _changes;
  92345. private _checkChanges;
  92346. /**
  92347. * Disposes of th webVRCOntroller
  92348. */
  92349. dispose(): void;
  92350. }
  92351. }
  92352. declare module BABYLON {
  92353. /**
  92354. * The HemisphericLight simulates the ambient environment light,
  92355. * so the passed direction is the light reflection direction, not the incoming direction.
  92356. */
  92357. export class HemisphericLight extends Light {
  92358. /**
  92359. * The groundColor is the light in the opposite direction to the one specified during creation.
  92360. * 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.
  92361. */
  92362. groundColor: Color3;
  92363. /**
  92364. * The light reflection direction, not the incoming direction.
  92365. */
  92366. direction: Vector3;
  92367. /**
  92368. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92369. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92370. * The HemisphericLight can't cast shadows.
  92371. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92372. * @param name The friendly name of the light
  92373. * @param direction The direction of the light reflection
  92374. * @param scene The scene the light belongs to
  92375. */
  92376. constructor(name: string, direction: Vector3, scene: Scene);
  92377. protected _buildUniformLayout(): void;
  92378. /**
  92379. * Returns the string "HemisphericLight".
  92380. * @return The class name
  92381. */
  92382. getClassName(): string;
  92383. /**
  92384. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92385. * Returns the updated direction.
  92386. * @param target The target the direction should point to
  92387. * @return The computed direction
  92388. */
  92389. setDirectionToTarget(target: Vector3): Vector3;
  92390. /**
  92391. * Returns the shadow generator associated to the light.
  92392. * @returns Always null for hemispheric lights because it does not support shadows.
  92393. */
  92394. getShadowGenerator(): Nullable<IShadowGenerator>;
  92395. /**
  92396. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92397. * @param effect The effect to update
  92398. * @param lightIndex The index of the light in the effect to update
  92399. * @returns The hemispheric light
  92400. */
  92401. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92402. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92403. /**
  92404. * Computes the world matrix of the node
  92405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92406. * @param useWasUpdatedFlag defines a reserved property
  92407. * @returns the world matrix
  92408. */
  92409. computeWorldMatrix(): Matrix;
  92410. /**
  92411. * Returns the integer 3.
  92412. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92413. */
  92414. getTypeID(): number;
  92415. /**
  92416. * Prepares the list of defines specific to the light type.
  92417. * @param defines the list of defines
  92418. * @param lightIndex defines the index of the light for the effect
  92419. */
  92420. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92421. }
  92422. }
  92423. declare module BABYLON {
  92424. /** @hidden */
  92425. export var vrMultiviewToSingleviewPixelShader: {
  92426. name: string;
  92427. shader: string;
  92428. };
  92429. }
  92430. declare module BABYLON {
  92431. /**
  92432. * Renders to multiple views with a single draw call
  92433. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92434. */
  92435. export class MultiviewRenderTarget extends RenderTargetTexture {
  92436. /**
  92437. * Creates a multiview render target
  92438. * @param scene scene used with the render target
  92439. * @param size the size of the render target (used for each view)
  92440. */
  92441. constructor(scene: Scene, size?: number | {
  92442. width: number;
  92443. height: number;
  92444. } | {
  92445. ratio: number;
  92446. });
  92447. /**
  92448. * @hidden
  92449. * @param faceIndex the face index, if its a cube texture
  92450. */
  92451. _bindFrameBuffer(faceIndex?: number): void;
  92452. /**
  92453. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92454. * @returns the view count
  92455. */
  92456. getViewCount(): number;
  92457. }
  92458. }
  92459. declare module BABYLON {
  92460. /**
  92461. * Represents a camera frustum
  92462. */
  92463. export class Frustum {
  92464. /**
  92465. * Gets the planes representing the frustum
  92466. * @param transform matrix to be applied to the returned planes
  92467. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92468. */
  92469. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92470. /**
  92471. * Gets the near frustum plane transformed by the transform matrix
  92472. * @param transform transformation matrix to be applied to the resulting frustum plane
  92473. * @param frustumPlane the resuling frustum plane
  92474. */
  92475. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92476. /**
  92477. * Gets the far frustum plane transformed by the transform matrix
  92478. * @param transform transformation matrix to be applied to the resulting frustum plane
  92479. * @param frustumPlane the resuling frustum plane
  92480. */
  92481. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92482. /**
  92483. * Gets the left frustum plane transformed by the transform matrix
  92484. * @param transform transformation matrix to be applied to the resulting frustum plane
  92485. * @param frustumPlane the resuling frustum plane
  92486. */
  92487. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92488. /**
  92489. * Gets the right frustum plane transformed by the transform matrix
  92490. * @param transform transformation matrix to be applied to the resulting frustum plane
  92491. * @param frustumPlane the resuling frustum plane
  92492. */
  92493. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92494. /**
  92495. * Gets the top frustum plane transformed by the transform matrix
  92496. * @param transform transformation matrix to be applied to the resulting frustum plane
  92497. * @param frustumPlane the resuling frustum plane
  92498. */
  92499. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92500. /**
  92501. * Gets the bottom frustum plane transformed by the transform matrix
  92502. * @param transform transformation matrix to be applied to the resulting frustum plane
  92503. * @param frustumPlane the resuling frustum plane
  92504. */
  92505. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92506. /**
  92507. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92508. * @param transform transformation matrix to be applied to the resulting frustum planes
  92509. * @param frustumPlanes the resuling frustum planes
  92510. */
  92511. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92512. }
  92513. }
  92514. declare module BABYLON {
  92515. interface Engine {
  92516. /**
  92517. * Creates a new multiview render target
  92518. * @param width defines the width of the texture
  92519. * @param height defines the height of the texture
  92520. * @returns the created multiview texture
  92521. */
  92522. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92523. /**
  92524. * Binds a multiview framebuffer to be drawn to
  92525. * @param multiviewTexture texture to bind
  92526. */
  92527. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92528. }
  92529. interface Camera {
  92530. /**
  92531. * @hidden
  92532. * 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)
  92533. */
  92534. _useMultiviewToSingleView: boolean;
  92535. /**
  92536. * @hidden
  92537. * 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)
  92538. */
  92539. _multiviewTexture: Nullable<RenderTargetTexture>;
  92540. /**
  92541. * @hidden
  92542. * ensures the multiview texture of the camera exists and has the specified width/height
  92543. * @param width height to set on the multiview texture
  92544. * @param height width to set on the multiview texture
  92545. */
  92546. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92547. }
  92548. interface Scene {
  92549. /** @hidden */
  92550. _transformMatrixR: Matrix;
  92551. /** @hidden */
  92552. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92553. /** @hidden */
  92554. _createMultiviewUbo(): void;
  92555. /** @hidden */
  92556. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92557. /** @hidden */
  92558. _renderMultiviewToSingleView(camera: Camera): void;
  92559. }
  92560. }
  92561. declare module BABYLON {
  92562. /**
  92563. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92564. * This will not be used for webXR as it supports displaying texture arrays directly
  92565. */
  92566. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92567. /**
  92568. * Initializes a VRMultiviewToSingleview
  92569. * @param name name of the post process
  92570. * @param camera camera to be applied to
  92571. * @param scaleFactor scaling factor to the size of the output texture
  92572. */
  92573. constructor(name: string, camera: Camera, scaleFactor: number);
  92574. }
  92575. }
  92576. declare module BABYLON {
  92577. /**
  92578. * Interface used to define additional presentation attributes
  92579. */
  92580. export interface IVRPresentationAttributes {
  92581. /**
  92582. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92583. */
  92584. highRefreshRate: boolean;
  92585. /**
  92586. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92587. */
  92588. foveationLevel: number;
  92589. }
  92590. interface Engine {
  92591. /** @hidden */
  92592. _vrDisplay: any;
  92593. /** @hidden */
  92594. _vrSupported: boolean;
  92595. /** @hidden */
  92596. _oldSize: Size;
  92597. /** @hidden */
  92598. _oldHardwareScaleFactor: number;
  92599. /** @hidden */
  92600. _vrExclusivePointerMode: boolean;
  92601. /** @hidden */
  92602. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92603. /** @hidden */
  92604. _onVRDisplayPointerRestricted: () => void;
  92605. /** @hidden */
  92606. _onVRDisplayPointerUnrestricted: () => void;
  92607. /** @hidden */
  92608. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92609. /** @hidden */
  92610. _onVrDisplayDisconnect: Nullable<() => void>;
  92611. /** @hidden */
  92612. _onVrDisplayPresentChange: Nullable<() => void>;
  92613. /**
  92614. * Observable signaled when VR display mode changes
  92615. */
  92616. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92617. /**
  92618. * Observable signaled when VR request present is complete
  92619. */
  92620. onVRRequestPresentComplete: Observable<boolean>;
  92621. /**
  92622. * Observable signaled when VR request present starts
  92623. */
  92624. onVRRequestPresentStart: Observable<Engine>;
  92625. /**
  92626. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92627. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92628. */
  92629. isInVRExclusivePointerMode: boolean;
  92630. /**
  92631. * Gets a boolean indicating if a webVR device was detected
  92632. * @returns true if a webVR device was detected
  92633. */
  92634. isVRDevicePresent(): boolean;
  92635. /**
  92636. * Gets the current webVR device
  92637. * @returns the current webVR device (or null)
  92638. */
  92639. getVRDevice(): any;
  92640. /**
  92641. * Initializes a webVR display and starts listening to display change events
  92642. * The onVRDisplayChangedObservable will be notified upon these changes
  92643. * @returns A promise containing a VRDisplay and if vr is supported
  92644. */
  92645. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92646. /** @hidden */
  92647. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92648. /**
  92649. * Gets or sets the presentation attributes used to configure VR rendering
  92650. */
  92651. vrPresentationAttributes?: IVRPresentationAttributes;
  92652. /**
  92653. * Call this function to switch to webVR mode
  92654. * Will do nothing if webVR is not supported or if there is no webVR device
  92655. * @param options the webvr options provided to the camera. mainly used for multiview
  92656. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92657. */
  92658. enableVR(options: WebVROptions): void;
  92659. /** @hidden */
  92660. _onVRFullScreenTriggered(): void;
  92661. }
  92662. }
  92663. declare module BABYLON {
  92664. /**
  92665. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92666. * IMPORTANT!! The data is right-hand data.
  92667. * @export
  92668. * @interface DevicePose
  92669. */
  92670. export interface DevicePose {
  92671. /**
  92672. * The position of the device, values in array are [x,y,z].
  92673. */
  92674. readonly position: Nullable<Float32Array>;
  92675. /**
  92676. * The linearVelocity of the device, values in array are [x,y,z].
  92677. */
  92678. readonly linearVelocity: Nullable<Float32Array>;
  92679. /**
  92680. * The linearAcceleration of the device, values in array are [x,y,z].
  92681. */
  92682. readonly linearAcceleration: Nullable<Float32Array>;
  92683. /**
  92684. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92685. */
  92686. readonly orientation: Nullable<Float32Array>;
  92687. /**
  92688. * The angularVelocity of the device, values in array are [x,y,z].
  92689. */
  92690. readonly angularVelocity: Nullable<Float32Array>;
  92691. /**
  92692. * The angularAcceleration of the device, values in array are [x,y,z].
  92693. */
  92694. readonly angularAcceleration: Nullable<Float32Array>;
  92695. }
  92696. /**
  92697. * Interface representing a pose controlled object in Babylon.
  92698. * A pose controlled object has both regular pose values as well as pose values
  92699. * from an external device such as a VR head mounted display
  92700. */
  92701. export interface PoseControlled {
  92702. /**
  92703. * The position of the object in babylon space.
  92704. */
  92705. position: Vector3;
  92706. /**
  92707. * The rotation quaternion of the object in babylon space.
  92708. */
  92709. rotationQuaternion: Quaternion;
  92710. /**
  92711. * The position of the device in babylon space.
  92712. */
  92713. devicePosition?: Vector3;
  92714. /**
  92715. * The rotation quaternion of the device in babylon space.
  92716. */
  92717. deviceRotationQuaternion: Quaternion;
  92718. /**
  92719. * The raw pose coming from the device.
  92720. */
  92721. rawPose: Nullable<DevicePose>;
  92722. /**
  92723. * The scale of the device to be used when translating from device space to babylon space.
  92724. */
  92725. deviceScaleFactor: number;
  92726. /**
  92727. * Updates the poseControlled values based on the input device pose.
  92728. * @param poseData the pose data to update the object with
  92729. */
  92730. updateFromDevice(poseData: DevicePose): void;
  92731. }
  92732. /**
  92733. * Set of options to customize the webVRCamera
  92734. */
  92735. export interface WebVROptions {
  92736. /**
  92737. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92738. */
  92739. trackPosition?: boolean;
  92740. /**
  92741. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92742. */
  92743. positionScale?: number;
  92744. /**
  92745. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92746. */
  92747. displayName?: string;
  92748. /**
  92749. * Should the native controller meshes be initialized. (default: true)
  92750. */
  92751. controllerMeshes?: boolean;
  92752. /**
  92753. * Creating a default HemiLight only on controllers. (default: true)
  92754. */
  92755. defaultLightingOnControllers?: boolean;
  92756. /**
  92757. * If you don't want to use the default VR button of the helper. (default: false)
  92758. */
  92759. useCustomVRButton?: boolean;
  92760. /**
  92761. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92762. */
  92763. customVRButton?: HTMLButtonElement;
  92764. /**
  92765. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92766. */
  92767. rayLength?: number;
  92768. /**
  92769. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92770. */
  92771. defaultHeight?: number;
  92772. /**
  92773. * If multiview should be used if availible (default: false)
  92774. */
  92775. useMultiview?: boolean;
  92776. }
  92777. /**
  92778. * This represents a WebVR camera.
  92779. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92780. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92781. */
  92782. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92783. private webVROptions;
  92784. /**
  92785. * @hidden
  92786. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92787. */
  92788. _vrDevice: any;
  92789. /**
  92790. * The rawPose of the vrDevice.
  92791. */
  92792. rawPose: Nullable<DevicePose>;
  92793. private _onVREnabled;
  92794. private _specsVersion;
  92795. private _attached;
  92796. private _frameData;
  92797. protected _descendants: Array<Node>;
  92798. private _deviceRoomPosition;
  92799. /** @hidden */
  92800. _deviceRoomRotationQuaternion: Quaternion;
  92801. private _standingMatrix;
  92802. /**
  92803. * Represents device position in babylon space.
  92804. */
  92805. devicePosition: Vector3;
  92806. /**
  92807. * Represents device rotation in babylon space.
  92808. */
  92809. deviceRotationQuaternion: Quaternion;
  92810. /**
  92811. * The scale of the device to be used when translating from device space to babylon space.
  92812. */
  92813. deviceScaleFactor: number;
  92814. private _deviceToWorld;
  92815. private _worldToDevice;
  92816. /**
  92817. * References to the webVR controllers for the vrDevice.
  92818. */
  92819. controllers: Array<WebVRController>;
  92820. /**
  92821. * Emits an event when a controller is attached.
  92822. */
  92823. onControllersAttachedObservable: Observable<WebVRController[]>;
  92824. /**
  92825. * Emits an event when a controller's mesh has been loaded;
  92826. */
  92827. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92828. /**
  92829. * Emits an event when the HMD's pose has been updated.
  92830. */
  92831. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92832. private _poseSet;
  92833. /**
  92834. * If the rig cameras be used as parent instead of this camera.
  92835. */
  92836. rigParenting: boolean;
  92837. private _lightOnControllers;
  92838. private _defaultHeight?;
  92839. /**
  92840. * Instantiates a WebVRFreeCamera.
  92841. * @param name The name of the WebVRFreeCamera
  92842. * @param position The starting anchor position for the camera
  92843. * @param scene The scene the camera belongs to
  92844. * @param webVROptions a set of customizable options for the webVRCamera
  92845. */
  92846. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92847. /**
  92848. * Gets the device distance from the ground in meters.
  92849. * @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.
  92850. */
  92851. deviceDistanceToRoomGround(): number;
  92852. /**
  92853. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92854. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92855. */
  92856. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92857. /**
  92858. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92859. * @returns A promise with a boolean set to if the standing matrix is supported.
  92860. */
  92861. useStandingMatrixAsync(): Promise<boolean>;
  92862. /**
  92863. * Disposes the camera
  92864. */
  92865. dispose(): void;
  92866. /**
  92867. * Gets a vrController by name.
  92868. * @param name The name of the controller to retreive
  92869. * @returns the controller matching the name specified or null if not found
  92870. */
  92871. getControllerByName(name: string): Nullable<WebVRController>;
  92872. private _leftController;
  92873. /**
  92874. * The controller corresponding to the users left hand.
  92875. */
  92876. get leftController(): Nullable<WebVRController>;
  92877. private _rightController;
  92878. /**
  92879. * The controller corresponding to the users right hand.
  92880. */
  92881. get rightController(): Nullable<WebVRController>;
  92882. /**
  92883. * Casts a ray forward from the vrCamera's gaze.
  92884. * @param length Length of the ray (default: 100)
  92885. * @returns the ray corresponding to the gaze
  92886. */
  92887. getForwardRay(length?: number): Ray;
  92888. /**
  92889. * @hidden
  92890. * Updates the camera based on device's frame data
  92891. */
  92892. _checkInputs(): void;
  92893. /**
  92894. * Updates the poseControlled values based on the input device pose.
  92895. * @param poseData Pose coming from the device
  92896. */
  92897. updateFromDevice(poseData: DevicePose): void;
  92898. private _htmlElementAttached;
  92899. private _detachIfAttached;
  92900. /**
  92901. * WebVR's attach control will start broadcasting frames to the device.
  92902. * Note that in certain browsers (chrome for example) this function must be called
  92903. * within a user-interaction callback. Example:
  92904. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92905. *
  92906. * @param element html element to attach the vrDevice to
  92907. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92908. */
  92909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92910. /**
  92911. * Detaches the camera from the html element and disables VR
  92912. *
  92913. * @param element html element to detach from
  92914. */
  92915. detachControl(element: HTMLElement): void;
  92916. /**
  92917. * @returns the name of this class
  92918. */
  92919. getClassName(): string;
  92920. /**
  92921. * Calls resetPose on the vrDisplay
  92922. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92923. */
  92924. resetToCurrentRotation(): void;
  92925. /**
  92926. * @hidden
  92927. * Updates the rig cameras (left and right eye)
  92928. */
  92929. _updateRigCameras(): void;
  92930. private _workingVector;
  92931. private _oneVector;
  92932. private _workingMatrix;
  92933. private updateCacheCalled;
  92934. private _correctPositionIfNotTrackPosition;
  92935. /**
  92936. * @hidden
  92937. * Updates the cached values of the camera
  92938. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92939. */
  92940. _updateCache(ignoreParentClass?: boolean): void;
  92941. /**
  92942. * @hidden
  92943. * Get current device position in babylon world
  92944. */
  92945. _computeDevicePosition(): void;
  92946. /**
  92947. * Updates the current device position and rotation in the babylon world
  92948. */
  92949. update(): void;
  92950. /**
  92951. * @hidden
  92952. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92953. * @returns an identity matrix
  92954. */
  92955. _getViewMatrix(): Matrix;
  92956. private _tmpMatrix;
  92957. /**
  92958. * This function is called by the two RIG cameras.
  92959. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92960. * @hidden
  92961. */
  92962. _getWebVRViewMatrix(): Matrix;
  92963. /** @hidden */
  92964. _getWebVRProjectionMatrix(): Matrix;
  92965. private _onGamepadConnectedObserver;
  92966. private _onGamepadDisconnectedObserver;
  92967. private _updateCacheWhenTrackingDisabledObserver;
  92968. /**
  92969. * Initializes the controllers and their meshes
  92970. */
  92971. initControllers(): void;
  92972. }
  92973. }
  92974. declare module BABYLON {
  92975. /**
  92976. * Size options for a post process
  92977. */
  92978. export type PostProcessOptions = {
  92979. width: number;
  92980. height: number;
  92981. };
  92982. /**
  92983. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92984. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92985. */
  92986. export class PostProcess {
  92987. /** Name of the PostProcess. */
  92988. name: string;
  92989. /**
  92990. * Gets or sets the unique id of the post process
  92991. */
  92992. uniqueId: number;
  92993. /**
  92994. * Width of the texture to apply the post process on
  92995. */
  92996. width: number;
  92997. /**
  92998. * Height of the texture to apply the post process on
  92999. */
  93000. height: number;
  93001. /**
  93002. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93003. * @hidden
  93004. */
  93005. _outputTexture: Nullable<InternalTexture>;
  93006. /**
  93007. * Sampling mode used by the shader
  93008. * See https://doc.babylonjs.com/classes/3.1/texture
  93009. */
  93010. renderTargetSamplingMode: number;
  93011. /**
  93012. * Clear color to use when screen clearing
  93013. */
  93014. clearColor: Color4;
  93015. /**
  93016. * If the buffer needs to be cleared before applying the post process. (default: true)
  93017. * Should be set to false if shader will overwrite all previous pixels.
  93018. */
  93019. autoClear: boolean;
  93020. /**
  93021. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93022. */
  93023. alphaMode: number;
  93024. /**
  93025. * Sets the setAlphaBlendConstants of the babylon engine
  93026. */
  93027. alphaConstants: Color4;
  93028. /**
  93029. * Animations to be used for the post processing
  93030. */
  93031. animations: Animation[];
  93032. /**
  93033. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93034. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93035. */
  93036. enablePixelPerfectMode: boolean;
  93037. /**
  93038. * Force the postprocess to be applied without taking in account viewport
  93039. */
  93040. forceFullscreenViewport: boolean;
  93041. /**
  93042. * List of inspectable custom properties (used by the Inspector)
  93043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93044. */
  93045. inspectableCustomProperties: IInspectable[];
  93046. /**
  93047. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93048. *
  93049. * | Value | Type | Description |
  93050. * | ----- | ----------------------------------- | ----------- |
  93051. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93052. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93053. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93054. *
  93055. */
  93056. scaleMode: number;
  93057. /**
  93058. * Force textures to be a power of two (default: false)
  93059. */
  93060. alwaysForcePOT: boolean;
  93061. private _samples;
  93062. /**
  93063. * Number of sample textures (default: 1)
  93064. */
  93065. get samples(): number;
  93066. set samples(n: number);
  93067. /**
  93068. * Modify the scale of the post process to be the same as the viewport (default: false)
  93069. */
  93070. adaptScaleToCurrentViewport: boolean;
  93071. private _camera;
  93072. private _scene;
  93073. private _engine;
  93074. private _options;
  93075. private _reusable;
  93076. private _textureType;
  93077. private _textureFormat;
  93078. /**
  93079. * Smart array of input and output textures for the post process.
  93080. * @hidden
  93081. */
  93082. _textures: SmartArray<InternalTexture>;
  93083. /**
  93084. * The index in _textures that corresponds to the output texture.
  93085. * @hidden
  93086. */
  93087. _currentRenderTextureInd: number;
  93088. private _effect;
  93089. private _samplers;
  93090. private _fragmentUrl;
  93091. private _vertexUrl;
  93092. private _parameters;
  93093. private _scaleRatio;
  93094. protected _indexParameters: any;
  93095. private _shareOutputWithPostProcess;
  93096. private _texelSize;
  93097. private _forcedOutputTexture;
  93098. /**
  93099. * Returns the fragment url or shader name used in the post process.
  93100. * @returns the fragment url or name in the shader store.
  93101. */
  93102. getEffectName(): string;
  93103. /**
  93104. * An event triggered when the postprocess is activated.
  93105. */
  93106. onActivateObservable: Observable<Camera>;
  93107. private _onActivateObserver;
  93108. /**
  93109. * A function that is added to the onActivateObservable
  93110. */
  93111. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93112. /**
  93113. * An event triggered when the postprocess changes its size.
  93114. */
  93115. onSizeChangedObservable: Observable<PostProcess>;
  93116. private _onSizeChangedObserver;
  93117. /**
  93118. * A function that is added to the onSizeChangedObservable
  93119. */
  93120. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93121. /**
  93122. * An event triggered when the postprocess applies its effect.
  93123. */
  93124. onApplyObservable: Observable<Effect>;
  93125. private _onApplyObserver;
  93126. /**
  93127. * A function that is added to the onApplyObservable
  93128. */
  93129. set onApply(callback: (effect: Effect) => void);
  93130. /**
  93131. * An event triggered before rendering the postprocess
  93132. */
  93133. onBeforeRenderObservable: Observable<Effect>;
  93134. private _onBeforeRenderObserver;
  93135. /**
  93136. * A function that is added to the onBeforeRenderObservable
  93137. */
  93138. set onBeforeRender(callback: (effect: Effect) => void);
  93139. /**
  93140. * An event triggered after rendering the postprocess
  93141. */
  93142. onAfterRenderObservable: Observable<Effect>;
  93143. private _onAfterRenderObserver;
  93144. /**
  93145. * A function that is added to the onAfterRenderObservable
  93146. */
  93147. set onAfterRender(callback: (efect: Effect) => void);
  93148. /**
  93149. * 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
  93150. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93151. */
  93152. get inputTexture(): InternalTexture;
  93153. set inputTexture(value: InternalTexture);
  93154. /**
  93155. * Gets the camera which post process is applied to.
  93156. * @returns The camera the post process is applied to.
  93157. */
  93158. getCamera(): Camera;
  93159. /**
  93160. * Gets the texel size of the postprocess.
  93161. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93162. */
  93163. get texelSize(): Vector2;
  93164. /**
  93165. * Creates a new instance PostProcess
  93166. * @param name The name of the PostProcess.
  93167. * @param fragmentUrl The url of the fragment shader to be used.
  93168. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93169. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93170. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93171. * @param camera The camera to apply the render pass to.
  93172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93173. * @param engine The engine which the post process will be applied. (default: current engine)
  93174. * @param reusable If the post process can be reused on the same frame. (default: false)
  93175. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93176. * @param textureType Type of textures used when performing the post process. (default: 0)
  93177. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93178. * @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
  93179. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93180. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93181. */
  93182. constructor(
  93183. /** Name of the PostProcess. */
  93184. 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);
  93185. /**
  93186. * Gets a string idenfifying the name of the class
  93187. * @returns "PostProcess" string
  93188. */
  93189. getClassName(): string;
  93190. /**
  93191. * Gets the engine which this post process belongs to.
  93192. * @returns The engine the post process was enabled with.
  93193. */
  93194. getEngine(): Engine;
  93195. /**
  93196. * The effect that is created when initializing the post process.
  93197. * @returns The created effect corresponding the the postprocess.
  93198. */
  93199. getEffect(): Effect;
  93200. /**
  93201. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93202. * @param postProcess The post process to share the output with.
  93203. * @returns This post process.
  93204. */
  93205. shareOutputWith(postProcess: PostProcess): PostProcess;
  93206. /**
  93207. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93208. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93209. */
  93210. useOwnOutput(): void;
  93211. /**
  93212. * Updates the effect with the current post process compile time values and recompiles the shader.
  93213. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93214. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93215. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93216. * @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
  93217. * @param onCompiled Called when the shader has been compiled.
  93218. * @param onError Called if there is an error when compiling a shader.
  93219. */
  93220. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93221. /**
  93222. * The post process is reusable if it can be used multiple times within one frame.
  93223. * @returns If the post process is reusable
  93224. */
  93225. isReusable(): boolean;
  93226. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93227. markTextureDirty(): void;
  93228. /**
  93229. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93230. * 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.
  93231. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93232. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93233. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93234. * @returns The target texture that was bound to be written to.
  93235. */
  93236. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93237. /**
  93238. * If the post process is supported.
  93239. */
  93240. get isSupported(): boolean;
  93241. /**
  93242. * The aspect ratio of the output texture.
  93243. */
  93244. get aspectRatio(): number;
  93245. /**
  93246. * Get a value indicating if the post-process is ready to be used
  93247. * @returns true if the post-process is ready (shader is compiled)
  93248. */
  93249. isReady(): boolean;
  93250. /**
  93251. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93252. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93253. */
  93254. apply(): Nullable<Effect>;
  93255. private _disposeTextures;
  93256. /**
  93257. * Disposes the post process.
  93258. * @param camera The camera to dispose the post process on.
  93259. */
  93260. dispose(camera?: Camera): void;
  93261. }
  93262. }
  93263. declare module BABYLON {
  93264. /** @hidden */
  93265. export var kernelBlurVaryingDeclaration: {
  93266. name: string;
  93267. shader: string;
  93268. };
  93269. }
  93270. declare module BABYLON {
  93271. /** @hidden */
  93272. export var kernelBlurFragment: {
  93273. name: string;
  93274. shader: string;
  93275. };
  93276. }
  93277. declare module BABYLON {
  93278. /** @hidden */
  93279. export var kernelBlurFragment2: {
  93280. name: string;
  93281. shader: string;
  93282. };
  93283. }
  93284. declare module BABYLON {
  93285. /** @hidden */
  93286. export var kernelBlurPixelShader: {
  93287. name: string;
  93288. shader: string;
  93289. };
  93290. }
  93291. declare module BABYLON {
  93292. /** @hidden */
  93293. export var kernelBlurVertex: {
  93294. name: string;
  93295. shader: string;
  93296. };
  93297. }
  93298. declare module BABYLON {
  93299. /** @hidden */
  93300. export var kernelBlurVertexShader: {
  93301. name: string;
  93302. shader: string;
  93303. };
  93304. }
  93305. declare module BABYLON {
  93306. /**
  93307. * The Blur Post Process which blurs an image based on a kernel and direction.
  93308. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93309. */
  93310. export class BlurPostProcess extends PostProcess {
  93311. /** The direction in which to blur the image. */
  93312. direction: Vector2;
  93313. private blockCompilation;
  93314. protected _kernel: number;
  93315. protected _idealKernel: number;
  93316. protected _packedFloat: boolean;
  93317. private _staticDefines;
  93318. /**
  93319. * Sets the length in pixels of the blur sample region
  93320. */
  93321. set kernel(v: number);
  93322. /**
  93323. * Gets the length in pixels of the blur sample region
  93324. */
  93325. get kernel(): number;
  93326. /**
  93327. * Sets wether or not the blur needs to unpack/repack floats
  93328. */
  93329. set packedFloat(v: boolean);
  93330. /**
  93331. * Gets wether or not the blur is unpacking/repacking floats
  93332. */
  93333. get packedFloat(): boolean;
  93334. /**
  93335. * Creates a new instance BlurPostProcess
  93336. * @param name The name of the effect.
  93337. * @param direction The direction in which to blur the image.
  93338. * @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.
  93339. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93340. * @param camera The camera to apply the render pass to.
  93341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93342. * @param engine The engine which the post process will be applied. (default: current engine)
  93343. * @param reusable If the post process can be reused on the same frame. (default: false)
  93344. * @param textureType Type of textures used when performing the post process. (default: 0)
  93345. * @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)
  93346. */
  93347. constructor(name: string,
  93348. /** The direction in which to blur the image. */
  93349. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93350. /**
  93351. * Updates the effect with the current post process compile time values and recompiles the shader.
  93352. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93353. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93354. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93355. * @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
  93356. * @param onCompiled Called when the shader has been compiled.
  93357. * @param onError Called if there is an error when compiling a shader.
  93358. */
  93359. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93360. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93361. /**
  93362. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93363. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93364. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93365. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93366. * The gaps between physical kernels are compensated for in the weighting of the samples
  93367. * @param idealKernel Ideal blur kernel.
  93368. * @return Nearest best kernel.
  93369. */
  93370. protected _nearestBestKernel(idealKernel: number): number;
  93371. /**
  93372. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93373. * @param x The point on the Gaussian distribution to sample.
  93374. * @return the value of the Gaussian function at x.
  93375. */
  93376. protected _gaussianWeight(x: number): number;
  93377. /**
  93378. * Generates a string that can be used as a floating point number in GLSL.
  93379. * @param x Value to print.
  93380. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93381. * @return GLSL float string.
  93382. */
  93383. protected _glslFloat(x: number, decimalFigures?: number): string;
  93384. }
  93385. }
  93386. declare module BABYLON {
  93387. /**
  93388. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93389. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93390. * You can then easily use it as a reflectionTexture on a flat surface.
  93391. * In case the surface is not a plane, please consider relying on reflection probes.
  93392. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93393. */
  93394. export class MirrorTexture extends RenderTargetTexture {
  93395. private scene;
  93396. /**
  93397. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93398. * 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.
  93399. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93400. */
  93401. mirrorPlane: Plane;
  93402. /**
  93403. * Define the blur ratio used to blur the reflection if needed.
  93404. */
  93405. set blurRatio(value: number);
  93406. get blurRatio(): number;
  93407. /**
  93408. * Define the adaptive blur kernel used to blur the reflection if needed.
  93409. * This will autocompute the closest best match for the `blurKernel`
  93410. */
  93411. set adaptiveBlurKernel(value: number);
  93412. /**
  93413. * Define the blur kernel used to blur the reflection if needed.
  93414. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93415. */
  93416. set blurKernel(value: number);
  93417. /**
  93418. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93419. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93420. */
  93421. set blurKernelX(value: number);
  93422. get blurKernelX(): number;
  93423. /**
  93424. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93425. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93426. */
  93427. set blurKernelY(value: number);
  93428. get blurKernelY(): number;
  93429. private _autoComputeBlurKernel;
  93430. protected _onRatioRescale(): void;
  93431. private _updateGammaSpace;
  93432. private _imageProcessingConfigChangeObserver;
  93433. private _transformMatrix;
  93434. private _mirrorMatrix;
  93435. private _savedViewMatrix;
  93436. private _blurX;
  93437. private _blurY;
  93438. private _adaptiveBlurKernel;
  93439. private _blurKernelX;
  93440. private _blurKernelY;
  93441. private _blurRatio;
  93442. /**
  93443. * Instantiates a Mirror Texture.
  93444. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93445. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93446. * You can then easily use it as a reflectionTexture on a flat surface.
  93447. * In case the surface is not a plane, please consider relying on reflection probes.
  93448. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93449. * @param name
  93450. * @param size
  93451. * @param scene
  93452. * @param generateMipMaps
  93453. * @param type
  93454. * @param samplingMode
  93455. * @param generateDepthBuffer
  93456. */
  93457. constructor(name: string, size: number | {
  93458. width: number;
  93459. height: number;
  93460. } | {
  93461. ratio: number;
  93462. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93463. private _preparePostProcesses;
  93464. /**
  93465. * Clone the mirror texture.
  93466. * @returns the cloned texture
  93467. */
  93468. clone(): MirrorTexture;
  93469. /**
  93470. * Serialize the texture to a JSON representation you could use in Parse later on
  93471. * @returns the serialized JSON representation
  93472. */
  93473. serialize(): any;
  93474. /**
  93475. * Dispose the texture and release its associated resources.
  93476. */
  93477. dispose(): void;
  93478. }
  93479. }
  93480. declare module BABYLON {
  93481. /**
  93482. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93483. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93484. */
  93485. export class Texture extends BaseTexture {
  93486. /**
  93487. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93488. */
  93489. static SerializeBuffers: boolean;
  93490. /** @hidden */
  93491. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93492. /** @hidden */
  93493. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93494. /** @hidden */
  93495. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93496. /** nearest is mag = nearest and min = nearest and mip = linear */
  93497. static readonly NEAREST_SAMPLINGMODE: number;
  93498. /** nearest is mag = nearest and min = nearest and mip = linear */
  93499. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93500. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93501. static readonly BILINEAR_SAMPLINGMODE: number;
  93502. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93503. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93504. /** Trilinear is mag = linear and min = linear and mip = linear */
  93505. static readonly TRILINEAR_SAMPLINGMODE: number;
  93506. /** Trilinear is mag = linear and min = linear and mip = linear */
  93507. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93508. /** mag = nearest and min = nearest and mip = nearest */
  93509. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93510. /** mag = nearest and min = linear and mip = nearest */
  93511. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93512. /** mag = nearest and min = linear and mip = linear */
  93513. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93514. /** mag = nearest and min = linear and mip = none */
  93515. static readonly NEAREST_LINEAR: number;
  93516. /** mag = nearest and min = nearest and mip = none */
  93517. static readonly NEAREST_NEAREST: number;
  93518. /** mag = linear and min = nearest and mip = nearest */
  93519. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93520. /** mag = linear and min = nearest and mip = linear */
  93521. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93522. /** mag = linear and min = linear and mip = none */
  93523. static readonly LINEAR_LINEAR: number;
  93524. /** mag = linear and min = nearest and mip = none */
  93525. static readonly LINEAR_NEAREST: number;
  93526. /** Explicit coordinates mode */
  93527. static readonly EXPLICIT_MODE: number;
  93528. /** Spherical coordinates mode */
  93529. static readonly SPHERICAL_MODE: number;
  93530. /** Planar coordinates mode */
  93531. static readonly PLANAR_MODE: number;
  93532. /** Cubic coordinates mode */
  93533. static readonly CUBIC_MODE: number;
  93534. /** Projection coordinates mode */
  93535. static readonly PROJECTION_MODE: number;
  93536. /** Inverse Cubic coordinates mode */
  93537. static readonly SKYBOX_MODE: number;
  93538. /** Inverse Cubic coordinates mode */
  93539. static readonly INVCUBIC_MODE: number;
  93540. /** Equirectangular coordinates mode */
  93541. static readonly EQUIRECTANGULAR_MODE: number;
  93542. /** Equirectangular Fixed coordinates mode */
  93543. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93544. /** Equirectangular Fixed Mirrored coordinates mode */
  93545. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93546. /** Texture is not repeating outside of 0..1 UVs */
  93547. static readonly CLAMP_ADDRESSMODE: number;
  93548. /** Texture is repeating outside of 0..1 UVs */
  93549. static readonly WRAP_ADDRESSMODE: number;
  93550. /** Texture is repeating and mirrored */
  93551. static readonly MIRROR_ADDRESSMODE: number;
  93552. /**
  93553. * 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
  93554. */
  93555. static UseSerializedUrlIfAny: boolean;
  93556. /**
  93557. * Define the url of the texture.
  93558. */
  93559. url: Nullable<string>;
  93560. /**
  93561. * Define an offset on the texture to offset the u coordinates of the UVs
  93562. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93563. */
  93564. uOffset: number;
  93565. /**
  93566. * Define an offset on the texture to offset the v coordinates of the UVs
  93567. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93568. */
  93569. vOffset: number;
  93570. /**
  93571. * Define an offset on the texture to scale the u coordinates of the UVs
  93572. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93573. */
  93574. uScale: number;
  93575. /**
  93576. * Define an offset on the texture to scale the v coordinates of the UVs
  93577. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93578. */
  93579. vScale: number;
  93580. /**
  93581. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93582. * @see http://doc.babylonjs.com/how_to/more_materials
  93583. */
  93584. uAng: number;
  93585. /**
  93586. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93587. * @see http://doc.babylonjs.com/how_to/more_materials
  93588. */
  93589. vAng: number;
  93590. /**
  93591. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93592. * @see http://doc.babylonjs.com/how_to/more_materials
  93593. */
  93594. wAng: number;
  93595. /**
  93596. * Defines the center of rotation (U)
  93597. */
  93598. uRotationCenter: number;
  93599. /**
  93600. * Defines the center of rotation (V)
  93601. */
  93602. vRotationCenter: number;
  93603. /**
  93604. * Defines the center of rotation (W)
  93605. */
  93606. wRotationCenter: number;
  93607. /**
  93608. * Are mip maps generated for this texture or not.
  93609. */
  93610. get noMipmap(): boolean;
  93611. /**
  93612. * List of inspectable custom properties (used by the Inspector)
  93613. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93614. */
  93615. inspectableCustomProperties: Nullable<IInspectable[]>;
  93616. private _noMipmap;
  93617. /** @hidden */
  93618. _invertY: boolean;
  93619. private _rowGenerationMatrix;
  93620. private _cachedTextureMatrix;
  93621. private _projectionModeMatrix;
  93622. private _t0;
  93623. private _t1;
  93624. private _t2;
  93625. private _cachedUOffset;
  93626. private _cachedVOffset;
  93627. private _cachedUScale;
  93628. private _cachedVScale;
  93629. private _cachedUAng;
  93630. private _cachedVAng;
  93631. private _cachedWAng;
  93632. private _cachedProjectionMatrixId;
  93633. private _cachedCoordinatesMode;
  93634. /** @hidden */
  93635. protected _initialSamplingMode: number;
  93636. /** @hidden */
  93637. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93638. private _deleteBuffer;
  93639. protected _format: Nullable<number>;
  93640. private _delayedOnLoad;
  93641. private _delayedOnError;
  93642. private _mimeType?;
  93643. /**
  93644. * Observable triggered once the texture has been loaded.
  93645. */
  93646. onLoadObservable: Observable<Texture>;
  93647. protected _isBlocking: boolean;
  93648. /**
  93649. * Is the texture preventing material to render while loading.
  93650. * If false, a default texture will be used instead of the loading one during the preparation step.
  93651. */
  93652. set isBlocking(value: boolean);
  93653. get isBlocking(): boolean;
  93654. /**
  93655. * Get the current sampling mode associated with the texture.
  93656. */
  93657. get samplingMode(): number;
  93658. /**
  93659. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93660. */
  93661. get invertY(): boolean;
  93662. /**
  93663. * Instantiates a new texture.
  93664. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93665. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93666. * @param url defines the url of the picture to load as a texture
  93667. * @param scene defines the scene or engine the texture will belong to
  93668. * @param noMipmap defines if the texture will require mip maps or not
  93669. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93670. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93671. * @param onLoad defines a callback triggered when the texture has been loaded
  93672. * @param onError defines a callback triggered when an error occurred during the loading session
  93673. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93674. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93675. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93676. * @param mimeType defines an optional mime type information
  93677. */
  93678. 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);
  93679. /**
  93680. * Update the url (and optional buffer) of this texture if url was null during construction.
  93681. * @param url the url of the texture
  93682. * @param buffer the buffer of the texture (defaults to null)
  93683. * @param onLoad callback called when the texture is loaded (defaults to null)
  93684. */
  93685. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93686. /**
  93687. * Finish the loading sequence of a texture flagged as delayed load.
  93688. * @hidden
  93689. */
  93690. delayLoad(): void;
  93691. private _prepareRowForTextureGeneration;
  93692. /**
  93693. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93694. * @returns the transform matrix of the texture.
  93695. */
  93696. getTextureMatrix(uBase?: number): Matrix;
  93697. /**
  93698. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93699. * @returns The reflection texture transform
  93700. */
  93701. getReflectionTextureMatrix(): Matrix;
  93702. /**
  93703. * Clones the texture.
  93704. * @returns the cloned texture
  93705. */
  93706. clone(): Texture;
  93707. /**
  93708. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93709. * @returns The JSON representation of the texture
  93710. */
  93711. serialize(): any;
  93712. /**
  93713. * Get the current class name of the texture useful for serialization or dynamic coding.
  93714. * @returns "Texture"
  93715. */
  93716. getClassName(): string;
  93717. /**
  93718. * Dispose the texture and release its associated resources.
  93719. */
  93720. dispose(): void;
  93721. /**
  93722. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93723. * @param parsedTexture Define the JSON representation of the texture
  93724. * @param scene Define the scene the parsed texture should be instantiated in
  93725. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93726. * @returns The parsed texture if successful
  93727. */
  93728. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93729. /**
  93730. * Creates a texture from its base 64 representation.
  93731. * @param data Define the base64 payload without the data: prefix
  93732. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93733. * @param scene Define the scene the texture should belong to
  93734. * @param noMipmap Forces the texture to not create mip map information if true
  93735. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93736. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93737. * @param onLoad define a callback triggered when the texture has been loaded
  93738. * @param onError define a callback triggered when an error occurred during the loading session
  93739. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93740. * @returns the created texture
  93741. */
  93742. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93743. /**
  93744. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93745. * @param data Define the base64 payload without the data: prefix
  93746. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93747. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93748. * @param scene Define the scene the texture should belong to
  93749. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93750. * @param noMipmap Forces the texture to not create mip map information if true
  93751. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93752. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93753. * @param onLoad define a callback triggered when the texture has been loaded
  93754. * @param onError define a callback triggered when an error occurred during the loading session
  93755. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93756. * @returns the created texture
  93757. */
  93758. 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;
  93759. }
  93760. }
  93761. declare module BABYLON {
  93762. /**
  93763. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93764. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93765. */
  93766. export class PostProcessManager {
  93767. private _scene;
  93768. private _indexBuffer;
  93769. private _vertexBuffers;
  93770. /**
  93771. * Creates a new instance PostProcess
  93772. * @param scene The scene that the post process is associated with.
  93773. */
  93774. constructor(scene: Scene);
  93775. private _prepareBuffers;
  93776. private _buildIndexBuffer;
  93777. /**
  93778. * Rebuilds the vertex buffers of the manager.
  93779. * @hidden
  93780. */
  93781. _rebuild(): void;
  93782. /**
  93783. * Prepares a frame to be run through a post process.
  93784. * @param sourceTexture The input texture to the post procesess. (default: null)
  93785. * @param postProcesses An array of post processes to be run. (default: null)
  93786. * @returns True if the post processes were able to be run.
  93787. * @hidden
  93788. */
  93789. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93790. /**
  93791. * Manually render a set of post processes to a texture.
  93792. * @param postProcesses An array of post processes to be run.
  93793. * @param targetTexture The target texture to render to.
  93794. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93795. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93796. * @param lodLevel defines which lod of the texture to render to
  93797. */
  93798. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93799. /**
  93800. * Finalize the result of the output of the postprocesses.
  93801. * @param doNotPresent If true the result will not be displayed to the screen.
  93802. * @param targetTexture The target texture to render to.
  93803. * @param faceIndex The index of the face to bind the target texture to.
  93804. * @param postProcesses The array of post processes to render.
  93805. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93806. * @hidden
  93807. */
  93808. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93809. /**
  93810. * Disposes of the post process manager.
  93811. */
  93812. dispose(): void;
  93813. }
  93814. }
  93815. declare module BABYLON {
  93816. /**
  93817. * This Helps creating a texture that will be created from a camera in your scene.
  93818. * It is basically a dynamic texture that could be used to create special effects for instance.
  93819. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93820. */
  93821. export class RenderTargetTexture extends Texture {
  93822. isCube: boolean;
  93823. /**
  93824. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93825. */
  93826. static readonly REFRESHRATE_RENDER_ONCE: number;
  93827. /**
  93828. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93829. */
  93830. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93831. /**
  93832. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93833. * the central point of your effect and can save a lot of performances.
  93834. */
  93835. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93836. /**
  93837. * Use this predicate to dynamically define the list of mesh you want to render.
  93838. * If set, the renderList property will be overwritten.
  93839. */
  93840. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93841. private _renderList;
  93842. /**
  93843. * Use this list to define the list of mesh you want to render.
  93844. */
  93845. get renderList(): Nullable<Array<AbstractMesh>>;
  93846. set renderList(value: Nullable<Array<AbstractMesh>>);
  93847. /**
  93848. * Use this function to overload the renderList array at rendering time.
  93849. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93850. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93851. * the cube (if the RTT is a cube, else layerOrFace=0).
  93852. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93853. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93854. * hold dummy elements!
  93855. */
  93856. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93857. private _hookArray;
  93858. /**
  93859. * Define if particles should be rendered in your texture.
  93860. */
  93861. renderParticles: boolean;
  93862. /**
  93863. * Define if sprites should be rendered in your texture.
  93864. */
  93865. renderSprites: boolean;
  93866. /**
  93867. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93868. */
  93869. coordinatesMode: number;
  93870. /**
  93871. * Define the camera used to render the texture.
  93872. */
  93873. activeCamera: Nullable<Camera>;
  93874. /**
  93875. * Override the render function of the texture with your own one.
  93876. */
  93877. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93878. /**
  93879. * Define if camera post processes should be use while rendering the texture.
  93880. */
  93881. useCameraPostProcesses: boolean;
  93882. /**
  93883. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93884. */
  93885. ignoreCameraViewport: boolean;
  93886. private _postProcessManager;
  93887. private _postProcesses;
  93888. private _resizeObserver;
  93889. /**
  93890. * An event triggered when the texture is unbind.
  93891. */
  93892. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93893. /**
  93894. * An event triggered when the texture is unbind.
  93895. */
  93896. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93897. private _onAfterUnbindObserver;
  93898. /**
  93899. * Set a after unbind callback in the texture.
  93900. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93901. */
  93902. set onAfterUnbind(callback: () => void);
  93903. /**
  93904. * An event triggered before rendering the texture
  93905. */
  93906. onBeforeRenderObservable: Observable<number>;
  93907. private _onBeforeRenderObserver;
  93908. /**
  93909. * Set a before render callback in the texture.
  93910. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93911. */
  93912. set onBeforeRender(callback: (faceIndex: number) => void);
  93913. /**
  93914. * An event triggered after rendering the texture
  93915. */
  93916. onAfterRenderObservable: Observable<number>;
  93917. private _onAfterRenderObserver;
  93918. /**
  93919. * Set a after render callback in the texture.
  93920. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93921. */
  93922. set onAfterRender(callback: (faceIndex: number) => void);
  93923. /**
  93924. * An event triggered after the texture clear
  93925. */
  93926. onClearObservable: Observable<Engine>;
  93927. private _onClearObserver;
  93928. /**
  93929. * Set a clear callback in the texture.
  93930. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93931. */
  93932. set onClear(callback: (Engine: Engine) => void);
  93933. /**
  93934. * An event triggered when the texture is resized.
  93935. */
  93936. onResizeObservable: Observable<RenderTargetTexture>;
  93937. /**
  93938. * Define the clear color of the Render Target if it should be different from the scene.
  93939. */
  93940. clearColor: Color4;
  93941. protected _size: number | {
  93942. width: number;
  93943. height: number;
  93944. layers?: number;
  93945. };
  93946. protected _initialSizeParameter: number | {
  93947. width: number;
  93948. height: number;
  93949. } | {
  93950. ratio: number;
  93951. };
  93952. protected _sizeRatio: Nullable<number>;
  93953. /** @hidden */
  93954. _generateMipMaps: boolean;
  93955. protected _renderingManager: RenderingManager;
  93956. /** @hidden */
  93957. _waitingRenderList: string[];
  93958. protected _doNotChangeAspectRatio: boolean;
  93959. protected _currentRefreshId: number;
  93960. protected _refreshRate: number;
  93961. protected _textureMatrix: Matrix;
  93962. protected _samples: number;
  93963. protected _renderTargetOptions: RenderTargetCreationOptions;
  93964. /**
  93965. * Gets render target creation options that were used.
  93966. */
  93967. get renderTargetOptions(): RenderTargetCreationOptions;
  93968. protected _engine: Engine;
  93969. protected _onRatioRescale(): void;
  93970. /**
  93971. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93972. * It must define where the camera used to render the texture is set
  93973. */
  93974. boundingBoxPosition: Vector3;
  93975. private _boundingBoxSize;
  93976. /**
  93977. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93978. * When defined, the cubemap will switch to local mode
  93979. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93980. * @example https://www.babylonjs-playground.com/#RNASML
  93981. */
  93982. set boundingBoxSize(value: Vector3);
  93983. get boundingBoxSize(): Vector3;
  93984. /**
  93985. * In case the RTT has been created with a depth texture, get the associated
  93986. * depth texture.
  93987. * Otherwise, return null.
  93988. */
  93989. get depthStencilTexture(): Nullable<InternalTexture>;
  93990. /**
  93991. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93992. * or used a shadow, depth texture...
  93993. * @param name The friendly name of the texture
  93994. * @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)
  93995. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93996. * @param generateMipMaps True if mip maps need to be generated after render.
  93997. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93998. * @param type The type of the buffer in the RTT (int, half float, float...)
  93999. * @param isCube True if a cube texture needs to be created
  94000. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94001. * @param generateDepthBuffer True to generate a depth buffer
  94002. * @param generateStencilBuffer True to generate a stencil buffer
  94003. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94004. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94005. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94006. */
  94007. constructor(name: string, size: number | {
  94008. width: number;
  94009. height: number;
  94010. layers?: number;
  94011. } | {
  94012. ratio: number;
  94013. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94014. /**
  94015. * Creates a depth stencil texture.
  94016. * This is only available in WebGL 2 or with the depth texture extension available.
  94017. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94018. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94019. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94020. */
  94021. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94022. private _processSizeParameter;
  94023. /**
  94024. * Define the number of samples to use in case of MSAA.
  94025. * It defaults to one meaning no MSAA has been enabled.
  94026. */
  94027. get samples(): number;
  94028. set samples(value: number);
  94029. /**
  94030. * Resets the refresh counter of the texture and start bak from scratch.
  94031. * Could be useful to regenerate the texture if it is setup to render only once.
  94032. */
  94033. resetRefreshCounter(): void;
  94034. /**
  94035. * Define the refresh rate of the texture or the rendering frequency.
  94036. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94037. */
  94038. get refreshRate(): number;
  94039. set refreshRate(value: number);
  94040. /**
  94041. * Adds a post process to the render target rendering passes.
  94042. * @param postProcess define the post process to add
  94043. */
  94044. addPostProcess(postProcess: PostProcess): void;
  94045. /**
  94046. * Clear all the post processes attached to the render target
  94047. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94048. */
  94049. clearPostProcesses(dispose?: boolean): void;
  94050. /**
  94051. * Remove one of the post process from the list of attached post processes to the texture
  94052. * @param postProcess define the post process to remove from the list
  94053. */
  94054. removePostProcess(postProcess: PostProcess): void;
  94055. /** @hidden */
  94056. _shouldRender(): boolean;
  94057. /**
  94058. * Gets the actual render size of the texture.
  94059. * @returns the width of the render size
  94060. */
  94061. getRenderSize(): number;
  94062. /**
  94063. * Gets the actual render width of the texture.
  94064. * @returns the width of the render size
  94065. */
  94066. getRenderWidth(): number;
  94067. /**
  94068. * Gets the actual render height of the texture.
  94069. * @returns the height of the render size
  94070. */
  94071. getRenderHeight(): number;
  94072. /**
  94073. * Gets the actual number of layers of the texture.
  94074. * @returns the number of layers
  94075. */
  94076. getRenderLayers(): number;
  94077. /**
  94078. * Get if the texture can be rescaled or not.
  94079. */
  94080. get canRescale(): boolean;
  94081. /**
  94082. * Resize the texture using a ratio.
  94083. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94084. */
  94085. scale(ratio: number): void;
  94086. /**
  94087. * Get the texture reflection matrix used to rotate/transform the reflection.
  94088. * @returns the reflection matrix
  94089. */
  94090. getReflectionTextureMatrix(): Matrix;
  94091. /**
  94092. * Resize the texture to a new desired size.
  94093. * Be carrefull as it will recreate all the data in the new texture.
  94094. * @param size Define the new size. It can be:
  94095. * - a number for squared texture,
  94096. * - an object containing { width: number, height: number }
  94097. * - or an object containing a ratio { ratio: number }
  94098. */
  94099. resize(size: number | {
  94100. width: number;
  94101. height: number;
  94102. } | {
  94103. ratio: number;
  94104. }): void;
  94105. private _defaultRenderListPrepared;
  94106. /**
  94107. * Renders all the objects from the render list into the texture.
  94108. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94109. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94110. */
  94111. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94112. private _bestReflectionRenderTargetDimension;
  94113. private _prepareRenderingManager;
  94114. /**
  94115. * @hidden
  94116. * @param faceIndex face index to bind to if this is a cubetexture
  94117. * @param layer defines the index of the texture to bind in the array
  94118. */
  94119. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94120. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94121. private renderToTarget;
  94122. /**
  94123. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94124. * This allowed control for front to back rendering or reversly depending of the special needs.
  94125. *
  94126. * @param renderingGroupId The rendering group id corresponding to its index
  94127. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94128. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94129. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94130. */
  94131. 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;
  94132. /**
  94133. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94134. *
  94135. * @param renderingGroupId The rendering group id corresponding to its index
  94136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94137. */
  94138. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94139. /**
  94140. * Clones the texture.
  94141. * @returns the cloned texture
  94142. */
  94143. clone(): RenderTargetTexture;
  94144. /**
  94145. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94146. * @returns The JSON representation of the texture
  94147. */
  94148. serialize(): any;
  94149. /**
  94150. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94151. */
  94152. disposeFramebufferObjects(): void;
  94153. /**
  94154. * Dispose the texture and release its associated resources.
  94155. */
  94156. dispose(): void;
  94157. /** @hidden */
  94158. _rebuild(): void;
  94159. /**
  94160. * Clear the info related to rendering groups preventing retention point in material dispose.
  94161. */
  94162. freeRenderingGroups(): void;
  94163. /**
  94164. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94165. * @returns the view count
  94166. */
  94167. getViewCount(): number;
  94168. }
  94169. }
  94170. declare module BABYLON {
  94171. /**
  94172. * Options for compiling materials.
  94173. */
  94174. export interface IMaterialCompilationOptions {
  94175. /**
  94176. * Defines whether clip planes are enabled.
  94177. */
  94178. clipPlane: boolean;
  94179. /**
  94180. * Defines whether instances are enabled.
  94181. */
  94182. useInstances: boolean;
  94183. }
  94184. /**
  94185. * Base class for the main features of a material in Babylon.js
  94186. */
  94187. export class Material implements IAnimatable {
  94188. /**
  94189. * Returns the triangle fill mode
  94190. */
  94191. static readonly TriangleFillMode: number;
  94192. /**
  94193. * Returns the wireframe mode
  94194. */
  94195. static readonly WireFrameFillMode: number;
  94196. /**
  94197. * Returns the point fill mode
  94198. */
  94199. static readonly PointFillMode: number;
  94200. /**
  94201. * Returns the point list draw mode
  94202. */
  94203. static readonly PointListDrawMode: number;
  94204. /**
  94205. * Returns the line list draw mode
  94206. */
  94207. static readonly LineListDrawMode: number;
  94208. /**
  94209. * Returns the line loop draw mode
  94210. */
  94211. static readonly LineLoopDrawMode: number;
  94212. /**
  94213. * Returns the line strip draw mode
  94214. */
  94215. static readonly LineStripDrawMode: number;
  94216. /**
  94217. * Returns the triangle strip draw mode
  94218. */
  94219. static readonly TriangleStripDrawMode: number;
  94220. /**
  94221. * Returns the triangle fan draw mode
  94222. */
  94223. static readonly TriangleFanDrawMode: number;
  94224. /**
  94225. * Stores the clock-wise side orientation
  94226. */
  94227. static readonly ClockWiseSideOrientation: number;
  94228. /**
  94229. * Stores the counter clock-wise side orientation
  94230. */
  94231. static readonly CounterClockWiseSideOrientation: number;
  94232. /**
  94233. * The dirty texture flag value
  94234. */
  94235. static readonly TextureDirtyFlag: number;
  94236. /**
  94237. * The dirty light flag value
  94238. */
  94239. static readonly LightDirtyFlag: number;
  94240. /**
  94241. * The dirty fresnel flag value
  94242. */
  94243. static readonly FresnelDirtyFlag: number;
  94244. /**
  94245. * The dirty attribute flag value
  94246. */
  94247. static readonly AttributesDirtyFlag: number;
  94248. /**
  94249. * The dirty misc flag value
  94250. */
  94251. static readonly MiscDirtyFlag: number;
  94252. /**
  94253. * The all dirty flag value
  94254. */
  94255. static readonly AllDirtyFlag: number;
  94256. /**
  94257. * The ID of the material
  94258. */
  94259. id: string;
  94260. /**
  94261. * Gets or sets the unique id of the material
  94262. */
  94263. uniqueId: number;
  94264. /**
  94265. * The name of the material
  94266. */
  94267. name: string;
  94268. /**
  94269. * Gets or sets user defined metadata
  94270. */
  94271. metadata: any;
  94272. /**
  94273. * For internal use only. Please do not use.
  94274. */
  94275. reservedDataStore: any;
  94276. /**
  94277. * Specifies if the ready state should be checked on each call
  94278. */
  94279. checkReadyOnEveryCall: boolean;
  94280. /**
  94281. * Specifies if the ready state should be checked once
  94282. */
  94283. checkReadyOnlyOnce: boolean;
  94284. /**
  94285. * The state of the material
  94286. */
  94287. state: string;
  94288. /**
  94289. * The alpha value of the material
  94290. */
  94291. protected _alpha: number;
  94292. /**
  94293. * List of inspectable custom properties (used by the Inspector)
  94294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94295. */
  94296. inspectableCustomProperties: IInspectable[];
  94297. /**
  94298. * Sets the alpha value of the material
  94299. */
  94300. set alpha(value: number);
  94301. /**
  94302. * Gets the alpha value of the material
  94303. */
  94304. get alpha(): number;
  94305. /**
  94306. * Specifies if back face culling is enabled
  94307. */
  94308. protected _backFaceCulling: boolean;
  94309. /**
  94310. * Sets the back-face culling state
  94311. */
  94312. set backFaceCulling(value: boolean);
  94313. /**
  94314. * Gets the back-face culling state
  94315. */
  94316. get backFaceCulling(): boolean;
  94317. /**
  94318. * Stores the value for side orientation
  94319. */
  94320. sideOrientation: number;
  94321. /**
  94322. * Callback triggered when the material is compiled
  94323. */
  94324. onCompiled: Nullable<(effect: Effect) => void>;
  94325. /**
  94326. * Callback triggered when an error occurs
  94327. */
  94328. onError: Nullable<(effect: Effect, errors: string) => void>;
  94329. /**
  94330. * Callback triggered to get the render target textures
  94331. */
  94332. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94333. /**
  94334. * Gets a boolean indicating that current material needs to register RTT
  94335. */
  94336. get hasRenderTargetTextures(): boolean;
  94337. /**
  94338. * Specifies if the material should be serialized
  94339. */
  94340. doNotSerialize: boolean;
  94341. /**
  94342. * @hidden
  94343. */
  94344. _storeEffectOnSubMeshes: boolean;
  94345. /**
  94346. * Stores the animations for the material
  94347. */
  94348. animations: Nullable<Array<Animation>>;
  94349. /**
  94350. * An event triggered when the material is disposed
  94351. */
  94352. onDisposeObservable: Observable<Material>;
  94353. /**
  94354. * An observer which watches for dispose events
  94355. */
  94356. private _onDisposeObserver;
  94357. private _onUnBindObservable;
  94358. /**
  94359. * Called during a dispose event
  94360. */
  94361. set onDispose(callback: () => void);
  94362. private _onBindObservable;
  94363. /**
  94364. * An event triggered when the material is bound
  94365. */
  94366. get onBindObservable(): Observable<AbstractMesh>;
  94367. /**
  94368. * An observer which watches for bind events
  94369. */
  94370. private _onBindObserver;
  94371. /**
  94372. * Called during a bind event
  94373. */
  94374. set onBind(callback: (Mesh: AbstractMesh) => void);
  94375. /**
  94376. * An event triggered when the material is unbound
  94377. */
  94378. get onUnBindObservable(): Observable<Material>;
  94379. /**
  94380. * Stores the value of the alpha mode
  94381. */
  94382. private _alphaMode;
  94383. /**
  94384. * Sets the value of the alpha mode.
  94385. *
  94386. * | Value | Type | Description |
  94387. * | --- | --- | --- |
  94388. * | 0 | ALPHA_DISABLE | |
  94389. * | 1 | ALPHA_ADD | |
  94390. * | 2 | ALPHA_COMBINE | |
  94391. * | 3 | ALPHA_SUBTRACT | |
  94392. * | 4 | ALPHA_MULTIPLY | |
  94393. * | 5 | ALPHA_MAXIMIZED | |
  94394. * | 6 | ALPHA_ONEONE | |
  94395. * | 7 | ALPHA_PREMULTIPLIED | |
  94396. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94397. * | 9 | ALPHA_INTERPOLATE | |
  94398. * | 10 | ALPHA_SCREENMODE | |
  94399. *
  94400. */
  94401. set alphaMode(value: number);
  94402. /**
  94403. * Gets the value of the alpha mode
  94404. */
  94405. get alphaMode(): number;
  94406. /**
  94407. * Stores the state of the need depth pre-pass value
  94408. */
  94409. private _needDepthPrePass;
  94410. /**
  94411. * Sets the need depth pre-pass value
  94412. */
  94413. set needDepthPrePass(value: boolean);
  94414. /**
  94415. * Gets the depth pre-pass value
  94416. */
  94417. get needDepthPrePass(): boolean;
  94418. /**
  94419. * Specifies if depth writing should be disabled
  94420. */
  94421. disableDepthWrite: boolean;
  94422. /**
  94423. * Specifies if depth writing should be forced
  94424. */
  94425. forceDepthWrite: boolean;
  94426. /**
  94427. * Specifies the depth function that should be used. 0 means the default engine function
  94428. */
  94429. depthFunction: number;
  94430. /**
  94431. * Specifies if there should be a separate pass for culling
  94432. */
  94433. separateCullingPass: boolean;
  94434. /**
  94435. * Stores the state specifing if fog should be enabled
  94436. */
  94437. private _fogEnabled;
  94438. /**
  94439. * Sets the state for enabling fog
  94440. */
  94441. set fogEnabled(value: boolean);
  94442. /**
  94443. * Gets the value of the fog enabled state
  94444. */
  94445. get fogEnabled(): boolean;
  94446. /**
  94447. * Stores the size of points
  94448. */
  94449. pointSize: number;
  94450. /**
  94451. * Stores the z offset value
  94452. */
  94453. zOffset: number;
  94454. /**
  94455. * Gets a value specifying if wireframe mode is enabled
  94456. */
  94457. get wireframe(): boolean;
  94458. /**
  94459. * Sets the state of wireframe mode
  94460. */
  94461. set wireframe(value: boolean);
  94462. /**
  94463. * Gets the value specifying if point clouds are enabled
  94464. */
  94465. get pointsCloud(): boolean;
  94466. /**
  94467. * Sets the state of point cloud mode
  94468. */
  94469. set pointsCloud(value: boolean);
  94470. /**
  94471. * Gets the material fill mode
  94472. */
  94473. get fillMode(): number;
  94474. /**
  94475. * Sets the material fill mode
  94476. */
  94477. set fillMode(value: number);
  94478. /**
  94479. * @hidden
  94480. * Stores the effects for the material
  94481. */
  94482. _effect: Nullable<Effect>;
  94483. /**
  94484. * Specifies if uniform buffers should be used
  94485. */
  94486. private _useUBO;
  94487. /**
  94488. * Stores a reference to the scene
  94489. */
  94490. private _scene;
  94491. /**
  94492. * Stores the fill mode state
  94493. */
  94494. private _fillMode;
  94495. /**
  94496. * Specifies if the depth write state should be cached
  94497. */
  94498. private _cachedDepthWriteState;
  94499. /**
  94500. * Specifies if the depth function state should be cached
  94501. */
  94502. private _cachedDepthFunctionState;
  94503. /**
  94504. * Stores the uniform buffer
  94505. */
  94506. protected _uniformBuffer: UniformBuffer;
  94507. /** @hidden */
  94508. _indexInSceneMaterialArray: number;
  94509. /** @hidden */
  94510. meshMap: Nullable<{
  94511. [id: string]: AbstractMesh | undefined;
  94512. }>;
  94513. /**
  94514. * Creates a material instance
  94515. * @param name defines the name of the material
  94516. * @param scene defines the scene to reference
  94517. * @param doNotAdd specifies if the material should be added to the scene
  94518. */
  94519. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94520. /**
  94521. * Returns a string representation of the current material
  94522. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94523. * @returns a string with material information
  94524. */
  94525. toString(fullDetails?: boolean): string;
  94526. /**
  94527. * Gets the class name of the material
  94528. * @returns a string with the class name of the material
  94529. */
  94530. getClassName(): string;
  94531. /**
  94532. * Specifies if updates for the material been locked
  94533. */
  94534. get isFrozen(): boolean;
  94535. /**
  94536. * Locks updates for the material
  94537. */
  94538. freeze(): void;
  94539. /**
  94540. * Unlocks updates for the material
  94541. */
  94542. unfreeze(): void;
  94543. /**
  94544. * Specifies if the material is ready to be used
  94545. * @param mesh defines the mesh to check
  94546. * @param useInstances specifies if instances should be used
  94547. * @returns a boolean indicating if the material is ready to be used
  94548. */
  94549. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94550. /**
  94551. * Specifies that the submesh is ready to be used
  94552. * @param mesh defines the mesh to check
  94553. * @param subMesh defines which submesh to check
  94554. * @param useInstances specifies that instances should be used
  94555. * @returns a boolean indicating that the submesh is ready or not
  94556. */
  94557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94558. /**
  94559. * Returns the material effect
  94560. * @returns the effect associated with the material
  94561. */
  94562. getEffect(): Nullable<Effect>;
  94563. /**
  94564. * Returns the current scene
  94565. * @returns a Scene
  94566. */
  94567. getScene(): Scene;
  94568. /**
  94569. * Specifies if the material will require alpha blending
  94570. * @returns a boolean specifying if alpha blending is needed
  94571. */
  94572. needAlphaBlending(): boolean;
  94573. /**
  94574. * Specifies if the mesh will require alpha blending
  94575. * @param mesh defines the mesh to check
  94576. * @returns a boolean specifying if alpha blending is needed for the mesh
  94577. */
  94578. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94579. /**
  94580. * Specifies if this material should be rendered in alpha test mode
  94581. * @returns a boolean specifying if an alpha test is needed.
  94582. */
  94583. needAlphaTesting(): boolean;
  94584. /**
  94585. * Gets the texture used for the alpha test
  94586. * @returns the texture to use for alpha testing
  94587. */
  94588. getAlphaTestTexture(): Nullable<BaseTexture>;
  94589. /**
  94590. * Marks the material to indicate that it needs to be re-calculated
  94591. */
  94592. markDirty(): void;
  94593. /** @hidden */
  94594. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94595. /**
  94596. * Binds the material to the mesh
  94597. * @param world defines the world transformation matrix
  94598. * @param mesh defines the mesh to bind the material to
  94599. */
  94600. bind(world: Matrix, mesh?: Mesh): void;
  94601. /**
  94602. * Binds the submesh to the material
  94603. * @param world defines the world transformation matrix
  94604. * @param mesh defines the mesh containing the submesh
  94605. * @param subMesh defines the submesh to bind the material to
  94606. */
  94607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94608. /**
  94609. * Binds the world matrix to the material
  94610. * @param world defines the world transformation matrix
  94611. */
  94612. bindOnlyWorldMatrix(world: Matrix): void;
  94613. /**
  94614. * Binds the scene's uniform buffer to the effect.
  94615. * @param effect defines the effect to bind to the scene uniform buffer
  94616. * @param sceneUbo defines the uniform buffer storing scene data
  94617. */
  94618. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94619. /**
  94620. * Binds the view matrix to the effect
  94621. * @param effect defines the effect to bind the view matrix to
  94622. */
  94623. bindView(effect: Effect): void;
  94624. /**
  94625. * Binds the view projection matrix to the effect
  94626. * @param effect defines the effect to bind the view projection matrix to
  94627. */
  94628. bindViewProjection(effect: Effect): void;
  94629. /**
  94630. * Specifies if material alpha testing should be turned on for the mesh
  94631. * @param mesh defines the mesh to check
  94632. */
  94633. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94634. /**
  94635. * Processes to execute after binding the material to a mesh
  94636. * @param mesh defines the rendered mesh
  94637. */
  94638. protected _afterBind(mesh?: Mesh): void;
  94639. /**
  94640. * Unbinds the material from the mesh
  94641. */
  94642. unbind(): void;
  94643. /**
  94644. * Gets the active textures from the material
  94645. * @returns an array of textures
  94646. */
  94647. getActiveTextures(): BaseTexture[];
  94648. /**
  94649. * Specifies if the material uses a texture
  94650. * @param texture defines the texture to check against the material
  94651. * @returns a boolean specifying if the material uses the texture
  94652. */
  94653. hasTexture(texture: BaseTexture): boolean;
  94654. /**
  94655. * Makes a duplicate of the material, and gives it a new name
  94656. * @param name defines the new name for the duplicated material
  94657. * @returns the cloned material
  94658. */
  94659. clone(name: string): Nullable<Material>;
  94660. /**
  94661. * Gets the meshes bound to the material
  94662. * @returns an array of meshes bound to the material
  94663. */
  94664. getBindedMeshes(): AbstractMesh[];
  94665. /**
  94666. * Force shader compilation
  94667. * @param mesh defines the mesh associated with this material
  94668. * @param onCompiled defines a function to execute once the material is compiled
  94669. * @param options defines the options to configure the compilation
  94670. * @param onError defines a function to execute if the material fails compiling
  94671. */
  94672. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94673. /**
  94674. * Force shader compilation
  94675. * @param mesh defines the mesh that will use this material
  94676. * @param options defines additional options for compiling the shaders
  94677. * @returns a promise that resolves when the compilation completes
  94678. */
  94679. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94680. private static readonly _AllDirtyCallBack;
  94681. private static readonly _ImageProcessingDirtyCallBack;
  94682. private static readonly _TextureDirtyCallBack;
  94683. private static readonly _FresnelDirtyCallBack;
  94684. private static readonly _MiscDirtyCallBack;
  94685. private static readonly _LightsDirtyCallBack;
  94686. private static readonly _AttributeDirtyCallBack;
  94687. private static _FresnelAndMiscDirtyCallBack;
  94688. private static _TextureAndMiscDirtyCallBack;
  94689. private static readonly _DirtyCallbackArray;
  94690. private static readonly _RunDirtyCallBacks;
  94691. /**
  94692. * Marks a define in the material to indicate that it needs to be re-computed
  94693. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94694. */
  94695. markAsDirty(flag: number): void;
  94696. /**
  94697. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94698. * @param func defines a function which checks material defines against the submeshes
  94699. */
  94700. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94701. /**
  94702. * Indicates that we need to re-calculated for all submeshes
  94703. */
  94704. protected _markAllSubMeshesAsAllDirty(): void;
  94705. /**
  94706. * Indicates that image processing needs to be re-calculated for all submeshes
  94707. */
  94708. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94709. /**
  94710. * Indicates that textures need to be re-calculated for all submeshes
  94711. */
  94712. protected _markAllSubMeshesAsTexturesDirty(): void;
  94713. /**
  94714. * Indicates that fresnel needs to be re-calculated for all submeshes
  94715. */
  94716. protected _markAllSubMeshesAsFresnelDirty(): void;
  94717. /**
  94718. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94719. */
  94720. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94721. /**
  94722. * Indicates that lights need to be re-calculated for all submeshes
  94723. */
  94724. protected _markAllSubMeshesAsLightsDirty(): void;
  94725. /**
  94726. * Indicates that attributes need to be re-calculated for all submeshes
  94727. */
  94728. protected _markAllSubMeshesAsAttributesDirty(): void;
  94729. /**
  94730. * Indicates that misc needs to be re-calculated for all submeshes
  94731. */
  94732. protected _markAllSubMeshesAsMiscDirty(): void;
  94733. /**
  94734. * Indicates that textures and misc need to be re-calculated for all submeshes
  94735. */
  94736. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94737. /**
  94738. * Disposes the material
  94739. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94740. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94741. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94742. */
  94743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94744. /** @hidden */
  94745. private releaseVertexArrayObject;
  94746. /**
  94747. * Serializes this material
  94748. * @returns the serialized material object
  94749. */
  94750. serialize(): any;
  94751. /**
  94752. * Creates a material from parsed material data
  94753. * @param parsedMaterial defines parsed material data
  94754. * @param scene defines the hosting scene
  94755. * @param rootUrl defines the root URL to use to load textures
  94756. * @returns a new material
  94757. */
  94758. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94759. }
  94760. }
  94761. declare module BABYLON {
  94762. /**
  94763. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94764. * separate meshes. This can be use to improve performances.
  94765. * @see http://doc.babylonjs.com/how_to/multi_materials
  94766. */
  94767. export class MultiMaterial extends Material {
  94768. private _subMaterials;
  94769. /**
  94770. * Gets or Sets the list of Materials used within the multi material.
  94771. * They need to be ordered according to the submeshes order in the associated mesh
  94772. */
  94773. get subMaterials(): Nullable<Material>[];
  94774. set subMaterials(value: Nullable<Material>[]);
  94775. /**
  94776. * Function used to align with Node.getChildren()
  94777. * @returns the list of Materials used within the multi material
  94778. */
  94779. getChildren(): Nullable<Material>[];
  94780. /**
  94781. * Instantiates a new Multi Material
  94782. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94783. * separate meshes. This can be use to improve performances.
  94784. * @see http://doc.babylonjs.com/how_to/multi_materials
  94785. * @param name Define the name in the scene
  94786. * @param scene Define the scene the material belongs to
  94787. */
  94788. constructor(name: string, scene: Scene);
  94789. private _hookArray;
  94790. /**
  94791. * Get one of the submaterial by its index in the submaterials array
  94792. * @param index The index to look the sub material at
  94793. * @returns The Material if the index has been defined
  94794. */
  94795. getSubMaterial(index: number): Nullable<Material>;
  94796. /**
  94797. * Get the list of active textures for the whole sub materials list.
  94798. * @returns All the textures that will be used during the rendering
  94799. */
  94800. getActiveTextures(): BaseTexture[];
  94801. /**
  94802. * Gets the current class name of the material e.g. "MultiMaterial"
  94803. * Mainly use in serialization.
  94804. * @returns the class name
  94805. */
  94806. getClassName(): string;
  94807. /**
  94808. * Checks if the material is ready to render the requested sub mesh
  94809. * @param mesh Define the mesh the submesh belongs to
  94810. * @param subMesh Define the sub mesh to look readyness for
  94811. * @param useInstances Define whether or not the material is used with instances
  94812. * @returns true if ready, otherwise false
  94813. */
  94814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94815. /**
  94816. * Clones the current material and its related sub materials
  94817. * @param name Define the name of the newly cloned material
  94818. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94819. * @returns the cloned material
  94820. */
  94821. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94822. /**
  94823. * Serializes the materials into a JSON representation.
  94824. * @returns the JSON representation
  94825. */
  94826. serialize(): any;
  94827. /**
  94828. * Dispose the material and release its associated resources
  94829. * @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)
  94830. * @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)
  94831. * @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)
  94832. */
  94833. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94834. /**
  94835. * Creates a MultiMaterial from parsed MultiMaterial data.
  94836. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94837. * @param scene defines the hosting scene
  94838. * @returns a new MultiMaterial
  94839. */
  94840. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94841. }
  94842. }
  94843. declare module BABYLON {
  94844. /**
  94845. * Base class for submeshes
  94846. */
  94847. export class BaseSubMesh {
  94848. /** @hidden */
  94849. _materialDefines: Nullable<MaterialDefines>;
  94850. /** @hidden */
  94851. _materialEffect: Nullable<Effect>;
  94852. /**
  94853. * Gets material defines used by the effect associated to the sub mesh
  94854. */
  94855. get materialDefines(): Nullable<MaterialDefines>;
  94856. /**
  94857. * Sets material defines used by the effect associated to the sub mesh
  94858. */
  94859. set materialDefines(defines: Nullable<MaterialDefines>);
  94860. /**
  94861. * Gets associated effect
  94862. */
  94863. get effect(): Nullable<Effect>;
  94864. /**
  94865. * Sets associated effect (effect used to render this submesh)
  94866. * @param effect defines the effect to associate with
  94867. * @param defines defines the set of defines used to compile this effect
  94868. */
  94869. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94870. }
  94871. /**
  94872. * Defines a subdivision inside a mesh
  94873. */
  94874. export class SubMesh extends BaseSubMesh implements ICullable {
  94875. /** the material index to use */
  94876. materialIndex: number;
  94877. /** vertex index start */
  94878. verticesStart: number;
  94879. /** vertices count */
  94880. verticesCount: number;
  94881. /** index start */
  94882. indexStart: number;
  94883. /** indices count */
  94884. indexCount: number;
  94885. /** @hidden */
  94886. _linesIndexCount: number;
  94887. private _mesh;
  94888. private _renderingMesh;
  94889. private _boundingInfo;
  94890. private _linesIndexBuffer;
  94891. /** @hidden */
  94892. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94893. /** @hidden */
  94894. _trianglePlanes: Plane[];
  94895. /** @hidden */
  94896. _lastColliderTransformMatrix: Nullable<Matrix>;
  94897. /** @hidden */
  94898. _renderId: number;
  94899. /** @hidden */
  94900. _alphaIndex: number;
  94901. /** @hidden */
  94902. _distanceToCamera: number;
  94903. /** @hidden */
  94904. _id: number;
  94905. private _currentMaterial;
  94906. /**
  94907. * Add a new submesh to a mesh
  94908. * @param materialIndex defines the material index to use
  94909. * @param verticesStart defines vertex index start
  94910. * @param verticesCount defines vertices count
  94911. * @param indexStart defines index start
  94912. * @param indexCount defines indices count
  94913. * @param mesh defines the parent mesh
  94914. * @param renderingMesh defines an optional rendering mesh
  94915. * @param createBoundingBox defines if bounding box should be created for this submesh
  94916. * @returns the new submesh
  94917. */
  94918. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94919. /**
  94920. * Creates a new submesh
  94921. * @param materialIndex defines the material index to use
  94922. * @param verticesStart defines vertex index start
  94923. * @param verticesCount defines vertices count
  94924. * @param indexStart defines index start
  94925. * @param indexCount defines indices count
  94926. * @param mesh defines the parent mesh
  94927. * @param renderingMesh defines an optional rendering mesh
  94928. * @param createBoundingBox defines if bounding box should be created for this submesh
  94929. */
  94930. constructor(
  94931. /** the material index to use */
  94932. materialIndex: number,
  94933. /** vertex index start */
  94934. verticesStart: number,
  94935. /** vertices count */
  94936. verticesCount: number,
  94937. /** index start */
  94938. indexStart: number,
  94939. /** indices count */
  94940. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94941. /**
  94942. * Returns true if this submesh covers the entire parent mesh
  94943. * @ignorenaming
  94944. */
  94945. get IsGlobal(): boolean;
  94946. /**
  94947. * Returns the submesh BoudingInfo object
  94948. * @returns current bounding info (or mesh's one if the submesh is global)
  94949. */
  94950. getBoundingInfo(): BoundingInfo;
  94951. /**
  94952. * Sets the submesh BoundingInfo
  94953. * @param boundingInfo defines the new bounding info to use
  94954. * @returns the SubMesh
  94955. */
  94956. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94957. /**
  94958. * Returns the mesh of the current submesh
  94959. * @return the parent mesh
  94960. */
  94961. getMesh(): AbstractMesh;
  94962. /**
  94963. * Returns the rendering mesh of the submesh
  94964. * @returns the rendering mesh (could be different from parent mesh)
  94965. */
  94966. getRenderingMesh(): Mesh;
  94967. /**
  94968. * Returns the submesh material
  94969. * @returns null or the current material
  94970. */
  94971. getMaterial(): Nullable<Material>;
  94972. /**
  94973. * Sets a new updated BoundingInfo object to the submesh
  94974. * @param data defines an optional position array to use to determine the bounding info
  94975. * @returns the SubMesh
  94976. */
  94977. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94978. /** @hidden */
  94979. _checkCollision(collider: Collider): boolean;
  94980. /**
  94981. * Updates the submesh BoundingInfo
  94982. * @param world defines the world matrix to use to update the bounding info
  94983. * @returns the submesh
  94984. */
  94985. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94986. /**
  94987. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94988. * @param frustumPlanes defines the frustum planes
  94989. * @returns true if the submesh is intersecting with the frustum
  94990. */
  94991. isInFrustum(frustumPlanes: Plane[]): boolean;
  94992. /**
  94993. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94994. * @param frustumPlanes defines the frustum planes
  94995. * @returns true if the submesh is inside the frustum
  94996. */
  94997. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94998. /**
  94999. * Renders the submesh
  95000. * @param enableAlphaMode defines if alpha needs to be used
  95001. * @returns the submesh
  95002. */
  95003. render(enableAlphaMode: boolean): SubMesh;
  95004. /**
  95005. * @hidden
  95006. */
  95007. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95008. /**
  95009. * Checks if the submesh intersects with a ray
  95010. * @param ray defines the ray to test
  95011. * @returns true is the passed ray intersects the submesh bounding box
  95012. */
  95013. canIntersects(ray: Ray): boolean;
  95014. /**
  95015. * Intersects current submesh with a ray
  95016. * @param ray defines the ray to test
  95017. * @param positions defines mesh's positions array
  95018. * @param indices defines mesh's indices array
  95019. * @param fastCheck defines if only bounding info should be used
  95020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95021. * @returns intersection info or null if no intersection
  95022. */
  95023. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95024. /** @hidden */
  95025. private _intersectLines;
  95026. /** @hidden */
  95027. private _intersectUnIndexedLines;
  95028. /** @hidden */
  95029. private _intersectTriangles;
  95030. /** @hidden */
  95031. private _intersectUnIndexedTriangles;
  95032. /** @hidden */
  95033. _rebuild(): void;
  95034. /**
  95035. * Creates a new submesh from the passed mesh
  95036. * @param newMesh defines the new hosting mesh
  95037. * @param newRenderingMesh defines an optional rendering mesh
  95038. * @returns the new submesh
  95039. */
  95040. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95041. /**
  95042. * Release associated resources
  95043. */
  95044. dispose(): void;
  95045. /**
  95046. * Gets the class name
  95047. * @returns the string "SubMesh".
  95048. */
  95049. getClassName(): string;
  95050. /**
  95051. * Creates a new submesh from indices data
  95052. * @param materialIndex the index of the main mesh material
  95053. * @param startIndex the index where to start the copy in the mesh indices array
  95054. * @param indexCount the number of indices to copy then from the startIndex
  95055. * @param mesh the main mesh to create the submesh from
  95056. * @param renderingMesh the optional rendering mesh
  95057. * @returns a new submesh
  95058. */
  95059. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95060. }
  95061. }
  95062. declare module BABYLON {
  95063. /**
  95064. * Class used to represent data loading progression
  95065. */
  95066. export class SceneLoaderFlags {
  95067. private static _ForceFullSceneLoadingForIncremental;
  95068. private static _ShowLoadingScreen;
  95069. private static _CleanBoneMatrixWeights;
  95070. private static _loggingLevel;
  95071. /**
  95072. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95073. */
  95074. static get ForceFullSceneLoadingForIncremental(): boolean;
  95075. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95076. /**
  95077. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95078. */
  95079. static get ShowLoadingScreen(): boolean;
  95080. static set ShowLoadingScreen(value: boolean);
  95081. /**
  95082. * Defines the current logging level (while loading the scene)
  95083. * @ignorenaming
  95084. */
  95085. static get loggingLevel(): number;
  95086. static set loggingLevel(value: number);
  95087. /**
  95088. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95089. */
  95090. static get CleanBoneMatrixWeights(): boolean;
  95091. static set CleanBoneMatrixWeights(value: boolean);
  95092. }
  95093. }
  95094. declare module BABYLON {
  95095. /**
  95096. * Class used to store geometry data (vertex buffers + index buffer)
  95097. */
  95098. export class Geometry implements IGetSetVerticesData {
  95099. /**
  95100. * Gets or sets the ID of the geometry
  95101. */
  95102. id: string;
  95103. /**
  95104. * Gets or sets the unique ID of the geometry
  95105. */
  95106. uniqueId: number;
  95107. /**
  95108. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95109. */
  95110. delayLoadState: number;
  95111. /**
  95112. * Gets the file containing the data to load when running in delay load state
  95113. */
  95114. delayLoadingFile: Nullable<string>;
  95115. /**
  95116. * Callback called when the geometry is updated
  95117. */
  95118. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95119. private _scene;
  95120. private _engine;
  95121. private _meshes;
  95122. private _totalVertices;
  95123. /** @hidden */
  95124. _indices: IndicesArray;
  95125. /** @hidden */
  95126. _vertexBuffers: {
  95127. [key: string]: VertexBuffer;
  95128. };
  95129. private _isDisposed;
  95130. private _extend;
  95131. private _boundingBias;
  95132. /** @hidden */
  95133. _delayInfo: Array<string>;
  95134. private _indexBuffer;
  95135. private _indexBufferIsUpdatable;
  95136. /** @hidden */
  95137. _boundingInfo: Nullable<BoundingInfo>;
  95138. /** @hidden */
  95139. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95140. /** @hidden */
  95141. _softwareSkinningFrameId: number;
  95142. private _vertexArrayObjects;
  95143. private _updatable;
  95144. /** @hidden */
  95145. _positions: Nullable<Vector3[]>;
  95146. /**
  95147. * 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
  95148. */
  95149. get boundingBias(): Vector2;
  95150. /**
  95151. * 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
  95152. */
  95153. set boundingBias(value: Vector2);
  95154. /**
  95155. * Static function used to attach a new empty geometry to a mesh
  95156. * @param mesh defines the mesh to attach the geometry to
  95157. * @returns the new Geometry
  95158. */
  95159. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95160. /**
  95161. * Creates a new geometry
  95162. * @param id defines the unique ID
  95163. * @param scene defines the hosting scene
  95164. * @param vertexData defines the VertexData used to get geometry data
  95165. * @param updatable defines if geometry must be updatable (false by default)
  95166. * @param mesh defines the mesh that will be associated with the geometry
  95167. */
  95168. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95169. /**
  95170. * Gets the current extend of the geometry
  95171. */
  95172. get extend(): {
  95173. minimum: Vector3;
  95174. maximum: Vector3;
  95175. };
  95176. /**
  95177. * Gets the hosting scene
  95178. * @returns the hosting Scene
  95179. */
  95180. getScene(): Scene;
  95181. /**
  95182. * Gets the hosting engine
  95183. * @returns the hosting Engine
  95184. */
  95185. getEngine(): Engine;
  95186. /**
  95187. * Defines if the geometry is ready to use
  95188. * @returns true if the geometry is ready to be used
  95189. */
  95190. isReady(): boolean;
  95191. /**
  95192. * Gets a value indicating that the geometry should not be serialized
  95193. */
  95194. get doNotSerialize(): boolean;
  95195. /** @hidden */
  95196. _rebuild(): void;
  95197. /**
  95198. * Affects all geometry data in one call
  95199. * @param vertexData defines the geometry data
  95200. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95201. */
  95202. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95203. /**
  95204. * Set specific vertex data
  95205. * @param kind defines the data kind (Position, normal, etc...)
  95206. * @param data defines the vertex data to use
  95207. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95208. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95209. */
  95210. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95211. /**
  95212. * Removes a specific vertex data
  95213. * @param kind defines the data kind (Position, normal, etc...)
  95214. */
  95215. removeVerticesData(kind: string): void;
  95216. /**
  95217. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95218. * @param buffer defines the vertex buffer to use
  95219. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95220. */
  95221. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95222. /**
  95223. * Update a specific vertex buffer
  95224. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95225. * It will do nothing if the buffer is not updatable
  95226. * @param kind defines the data kind (Position, normal, etc...)
  95227. * @param data defines the data to use
  95228. * @param offset defines the offset in the target buffer where to store the data
  95229. * @param useBytes set to true if the offset is in bytes
  95230. */
  95231. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95232. /**
  95233. * Update a specific vertex buffer
  95234. * This function will create a new buffer if the current one is not updatable
  95235. * @param kind defines the data kind (Position, normal, etc...)
  95236. * @param data defines the data to use
  95237. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95238. */
  95239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95240. private _updateBoundingInfo;
  95241. /** @hidden */
  95242. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95243. /**
  95244. * Gets total number of vertices
  95245. * @returns the total number of vertices
  95246. */
  95247. getTotalVertices(): number;
  95248. /**
  95249. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95250. * @param kind defines the data kind (Position, normal, etc...)
  95251. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95252. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95253. * @returns a float array containing vertex data
  95254. */
  95255. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95256. /**
  95257. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95258. * @param kind defines the data kind (Position, normal, etc...)
  95259. * @returns true if the vertex buffer with the specified kind is updatable
  95260. */
  95261. isVertexBufferUpdatable(kind: string): boolean;
  95262. /**
  95263. * Gets a specific vertex buffer
  95264. * @param kind defines the data kind (Position, normal, etc...)
  95265. * @returns a VertexBuffer
  95266. */
  95267. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95268. /**
  95269. * Returns all vertex buffers
  95270. * @return an object holding all vertex buffers indexed by kind
  95271. */
  95272. getVertexBuffers(): Nullable<{
  95273. [key: string]: VertexBuffer;
  95274. }>;
  95275. /**
  95276. * Gets a boolean indicating if specific vertex buffer is present
  95277. * @param kind defines the data kind (Position, normal, etc...)
  95278. * @returns true if data is present
  95279. */
  95280. isVerticesDataPresent(kind: string): boolean;
  95281. /**
  95282. * Gets a list of all attached data kinds (Position, normal, etc...)
  95283. * @returns a list of string containing all kinds
  95284. */
  95285. getVerticesDataKinds(): string[];
  95286. /**
  95287. * Update index buffer
  95288. * @param indices defines the indices to store in the index buffer
  95289. * @param offset defines the offset in the target buffer where to store the data
  95290. * @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)
  95291. */
  95292. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95293. /**
  95294. * Creates a new index buffer
  95295. * @param indices defines the indices to store in the index buffer
  95296. * @param totalVertices defines the total number of vertices (could be null)
  95297. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95298. */
  95299. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95300. /**
  95301. * Return the total number of indices
  95302. * @returns the total number of indices
  95303. */
  95304. getTotalIndices(): number;
  95305. /**
  95306. * Gets the index buffer array
  95307. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95309. * @returns the index buffer array
  95310. */
  95311. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95312. /**
  95313. * Gets the index buffer
  95314. * @return the index buffer
  95315. */
  95316. getIndexBuffer(): Nullable<DataBuffer>;
  95317. /** @hidden */
  95318. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95319. /**
  95320. * Release the associated resources for a specific mesh
  95321. * @param mesh defines the source mesh
  95322. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95323. */
  95324. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95325. /**
  95326. * Apply current geometry to a given mesh
  95327. * @param mesh defines the mesh to apply geometry to
  95328. */
  95329. applyToMesh(mesh: Mesh): void;
  95330. private _updateExtend;
  95331. private _applyToMesh;
  95332. private notifyUpdate;
  95333. /**
  95334. * Load the geometry if it was flagged as delay loaded
  95335. * @param scene defines the hosting scene
  95336. * @param onLoaded defines a callback called when the geometry is loaded
  95337. */
  95338. load(scene: Scene, onLoaded?: () => void): void;
  95339. private _queueLoad;
  95340. /**
  95341. * Invert the geometry to move from a right handed system to a left handed one.
  95342. */
  95343. toLeftHanded(): void;
  95344. /** @hidden */
  95345. _resetPointsArrayCache(): void;
  95346. /** @hidden */
  95347. _generatePointsArray(): boolean;
  95348. /**
  95349. * Gets a value indicating if the geometry is disposed
  95350. * @returns true if the geometry was disposed
  95351. */
  95352. isDisposed(): boolean;
  95353. private _disposeVertexArrayObjects;
  95354. /**
  95355. * Free all associated resources
  95356. */
  95357. dispose(): void;
  95358. /**
  95359. * Clone the current geometry into a new geometry
  95360. * @param id defines the unique ID of the new geometry
  95361. * @returns a new geometry object
  95362. */
  95363. copy(id: string): Geometry;
  95364. /**
  95365. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95366. * @return a JSON representation of the current geometry data (without the vertices data)
  95367. */
  95368. serialize(): any;
  95369. private toNumberArray;
  95370. /**
  95371. * Serialize all vertices data into a JSON oject
  95372. * @returns a JSON representation of the current geometry data
  95373. */
  95374. serializeVerticeData(): any;
  95375. /**
  95376. * Extracts a clone of a mesh geometry
  95377. * @param mesh defines the source mesh
  95378. * @param id defines the unique ID of the new geometry object
  95379. * @returns the new geometry object
  95380. */
  95381. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95382. /**
  95383. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95384. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95385. * Be aware Math.random() could cause collisions, but:
  95386. * "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"
  95387. * @returns a string containing a new GUID
  95388. */
  95389. static RandomId(): string;
  95390. /** @hidden */
  95391. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95392. private static _CleanMatricesWeights;
  95393. /**
  95394. * Create a new geometry from persisted data (Using .babylon file format)
  95395. * @param parsedVertexData defines the persisted data
  95396. * @param scene defines the hosting scene
  95397. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95398. * @returns the new geometry object
  95399. */
  95400. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95401. }
  95402. }
  95403. declare module BABYLON {
  95404. /**
  95405. * Define an interface for all classes that will get and set the data on vertices
  95406. */
  95407. export interface IGetSetVerticesData {
  95408. /**
  95409. * Gets a boolean indicating if specific vertex data is present
  95410. * @param kind defines the vertex data kind to use
  95411. * @returns true is data kind is present
  95412. */
  95413. isVerticesDataPresent(kind: string): boolean;
  95414. /**
  95415. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95416. * @param kind defines the data kind (Position, normal, etc...)
  95417. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95418. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95419. * @returns a float array containing vertex data
  95420. */
  95421. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95422. /**
  95423. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95424. * @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.
  95425. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95426. * @returns the indices array or an empty array if the mesh has no geometry
  95427. */
  95428. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95429. /**
  95430. * Set specific vertex data
  95431. * @param kind defines the data kind (Position, normal, etc...)
  95432. * @param data defines the vertex data to use
  95433. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95434. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95435. */
  95436. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95437. /**
  95438. * Update a specific associated vertex buffer
  95439. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95440. * - VertexBuffer.PositionKind
  95441. * - VertexBuffer.UVKind
  95442. * - VertexBuffer.UV2Kind
  95443. * - VertexBuffer.UV3Kind
  95444. * - VertexBuffer.UV4Kind
  95445. * - VertexBuffer.UV5Kind
  95446. * - VertexBuffer.UV6Kind
  95447. * - VertexBuffer.ColorKind
  95448. * - VertexBuffer.MatricesIndicesKind
  95449. * - VertexBuffer.MatricesIndicesExtraKind
  95450. * - VertexBuffer.MatricesWeightsKind
  95451. * - VertexBuffer.MatricesWeightsExtraKind
  95452. * @param data defines the data source
  95453. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95454. * @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)
  95455. */
  95456. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95457. /**
  95458. * Creates a new index buffer
  95459. * @param indices defines the indices to store in the index buffer
  95460. * @param totalVertices defines the total number of vertices (could be null)
  95461. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95462. */
  95463. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95464. }
  95465. /**
  95466. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95467. */
  95468. export class VertexData {
  95469. /**
  95470. * Mesh side orientation : usually the external or front surface
  95471. */
  95472. static readonly FRONTSIDE: number;
  95473. /**
  95474. * Mesh side orientation : usually the internal or back surface
  95475. */
  95476. static readonly BACKSIDE: number;
  95477. /**
  95478. * Mesh side orientation : both internal and external or front and back surfaces
  95479. */
  95480. static readonly DOUBLESIDE: number;
  95481. /**
  95482. * Mesh side orientation : by default, `FRONTSIDE`
  95483. */
  95484. static readonly DEFAULTSIDE: number;
  95485. /**
  95486. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95487. */
  95488. positions: Nullable<FloatArray>;
  95489. /**
  95490. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95491. */
  95492. normals: Nullable<FloatArray>;
  95493. /**
  95494. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95495. */
  95496. tangents: Nullable<FloatArray>;
  95497. /**
  95498. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95499. */
  95500. uvs: Nullable<FloatArray>;
  95501. /**
  95502. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95503. */
  95504. uvs2: Nullable<FloatArray>;
  95505. /**
  95506. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95507. */
  95508. uvs3: Nullable<FloatArray>;
  95509. /**
  95510. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95511. */
  95512. uvs4: Nullable<FloatArray>;
  95513. /**
  95514. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95515. */
  95516. uvs5: Nullable<FloatArray>;
  95517. /**
  95518. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95519. */
  95520. uvs6: Nullable<FloatArray>;
  95521. /**
  95522. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95523. */
  95524. colors: Nullable<FloatArray>;
  95525. /**
  95526. * 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).
  95527. */
  95528. matricesIndices: Nullable<FloatArray>;
  95529. /**
  95530. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95531. */
  95532. matricesWeights: Nullable<FloatArray>;
  95533. /**
  95534. * An array extending the number of possible indices
  95535. */
  95536. matricesIndicesExtra: Nullable<FloatArray>;
  95537. /**
  95538. * An array extending the number of possible weights when the number of indices is extended
  95539. */
  95540. matricesWeightsExtra: Nullable<FloatArray>;
  95541. /**
  95542. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95543. */
  95544. indices: Nullable<IndicesArray>;
  95545. /**
  95546. * Uses the passed data array to set the set the values for the specified kind of data
  95547. * @param data a linear array of floating numbers
  95548. * @param kind the type of data that is being set, eg positions, colors etc
  95549. */
  95550. set(data: FloatArray, kind: string): void;
  95551. /**
  95552. * Associates the vertexData to the passed Mesh.
  95553. * Sets it as updatable or not (default `false`)
  95554. * @param mesh the mesh the vertexData is applied to
  95555. * @param updatable when used and having the value true allows new data to update the vertexData
  95556. * @returns the VertexData
  95557. */
  95558. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95559. /**
  95560. * Associates the vertexData to the passed Geometry.
  95561. * Sets it as updatable or not (default `false`)
  95562. * @param geometry the geometry the vertexData is applied to
  95563. * @param updatable when used and having the value true allows new data to update the vertexData
  95564. * @returns VertexData
  95565. */
  95566. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95567. /**
  95568. * Updates the associated mesh
  95569. * @param mesh the mesh to be updated
  95570. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95571. * @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
  95572. * @returns VertexData
  95573. */
  95574. updateMesh(mesh: Mesh): VertexData;
  95575. /**
  95576. * Updates the associated geometry
  95577. * @param geometry the geometry to be updated
  95578. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95579. * @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
  95580. * @returns VertexData.
  95581. */
  95582. updateGeometry(geometry: Geometry): VertexData;
  95583. private _applyTo;
  95584. private _update;
  95585. /**
  95586. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95587. * @param matrix the transforming matrix
  95588. * @returns the VertexData
  95589. */
  95590. transform(matrix: Matrix): VertexData;
  95591. /**
  95592. * Merges the passed VertexData into the current one
  95593. * @param other the VertexData to be merged into the current one
  95594. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95595. * @returns the modified VertexData
  95596. */
  95597. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95598. private _mergeElement;
  95599. private _validate;
  95600. /**
  95601. * Serializes the VertexData
  95602. * @returns a serialized object
  95603. */
  95604. serialize(): any;
  95605. /**
  95606. * Extracts the vertexData from a mesh
  95607. * @param mesh the mesh from which to extract the VertexData
  95608. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95609. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95610. * @returns the object VertexData associated to the passed mesh
  95611. */
  95612. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95613. /**
  95614. * Extracts the vertexData from the geometry
  95615. * @param geometry the geometry from which to extract the VertexData
  95616. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95617. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95618. * @returns the object VertexData associated to the passed mesh
  95619. */
  95620. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95621. private static _ExtractFrom;
  95622. /**
  95623. * Creates the VertexData for a Ribbon
  95624. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95625. * * pathArray array of paths, each of which an array of successive Vector3
  95626. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95627. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95628. * * 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
  95629. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95630. * * 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)
  95631. * * 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)
  95632. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95633. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95634. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95635. * @returns the VertexData of the ribbon
  95636. */
  95637. static CreateRibbon(options: {
  95638. pathArray: Vector3[][];
  95639. closeArray?: boolean;
  95640. closePath?: boolean;
  95641. offset?: number;
  95642. sideOrientation?: number;
  95643. frontUVs?: Vector4;
  95644. backUVs?: Vector4;
  95645. invertUV?: boolean;
  95646. uvs?: Vector2[];
  95647. colors?: Color4[];
  95648. }): VertexData;
  95649. /**
  95650. * Creates the VertexData for a box
  95651. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95652. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95653. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95654. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95655. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95656. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95657. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95659. * * 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)
  95660. * * 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)
  95661. * @returns the VertexData of the box
  95662. */
  95663. static CreateBox(options: {
  95664. size?: number;
  95665. width?: number;
  95666. height?: number;
  95667. depth?: number;
  95668. faceUV?: Vector4[];
  95669. faceColors?: Color4[];
  95670. sideOrientation?: number;
  95671. frontUVs?: Vector4;
  95672. backUVs?: Vector4;
  95673. }): VertexData;
  95674. /**
  95675. * Creates the VertexData for a tiled box
  95676. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95677. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95678. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95679. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95681. * @returns the VertexData of the box
  95682. */
  95683. static CreateTiledBox(options: {
  95684. pattern?: number;
  95685. width?: number;
  95686. height?: number;
  95687. depth?: number;
  95688. tileSize?: number;
  95689. tileWidth?: number;
  95690. tileHeight?: number;
  95691. alignHorizontal?: number;
  95692. alignVertical?: number;
  95693. faceUV?: Vector4[];
  95694. faceColors?: Color4[];
  95695. sideOrientation?: number;
  95696. }): VertexData;
  95697. /**
  95698. * Creates the VertexData for a tiled plane
  95699. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95700. * * pattern a limited pattern arrangement depending on the number
  95701. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95702. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95703. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95705. * * 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)
  95706. * * 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)
  95707. * @returns the VertexData of the tiled plane
  95708. */
  95709. static CreateTiledPlane(options: {
  95710. pattern?: number;
  95711. tileSize?: number;
  95712. tileWidth?: number;
  95713. tileHeight?: number;
  95714. size?: number;
  95715. width?: number;
  95716. height?: number;
  95717. alignHorizontal?: number;
  95718. alignVertical?: number;
  95719. sideOrientation?: number;
  95720. frontUVs?: Vector4;
  95721. backUVs?: Vector4;
  95722. }): VertexData;
  95723. /**
  95724. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95725. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95726. * * segments sets the number of horizontal strips optional, default 32
  95727. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95728. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95729. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95730. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95731. * * 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
  95732. * * 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
  95733. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95734. * * 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)
  95735. * * 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)
  95736. * @returns the VertexData of the ellipsoid
  95737. */
  95738. static CreateSphere(options: {
  95739. segments?: number;
  95740. diameter?: number;
  95741. diameterX?: number;
  95742. diameterY?: number;
  95743. diameterZ?: number;
  95744. arc?: number;
  95745. slice?: number;
  95746. sideOrientation?: number;
  95747. frontUVs?: Vector4;
  95748. backUVs?: Vector4;
  95749. }): VertexData;
  95750. /**
  95751. * Creates the VertexData for a cylinder, cone or prism
  95752. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95753. * * height sets the height (y direction) of the cylinder, optional, default 2
  95754. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95755. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95756. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95757. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95758. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95759. * * 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
  95760. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95761. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95762. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95763. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95765. * * 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)
  95766. * * 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)
  95767. * @returns the VertexData of the cylinder, cone or prism
  95768. */
  95769. static CreateCylinder(options: {
  95770. height?: number;
  95771. diameterTop?: number;
  95772. diameterBottom?: number;
  95773. diameter?: number;
  95774. tessellation?: number;
  95775. subdivisions?: number;
  95776. arc?: number;
  95777. faceColors?: Color4[];
  95778. faceUV?: Vector4[];
  95779. hasRings?: boolean;
  95780. enclose?: boolean;
  95781. sideOrientation?: number;
  95782. frontUVs?: Vector4;
  95783. backUVs?: Vector4;
  95784. }): VertexData;
  95785. /**
  95786. * Creates the VertexData for a torus
  95787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95788. * * diameter the diameter of the torus, optional default 1
  95789. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95790. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95792. * * 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)
  95793. * * 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)
  95794. * @returns the VertexData of the torus
  95795. */
  95796. static CreateTorus(options: {
  95797. diameter?: number;
  95798. thickness?: number;
  95799. tessellation?: number;
  95800. sideOrientation?: number;
  95801. frontUVs?: Vector4;
  95802. backUVs?: Vector4;
  95803. }): VertexData;
  95804. /**
  95805. * Creates the VertexData of the LineSystem
  95806. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95807. * - lines an array of lines, each line being an array of successive Vector3
  95808. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95809. * @returns the VertexData of the LineSystem
  95810. */
  95811. static CreateLineSystem(options: {
  95812. lines: Vector3[][];
  95813. colors?: Nullable<Color4[][]>;
  95814. }): VertexData;
  95815. /**
  95816. * Create the VertexData for a DashedLines
  95817. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95818. * - points an array successive Vector3
  95819. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95820. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95821. * - dashNb the intended total number of dashes, optional, default 200
  95822. * @returns the VertexData for the DashedLines
  95823. */
  95824. static CreateDashedLines(options: {
  95825. points: Vector3[];
  95826. dashSize?: number;
  95827. gapSize?: number;
  95828. dashNb?: number;
  95829. }): VertexData;
  95830. /**
  95831. * Creates the VertexData for a Ground
  95832. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95833. * - width the width (x direction) of the ground, optional, default 1
  95834. * - height the height (z direction) of the ground, optional, default 1
  95835. * - subdivisions the number of subdivisions per side, optional, default 1
  95836. * @returns the VertexData of the Ground
  95837. */
  95838. static CreateGround(options: {
  95839. width?: number;
  95840. height?: number;
  95841. subdivisions?: number;
  95842. subdivisionsX?: number;
  95843. subdivisionsY?: number;
  95844. }): VertexData;
  95845. /**
  95846. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95847. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95848. * * xmin the ground minimum X coordinate, optional, default -1
  95849. * * zmin the ground minimum Z coordinate, optional, default -1
  95850. * * xmax the ground maximum X coordinate, optional, default 1
  95851. * * zmax the ground maximum Z coordinate, optional, default 1
  95852. * * 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}
  95853. * * 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}
  95854. * @returns the VertexData of the TiledGround
  95855. */
  95856. static CreateTiledGround(options: {
  95857. xmin: number;
  95858. zmin: number;
  95859. xmax: number;
  95860. zmax: number;
  95861. subdivisions?: {
  95862. w: number;
  95863. h: number;
  95864. };
  95865. precision?: {
  95866. w: number;
  95867. h: number;
  95868. };
  95869. }): VertexData;
  95870. /**
  95871. * Creates the VertexData of the Ground designed from a heightmap
  95872. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95873. * * width the width (x direction) of the ground
  95874. * * height the height (z direction) of the ground
  95875. * * subdivisions the number of subdivisions per side
  95876. * * minHeight the minimum altitude on the ground, optional, default 0
  95877. * * maxHeight the maximum altitude on the ground, optional default 1
  95878. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95879. * * buffer the array holding the image color data
  95880. * * bufferWidth the width of image
  95881. * * bufferHeight the height of image
  95882. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95883. * @returns the VertexData of the Ground designed from a heightmap
  95884. */
  95885. static CreateGroundFromHeightMap(options: {
  95886. width: number;
  95887. height: number;
  95888. subdivisions: number;
  95889. minHeight: number;
  95890. maxHeight: number;
  95891. colorFilter: Color3;
  95892. buffer: Uint8Array;
  95893. bufferWidth: number;
  95894. bufferHeight: number;
  95895. alphaFilter: number;
  95896. }): VertexData;
  95897. /**
  95898. * Creates the VertexData for a Plane
  95899. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95900. * * size sets the width and height of the plane to the value of size, optional default 1
  95901. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95902. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95904. * * 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)
  95905. * * 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)
  95906. * @returns the VertexData of the box
  95907. */
  95908. static CreatePlane(options: {
  95909. size?: number;
  95910. width?: number;
  95911. height?: number;
  95912. sideOrientation?: number;
  95913. frontUVs?: Vector4;
  95914. backUVs?: Vector4;
  95915. }): VertexData;
  95916. /**
  95917. * Creates the VertexData of the Disc or regular Polygon
  95918. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95919. * * radius the radius of the disc, optional default 0.5
  95920. * * tessellation the number of polygon sides, optional, default 64
  95921. * * 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
  95922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95923. * * 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)
  95924. * * 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)
  95925. * @returns the VertexData of the box
  95926. */
  95927. static CreateDisc(options: {
  95928. radius?: number;
  95929. tessellation?: number;
  95930. arc?: number;
  95931. sideOrientation?: number;
  95932. frontUVs?: Vector4;
  95933. backUVs?: Vector4;
  95934. }): VertexData;
  95935. /**
  95936. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95937. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95938. * @param polygon a mesh built from polygonTriangulation.build()
  95939. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95940. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95941. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95942. * @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)
  95943. * @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)
  95944. * @returns the VertexData of the Polygon
  95945. */
  95946. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95947. /**
  95948. * Creates the VertexData of the IcoSphere
  95949. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95950. * * radius the radius of the IcoSphere, optional default 1
  95951. * * radiusX allows stretching in the x direction, optional, default radius
  95952. * * radiusY allows stretching in the y direction, optional, default radius
  95953. * * radiusZ allows stretching in the z direction, optional, default radius
  95954. * * flat when true creates a flat shaded mesh, optional, default true
  95955. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95957. * * 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)
  95958. * * 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)
  95959. * @returns the VertexData of the IcoSphere
  95960. */
  95961. static CreateIcoSphere(options: {
  95962. radius?: number;
  95963. radiusX?: number;
  95964. radiusY?: number;
  95965. radiusZ?: number;
  95966. flat?: boolean;
  95967. subdivisions?: number;
  95968. sideOrientation?: number;
  95969. frontUVs?: Vector4;
  95970. backUVs?: Vector4;
  95971. }): VertexData;
  95972. /**
  95973. * Creates the VertexData for a Polyhedron
  95974. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95975. * * type provided types are:
  95976. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95977. * * 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)
  95978. * * size the size of the IcoSphere, optional default 1
  95979. * * sizeX allows stretching in the x direction, optional, default size
  95980. * * sizeY allows stretching in the y direction, optional, default size
  95981. * * sizeZ allows stretching in the z direction, optional, default size
  95982. * * 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
  95983. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95984. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95985. * * flat when true creates a flat shaded mesh, optional, default true
  95986. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95988. * * 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)
  95989. * * 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)
  95990. * @returns the VertexData of the Polyhedron
  95991. */
  95992. static CreatePolyhedron(options: {
  95993. type?: number;
  95994. size?: number;
  95995. sizeX?: number;
  95996. sizeY?: number;
  95997. sizeZ?: number;
  95998. custom?: any;
  95999. faceUV?: Vector4[];
  96000. faceColors?: Color4[];
  96001. flat?: boolean;
  96002. sideOrientation?: number;
  96003. frontUVs?: Vector4;
  96004. backUVs?: Vector4;
  96005. }): VertexData;
  96006. /**
  96007. * Creates the VertexData for a TorusKnot
  96008. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96009. * * radius the radius of the torus knot, optional, default 2
  96010. * * tube the thickness of the tube, optional, default 0.5
  96011. * * radialSegments the number of sides on each tube segments, optional, default 32
  96012. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96013. * * p the number of windings around the z axis, optional, default 2
  96014. * * q the number of windings around the x axis, optional, default 3
  96015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96016. * * 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)
  96017. * * 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)
  96018. * @returns the VertexData of the Torus Knot
  96019. */
  96020. static CreateTorusKnot(options: {
  96021. radius?: number;
  96022. tube?: number;
  96023. radialSegments?: number;
  96024. tubularSegments?: number;
  96025. p?: number;
  96026. q?: number;
  96027. sideOrientation?: number;
  96028. frontUVs?: Vector4;
  96029. backUVs?: Vector4;
  96030. }): VertexData;
  96031. /**
  96032. * Compute normals for given positions and indices
  96033. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96034. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96035. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96036. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96037. * * facetNormals : optional array of facet normals (vector3)
  96038. * * facetPositions : optional array of facet positions (vector3)
  96039. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96040. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96041. * * bInfo : optional bounding info, required for facetPartitioning computation
  96042. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96043. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96044. * * useRightHandedSystem: optional boolean to for right handed system computation
  96045. * * depthSort : optional boolean to enable the facet depth sort computation
  96046. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96047. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96048. */
  96049. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96050. facetNormals?: any;
  96051. facetPositions?: any;
  96052. facetPartitioning?: any;
  96053. ratio?: number;
  96054. bInfo?: any;
  96055. bbSize?: Vector3;
  96056. subDiv?: any;
  96057. useRightHandedSystem?: boolean;
  96058. depthSort?: boolean;
  96059. distanceTo?: Vector3;
  96060. depthSortedFacets?: any;
  96061. }): void;
  96062. /** @hidden */
  96063. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96064. /**
  96065. * Applies VertexData created from the imported parameters to the geometry
  96066. * @param parsedVertexData the parsed data from an imported file
  96067. * @param geometry the geometry to apply the VertexData to
  96068. */
  96069. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96070. }
  96071. }
  96072. declare module BABYLON {
  96073. /**
  96074. * Defines a target to use with MorphTargetManager
  96075. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96076. */
  96077. export class MorphTarget implements IAnimatable {
  96078. /** defines the name of the target */
  96079. name: string;
  96080. /**
  96081. * Gets or sets the list of animations
  96082. */
  96083. animations: Animation[];
  96084. private _scene;
  96085. private _positions;
  96086. private _normals;
  96087. private _tangents;
  96088. private _uvs;
  96089. private _influence;
  96090. private _uniqueId;
  96091. /**
  96092. * Observable raised when the influence changes
  96093. */
  96094. onInfluenceChanged: Observable<boolean>;
  96095. /** @hidden */
  96096. _onDataLayoutChanged: Observable<void>;
  96097. /**
  96098. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96099. */
  96100. get influence(): number;
  96101. set influence(influence: number);
  96102. /**
  96103. * Gets or sets the id of the morph Target
  96104. */
  96105. id: string;
  96106. private _animationPropertiesOverride;
  96107. /**
  96108. * Gets or sets the animation properties override
  96109. */
  96110. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96111. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96112. /**
  96113. * Creates a new MorphTarget
  96114. * @param name defines the name of the target
  96115. * @param influence defines the influence to use
  96116. * @param scene defines the scene the morphtarget belongs to
  96117. */
  96118. constructor(
  96119. /** defines the name of the target */
  96120. name: string, influence?: number, scene?: Nullable<Scene>);
  96121. /**
  96122. * Gets the unique ID of this manager
  96123. */
  96124. get uniqueId(): number;
  96125. /**
  96126. * Gets a boolean defining if the target contains position data
  96127. */
  96128. get hasPositions(): boolean;
  96129. /**
  96130. * Gets a boolean defining if the target contains normal data
  96131. */
  96132. get hasNormals(): boolean;
  96133. /**
  96134. * Gets a boolean defining if the target contains tangent data
  96135. */
  96136. get hasTangents(): boolean;
  96137. /**
  96138. * Gets a boolean defining if the target contains texture coordinates data
  96139. */
  96140. get hasUVs(): boolean;
  96141. /**
  96142. * Affects position data to this target
  96143. * @param data defines the position data to use
  96144. */
  96145. setPositions(data: Nullable<FloatArray>): void;
  96146. /**
  96147. * Gets the position data stored in this target
  96148. * @returns a FloatArray containing the position data (or null if not present)
  96149. */
  96150. getPositions(): Nullable<FloatArray>;
  96151. /**
  96152. * Affects normal data to this target
  96153. * @param data defines the normal data to use
  96154. */
  96155. setNormals(data: Nullable<FloatArray>): void;
  96156. /**
  96157. * Gets the normal data stored in this target
  96158. * @returns a FloatArray containing the normal data (or null if not present)
  96159. */
  96160. getNormals(): Nullable<FloatArray>;
  96161. /**
  96162. * Affects tangent data to this target
  96163. * @param data defines the tangent data to use
  96164. */
  96165. setTangents(data: Nullable<FloatArray>): void;
  96166. /**
  96167. * Gets the tangent data stored in this target
  96168. * @returns a FloatArray containing the tangent data (or null if not present)
  96169. */
  96170. getTangents(): Nullable<FloatArray>;
  96171. /**
  96172. * Affects texture coordinates data to this target
  96173. * @param data defines the texture coordinates data to use
  96174. */
  96175. setUVs(data: Nullable<FloatArray>): void;
  96176. /**
  96177. * Gets the texture coordinates data stored in this target
  96178. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96179. */
  96180. getUVs(): Nullable<FloatArray>;
  96181. /**
  96182. * Clone the current target
  96183. * @returns a new MorphTarget
  96184. */
  96185. clone(): MorphTarget;
  96186. /**
  96187. * Serializes the current target into a Serialization object
  96188. * @returns the serialized object
  96189. */
  96190. serialize(): any;
  96191. /**
  96192. * Returns the string "MorphTarget"
  96193. * @returns "MorphTarget"
  96194. */
  96195. getClassName(): string;
  96196. /**
  96197. * Creates a new target from serialized data
  96198. * @param serializationObject defines the serialized data to use
  96199. * @returns a new MorphTarget
  96200. */
  96201. static Parse(serializationObject: any): MorphTarget;
  96202. /**
  96203. * Creates a MorphTarget from mesh data
  96204. * @param mesh defines the source mesh
  96205. * @param name defines the name to use for the new target
  96206. * @param influence defines the influence to attach to the target
  96207. * @returns a new MorphTarget
  96208. */
  96209. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96210. }
  96211. }
  96212. declare module BABYLON {
  96213. /**
  96214. * This class is used to deform meshes using morphing between different targets
  96215. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96216. */
  96217. export class MorphTargetManager {
  96218. private _targets;
  96219. private _targetInfluenceChangedObservers;
  96220. private _targetDataLayoutChangedObservers;
  96221. private _activeTargets;
  96222. private _scene;
  96223. private _influences;
  96224. private _supportsNormals;
  96225. private _supportsTangents;
  96226. private _supportsUVs;
  96227. private _vertexCount;
  96228. private _uniqueId;
  96229. private _tempInfluences;
  96230. /**
  96231. * Gets or sets a boolean indicating if normals must be morphed
  96232. */
  96233. enableNormalMorphing: boolean;
  96234. /**
  96235. * Gets or sets a boolean indicating if tangents must be morphed
  96236. */
  96237. enableTangentMorphing: boolean;
  96238. /**
  96239. * Gets or sets a boolean indicating if UV must be morphed
  96240. */
  96241. enableUVMorphing: boolean;
  96242. /**
  96243. * Creates a new MorphTargetManager
  96244. * @param scene defines the current scene
  96245. */
  96246. constructor(scene?: Nullable<Scene>);
  96247. /**
  96248. * Gets the unique ID of this manager
  96249. */
  96250. get uniqueId(): number;
  96251. /**
  96252. * Gets the number of vertices handled by this manager
  96253. */
  96254. get vertexCount(): number;
  96255. /**
  96256. * Gets a boolean indicating if this manager supports morphing of normals
  96257. */
  96258. get supportsNormals(): boolean;
  96259. /**
  96260. * Gets a boolean indicating if this manager supports morphing of tangents
  96261. */
  96262. get supportsTangents(): boolean;
  96263. /**
  96264. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96265. */
  96266. get supportsUVs(): boolean;
  96267. /**
  96268. * Gets the number of targets stored in this manager
  96269. */
  96270. get numTargets(): number;
  96271. /**
  96272. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96273. */
  96274. get numInfluencers(): number;
  96275. /**
  96276. * Gets the list of influences (one per target)
  96277. */
  96278. get influences(): Float32Array;
  96279. /**
  96280. * Gets the active target at specified index. An active target is a target with an influence > 0
  96281. * @param index defines the index to check
  96282. * @returns the requested target
  96283. */
  96284. getActiveTarget(index: number): MorphTarget;
  96285. /**
  96286. * Gets the target at specified index
  96287. * @param index defines the index to check
  96288. * @returns the requested target
  96289. */
  96290. getTarget(index: number): MorphTarget;
  96291. /**
  96292. * Add a new target to this manager
  96293. * @param target defines the target to add
  96294. */
  96295. addTarget(target: MorphTarget): void;
  96296. /**
  96297. * Removes a target from the manager
  96298. * @param target defines the target to remove
  96299. */
  96300. removeTarget(target: MorphTarget): void;
  96301. /**
  96302. * Clone the current manager
  96303. * @returns a new MorphTargetManager
  96304. */
  96305. clone(): MorphTargetManager;
  96306. /**
  96307. * Serializes the current manager into a Serialization object
  96308. * @returns the serialized object
  96309. */
  96310. serialize(): any;
  96311. private _syncActiveTargets;
  96312. /**
  96313. * Syncrhonize the targets with all the meshes using this morph target manager
  96314. */
  96315. synchronize(): void;
  96316. /**
  96317. * Creates a new MorphTargetManager from serialized data
  96318. * @param serializationObject defines the serialized data
  96319. * @param scene defines the hosting scene
  96320. * @returns the new MorphTargetManager
  96321. */
  96322. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96323. }
  96324. }
  96325. declare module BABYLON {
  96326. /**
  96327. * Class used to represent a specific level of detail of a mesh
  96328. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96329. */
  96330. export class MeshLODLevel {
  96331. /** Defines the distance where this level should start being displayed */
  96332. distance: number;
  96333. /** Defines the mesh to use to render this level */
  96334. mesh: Nullable<Mesh>;
  96335. /**
  96336. * Creates a new LOD level
  96337. * @param distance defines the distance where this level should star being displayed
  96338. * @param mesh defines the mesh to use to render this level
  96339. */
  96340. constructor(
  96341. /** Defines the distance where this level should start being displayed */
  96342. distance: number,
  96343. /** Defines the mesh to use to render this level */
  96344. mesh: Nullable<Mesh>);
  96345. }
  96346. }
  96347. declare module BABYLON {
  96348. /**
  96349. * Mesh representing the gorund
  96350. */
  96351. export class GroundMesh extends Mesh {
  96352. /** If octree should be generated */
  96353. generateOctree: boolean;
  96354. private _heightQuads;
  96355. /** @hidden */
  96356. _subdivisionsX: number;
  96357. /** @hidden */
  96358. _subdivisionsY: number;
  96359. /** @hidden */
  96360. _width: number;
  96361. /** @hidden */
  96362. _height: number;
  96363. /** @hidden */
  96364. _minX: number;
  96365. /** @hidden */
  96366. _maxX: number;
  96367. /** @hidden */
  96368. _minZ: number;
  96369. /** @hidden */
  96370. _maxZ: number;
  96371. constructor(name: string, scene: Scene);
  96372. /**
  96373. * "GroundMesh"
  96374. * @returns "GroundMesh"
  96375. */
  96376. getClassName(): string;
  96377. /**
  96378. * The minimum of x and y subdivisions
  96379. */
  96380. get subdivisions(): number;
  96381. /**
  96382. * X subdivisions
  96383. */
  96384. get subdivisionsX(): number;
  96385. /**
  96386. * Y subdivisions
  96387. */
  96388. get subdivisionsY(): number;
  96389. /**
  96390. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96391. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96392. * @param chunksCount the number of subdivisions for x and y
  96393. * @param octreeBlocksSize (Default: 32)
  96394. */
  96395. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96396. /**
  96397. * Returns a height (y) value in the Worl system :
  96398. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96399. * @param x x coordinate
  96400. * @param z z coordinate
  96401. * @returns the ground y position if (x, z) are outside the ground surface.
  96402. */
  96403. getHeightAtCoordinates(x: number, z: number): number;
  96404. /**
  96405. * Returns a normalized vector (Vector3) orthogonal to the ground
  96406. * at the ground coordinates (x, z) expressed in the World system.
  96407. * @param x x coordinate
  96408. * @param z z coordinate
  96409. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96410. */
  96411. getNormalAtCoordinates(x: number, z: number): Vector3;
  96412. /**
  96413. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96414. * at the ground coordinates (x, z) expressed in the World system.
  96415. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96416. * @param x x coordinate
  96417. * @param z z coordinate
  96418. * @param ref vector to store the result
  96419. * @returns the GroundMesh.
  96420. */
  96421. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96422. /**
  96423. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96424. * if the ground has been updated.
  96425. * This can be used in the render loop.
  96426. * @returns the GroundMesh.
  96427. */
  96428. updateCoordinateHeights(): GroundMesh;
  96429. private _getFacetAt;
  96430. private _initHeightQuads;
  96431. private _computeHeightQuads;
  96432. /**
  96433. * Serializes this ground mesh
  96434. * @param serializationObject object to write serialization to
  96435. */
  96436. serialize(serializationObject: any): void;
  96437. /**
  96438. * Parses a serialized ground mesh
  96439. * @param parsedMesh the serialized mesh
  96440. * @param scene the scene to create the ground mesh in
  96441. * @returns the created ground mesh
  96442. */
  96443. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96444. }
  96445. }
  96446. declare module BABYLON {
  96447. /**
  96448. * Interface for Physics-Joint data
  96449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96450. */
  96451. export interface PhysicsJointData {
  96452. /**
  96453. * The main pivot of the joint
  96454. */
  96455. mainPivot?: Vector3;
  96456. /**
  96457. * The connected pivot of the joint
  96458. */
  96459. connectedPivot?: Vector3;
  96460. /**
  96461. * The main axis of the joint
  96462. */
  96463. mainAxis?: Vector3;
  96464. /**
  96465. * The connected axis of the joint
  96466. */
  96467. connectedAxis?: Vector3;
  96468. /**
  96469. * The collision of the joint
  96470. */
  96471. collision?: boolean;
  96472. /**
  96473. * Native Oimo/Cannon/Energy data
  96474. */
  96475. nativeParams?: any;
  96476. }
  96477. /**
  96478. * This is a holder class for the physics joint created by the physics plugin
  96479. * It holds a set of functions to control the underlying joint
  96480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96481. */
  96482. export class PhysicsJoint {
  96483. /**
  96484. * The type of the physics joint
  96485. */
  96486. type: number;
  96487. /**
  96488. * The data for the physics joint
  96489. */
  96490. jointData: PhysicsJointData;
  96491. private _physicsJoint;
  96492. protected _physicsPlugin: IPhysicsEnginePlugin;
  96493. /**
  96494. * Initializes the physics joint
  96495. * @param type The type of the physics joint
  96496. * @param jointData The data for the physics joint
  96497. */
  96498. constructor(
  96499. /**
  96500. * The type of the physics joint
  96501. */
  96502. type: number,
  96503. /**
  96504. * The data for the physics joint
  96505. */
  96506. jointData: PhysicsJointData);
  96507. /**
  96508. * Gets the physics joint
  96509. */
  96510. get physicsJoint(): any;
  96511. /**
  96512. * Sets the physics joint
  96513. */
  96514. set physicsJoint(newJoint: any);
  96515. /**
  96516. * Sets the physics plugin
  96517. */
  96518. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96519. /**
  96520. * Execute a function that is physics-plugin specific.
  96521. * @param {Function} func the function that will be executed.
  96522. * It accepts two parameters: the physics world and the physics joint
  96523. */
  96524. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96525. /**
  96526. * Distance-Joint type
  96527. */
  96528. static DistanceJoint: number;
  96529. /**
  96530. * Hinge-Joint type
  96531. */
  96532. static HingeJoint: number;
  96533. /**
  96534. * Ball-and-Socket joint type
  96535. */
  96536. static BallAndSocketJoint: number;
  96537. /**
  96538. * Wheel-Joint type
  96539. */
  96540. static WheelJoint: number;
  96541. /**
  96542. * Slider-Joint type
  96543. */
  96544. static SliderJoint: number;
  96545. /**
  96546. * Prismatic-Joint type
  96547. */
  96548. static PrismaticJoint: number;
  96549. /**
  96550. * Universal-Joint type
  96551. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96552. */
  96553. static UniversalJoint: number;
  96554. /**
  96555. * Hinge-Joint 2 type
  96556. */
  96557. static Hinge2Joint: number;
  96558. /**
  96559. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96560. */
  96561. static PointToPointJoint: number;
  96562. /**
  96563. * Spring-Joint type
  96564. */
  96565. static SpringJoint: number;
  96566. /**
  96567. * Lock-Joint type
  96568. */
  96569. static LockJoint: number;
  96570. }
  96571. /**
  96572. * A class representing a physics distance joint
  96573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96574. */
  96575. export class DistanceJoint extends PhysicsJoint {
  96576. /**
  96577. *
  96578. * @param jointData The data for the Distance-Joint
  96579. */
  96580. constructor(jointData: DistanceJointData);
  96581. /**
  96582. * Update the predefined distance.
  96583. * @param maxDistance The maximum preferred distance
  96584. * @param minDistance The minimum preferred distance
  96585. */
  96586. updateDistance(maxDistance: number, minDistance?: number): void;
  96587. }
  96588. /**
  96589. * Represents a Motor-Enabled Joint
  96590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96591. */
  96592. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96593. /**
  96594. * Initializes the Motor-Enabled Joint
  96595. * @param type The type of the joint
  96596. * @param jointData The physica joint data for the joint
  96597. */
  96598. constructor(type: number, jointData: PhysicsJointData);
  96599. /**
  96600. * Set the motor values.
  96601. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96602. * @param force the force to apply
  96603. * @param maxForce max force for this motor.
  96604. */
  96605. setMotor(force?: number, maxForce?: number): void;
  96606. /**
  96607. * Set the motor's limits.
  96608. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96609. * @param upperLimit The upper limit of the motor
  96610. * @param lowerLimit The lower limit of the motor
  96611. */
  96612. setLimit(upperLimit: number, lowerLimit?: number): void;
  96613. }
  96614. /**
  96615. * This class represents a single physics Hinge-Joint
  96616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96617. */
  96618. export class HingeJoint extends MotorEnabledJoint {
  96619. /**
  96620. * Initializes the Hinge-Joint
  96621. * @param jointData The joint data for the Hinge-Joint
  96622. */
  96623. constructor(jointData: PhysicsJointData);
  96624. /**
  96625. * Set the motor values.
  96626. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96627. * @param {number} force the force to apply
  96628. * @param {number} maxForce max force for this motor.
  96629. */
  96630. setMotor(force?: number, maxForce?: number): void;
  96631. /**
  96632. * Set the motor's limits.
  96633. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96634. * @param upperLimit The upper limit of the motor
  96635. * @param lowerLimit The lower limit of the motor
  96636. */
  96637. setLimit(upperLimit: number, lowerLimit?: number): void;
  96638. }
  96639. /**
  96640. * This class represents a dual hinge physics joint (same as wheel joint)
  96641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96642. */
  96643. export class Hinge2Joint extends MotorEnabledJoint {
  96644. /**
  96645. * Initializes the Hinge2-Joint
  96646. * @param jointData The joint data for the Hinge2-Joint
  96647. */
  96648. constructor(jointData: PhysicsJointData);
  96649. /**
  96650. * Set the motor values.
  96651. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96652. * @param {number} targetSpeed the speed the motor is to reach
  96653. * @param {number} maxForce max force for this motor.
  96654. * @param {motorIndex} the motor's index, 0 or 1.
  96655. */
  96656. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96657. /**
  96658. * Set the motor limits.
  96659. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96660. * @param {number} upperLimit the upper limit
  96661. * @param {number} lowerLimit lower limit
  96662. * @param {motorIndex} the motor's index, 0 or 1.
  96663. */
  96664. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96665. }
  96666. /**
  96667. * Interface for a motor enabled joint
  96668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96669. */
  96670. export interface IMotorEnabledJoint {
  96671. /**
  96672. * Physics joint
  96673. */
  96674. physicsJoint: any;
  96675. /**
  96676. * Sets the motor of the motor-enabled joint
  96677. * @param force The force of the motor
  96678. * @param maxForce The maximum force of the motor
  96679. * @param motorIndex The index of the motor
  96680. */
  96681. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96682. /**
  96683. * Sets the limit of the motor
  96684. * @param upperLimit The upper limit of the motor
  96685. * @param lowerLimit The lower limit of the motor
  96686. * @param motorIndex The index of the motor
  96687. */
  96688. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96689. }
  96690. /**
  96691. * Joint data for a Distance-Joint
  96692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96693. */
  96694. export interface DistanceJointData extends PhysicsJointData {
  96695. /**
  96696. * Max distance the 2 joint objects can be apart
  96697. */
  96698. maxDistance: number;
  96699. }
  96700. /**
  96701. * Joint data from a spring joint
  96702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96703. */
  96704. export interface SpringJointData extends PhysicsJointData {
  96705. /**
  96706. * Length of the spring
  96707. */
  96708. length: number;
  96709. /**
  96710. * Stiffness of the spring
  96711. */
  96712. stiffness: number;
  96713. /**
  96714. * Damping of the spring
  96715. */
  96716. damping: number;
  96717. /** this callback will be called when applying the force to the impostors. */
  96718. forceApplicationCallback: () => void;
  96719. }
  96720. }
  96721. declare module BABYLON {
  96722. /**
  96723. * Holds the data for the raycast result
  96724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96725. */
  96726. export class PhysicsRaycastResult {
  96727. private _hasHit;
  96728. private _hitDistance;
  96729. private _hitNormalWorld;
  96730. private _hitPointWorld;
  96731. private _rayFromWorld;
  96732. private _rayToWorld;
  96733. /**
  96734. * Gets if there was a hit
  96735. */
  96736. get hasHit(): boolean;
  96737. /**
  96738. * Gets the distance from the hit
  96739. */
  96740. get hitDistance(): number;
  96741. /**
  96742. * Gets the hit normal/direction in the world
  96743. */
  96744. get hitNormalWorld(): Vector3;
  96745. /**
  96746. * Gets the hit point in the world
  96747. */
  96748. get hitPointWorld(): Vector3;
  96749. /**
  96750. * Gets the ray "start point" of the ray in the world
  96751. */
  96752. get rayFromWorld(): Vector3;
  96753. /**
  96754. * Gets the ray "end point" of the ray in the world
  96755. */
  96756. get rayToWorld(): Vector3;
  96757. /**
  96758. * Sets the hit data (normal & point in world space)
  96759. * @param hitNormalWorld defines the normal in world space
  96760. * @param hitPointWorld defines the point in world space
  96761. */
  96762. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96763. /**
  96764. * Sets the distance from the start point to the hit point
  96765. * @param distance
  96766. */
  96767. setHitDistance(distance: number): void;
  96768. /**
  96769. * Calculates the distance manually
  96770. */
  96771. calculateHitDistance(): void;
  96772. /**
  96773. * Resets all the values to default
  96774. * @param from The from point on world space
  96775. * @param to The to point on world space
  96776. */
  96777. reset(from?: Vector3, to?: Vector3): void;
  96778. }
  96779. /**
  96780. * Interface for the size containing width and height
  96781. */
  96782. interface IXYZ {
  96783. /**
  96784. * X
  96785. */
  96786. x: number;
  96787. /**
  96788. * Y
  96789. */
  96790. y: number;
  96791. /**
  96792. * Z
  96793. */
  96794. z: number;
  96795. }
  96796. }
  96797. declare module BABYLON {
  96798. /**
  96799. * Interface used to describe a physics joint
  96800. */
  96801. export interface PhysicsImpostorJoint {
  96802. /** Defines the main impostor to which the joint is linked */
  96803. mainImpostor: PhysicsImpostor;
  96804. /** Defines the impostor that is connected to the main impostor using this joint */
  96805. connectedImpostor: PhysicsImpostor;
  96806. /** Defines the joint itself */
  96807. joint: PhysicsJoint;
  96808. }
  96809. /** @hidden */
  96810. export interface IPhysicsEnginePlugin {
  96811. world: any;
  96812. name: string;
  96813. setGravity(gravity: Vector3): void;
  96814. setTimeStep(timeStep: number): void;
  96815. getTimeStep(): number;
  96816. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96817. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96818. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96819. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96820. removePhysicsBody(impostor: PhysicsImpostor): void;
  96821. generateJoint(joint: PhysicsImpostorJoint): void;
  96822. removeJoint(joint: PhysicsImpostorJoint): void;
  96823. isSupported(): boolean;
  96824. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96825. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96826. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96827. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96828. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96829. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96830. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96831. getBodyMass(impostor: PhysicsImpostor): number;
  96832. getBodyFriction(impostor: PhysicsImpostor): number;
  96833. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96834. getBodyRestitution(impostor: PhysicsImpostor): number;
  96835. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96836. getBodyPressure?(impostor: PhysicsImpostor): number;
  96837. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96838. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96839. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96840. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96841. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96842. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96843. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96844. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96845. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96846. sleepBody(impostor: PhysicsImpostor): void;
  96847. wakeUpBody(impostor: PhysicsImpostor): void;
  96848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96849. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96850. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96851. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96852. getRadius(impostor: PhysicsImpostor): number;
  96853. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96854. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96855. dispose(): void;
  96856. }
  96857. /**
  96858. * Interface used to define a physics engine
  96859. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96860. */
  96861. export interface IPhysicsEngine {
  96862. /**
  96863. * Gets the gravity vector used by the simulation
  96864. */
  96865. gravity: Vector3;
  96866. /**
  96867. * Sets the gravity vector used by the simulation
  96868. * @param gravity defines the gravity vector to use
  96869. */
  96870. setGravity(gravity: Vector3): void;
  96871. /**
  96872. * Set the time step of the physics engine.
  96873. * Default is 1/60.
  96874. * To slow it down, enter 1/600 for example.
  96875. * To speed it up, 1/30
  96876. * @param newTimeStep the new timestep to apply to this world.
  96877. */
  96878. setTimeStep(newTimeStep: number): void;
  96879. /**
  96880. * Get the time step of the physics engine.
  96881. * @returns the current time step
  96882. */
  96883. getTimeStep(): number;
  96884. /**
  96885. * Set the sub time step of the physics engine.
  96886. * Default is 0 meaning there is no sub steps
  96887. * To increase physics resolution precision, set a small value (like 1 ms)
  96888. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96889. */
  96890. setSubTimeStep(subTimeStep: number): void;
  96891. /**
  96892. * Get the sub time step of the physics engine.
  96893. * @returns the current sub time step
  96894. */
  96895. getSubTimeStep(): number;
  96896. /**
  96897. * Release all resources
  96898. */
  96899. dispose(): void;
  96900. /**
  96901. * Gets the name of the current physics plugin
  96902. * @returns the name of the plugin
  96903. */
  96904. getPhysicsPluginName(): string;
  96905. /**
  96906. * Adding a new impostor for the impostor tracking.
  96907. * This will be done by the impostor itself.
  96908. * @param impostor the impostor to add
  96909. */
  96910. addImpostor(impostor: PhysicsImpostor): void;
  96911. /**
  96912. * Remove an impostor from the engine.
  96913. * This impostor and its mesh will not longer be updated by the physics engine.
  96914. * @param impostor the impostor to remove
  96915. */
  96916. removeImpostor(impostor: PhysicsImpostor): void;
  96917. /**
  96918. * Add a joint to the physics engine
  96919. * @param mainImpostor defines the main impostor to which the joint is added.
  96920. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96921. * @param joint defines the joint that will connect both impostors.
  96922. */
  96923. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96924. /**
  96925. * Removes a joint from the simulation
  96926. * @param mainImpostor defines the impostor used with the joint
  96927. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96928. * @param joint defines the joint to remove
  96929. */
  96930. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96931. /**
  96932. * Gets the current plugin used to run the simulation
  96933. * @returns current plugin
  96934. */
  96935. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96936. /**
  96937. * Gets the list of physic impostors
  96938. * @returns an array of PhysicsImpostor
  96939. */
  96940. getImpostors(): Array<PhysicsImpostor>;
  96941. /**
  96942. * Gets the impostor for a physics enabled object
  96943. * @param object defines the object impersonated by the impostor
  96944. * @returns the PhysicsImpostor or null if not found
  96945. */
  96946. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96947. /**
  96948. * Gets the impostor for a physics body object
  96949. * @param body defines physics body used by the impostor
  96950. * @returns the PhysicsImpostor or null if not found
  96951. */
  96952. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96953. /**
  96954. * Does a raycast in the physics world
  96955. * @param from when should the ray start?
  96956. * @param to when should the ray end?
  96957. * @returns PhysicsRaycastResult
  96958. */
  96959. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96960. /**
  96961. * Called by the scene. No need to call it.
  96962. * @param delta defines the timespam between frames
  96963. */
  96964. _step(delta: number): void;
  96965. }
  96966. }
  96967. declare module BABYLON {
  96968. /**
  96969. * The interface for the physics imposter parameters
  96970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96971. */
  96972. export interface PhysicsImpostorParameters {
  96973. /**
  96974. * The mass of the physics imposter
  96975. */
  96976. mass: number;
  96977. /**
  96978. * The friction of the physics imposter
  96979. */
  96980. friction?: number;
  96981. /**
  96982. * The coefficient of restitution of the physics imposter
  96983. */
  96984. restitution?: number;
  96985. /**
  96986. * The native options of the physics imposter
  96987. */
  96988. nativeOptions?: any;
  96989. /**
  96990. * Specifies if the parent should be ignored
  96991. */
  96992. ignoreParent?: boolean;
  96993. /**
  96994. * Specifies if bi-directional transformations should be disabled
  96995. */
  96996. disableBidirectionalTransformation?: boolean;
  96997. /**
  96998. * The pressure inside the physics imposter, soft object only
  96999. */
  97000. pressure?: number;
  97001. /**
  97002. * The stiffness the physics imposter, soft object only
  97003. */
  97004. stiffness?: number;
  97005. /**
  97006. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97007. */
  97008. velocityIterations?: number;
  97009. /**
  97010. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97011. */
  97012. positionIterations?: number;
  97013. /**
  97014. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97015. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97016. * Add to fix multiple points
  97017. */
  97018. fixedPoints?: number;
  97019. /**
  97020. * The collision margin around a soft object
  97021. */
  97022. margin?: number;
  97023. /**
  97024. * The collision margin around a soft object
  97025. */
  97026. damping?: number;
  97027. /**
  97028. * The path for a rope based on an extrusion
  97029. */
  97030. path?: any;
  97031. /**
  97032. * The shape of an extrusion used for a rope based on an extrusion
  97033. */
  97034. shape?: any;
  97035. }
  97036. /**
  97037. * Interface for a physics-enabled object
  97038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97039. */
  97040. export interface IPhysicsEnabledObject {
  97041. /**
  97042. * The position of the physics-enabled object
  97043. */
  97044. position: Vector3;
  97045. /**
  97046. * The rotation of the physics-enabled object
  97047. */
  97048. rotationQuaternion: Nullable<Quaternion>;
  97049. /**
  97050. * The scale of the physics-enabled object
  97051. */
  97052. scaling: Vector3;
  97053. /**
  97054. * The rotation of the physics-enabled object
  97055. */
  97056. rotation?: Vector3;
  97057. /**
  97058. * The parent of the physics-enabled object
  97059. */
  97060. parent?: any;
  97061. /**
  97062. * The bounding info of the physics-enabled object
  97063. * @returns The bounding info of the physics-enabled object
  97064. */
  97065. getBoundingInfo(): BoundingInfo;
  97066. /**
  97067. * Computes the world matrix
  97068. * @param force Specifies if the world matrix should be computed by force
  97069. * @returns A world matrix
  97070. */
  97071. computeWorldMatrix(force: boolean): Matrix;
  97072. /**
  97073. * Gets the world matrix
  97074. * @returns A world matrix
  97075. */
  97076. getWorldMatrix?(): Matrix;
  97077. /**
  97078. * Gets the child meshes
  97079. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97080. * @returns An array of abstract meshes
  97081. */
  97082. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97083. /**
  97084. * Gets the vertex data
  97085. * @param kind The type of vertex data
  97086. * @returns A nullable array of numbers, or a float32 array
  97087. */
  97088. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97089. /**
  97090. * Gets the indices from the mesh
  97091. * @returns A nullable array of index arrays
  97092. */
  97093. getIndices?(): Nullable<IndicesArray>;
  97094. /**
  97095. * Gets the scene from the mesh
  97096. * @returns the indices array or null
  97097. */
  97098. getScene?(): Scene;
  97099. /**
  97100. * Gets the absolute position from the mesh
  97101. * @returns the absolute position
  97102. */
  97103. getAbsolutePosition(): Vector3;
  97104. /**
  97105. * Gets the absolute pivot point from the mesh
  97106. * @returns the absolute pivot point
  97107. */
  97108. getAbsolutePivotPoint(): Vector3;
  97109. /**
  97110. * Rotates the mesh
  97111. * @param axis The axis of rotation
  97112. * @param amount The amount of rotation
  97113. * @param space The space of the rotation
  97114. * @returns The rotation transform node
  97115. */
  97116. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97117. /**
  97118. * Translates the mesh
  97119. * @param axis The axis of translation
  97120. * @param distance The distance of translation
  97121. * @param space The space of the translation
  97122. * @returns The transform node
  97123. */
  97124. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97125. /**
  97126. * Sets the absolute position of the mesh
  97127. * @param absolutePosition The absolute position of the mesh
  97128. * @returns The transform node
  97129. */
  97130. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97131. /**
  97132. * Gets the class name of the mesh
  97133. * @returns The class name
  97134. */
  97135. getClassName(): string;
  97136. }
  97137. /**
  97138. * Represents a physics imposter
  97139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97140. */
  97141. export class PhysicsImpostor {
  97142. /**
  97143. * The physics-enabled object used as the physics imposter
  97144. */
  97145. object: IPhysicsEnabledObject;
  97146. /**
  97147. * The type of the physics imposter
  97148. */
  97149. type: number;
  97150. private _options;
  97151. private _scene?;
  97152. /**
  97153. * The default object size of the imposter
  97154. */
  97155. static DEFAULT_OBJECT_SIZE: Vector3;
  97156. /**
  97157. * The identity quaternion of the imposter
  97158. */
  97159. static IDENTITY_QUATERNION: Quaternion;
  97160. /** @hidden */
  97161. _pluginData: any;
  97162. private _physicsEngine;
  97163. private _physicsBody;
  97164. private _bodyUpdateRequired;
  97165. private _onBeforePhysicsStepCallbacks;
  97166. private _onAfterPhysicsStepCallbacks;
  97167. /** @hidden */
  97168. _onPhysicsCollideCallbacks: Array<{
  97169. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97170. otherImpostors: Array<PhysicsImpostor>;
  97171. }>;
  97172. private _deltaPosition;
  97173. private _deltaRotation;
  97174. private _deltaRotationConjugated;
  97175. /** @hidden */
  97176. _isFromLine: boolean;
  97177. private _parent;
  97178. private _isDisposed;
  97179. private static _tmpVecs;
  97180. private static _tmpQuat;
  97181. /**
  97182. * Specifies if the physics imposter is disposed
  97183. */
  97184. get isDisposed(): boolean;
  97185. /**
  97186. * Gets the mass of the physics imposter
  97187. */
  97188. get mass(): number;
  97189. set mass(value: number);
  97190. /**
  97191. * Gets the coefficient of friction
  97192. */
  97193. get friction(): number;
  97194. /**
  97195. * Sets the coefficient of friction
  97196. */
  97197. set friction(value: number);
  97198. /**
  97199. * Gets the coefficient of restitution
  97200. */
  97201. get restitution(): number;
  97202. /**
  97203. * Sets the coefficient of restitution
  97204. */
  97205. set restitution(value: number);
  97206. /**
  97207. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97208. */
  97209. get pressure(): number;
  97210. /**
  97211. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97212. */
  97213. set pressure(value: number);
  97214. /**
  97215. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97216. */
  97217. get stiffness(): number;
  97218. /**
  97219. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97220. */
  97221. set stiffness(value: number);
  97222. /**
  97223. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97224. */
  97225. get velocityIterations(): number;
  97226. /**
  97227. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97228. */
  97229. set velocityIterations(value: number);
  97230. /**
  97231. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97232. */
  97233. get positionIterations(): number;
  97234. /**
  97235. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97236. */
  97237. set positionIterations(value: number);
  97238. /**
  97239. * The unique id of the physics imposter
  97240. * set by the physics engine when adding this impostor to the array
  97241. */
  97242. uniqueId: number;
  97243. /**
  97244. * @hidden
  97245. */
  97246. soft: boolean;
  97247. /**
  97248. * @hidden
  97249. */
  97250. segments: number;
  97251. private _joints;
  97252. /**
  97253. * Initializes the physics imposter
  97254. * @param object The physics-enabled object used as the physics imposter
  97255. * @param type The type of the physics imposter
  97256. * @param _options The options for the physics imposter
  97257. * @param _scene The Babylon scene
  97258. */
  97259. constructor(
  97260. /**
  97261. * The physics-enabled object used as the physics imposter
  97262. */
  97263. object: IPhysicsEnabledObject,
  97264. /**
  97265. * The type of the physics imposter
  97266. */
  97267. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97268. /**
  97269. * This function will completly initialize this impostor.
  97270. * It will create a new body - but only if this mesh has no parent.
  97271. * If it has, this impostor will not be used other than to define the impostor
  97272. * of the child mesh.
  97273. * @hidden
  97274. */
  97275. _init(): void;
  97276. private _getPhysicsParent;
  97277. /**
  97278. * Should a new body be generated.
  97279. * @returns boolean specifying if body initialization is required
  97280. */
  97281. isBodyInitRequired(): boolean;
  97282. /**
  97283. * Sets the updated scaling
  97284. * @param updated Specifies if the scaling is updated
  97285. */
  97286. setScalingUpdated(): void;
  97287. /**
  97288. * Force a regeneration of this or the parent's impostor's body.
  97289. * Use under cautious - This will remove all joints already implemented.
  97290. */
  97291. forceUpdate(): void;
  97292. /**
  97293. * Gets the body that holds this impostor. Either its own, or its parent.
  97294. */
  97295. get physicsBody(): any;
  97296. /**
  97297. * Get the parent of the physics imposter
  97298. * @returns Physics imposter or null
  97299. */
  97300. get parent(): Nullable<PhysicsImpostor>;
  97301. /**
  97302. * Sets the parent of the physics imposter
  97303. */
  97304. set parent(value: Nullable<PhysicsImpostor>);
  97305. /**
  97306. * Set the physics body. Used mainly by the physics engine/plugin
  97307. */
  97308. set physicsBody(physicsBody: any);
  97309. /**
  97310. * Resets the update flags
  97311. */
  97312. resetUpdateFlags(): void;
  97313. /**
  97314. * Gets the object extend size
  97315. * @returns the object extend size
  97316. */
  97317. getObjectExtendSize(): Vector3;
  97318. /**
  97319. * Gets the object center
  97320. * @returns The object center
  97321. */
  97322. getObjectCenter(): Vector3;
  97323. /**
  97324. * Get a specific parameter from the options parameters
  97325. * @param paramName The object parameter name
  97326. * @returns The object parameter
  97327. */
  97328. getParam(paramName: string): any;
  97329. /**
  97330. * Sets a specific parameter in the options given to the physics plugin
  97331. * @param paramName The parameter name
  97332. * @param value The value of the parameter
  97333. */
  97334. setParam(paramName: string, value: number): void;
  97335. /**
  97336. * Specifically change the body's mass option. Won't recreate the physics body object
  97337. * @param mass The mass of the physics imposter
  97338. */
  97339. setMass(mass: number): void;
  97340. /**
  97341. * Gets the linear velocity
  97342. * @returns linear velocity or null
  97343. */
  97344. getLinearVelocity(): Nullable<Vector3>;
  97345. /**
  97346. * Sets the linear velocity
  97347. * @param velocity linear velocity or null
  97348. */
  97349. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97350. /**
  97351. * Gets the angular velocity
  97352. * @returns angular velocity or null
  97353. */
  97354. getAngularVelocity(): Nullable<Vector3>;
  97355. /**
  97356. * Sets the angular velocity
  97357. * @param velocity The velocity or null
  97358. */
  97359. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97360. /**
  97361. * Execute a function with the physics plugin native code
  97362. * Provide a function the will have two variables - the world object and the physics body object
  97363. * @param func The function to execute with the physics plugin native code
  97364. */
  97365. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97366. /**
  97367. * Register a function that will be executed before the physics world is stepping forward
  97368. * @param func The function to execute before the physics world is stepped forward
  97369. */
  97370. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97371. /**
  97372. * Unregister a function that will be executed before the physics world is stepping forward
  97373. * @param func The function to execute before the physics world is stepped forward
  97374. */
  97375. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97376. /**
  97377. * Register a function that will be executed after the physics step
  97378. * @param func The function to execute after physics step
  97379. */
  97380. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97381. /**
  97382. * Unregisters a function that will be executed after the physics step
  97383. * @param func The function to execute after physics step
  97384. */
  97385. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97386. /**
  97387. * register a function that will be executed when this impostor collides against a different body
  97388. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97389. * @param func Callback that is executed on collision
  97390. */
  97391. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97392. /**
  97393. * Unregisters the physics imposter on contact
  97394. * @param collideAgainst The physics object to collide against
  97395. * @param func Callback to execute on collision
  97396. */
  97397. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97398. private _tmpQuat;
  97399. private _tmpQuat2;
  97400. /**
  97401. * Get the parent rotation
  97402. * @returns The parent rotation
  97403. */
  97404. getParentsRotation(): Quaternion;
  97405. /**
  97406. * this function is executed by the physics engine.
  97407. */
  97408. beforeStep: () => void;
  97409. /**
  97410. * this function is executed by the physics engine
  97411. */
  97412. afterStep: () => void;
  97413. /**
  97414. * Legacy collision detection event support
  97415. */
  97416. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97417. /**
  97418. * event and body object due to cannon's event-based architecture.
  97419. */
  97420. onCollide: (e: {
  97421. body: any;
  97422. }) => void;
  97423. /**
  97424. * Apply a force
  97425. * @param force The force to apply
  97426. * @param contactPoint The contact point for the force
  97427. * @returns The physics imposter
  97428. */
  97429. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97430. /**
  97431. * Apply an impulse
  97432. * @param force The impulse force
  97433. * @param contactPoint The contact point for the impulse force
  97434. * @returns The physics imposter
  97435. */
  97436. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97437. /**
  97438. * A help function to create a joint
  97439. * @param otherImpostor A physics imposter used to create a joint
  97440. * @param jointType The type of joint
  97441. * @param jointData The data for the joint
  97442. * @returns The physics imposter
  97443. */
  97444. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97445. /**
  97446. * Add a joint to this impostor with a different impostor
  97447. * @param otherImpostor A physics imposter used to add a joint
  97448. * @param joint The joint to add
  97449. * @returns The physics imposter
  97450. */
  97451. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97452. /**
  97453. * Add an anchor to a cloth impostor
  97454. * @param otherImpostor rigid impostor to anchor to
  97455. * @param width ratio across width from 0 to 1
  97456. * @param height ratio up height from 0 to 1
  97457. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97458. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97459. * @returns impostor the soft imposter
  97460. */
  97461. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97462. /**
  97463. * Add a hook to a rope impostor
  97464. * @param otherImpostor rigid impostor to anchor to
  97465. * @param length ratio across rope from 0 to 1
  97466. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97467. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97468. * @returns impostor the rope imposter
  97469. */
  97470. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97471. /**
  97472. * Will keep this body still, in a sleep mode.
  97473. * @returns the physics imposter
  97474. */
  97475. sleep(): PhysicsImpostor;
  97476. /**
  97477. * Wake the body up.
  97478. * @returns The physics imposter
  97479. */
  97480. wakeUp(): PhysicsImpostor;
  97481. /**
  97482. * Clones the physics imposter
  97483. * @param newObject The physics imposter clones to this physics-enabled object
  97484. * @returns A nullable physics imposter
  97485. */
  97486. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97487. /**
  97488. * Disposes the physics imposter
  97489. */
  97490. dispose(): void;
  97491. /**
  97492. * Sets the delta position
  97493. * @param position The delta position amount
  97494. */
  97495. setDeltaPosition(position: Vector3): void;
  97496. /**
  97497. * Sets the delta rotation
  97498. * @param rotation The delta rotation amount
  97499. */
  97500. setDeltaRotation(rotation: Quaternion): void;
  97501. /**
  97502. * Gets the box size of the physics imposter and stores the result in the input parameter
  97503. * @param result Stores the box size
  97504. * @returns The physics imposter
  97505. */
  97506. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97507. /**
  97508. * Gets the radius of the physics imposter
  97509. * @returns Radius of the physics imposter
  97510. */
  97511. getRadius(): number;
  97512. /**
  97513. * Sync a bone with this impostor
  97514. * @param bone The bone to sync to the impostor.
  97515. * @param boneMesh The mesh that the bone is influencing.
  97516. * @param jointPivot The pivot of the joint / bone in local space.
  97517. * @param distToJoint Optional distance from the impostor to the joint.
  97518. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97519. */
  97520. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97521. /**
  97522. * Sync impostor to a bone
  97523. * @param bone The bone that the impostor will be synced to.
  97524. * @param boneMesh The mesh that the bone is influencing.
  97525. * @param jointPivot The pivot of the joint / bone in local space.
  97526. * @param distToJoint Optional distance from the impostor to the joint.
  97527. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97528. * @param boneAxis Optional vector3 axis the bone is aligned with
  97529. */
  97530. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97531. /**
  97532. * No-Imposter type
  97533. */
  97534. static NoImpostor: number;
  97535. /**
  97536. * Sphere-Imposter type
  97537. */
  97538. static SphereImpostor: number;
  97539. /**
  97540. * Box-Imposter type
  97541. */
  97542. static BoxImpostor: number;
  97543. /**
  97544. * Plane-Imposter type
  97545. */
  97546. static PlaneImpostor: number;
  97547. /**
  97548. * Mesh-imposter type
  97549. */
  97550. static MeshImpostor: number;
  97551. /**
  97552. * Capsule-Impostor type (Ammo.js plugin only)
  97553. */
  97554. static CapsuleImpostor: number;
  97555. /**
  97556. * Cylinder-Imposter type
  97557. */
  97558. static CylinderImpostor: number;
  97559. /**
  97560. * Particle-Imposter type
  97561. */
  97562. static ParticleImpostor: number;
  97563. /**
  97564. * Heightmap-Imposter type
  97565. */
  97566. static HeightmapImpostor: number;
  97567. /**
  97568. * ConvexHull-Impostor type (Ammo.js plugin only)
  97569. */
  97570. static ConvexHullImpostor: number;
  97571. /**
  97572. * Custom-Imposter type (Ammo.js plugin only)
  97573. */
  97574. static CustomImpostor: number;
  97575. /**
  97576. * Rope-Imposter type
  97577. */
  97578. static RopeImpostor: number;
  97579. /**
  97580. * Cloth-Imposter type
  97581. */
  97582. static ClothImpostor: number;
  97583. /**
  97584. * Softbody-Imposter type
  97585. */
  97586. static SoftbodyImpostor: number;
  97587. }
  97588. }
  97589. declare module BABYLON {
  97590. /**
  97591. * @hidden
  97592. **/
  97593. export class _CreationDataStorage {
  97594. closePath?: boolean;
  97595. closeArray?: boolean;
  97596. idx: number[];
  97597. dashSize: number;
  97598. gapSize: number;
  97599. path3D: Path3D;
  97600. pathArray: Vector3[][];
  97601. arc: number;
  97602. radius: number;
  97603. cap: number;
  97604. tessellation: number;
  97605. }
  97606. /**
  97607. * @hidden
  97608. **/
  97609. class _InstanceDataStorage {
  97610. visibleInstances: any;
  97611. batchCache: _InstancesBatch;
  97612. instancesBufferSize: number;
  97613. instancesBuffer: Nullable<Buffer>;
  97614. instancesData: Float32Array;
  97615. overridenInstanceCount: number;
  97616. isFrozen: boolean;
  97617. previousBatch: Nullable<_InstancesBatch>;
  97618. hardwareInstancedRendering: boolean;
  97619. sideOrientation: number;
  97620. manualUpdate: boolean;
  97621. }
  97622. /**
  97623. * @hidden
  97624. **/
  97625. export class _InstancesBatch {
  97626. mustReturn: boolean;
  97627. visibleInstances: Nullable<InstancedMesh[]>[];
  97628. renderSelf: boolean[];
  97629. hardwareInstancedRendering: boolean[];
  97630. }
  97631. /**
  97632. * Class used to represent renderable models
  97633. */
  97634. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97635. /**
  97636. * Mesh side orientation : usually the external or front surface
  97637. */
  97638. static readonly FRONTSIDE: number;
  97639. /**
  97640. * Mesh side orientation : usually the internal or back surface
  97641. */
  97642. static readonly BACKSIDE: number;
  97643. /**
  97644. * Mesh side orientation : both internal and external or front and back surfaces
  97645. */
  97646. static readonly DOUBLESIDE: number;
  97647. /**
  97648. * Mesh side orientation : by default, `FRONTSIDE`
  97649. */
  97650. static readonly DEFAULTSIDE: number;
  97651. /**
  97652. * Mesh cap setting : no cap
  97653. */
  97654. static readonly NO_CAP: number;
  97655. /**
  97656. * Mesh cap setting : one cap at the beginning of the mesh
  97657. */
  97658. static readonly CAP_START: number;
  97659. /**
  97660. * Mesh cap setting : one cap at the end of the mesh
  97661. */
  97662. static readonly CAP_END: number;
  97663. /**
  97664. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97665. */
  97666. static readonly CAP_ALL: number;
  97667. /**
  97668. * Mesh pattern setting : no flip or rotate
  97669. */
  97670. static readonly NO_FLIP: number;
  97671. /**
  97672. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97673. */
  97674. static readonly FLIP_TILE: number;
  97675. /**
  97676. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97677. */
  97678. static readonly ROTATE_TILE: number;
  97679. /**
  97680. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97681. */
  97682. static readonly FLIP_ROW: number;
  97683. /**
  97684. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97685. */
  97686. static readonly ROTATE_ROW: number;
  97687. /**
  97688. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97689. */
  97690. static readonly FLIP_N_ROTATE_TILE: number;
  97691. /**
  97692. * Mesh pattern setting : rotate pattern and rotate
  97693. */
  97694. static readonly FLIP_N_ROTATE_ROW: number;
  97695. /**
  97696. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97697. */
  97698. static readonly CENTER: number;
  97699. /**
  97700. * Mesh tile positioning : part tiles on left
  97701. */
  97702. static readonly LEFT: number;
  97703. /**
  97704. * Mesh tile positioning : part tiles on right
  97705. */
  97706. static readonly RIGHT: number;
  97707. /**
  97708. * Mesh tile positioning : part tiles on top
  97709. */
  97710. static readonly TOP: number;
  97711. /**
  97712. * Mesh tile positioning : part tiles on bottom
  97713. */
  97714. static readonly BOTTOM: number;
  97715. /**
  97716. * Gets the default side orientation.
  97717. * @param orientation the orientation to value to attempt to get
  97718. * @returns the default orientation
  97719. * @hidden
  97720. */
  97721. static _GetDefaultSideOrientation(orientation?: number): number;
  97722. private _internalMeshDataInfo;
  97723. /**
  97724. * An event triggered before rendering the mesh
  97725. */
  97726. get onBeforeRenderObservable(): Observable<Mesh>;
  97727. /**
  97728. * An event triggered before binding the mesh
  97729. */
  97730. get onBeforeBindObservable(): Observable<Mesh>;
  97731. /**
  97732. * An event triggered after rendering the mesh
  97733. */
  97734. get onAfterRenderObservable(): Observable<Mesh>;
  97735. /**
  97736. * An event triggered before drawing the mesh
  97737. */
  97738. get onBeforeDrawObservable(): Observable<Mesh>;
  97739. private _onBeforeDrawObserver;
  97740. /**
  97741. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97742. */
  97743. set onBeforeDraw(callback: () => void);
  97744. get hasInstances(): boolean;
  97745. /**
  97746. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97747. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97748. */
  97749. delayLoadState: number;
  97750. /**
  97751. * Gets the list of instances created from this mesh
  97752. * it is not supposed to be modified manually.
  97753. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97754. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97755. */
  97756. instances: InstancedMesh[];
  97757. /**
  97758. * Gets the file containing delay loading data for this mesh
  97759. */
  97760. delayLoadingFile: string;
  97761. /** @hidden */
  97762. _binaryInfo: any;
  97763. /**
  97764. * User defined function used to change how LOD level selection is done
  97765. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97766. */
  97767. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97768. /**
  97769. * Gets or sets the morph target manager
  97770. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97771. */
  97772. get morphTargetManager(): Nullable<MorphTargetManager>;
  97773. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97774. /** @hidden */
  97775. _creationDataStorage: Nullable<_CreationDataStorage>;
  97776. /** @hidden */
  97777. _geometry: Nullable<Geometry>;
  97778. /** @hidden */
  97779. _delayInfo: Array<string>;
  97780. /** @hidden */
  97781. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97782. /** @hidden */
  97783. _instanceDataStorage: _InstanceDataStorage;
  97784. private _effectiveMaterial;
  97785. /** @hidden */
  97786. _shouldGenerateFlatShading: boolean;
  97787. /** @hidden */
  97788. _originalBuilderSideOrientation: number;
  97789. /**
  97790. * Use this property to change the original side orientation defined at construction time
  97791. */
  97792. overrideMaterialSideOrientation: Nullable<number>;
  97793. /**
  97794. * Gets the source mesh (the one used to clone this one from)
  97795. */
  97796. get source(): Nullable<Mesh>;
  97797. /**
  97798. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97799. */
  97800. get isUnIndexed(): boolean;
  97801. set isUnIndexed(value: boolean);
  97802. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97803. get worldMatrixInstancedBuffer(): Float32Array;
  97804. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97805. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97806. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97807. /**
  97808. * @constructor
  97809. * @param name The value used by scene.getMeshByName() to do a lookup.
  97810. * @param scene The scene to add this mesh to.
  97811. * @param parent The parent of this mesh, if it has one
  97812. * @param source An optional Mesh from which geometry is shared, cloned.
  97813. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97814. * When false, achieved by calling a clone(), also passing False.
  97815. * This will make creation of children, recursive.
  97816. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97817. */
  97818. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97819. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97820. doNotInstantiate: boolean;
  97821. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97822. /**
  97823. * Gets the class name
  97824. * @returns the string "Mesh".
  97825. */
  97826. getClassName(): string;
  97827. /** @hidden */
  97828. get _isMesh(): boolean;
  97829. /**
  97830. * Returns a description of this mesh
  97831. * @param fullDetails define if full details about this mesh must be used
  97832. * @returns a descriptive string representing this mesh
  97833. */
  97834. toString(fullDetails?: boolean): string;
  97835. /** @hidden */
  97836. _unBindEffect(): void;
  97837. /**
  97838. * Gets a boolean indicating if this mesh has LOD
  97839. */
  97840. get hasLODLevels(): boolean;
  97841. /**
  97842. * Gets the list of MeshLODLevel associated with the current mesh
  97843. * @returns an array of MeshLODLevel
  97844. */
  97845. getLODLevels(): MeshLODLevel[];
  97846. private _sortLODLevels;
  97847. /**
  97848. * Add a mesh as LOD level triggered at the given distance.
  97849. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97850. * @param distance The distance from the center of the object to show this level
  97851. * @param mesh The mesh to be added as LOD level (can be null)
  97852. * @return This mesh (for chaining)
  97853. */
  97854. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97855. /**
  97856. * Returns the LOD level mesh at the passed distance or null if not found.
  97857. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97858. * @param distance The distance from the center of the object to show this level
  97859. * @returns a Mesh or `null`
  97860. */
  97861. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97862. /**
  97863. * Remove a mesh from the LOD array
  97864. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97865. * @param mesh defines the mesh to be removed
  97866. * @return This mesh (for chaining)
  97867. */
  97868. removeLODLevel(mesh: Mesh): Mesh;
  97869. /**
  97870. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97871. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97872. * @param camera defines the camera to use to compute distance
  97873. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97874. * @return This mesh (for chaining)
  97875. */
  97876. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97877. /**
  97878. * Gets the mesh internal Geometry object
  97879. */
  97880. get geometry(): Nullable<Geometry>;
  97881. /**
  97882. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97883. * @returns the total number of vertices
  97884. */
  97885. getTotalVertices(): number;
  97886. /**
  97887. * Returns the content of an associated vertex buffer
  97888. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97889. * - VertexBuffer.PositionKind
  97890. * - VertexBuffer.UVKind
  97891. * - VertexBuffer.UV2Kind
  97892. * - VertexBuffer.UV3Kind
  97893. * - VertexBuffer.UV4Kind
  97894. * - VertexBuffer.UV5Kind
  97895. * - VertexBuffer.UV6Kind
  97896. * - VertexBuffer.ColorKind
  97897. * - VertexBuffer.MatricesIndicesKind
  97898. * - VertexBuffer.MatricesIndicesExtraKind
  97899. * - VertexBuffer.MatricesWeightsKind
  97900. * - VertexBuffer.MatricesWeightsExtraKind
  97901. * @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
  97902. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97903. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97904. */
  97905. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97906. /**
  97907. * Returns the mesh VertexBuffer object from the requested `kind`
  97908. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97909. * - VertexBuffer.PositionKind
  97910. * - VertexBuffer.NormalKind
  97911. * - VertexBuffer.UVKind
  97912. * - VertexBuffer.UV2Kind
  97913. * - VertexBuffer.UV3Kind
  97914. * - VertexBuffer.UV4Kind
  97915. * - VertexBuffer.UV5Kind
  97916. * - VertexBuffer.UV6Kind
  97917. * - VertexBuffer.ColorKind
  97918. * - VertexBuffer.MatricesIndicesKind
  97919. * - VertexBuffer.MatricesIndicesExtraKind
  97920. * - VertexBuffer.MatricesWeightsKind
  97921. * - VertexBuffer.MatricesWeightsExtraKind
  97922. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97923. */
  97924. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97925. /**
  97926. * Tests if a specific vertex buffer is associated with this mesh
  97927. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97928. * - VertexBuffer.PositionKind
  97929. * - VertexBuffer.NormalKind
  97930. * - VertexBuffer.UVKind
  97931. * - VertexBuffer.UV2Kind
  97932. * - VertexBuffer.UV3Kind
  97933. * - VertexBuffer.UV4Kind
  97934. * - VertexBuffer.UV5Kind
  97935. * - VertexBuffer.UV6Kind
  97936. * - VertexBuffer.ColorKind
  97937. * - VertexBuffer.MatricesIndicesKind
  97938. * - VertexBuffer.MatricesIndicesExtraKind
  97939. * - VertexBuffer.MatricesWeightsKind
  97940. * - VertexBuffer.MatricesWeightsExtraKind
  97941. * @returns a boolean
  97942. */
  97943. isVerticesDataPresent(kind: string): boolean;
  97944. /**
  97945. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97946. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97947. * - VertexBuffer.PositionKind
  97948. * - VertexBuffer.UVKind
  97949. * - VertexBuffer.UV2Kind
  97950. * - VertexBuffer.UV3Kind
  97951. * - VertexBuffer.UV4Kind
  97952. * - VertexBuffer.UV5Kind
  97953. * - VertexBuffer.UV6Kind
  97954. * - VertexBuffer.ColorKind
  97955. * - VertexBuffer.MatricesIndicesKind
  97956. * - VertexBuffer.MatricesIndicesExtraKind
  97957. * - VertexBuffer.MatricesWeightsKind
  97958. * - VertexBuffer.MatricesWeightsExtraKind
  97959. * @returns a boolean
  97960. */
  97961. isVertexBufferUpdatable(kind: string): boolean;
  97962. /**
  97963. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97964. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97965. * - VertexBuffer.PositionKind
  97966. * - VertexBuffer.NormalKind
  97967. * - VertexBuffer.UVKind
  97968. * - VertexBuffer.UV2Kind
  97969. * - VertexBuffer.UV3Kind
  97970. * - VertexBuffer.UV4Kind
  97971. * - VertexBuffer.UV5Kind
  97972. * - VertexBuffer.UV6Kind
  97973. * - VertexBuffer.ColorKind
  97974. * - VertexBuffer.MatricesIndicesKind
  97975. * - VertexBuffer.MatricesIndicesExtraKind
  97976. * - VertexBuffer.MatricesWeightsKind
  97977. * - VertexBuffer.MatricesWeightsExtraKind
  97978. * @returns an array of strings
  97979. */
  97980. getVerticesDataKinds(): string[];
  97981. /**
  97982. * Returns a positive integer : the total number of indices in this mesh geometry.
  97983. * @returns the numner of indices or zero if the mesh has no geometry.
  97984. */
  97985. getTotalIndices(): number;
  97986. /**
  97987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97988. * @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.
  97989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97990. * @returns the indices array or an empty array if the mesh has no geometry
  97991. */
  97992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97993. get isBlocked(): boolean;
  97994. /**
  97995. * Determine if the current mesh is ready to be rendered
  97996. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97997. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97998. * @returns true if all associated assets are ready (material, textures, shaders)
  97999. */
  98000. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98001. /**
  98002. * 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.
  98003. */
  98004. get areNormalsFrozen(): boolean;
  98005. /**
  98006. * 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.
  98007. * @returns the current mesh
  98008. */
  98009. freezeNormals(): Mesh;
  98010. /**
  98011. * 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
  98012. * @returns the current mesh
  98013. */
  98014. unfreezeNormals(): Mesh;
  98015. /**
  98016. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98017. */
  98018. set overridenInstanceCount(count: number);
  98019. /** @hidden */
  98020. _preActivate(): Mesh;
  98021. /** @hidden */
  98022. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98023. /** @hidden */
  98024. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98025. /**
  98026. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98027. * This means the mesh underlying bounding box and sphere are recomputed.
  98028. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98029. * @returns the current mesh
  98030. */
  98031. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98032. /** @hidden */
  98033. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98034. /**
  98035. * This function will subdivide the mesh into multiple submeshes
  98036. * @param count defines the expected number of submeshes
  98037. */
  98038. subdivide(count: number): void;
  98039. /**
  98040. * Copy a FloatArray into a specific associated vertex buffer
  98041. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98042. * - VertexBuffer.PositionKind
  98043. * - VertexBuffer.UVKind
  98044. * - VertexBuffer.UV2Kind
  98045. * - VertexBuffer.UV3Kind
  98046. * - VertexBuffer.UV4Kind
  98047. * - VertexBuffer.UV5Kind
  98048. * - VertexBuffer.UV6Kind
  98049. * - VertexBuffer.ColorKind
  98050. * - VertexBuffer.MatricesIndicesKind
  98051. * - VertexBuffer.MatricesIndicesExtraKind
  98052. * - VertexBuffer.MatricesWeightsKind
  98053. * - VertexBuffer.MatricesWeightsExtraKind
  98054. * @param data defines the data source
  98055. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98056. * @param stride defines the data stride size (can be null)
  98057. * @returns the current mesh
  98058. */
  98059. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98060. /**
  98061. * Delete a vertex buffer associated with this mesh
  98062. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98063. * - VertexBuffer.PositionKind
  98064. * - VertexBuffer.UVKind
  98065. * - VertexBuffer.UV2Kind
  98066. * - VertexBuffer.UV3Kind
  98067. * - VertexBuffer.UV4Kind
  98068. * - VertexBuffer.UV5Kind
  98069. * - VertexBuffer.UV6Kind
  98070. * - VertexBuffer.ColorKind
  98071. * - VertexBuffer.MatricesIndicesKind
  98072. * - VertexBuffer.MatricesIndicesExtraKind
  98073. * - VertexBuffer.MatricesWeightsKind
  98074. * - VertexBuffer.MatricesWeightsExtraKind
  98075. */
  98076. removeVerticesData(kind: string): void;
  98077. /**
  98078. * Flags an associated vertex buffer as updatable
  98079. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98080. * - VertexBuffer.PositionKind
  98081. * - VertexBuffer.UVKind
  98082. * - VertexBuffer.UV2Kind
  98083. * - VertexBuffer.UV3Kind
  98084. * - VertexBuffer.UV4Kind
  98085. * - VertexBuffer.UV5Kind
  98086. * - VertexBuffer.UV6Kind
  98087. * - VertexBuffer.ColorKind
  98088. * - VertexBuffer.MatricesIndicesKind
  98089. * - VertexBuffer.MatricesIndicesExtraKind
  98090. * - VertexBuffer.MatricesWeightsKind
  98091. * - VertexBuffer.MatricesWeightsExtraKind
  98092. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98093. */
  98094. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98095. /**
  98096. * Sets the mesh global Vertex Buffer
  98097. * @param buffer defines the buffer to use
  98098. * @returns the current mesh
  98099. */
  98100. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98101. /**
  98102. * Update a specific associated vertex buffer
  98103. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98104. * - VertexBuffer.PositionKind
  98105. * - VertexBuffer.UVKind
  98106. * - VertexBuffer.UV2Kind
  98107. * - VertexBuffer.UV3Kind
  98108. * - VertexBuffer.UV4Kind
  98109. * - VertexBuffer.UV5Kind
  98110. * - VertexBuffer.UV6Kind
  98111. * - VertexBuffer.ColorKind
  98112. * - VertexBuffer.MatricesIndicesKind
  98113. * - VertexBuffer.MatricesIndicesExtraKind
  98114. * - VertexBuffer.MatricesWeightsKind
  98115. * - VertexBuffer.MatricesWeightsExtraKind
  98116. * @param data defines the data source
  98117. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98118. * @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)
  98119. * @returns the current mesh
  98120. */
  98121. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98122. /**
  98123. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98124. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98125. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98126. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98127. * @returns the current mesh
  98128. */
  98129. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98130. /**
  98131. * Creates a un-shared specific occurence of the geometry for the mesh.
  98132. * @returns the current mesh
  98133. */
  98134. makeGeometryUnique(): Mesh;
  98135. /**
  98136. * Set the index buffer of this mesh
  98137. * @param indices defines the source data
  98138. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98139. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98140. * @returns the current mesh
  98141. */
  98142. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98143. /**
  98144. * Update the current index buffer
  98145. * @param indices defines the source data
  98146. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98147. * @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)
  98148. * @returns the current mesh
  98149. */
  98150. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98151. /**
  98152. * Invert the geometry to move from a right handed system to a left handed one.
  98153. * @returns the current mesh
  98154. */
  98155. toLeftHanded(): Mesh;
  98156. /** @hidden */
  98157. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98158. /** @hidden */
  98159. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98160. /**
  98161. * Registers for this mesh a javascript function called just before the rendering process
  98162. * @param func defines the function to call before rendering this mesh
  98163. * @returns the current mesh
  98164. */
  98165. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98166. /**
  98167. * Disposes a previously registered javascript function called before the rendering
  98168. * @param func defines the function to remove
  98169. * @returns the current mesh
  98170. */
  98171. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98172. /**
  98173. * Registers for this mesh a javascript function called just after the rendering is complete
  98174. * @param func defines the function to call after rendering this mesh
  98175. * @returns the current mesh
  98176. */
  98177. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98178. /**
  98179. * Disposes a previously registered javascript function called after the rendering.
  98180. * @param func defines the function to remove
  98181. * @returns the current mesh
  98182. */
  98183. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98184. /** @hidden */
  98185. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98186. /** @hidden */
  98187. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98188. /** @hidden */
  98189. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98190. /** @hidden */
  98191. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98192. /** @hidden */
  98193. _rebuild(): void;
  98194. /** @hidden */
  98195. _freeze(): void;
  98196. /** @hidden */
  98197. _unFreeze(): void;
  98198. /**
  98199. * 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
  98200. * @param subMesh defines the subMesh to render
  98201. * @param enableAlphaMode defines if alpha mode can be changed
  98202. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98203. * @returns the current mesh
  98204. */
  98205. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98206. private _onBeforeDraw;
  98207. /**
  98208. * Renormalize the mesh and patch it up if there are no weights
  98209. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98210. * However in the case of zero weights then we set just a single influence to 1.
  98211. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98212. */
  98213. cleanMatrixWeights(): void;
  98214. private normalizeSkinFourWeights;
  98215. private normalizeSkinWeightsAndExtra;
  98216. /**
  98217. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98218. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98219. * the user know there was an issue with importing the mesh
  98220. * @returns a validation object with skinned, valid and report string
  98221. */
  98222. validateSkinning(): {
  98223. skinned: boolean;
  98224. valid: boolean;
  98225. report: string;
  98226. };
  98227. /** @hidden */
  98228. _checkDelayState(): Mesh;
  98229. private _queueLoad;
  98230. /**
  98231. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98232. * A mesh is in the frustum if its bounding box intersects the frustum
  98233. * @param frustumPlanes defines the frustum to test
  98234. * @returns true if the mesh is in the frustum planes
  98235. */
  98236. isInFrustum(frustumPlanes: Plane[]): boolean;
  98237. /**
  98238. * Sets the mesh material by the material or multiMaterial `id` property
  98239. * @param id is a string identifying the material or the multiMaterial
  98240. * @returns the current mesh
  98241. */
  98242. setMaterialByID(id: string): Mesh;
  98243. /**
  98244. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98245. * @returns an array of IAnimatable
  98246. */
  98247. getAnimatables(): IAnimatable[];
  98248. /**
  98249. * Modifies the mesh geometry according to the passed transformation matrix.
  98250. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98251. * The mesh normals are modified using the same transformation.
  98252. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98253. * @param transform defines the transform matrix to use
  98254. * @see http://doc.babylonjs.com/resources/baking_transformations
  98255. * @returns the current mesh
  98256. */
  98257. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98258. /**
  98259. * Modifies the mesh geometry according to its own current World Matrix.
  98260. * The mesh World Matrix is then reset.
  98261. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98262. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98263. * @see http://doc.babylonjs.com/resources/baking_transformations
  98264. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98265. * @returns the current mesh
  98266. */
  98267. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98268. /** @hidden */
  98269. get _positions(): Nullable<Vector3[]>;
  98270. /** @hidden */
  98271. _resetPointsArrayCache(): Mesh;
  98272. /** @hidden */
  98273. _generatePointsArray(): boolean;
  98274. /**
  98275. * Returns a new Mesh object generated from the current mesh properties.
  98276. * This method must not get confused with createInstance()
  98277. * @param name is a string, the name given to the new mesh
  98278. * @param newParent can be any Node object (default `null`)
  98279. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98280. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98281. * @returns a new mesh
  98282. */
  98283. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98284. /**
  98285. * Releases resources associated with this mesh.
  98286. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98287. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98288. */
  98289. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98290. /** @hidden */
  98291. _disposeInstanceSpecificData(): void;
  98292. /**
  98293. * Modifies the mesh geometry according to a displacement map.
  98294. * 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.
  98295. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98296. * @param url is a string, the URL from the image file is to be downloaded.
  98297. * @param minHeight is the lower limit of the displacement.
  98298. * @param maxHeight is the upper limit of the displacement.
  98299. * @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.
  98300. * @param uvOffset is an optional vector2 used to offset UV.
  98301. * @param uvScale is an optional vector2 used to scale UV.
  98302. * @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.
  98303. * @returns the Mesh.
  98304. */
  98305. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98306. /**
  98307. * Modifies the mesh geometry according to a displacementMap buffer.
  98308. * 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.
  98309. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98310. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98311. * @param heightMapWidth is the width of the buffer image.
  98312. * @param heightMapHeight is the height of the buffer image.
  98313. * @param minHeight is the lower limit of the displacement.
  98314. * @param maxHeight is the upper limit of the displacement.
  98315. * @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.
  98316. * @param uvOffset is an optional vector2 used to offset UV.
  98317. * @param uvScale is an optional vector2 used to scale UV.
  98318. * @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.
  98319. * @returns the Mesh.
  98320. */
  98321. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98322. /**
  98323. * Modify the mesh to get a flat shading rendering.
  98324. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98325. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98326. * @returns current mesh
  98327. */
  98328. convertToFlatShadedMesh(): Mesh;
  98329. /**
  98330. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98331. * In other words, more vertices, no more indices and a single bigger VBO.
  98332. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98333. * @returns current mesh
  98334. */
  98335. convertToUnIndexedMesh(): Mesh;
  98336. /**
  98337. * Inverses facet orientations.
  98338. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98339. * @param flipNormals will also inverts the normals
  98340. * @returns current mesh
  98341. */
  98342. flipFaces(flipNormals?: boolean): Mesh;
  98343. /**
  98344. * Increase the number of facets and hence vertices in a mesh
  98345. * Vertex normals are interpolated from existing vertex normals
  98346. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98347. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98348. */
  98349. increaseVertices(numberPerEdge: number): void;
  98350. /**
  98351. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98352. * This will undo any application of covertToFlatShadedMesh
  98353. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98354. */
  98355. forceSharedVertices(): void;
  98356. /** @hidden */
  98357. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98358. /** @hidden */
  98359. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98360. /**
  98361. * Creates a new InstancedMesh object from the mesh model.
  98362. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98363. * @param name defines the name of the new instance
  98364. * @returns a new InstancedMesh
  98365. */
  98366. createInstance(name: string): InstancedMesh;
  98367. /**
  98368. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98369. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98370. * @returns the current mesh
  98371. */
  98372. synchronizeInstances(): Mesh;
  98373. /**
  98374. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98375. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98376. * This should be used together with the simplification to avoid disappearing triangles.
  98377. * @param successCallback an optional success callback to be called after the optimization finished.
  98378. * @returns the current mesh
  98379. */
  98380. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98381. /**
  98382. * Serialize current mesh
  98383. * @param serializationObject defines the object which will receive the serialization data
  98384. */
  98385. serialize(serializationObject: any): void;
  98386. /** @hidden */
  98387. _syncGeometryWithMorphTargetManager(): void;
  98388. /** @hidden */
  98389. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98390. /**
  98391. * Returns a new Mesh object parsed from the source provided.
  98392. * @param parsedMesh is the source
  98393. * @param scene defines the hosting scene
  98394. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98395. * @returns a new Mesh
  98396. */
  98397. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98398. /**
  98399. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98400. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98401. * @param name defines the name of the mesh to create
  98402. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98403. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98404. * @param closePath creates a seam between the first and the last points of each path of the path array
  98405. * @param offset is taken in account only if the `pathArray` is containing a single path
  98406. * @param scene defines the hosting scene
  98407. * @param updatable defines if the mesh must be flagged as updatable
  98408. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98409. * @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)
  98410. * @returns a new Mesh
  98411. */
  98412. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98413. /**
  98414. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98415. * @param name defines the name of the mesh to create
  98416. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98417. * @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
  98418. * @param scene defines the hosting scene
  98419. * @param updatable defines if the mesh must be flagged as updatable
  98420. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98421. * @returns a new Mesh
  98422. */
  98423. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98424. /**
  98425. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98426. * @param name defines the name of the mesh to create
  98427. * @param size sets the size (float) of each box side (default 1)
  98428. * @param scene defines the hosting scene
  98429. * @param updatable defines if the mesh must be flagged as updatable
  98430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98431. * @returns a new Mesh
  98432. */
  98433. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98434. /**
  98435. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98436. * @param name defines the name of the mesh to create
  98437. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98438. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98439. * @param scene defines the hosting scene
  98440. * @param updatable defines if the mesh must be flagged as updatable
  98441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98442. * @returns a new Mesh
  98443. */
  98444. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98445. /**
  98446. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98447. * @param name defines the name of the mesh to create
  98448. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98449. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98450. * @param scene defines the hosting scene
  98451. * @returns a new Mesh
  98452. */
  98453. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98454. /**
  98455. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98456. * @param name defines the name of the mesh to create
  98457. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98458. * @param diameterTop set the top cap diameter (floats, default 1)
  98459. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98460. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98461. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  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. * @returns a new Mesh
  98466. */
  98467. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98468. /**
  98469. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98470. * @param name defines the name of the mesh to create
  98471. * @param diameter sets the diameter size (float) of the torus (default 1)
  98472. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98473. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98474. * @param scene defines the hosting scene
  98475. * @param updatable defines if the mesh must be flagged as updatable
  98476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98477. * @returns a new Mesh
  98478. */
  98479. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98480. /**
  98481. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98482. * @param name defines the name of the mesh to create
  98483. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98484. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98485. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98486. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98487. * @param p the number of windings on X axis (positive integers, default 2)
  98488. * @param q the number of windings on Y axis (positive integers, default 3)
  98489. * @param scene defines the hosting scene
  98490. * @param updatable defines if the mesh must be flagged as updatable
  98491. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98492. * @returns a new Mesh
  98493. */
  98494. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98495. /**
  98496. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98497. * @param name defines the name of the mesh to create
  98498. * @param points is an array successive Vector3
  98499. * @param scene defines the hosting scene
  98500. * @param updatable defines if the mesh must be flagged as updatable
  98501. * @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).
  98502. * @returns a new Mesh
  98503. */
  98504. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98505. /**
  98506. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98507. * @param name defines the name of the mesh to create
  98508. * @param points is an array successive Vector3
  98509. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98510. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98511. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98512. * @param scene defines the hosting scene
  98513. * @param updatable defines if the mesh must be flagged as updatable
  98514. * @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)
  98515. * @returns a new Mesh
  98516. */
  98517. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98518. /**
  98519. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98520. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98521. * 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.
  98522. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98523. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98524. * Remember you can only change the shape positions, not their number when updating a polygon.
  98525. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98526. * @param name defines the name of the mesh to create
  98527. * @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
  98528. * @param scene defines the hosting scene
  98529. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98530. * @param updatable defines if the mesh must be flagged as updatable
  98531. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98532. * @param earcutInjection can be used to inject your own earcut reference
  98533. * @returns a new Mesh
  98534. */
  98535. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98536. /**
  98537. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98538. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98539. * @param name defines the name of the mesh to create
  98540. * @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
  98541. * @param depth defines the height of extrusion
  98542. * @param scene defines the hosting scene
  98543. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98544. * @param updatable defines if the mesh must be flagged as updatable
  98545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98546. * @param earcutInjection can be used to inject your own earcut reference
  98547. * @returns a new Mesh
  98548. */
  98549. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98550. /**
  98551. * Creates an extruded shape mesh.
  98552. * 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
  98553. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98554. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98555. * @param name defines the name of the mesh to create
  98556. * @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
  98557. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98558. * @param scale is the value to scale the shape
  98559. * @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
  98560. * @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
  98561. * @param scene defines the hosting scene
  98562. * @param updatable defines if the mesh must be flagged as updatable
  98563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98564. * @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)
  98565. * @returns a new Mesh
  98566. */
  98567. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98568. /**
  98569. * Creates an custom extruded shape mesh.
  98570. * The custom extrusion is a parametric shape.
  98571. * It has no predefined shape. Its final shape will depend on the input parameters.
  98572. * Please consider using the same method from the MeshBuilder class instead
  98573. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98574. * @param name defines the name of the mesh to create
  98575. * @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
  98576. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98577. * @param scaleFunction is a custom Javascript function called on each path point
  98578. * @param rotationFunction is a custom Javascript function called on each path point
  98579. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98580. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98581. * @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
  98582. * @param scene defines the hosting scene
  98583. * @param updatable defines if the mesh must be flagged as updatable
  98584. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98585. * @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)
  98586. * @returns a new Mesh
  98587. */
  98588. 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;
  98589. /**
  98590. * Creates lathe mesh.
  98591. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98592. * Please consider using the same method from the MeshBuilder class instead
  98593. * @param name defines the name of the mesh to create
  98594. * @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
  98595. * @param radius is the radius value of the lathe
  98596. * @param tessellation is the side number of the lathe.
  98597. * @param scene defines the hosting scene
  98598. * @param updatable defines if the mesh must be flagged as updatable
  98599. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98600. * @returns a new Mesh
  98601. */
  98602. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98603. /**
  98604. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98605. * @param name defines the name of the mesh to create
  98606. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98607. * @param scene defines the hosting scene
  98608. * @param updatable defines if the mesh must be flagged as updatable
  98609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98610. * @returns a new Mesh
  98611. */
  98612. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98613. /**
  98614. * Creates a ground mesh.
  98615. * Please consider using the same method from the MeshBuilder class instead
  98616. * @param name defines the name of the mesh to create
  98617. * @param width set the width of the ground
  98618. * @param height set the height of the ground
  98619. * @param subdivisions sets the number of subdivisions per side
  98620. * @param scene defines the hosting scene
  98621. * @param updatable defines if the mesh must be flagged as updatable
  98622. * @returns a new Mesh
  98623. */
  98624. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98625. /**
  98626. * Creates a tiled ground mesh.
  98627. * Please consider using the same method from the MeshBuilder class instead
  98628. * @param name defines the name of the mesh to create
  98629. * @param xmin set the ground minimum X coordinate
  98630. * @param zmin set the ground minimum Y coordinate
  98631. * @param xmax set the ground maximum X coordinate
  98632. * @param zmax set the ground maximum Z coordinate
  98633. * @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
  98634. * @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
  98635. * @param scene defines the hosting scene
  98636. * @param updatable defines if the mesh must be flagged as updatable
  98637. * @returns a new Mesh
  98638. */
  98639. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98640. w: number;
  98641. h: number;
  98642. }, precision: {
  98643. w: number;
  98644. h: number;
  98645. }, scene: Scene, updatable?: boolean): Mesh;
  98646. /**
  98647. * Creates a ground mesh from a height map.
  98648. * Please consider using the same method from the MeshBuilder class instead
  98649. * @see http://doc.babylonjs.com/babylon101/height_map
  98650. * @param name defines the name of the mesh to create
  98651. * @param url sets the URL of the height map image resource
  98652. * @param width set the ground width size
  98653. * @param height set the ground height size
  98654. * @param subdivisions sets the number of subdivision per side
  98655. * @param minHeight is the minimum altitude on the ground
  98656. * @param maxHeight is the maximum altitude on the ground
  98657. * @param scene defines the hosting scene
  98658. * @param updatable defines if the mesh must be flagged as updatable
  98659. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98660. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98661. * @returns a new Mesh
  98662. */
  98663. 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;
  98664. /**
  98665. * Creates a tube mesh.
  98666. * The tube is a parametric shape.
  98667. * It has no predefined shape. Its final shape will depend on the input parameters.
  98668. * Please consider using the same method from the MeshBuilder class instead
  98669. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98670. * @param name defines the name of the mesh to create
  98671. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98672. * @param radius sets the tube radius size
  98673. * @param tessellation is the number of sides on the tubular surface
  98674. * @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
  98675. * @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
  98676. * @param scene defines the hosting scene
  98677. * @param updatable defines if the mesh must be flagged as updatable
  98678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98679. * @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)
  98680. * @returns a new Mesh
  98681. */
  98682. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98683. (i: number, distance: number): number;
  98684. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98685. /**
  98686. * Creates a polyhedron mesh.
  98687. * Please consider using the same method from the MeshBuilder class instead.
  98688. * * 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
  98689. * * The parameter `size` (positive float, default 1) sets the polygon size
  98690. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98691. * * 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`
  98692. * * 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
  98693. * * 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)`)
  98694. * * 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
  98695. * * 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
  98696. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98697. * * If you create a double-sided mesh, you can choose what parts of 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
  98698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98699. * @param name defines the name of the mesh to create
  98700. * @param options defines the options used to create the mesh
  98701. * @param scene defines the hosting scene
  98702. * @returns a new Mesh
  98703. */
  98704. static CreatePolyhedron(name: string, options: {
  98705. type?: number;
  98706. size?: number;
  98707. sizeX?: number;
  98708. sizeY?: number;
  98709. sizeZ?: number;
  98710. custom?: any;
  98711. faceUV?: Vector4[];
  98712. faceColors?: Color4[];
  98713. updatable?: boolean;
  98714. sideOrientation?: number;
  98715. }, scene: Scene): Mesh;
  98716. /**
  98717. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98718. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98719. * * 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`)
  98720. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98721. * * 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
  98722. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98723. * * If you create a double-sided mesh, you can choose what parts of 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
  98724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98725. * @param name defines the name of the mesh
  98726. * @param options defines the options used to create the mesh
  98727. * @param scene defines the hosting scene
  98728. * @returns a new Mesh
  98729. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98730. */
  98731. static CreateIcoSphere(name: string, options: {
  98732. radius?: number;
  98733. flat?: boolean;
  98734. subdivisions?: number;
  98735. sideOrientation?: number;
  98736. updatable?: boolean;
  98737. }, scene: Scene): Mesh;
  98738. /**
  98739. * Creates a decal mesh.
  98740. * Please consider using the same method from the MeshBuilder class instead.
  98741. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98742. * @param name defines the name of the mesh
  98743. * @param sourceMesh defines the mesh receiving the decal
  98744. * @param position sets the position of the decal in world coordinates
  98745. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98746. * @param size sets the decal scaling
  98747. * @param angle sets the angle to rotate the decal
  98748. * @returns a new Mesh
  98749. */
  98750. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98751. /**
  98752. * Prepare internal position array for software CPU skinning
  98753. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98754. */
  98755. setPositionsForCPUSkinning(): Float32Array;
  98756. /**
  98757. * Prepare internal normal array for software CPU skinning
  98758. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98759. */
  98760. setNormalsForCPUSkinning(): Float32Array;
  98761. /**
  98762. * Updates the vertex buffer by applying transformation from the bones
  98763. * @param skeleton defines the skeleton to apply to current mesh
  98764. * @returns the current mesh
  98765. */
  98766. applySkeleton(skeleton: Skeleton): Mesh;
  98767. /**
  98768. * 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
  98769. * @param meshes defines the list of meshes to scan
  98770. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98771. */
  98772. static MinMax(meshes: AbstractMesh[]): {
  98773. min: Vector3;
  98774. max: Vector3;
  98775. };
  98776. /**
  98777. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98778. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98779. * @returns a vector3
  98780. */
  98781. static Center(meshesOrMinMaxVector: {
  98782. min: Vector3;
  98783. max: Vector3;
  98784. } | AbstractMesh[]): Vector3;
  98785. /**
  98786. * Merge the array of meshes into a single mesh for performance reasons.
  98787. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98788. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98789. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98790. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98791. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98792. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98793. * @returns a new mesh
  98794. */
  98795. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98796. /** @hidden */
  98797. addInstance(instance: InstancedMesh): void;
  98798. /** @hidden */
  98799. removeInstance(instance: InstancedMesh): void;
  98800. }
  98801. }
  98802. declare module BABYLON {
  98803. /**
  98804. * This is the base class of all the camera used in the application.
  98805. * @see http://doc.babylonjs.com/features/cameras
  98806. */
  98807. export class Camera extends Node {
  98808. /** @hidden */
  98809. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98810. /**
  98811. * This is the default projection mode used by the cameras.
  98812. * It helps recreating a feeling of perspective and better appreciate depth.
  98813. * This is the best way to simulate real life cameras.
  98814. */
  98815. static readonly PERSPECTIVE_CAMERA: number;
  98816. /**
  98817. * This helps creating camera with an orthographic mode.
  98818. * 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.
  98819. */
  98820. static readonly ORTHOGRAPHIC_CAMERA: number;
  98821. /**
  98822. * This is the default FOV mode for perspective cameras.
  98823. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98824. */
  98825. static readonly FOVMODE_VERTICAL_FIXED: number;
  98826. /**
  98827. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98828. */
  98829. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98830. /**
  98831. * This specifies ther is no need for a camera rig.
  98832. * Basically only one eye is rendered corresponding to the camera.
  98833. */
  98834. static readonly RIG_MODE_NONE: number;
  98835. /**
  98836. * Simulates a camera Rig with one blue eye and one red eye.
  98837. * This can be use with 3d blue and red glasses.
  98838. */
  98839. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98840. /**
  98841. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98842. */
  98843. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98844. /**
  98845. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98846. */
  98847. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98848. /**
  98849. * Defines that both eyes of the camera will be rendered over under each other.
  98850. */
  98851. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98852. /**
  98853. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98854. */
  98855. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98856. /**
  98857. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98858. */
  98859. static readonly RIG_MODE_VR: number;
  98860. /**
  98861. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98862. */
  98863. static readonly RIG_MODE_WEBVR: number;
  98864. /**
  98865. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98866. */
  98867. static readonly RIG_MODE_CUSTOM: number;
  98868. /**
  98869. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98870. */
  98871. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98872. /**
  98873. * Define the input manager associated with the camera.
  98874. */
  98875. inputs: CameraInputsManager<Camera>;
  98876. /** @hidden */
  98877. _position: Vector3;
  98878. /**
  98879. * Define the current local position of the camera in the scene
  98880. */
  98881. get position(): Vector3;
  98882. set position(newPosition: Vector3);
  98883. /**
  98884. * The vector the camera should consider as up.
  98885. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98886. */
  98887. upVector: Vector3;
  98888. /**
  98889. * Define the current limit on the left side for an orthographic camera
  98890. * In scene unit
  98891. */
  98892. orthoLeft: Nullable<number>;
  98893. /**
  98894. * Define the current limit on the right side for an orthographic camera
  98895. * In scene unit
  98896. */
  98897. orthoRight: Nullable<number>;
  98898. /**
  98899. * Define the current limit on the bottom side for an orthographic camera
  98900. * In scene unit
  98901. */
  98902. orthoBottom: Nullable<number>;
  98903. /**
  98904. * Define the current limit on the top side for an orthographic camera
  98905. * In scene unit
  98906. */
  98907. orthoTop: Nullable<number>;
  98908. /**
  98909. * Field Of View is set in Radians. (default is 0.8)
  98910. */
  98911. fov: number;
  98912. /**
  98913. * Define the minimum distance the camera can see from.
  98914. * This is important to note that the depth buffer are not infinite and the closer it starts
  98915. * the more your scene might encounter depth fighting issue.
  98916. */
  98917. minZ: number;
  98918. /**
  98919. * Define the maximum distance the camera can see to.
  98920. * This is important to note that the depth buffer are not infinite and the further it end
  98921. * the more your scene might encounter depth fighting issue.
  98922. */
  98923. maxZ: number;
  98924. /**
  98925. * Define the default inertia of the camera.
  98926. * This helps giving a smooth feeling to the camera movement.
  98927. */
  98928. inertia: number;
  98929. /**
  98930. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98931. */
  98932. mode: number;
  98933. /**
  98934. * Define whether the camera is intermediate.
  98935. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98936. */
  98937. isIntermediate: boolean;
  98938. /**
  98939. * Define the viewport of the camera.
  98940. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98941. */
  98942. viewport: Viewport;
  98943. /**
  98944. * Restricts the camera to viewing objects with the same layerMask.
  98945. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98946. */
  98947. layerMask: number;
  98948. /**
  98949. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98950. */
  98951. fovMode: number;
  98952. /**
  98953. * Rig mode of the camera.
  98954. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98955. * This is normally controlled byt the camera themselves as internal use.
  98956. */
  98957. cameraRigMode: number;
  98958. /**
  98959. * Defines the distance between both "eyes" in case of a RIG
  98960. */
  98961. interaxialDistance: number;
  98962. /**
  98963. * Defines if stereoscopic rendering is done side by side or over under.
  98964. */
  98965. isStereoscopicSideBySide: boolean;
  98966. /**
  98967. * 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
  98968. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98969. * else in the scene. (Eg. security camera)
  98970. *
  98971. * 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)
  98972. */
  98973. customRenderTargets: RenderTargetTexture[];
  98974. /**
  98975. * When set, the camera will render to this render target instead of the default canvas
  98976. *
  98977. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98978. */
  98979. outputRenderTarget: Nullable<RenderTargetTexture>;
  98980. /**
  98981. * Observable triggered when the camera view matrix has changed.
  98982. */
  98983. onViewMatrixChangedObservable: Observable<Camera>;
  98984. /**
  98985. * Observable triggered when the camera Projection matrix has changed.
  98986. */
  98987. onProjectionMatrixChangedObservable: Observable<Camera>;
  98988. /**
  98989. * Observable triggered when the inputs have been processed.
  98990. */
  98991. onAfterCheckInputsObservable: Observable<Camera>;
  98992. /**
  98993. * Observable triggered when reset has been called and applied to the camera.
  98994. */
  98995. onRestoreStateObservable: Observable<Camera>;
  98996. /**
  98997. * Is this camera a part of a rig system?
  98998. */
  98999. isRigCamera: boolean;
  99000. /**
  99001. * If isRigCamera set to true this will be set with the parent camera.
  99002. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99003. */
  99004. rigParent?: Camera;
  99005. /** @hidden */
  99006. _cameraRigParams: any;
  99007. /** @hidden */
  99008. _rigCameras: Camera[];
  99009. /** @hidden */
  99010. _rigPostProcess: Nullable<PostProcess>;
  99011. protected _webvrViewMatrix: Matrix;
  99012. /** @hidden */
  99013. _skipRendering: boolean;
  99014. /** @hidden */
  99015. _projectionMatrix: Matrix;
  99016. /** @hidden */
  99017. _postProcesses: Nullable<PostProcess>[];
  99018. /** @hidden */
  99019. _activeMeshes: SmartArray<AbstractMesh>;
  99020. protected _globalPosition: Vector3;
  99021. /** @hidden */
  99022. _computedViewMatrix: Matrix;
  99023. private _doNotComputeProjectionMatrix;
  99024. private _transformMatrix;
  99025. private _frustumPlanes;
  99026. private _refreshFrustumPlanes;
  99027. private _storedFov;
  99028. private _stateStored;
  99029. /**
  99030. * Instantiates a new camera object.
  99031. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99032. * @see http://doc.babylonjs.com/features/cameras
  99033. * @param name Defines the name of the camera in the scene
  99034. * @param position Defines the position of the camera
  99035. * @param scene Defines the scene the camera belongs too
  99036. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99037. */
  99038. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99039. /**
  99040. * Store current camera state (fov, position, etc..)
  99041. * @returns the camera
  99042. */
  99043. storeState(): Camera;
  99044. /**
  99045. * Restores the camera state values if it has been stored. You must call storeState() first
  99046. */
  99047. protected _restoreStateValues(): boolean;
  99048. /**
  99049. * Restored camera state. You must call storeState() first.
  99050. * @returns true if restored and false otherwise
  99051. */
  99052. restoreState(): boolean;
  99053. /**
  99054. * Gets the class name of the camera.
  99055. * @returns the class name
  99056. */
  99057. getClassName(): string;
  99058. /** @hidden */
  99059. readonly _isCamera: boolean;
  99060. /**
  99061. * Gets a string representation of the camera useful for debug purpose.
  99062. * @param fullDetails Defines that a more verboe level of logging is required
  99063. * @returns the string representation
  99064. */
  99065. toString(fullDetails?: boolean): string;
  99066. /**
  99067. * Gets the current world space position of the camera.
  99068. */
  99069. get globalPosition(): Vector3;
  99070. /**
  99071. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99072. * @returns the active meshe list
  99073. */
  99074. getActiveMeshes(): SmartArray<AbstractMesh>;
  99075. /**
  99076. * Check whether a mesh is part of the current active mesh list of the camera
  99077. * @param mesh Defines the mesh to check
  99078. * @returns true if active, false otherwise
  99079. */
  99080. isActiveMesh(mesh: Mesh): boolean;
  99081. /**
  99082. * Is this camera ready to be used/rendered
  99083. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99084. * @return true if the camera is ready
  99085. */
  99086. isReady(completeCheck?: boolean): boolean;
  99087. /** @hidden */
  99088. _initCache(): void;
  99089. /** @hidden */
  99090. _updateCache(ignoreParentClass?: boolean): void;
  99091. /** @hidden */
  99092. _isSynchronized(): boolean;
  99093. /** @hidden */
  99094. _isSynchronizedViewMatrix(): boolean;
  99095. /** @hidden */
  99096. _isSynchronizedProjectionMatrix(): boolean;
  99097. /**
  99098. * Attach the input controls to a specific dom element to get the input from.
  99099. * @param element Defines the element the controls should be listened from
  99100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99101. */
  99102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99103. /**
  99104. * Detach the current controls from the specified dom element.
  99105. * @param element Defines the element to stop listening the inputs from
  99106. */
  99107. detachControl(element: HTMLElement): void;
  99108. /**
  99109. * Update the camera state according to the different inputs gathered during the frame.
  99110. */
  99111. update(): void;
  99112. /** @hidden */
  99113. _checkInputs(): void;
  99114. /** @hidden */
  99115. get rigCameras(): Camera[];
  99116. /**
  99117. * Gets the post process used by the rig cameras
  99118. */
  99119. get rigPostProcess(): Nullable<PostProcess>;
  99120. /**
  99121. * Internal, gets the first post proces.
  99122. * @returns the first post process to be run on this camera.
  99123. */
  99124. _getFirstPostProcess(): Nullable<PostProcess>;
  99125. private _cascadePostProcessesToRigCams;
  99126. /**
  99127. * Attach a post process to the camera.
  99128. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99129. * @param postProcess The post process to attach to the camera
  99130. * @param insertAt The position of the post process in case several of them are in use in the scene
  99131. * @returns the position the post process has been inserted at
  99132. */
  99133. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99134. /**
  99135. * Detach a post process to the camera.
  99136. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99137. * @param postProcess The post process to detach from the camera
  99138. */
  99139. detachPostProcess(postProcess: PostProcess): void;
  99140. /**
  99141. * Gets the current world matrix of the camera
  99142. */
  99143. getWorldMatrix(): Matrix;
  99144. /** @hidden */
  99145. _getViewMatrix(): Matrix;
  99146. /**
  99147. * Gets the current view matrix of the camera.
  99148. * @param force forces the camera to recompute the matrix without looking at the cached state
  99149. * @returns the view matrix
  99150. */
  99151. getViewMatrix(force?: boolean): Matrix;
  99152. /**
  99153. * Freeze the projection matrix.
  99154. * It will prevent the cache check of the camera projection compute and can speed up perf
  99155. * if no parameter of the camera are meant to change
  99156. * @param projection Defines manually a projection if necessary
  99157. */
  99158. freezeProjectionMatrix(projection?: Matrix): void;
  99159. /**
  99160. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99161. */
  99162. unfreezeProjectionMatrix(): void;
  99163. /**
  99164. * Gets the current projection matrix of the camera.
  99165. * @param force forces the camera to recompute the matrix without looking at the cached state
  99166. * @returns the projection matrix
  99167. */
  99168. getProjectionMatrix(force?: boolean): Matrix;
  99169. /**
  99170. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99171. * @returns a Matrix
  99172. */
  99173. getTransformationMatrix(): Matrix;
  99174. private _updateFrustumPlanes;
  99175. /**
  99176. * Checks if a cullable object (mesh...) is in the camera frustum
  99177. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99178. * @param target The object to check
  99179. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99180. * @returns true if the object is in frustum otherwise false
  99181. */
  99182. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99183. /**
  99184. * Checks if a cullable object (mesh...) is in the camera frustum
  99185. * Unlike isInFrustum this cheks the full bounding box
  99186. * @param target The object to check
  99187. * @returns true if the object is in frustum otherwise false
  99188. */
  99189. isCompletelyInFrustum(target: ICullable): boolean;
  99190. /**
  99191. * Gets a ray in the forward direction from the camera.
  99192. * @param length Defines the length of the ray to create
  99193. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99194. * @param origin Defines the start point of the ray which defaults to the camera position
  99195. * @returns the forward ray
  99196. */
  99197. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99198. /**
  99199. * Releases resources associated with this node.
  99200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99202. */
  99203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99204. /** @hidden */
  99205. _isLeftCamera: boolean;
  99206. /**
  99207. * Gets the left camera of a rig setup in case of Rigged Camera
  99208. */
  99209. get isLeftCamera(): boolean;
  99210. /** @hidden */
  99211. _isRightCamera: boolean;
  99212. /**
  99213. * Gets the right camera of a rig setup in case of Rigged Camera
  99214. */
  99215. get isRightCamera(): boolean;
  99216. /**
  99217. * Gets the left camera of a rig setup in case of Rigged Camera
  99218. */
  99219. get leftCamera(): Nullable<FreeCamera>;
  99220. /**
  99221. * Gets the right camera of a rig setup in case of Rigged Camera
  99222. */
  99223. get rightCamera(): Nullable<FreeCamera>;
  99224. /**
  99225. * Gets the left camera target of a rig setup in case of Rigged Camera
  99226. * @returns the target position
  99227. */
  99228. getLeftTarget(): Nullable<Vector3>;
  99229. /**
  99230. * Gets the right camera target of a rig setup in case of Rigged Camera
  99231. * @returns the target position
  99232. */
  99233. getRightTarget(): Nullable<Vector3>;
  99234. /**
  99235. * @hidden
  99236. */
  99237. setCameraRigMode(mode: number, rigParams: any): void;
  99238. /** @hidden */
  99239. static _setStereoscopicRigMode(camera: Camera): void;
  99240. /** @hidden */
  99241. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99242. /** @hidden */
  99243. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99244. /** @hidden */
  99245. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99246. /** @hidden */
  99247. _getVRProjectionMatrix(): Matrix;
  99248. protected _updateCameraRotationMatrix(): void;
  99249. protected _updateWebVRCameraRotationMatrix(): void;
  99250. /**
  99251. * This function MUST be overwritten by the different WebVR cameras available.
  99252. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99253. * @hidden
  99254. */
  99255. _getWebVRProjectionMatrix(): Matrix;
  99256. /**
  99257. * This function MUST be overwritten by the different WebVR cameras available.
  99258. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99259. * @hidden
  99260. */
  99261. _getWebVRViewMatrix(): Matrix;
  99262. /** @hidden */
  99263. setCameraRigParameter(name: string, value: any): void;
  99264. /**
  99265. * needs to be overridden by children so sub has required properties to be copied
  99266. * @hidden
  99267. */
  99268. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99269. /**
  99270. * May need to be overridden by children
  99271. * @hidden
  99272. */
  99273. _updateRigCameras(): void;
  99274. /** @hidden */
  99275. _setupInputs(): void;
  99276. /**
  99277. * Serialiaze the camera setup to a json represention
  99278. * @returns the JSON representation
  99279. */
  99280. serialize(): any;
  99281. /**
  99282. * Clones the current camera.
  99283. * @param name The cloned camera name
  99284. * @returns the cloned camera
  99285. */
  99286. clone(name: string): Camera;
  99287. /**
  99288. * Gets the direction of the camera relative to a given local axis.
  99289. * @param localAxis Defines the reference axis to provide a relative direction.
  99290. * @return the direction
  99291. */
  99292. getDirection(localAxis: Vector3): Vector3;
  99293. /**
  99294. * Returns the current camera absolute rotation
  99295. */
  99296. get absoluteRotation(): Quaternion;
  99297. /**
  99298. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99299. * @param localAxis Defines the reference axis to provide a relative direction.
  99300. * @param result Defines the vector to store the result in
  99301. */
  99302. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99303. /**
  99304. * Gets a camera constructor for a given camera type
  99305. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99306. * @param name The name of the camera the result will be able to instantiate
  99307. * @param scene The scene the result will construct the camera in
  99308. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99309. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99310. * @returns a factory method to construc the camera
  99311. */
  99312. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99313. /**
  99314. * Compute the world matrix of the camera.
  99315. * @returns the camera world matrix
  99316. */
  99317. computeWorldMatrix(): Matrix;
  99318. /**
  99319. * Parse a JSON and creates the camera from the parsed information
  99320. * @param parsedCamera The JSON to parse
  99321. * @param scene The scene to instantiate the camera in
  99322. * @returns the newly constructed camera
  99323. */
  99324. static Parse(parsedCamera: any, scene: Scene): Camera;
  99325. }
  99326. }
  99327. declare module BABYLON {
  99328. /**
  99329. * Class containing static functions to help procedurally build meshes
  99330. */
  99331. export class DiscBuilder {
  99332. /**
  99333. * Creates a plane polygonal mesh. By default, this is a disc
  99334. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99335. * * 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
  99336. * * 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
  99337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99340. * @param name defines the name of the mesh
  99341. * @param options defines the options used to create the mesh
  99342. * @param scene defines the hosting scene
  99343. * @returns the plane polygonal mesh
  99344. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99345. */
  99346. static CreateDisc(name: string, options: {
  99347. radius?: number;
  99348. tessellation?: number;
  99349. arc?: number;
  99350. updatable?: boolean;
  99351. sideOrientation?: number;
  99352. frontUVs?: Vector4;
  99353. backUVs?: Vector4;
  99354. }, scene?: Nullable<Scene>): Mesh;
  99355. }
  99356. }
  99357. declare module BABYLON {
  99358. /**
  99359. * This represents all the required information to add a fresnel effect on a material:
  99360. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99361. */
  99362. export class FresnelParameters {
  99363. private _isEnabled;
  99364. /**
  99365. * Define if the fresnel effect is enable or not.
  99366. */
  99367. get isEnabled(): boolean;
  99368. set isEnabled(value: boolean);
  99369. /**
  99370. * Define the color used on edges (grazing angle)
  99371. */
  99372. leftColor: Color3;
  99373. /**
  99374. * Define the color used on center
  99375. */
  99376. rightColor: Color3;
  99377. /**
  99378. * Define bias applied to computed fresnel term
  99379. */
  99380. bias: number;
  99381. /**
  99382. * Defined the power exponent applied to fresnel term
  99383. */
  99384. power: number;
  99385. /**
  99386. * Clones the current fresnel and its valuues
  99387. * @returns a clone fresnel configuration
  99388. */
  99389. clone(): FresnelParameters;
  99390. /**
  99391. * Serializes the current fresnel parameters to a JSON representation.
  99392. * @return the JSON serialization
  99393. */
  99394. serialize(): any;
  99395. /**
  99396. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99397. * @param parsedFresnelParameters Define the JSON representation
  99398. * @returns the parsed parameters
  99399. */
  99400. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99401. }
  99402. }
  99403. declare module BABYLON {
  99404. /**
  99405. * Base class of materials working in push mode in babylon JS
  99406. * @hidden
  99407. */
  99408. export class PushMaterial extends Material {
  99409. protected _activeEffect: Effect;
  99410. protected _normalMatrix: Matrix;
  99411. /**
  99412. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99413. * This means that the material can keep using a previous shader while a new one is being compiled.
  99414. * This is mostly used when shader parallel compilation is supported (true by default)
  99415. */
  99416. allowShaderHotSwapping: boolean;
  99417. constructor(name: string, scene: Scene);
  99418. getEffect(): Effect;
  99419. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99420. /**
  99421. * Binds the given world matrix to the active effect
  99422. *
  99423. * @param world the matrix to bind
  99424. */
  99425. bindOnlyWorldMatrix(world: Matrix): void;
  99426. /**
  99427. * Binds the given normal matrix to the active effect
  99428. *
  99429. * @param normalMatrix the matrix to bind
  99430. */
  99431. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99432. bind(world: Matrix, mesh?: Mesh): void;
  99433. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99434. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99435. }
  99436. }
  99437. declare module BABYLON {
  99438. /**
  99439. * This groups all the flags used to control the materials channel.
  99440. */
  99441. export class MaterialFlags {
  99442. private static _DiffuseTextureEnabled;
  99443. /**
  99444. * Are diffuse textures enabled in the application.
  99445. */
  99446. static get DiffuseTextureEnabled(): boolean;
  99447. static set DiffuseTextureEnabled(value: boolean);
  99448. private static _AmbientTextureEnabled;
  99449. /**
  99450. * Are ambient textures enabled in the application.
  99451. */
  99452. static get AmbientTextureEnabled(): boolean;
  99453. static set AmbientTextureEnabled(value: boolean);
  99454. private static _OpacityTextureEnabled;
  99455. /**
  99456. * Are opacity textures enabled in the application.
  99457. */
  99458. static get OpacityTextureEnabled(): boolean;
  99459. static set OpacityTextureEnabled(value: boolean);
  99460. private static _ReflectionTextureEnabled;
  99461. /**
  99462. * Are reflection textures enabled in the application.
  99463. */
  99464. static get ReflectionTextureEnabled(): boolean;
  99465. static set ReflectionTextureEnabled(value: boolean);
  99466. private static _EmissiveTextureEnabled;
  99467. /**
  99468. * Are emissive textures enabled in the application.
  99469. */
  99470. static get EmissiveTextureEnabled(): boolean;
  99471. static set EmissiveTextureEnabled(value: boolean);
  99472. private static _SpecularTextureEnabled;
  99473. /**
  99474. * Are specular textures enabled in the application.
  99475. */
  99476. static get SpecularTextureEnabled(): boolean;
  99477. static set SpecularTextureEnabled(value: boolean);
  99478. private static _BumpTextureEnabled;
  99479. /**
  99480. * Are bump textures enabled in the application.
  99481. */
  99482. static get BumpTextureEnabled(): boolean;
  99483. static set BumpTextureEnabled(value: boolean);
  99484. private static _LightmapTextureEnabled;
  99485. /**
  99486. * Are lightmap textures enabled in the application.
  99487. */
  99488. static get LightmapTextureEnabled(): boolean;
  99489. static set LightmapTextureEnabled(value: boolean);
  99490. private static _RefractionTextureEnabled;
  99491. /**
  99492. * Are refraction textures enabled in the application.
  99493. */
  99494. static get RefractionTextureEnabled(): boolean;
  99495. static set RefractionTextureEnabled(value: boolean);
  99496. private static _ColorGradingTextureEnabled;
  99497. /**
  99498. * Are color grading textures enabled in the application.
  99499. */
  99500. static get ColorGradingTextureEnabled(): boolean;
  99501. static set ColorGradingTextureEnabled(value: boolean);
  99502. private static _FresnelEnabled;
  99503. /**
  99504. * Are fresnels enabled in the application.
  99505. */
  99506. static get FresnelEnabled(): boolean;
  99507. static set FresnelEnabled(value: boolean);
  99508. private static _ClearCoatTextureEnabled;
  99509. /**
  99510. * Are clear coat textures enabled in the application.
  99511. */
  99512. static get ClearCoatTextureEnabled(): boolean;
  99513. static set ClearCoatTextureEnabled(value: boolean);
  99514. private static _ClearCoatBumpTextureEnabled;
  99515. /**
  99516. * Are clear coat bump textures enabled in the application.
  99517. */
  99518. static get ClearCoatBumpTextureEnabled(): boolean;
  99519. static set ClearCoatBumpTextureEnabled(value: boolean);
  99520. private static _ClearCoatTintTextureEnabled;
  99521. /**
  99522. * Are clear coat tint textures enabled in the application.
  99523. */
  99524. static get ClearCoatTintTextureEnabled(): boolean;
  99525. static set ClearCoatTintTextureEnabled(value: boolean);
  99526. private static _SheenTextureEnabled;
  99527. /**
  99528. * Are sheen textures enabled in the application.
  99529. */
  99530. static get SheenTextureEnabled(): boolean;
  99531. static set SheenTextureEnabled(value: boolean);
  99532. private static _AnisotropicTextureEnabled;
  99533. /**
  99534. * Are anisotropic textures enabled in the application.
  99535. */
  99536. static get AnisotropicTextureEnabled(): boolean;
  99537. static set AnisotropicTextureEnabled(value: boolean);
  99538. private static _ThicknessTextureEnabled;
  99539. /**
  99540. * Are thickness textures enabled in the application.
  99541. */
  99542. static get ThicknessTextureEnabled(): boolean;
  99543. static set ThicknessTextureEnabled(value: boolean);
  99544. }
  99545. }
  99546. declare module BABYLON {
  99547. /** @hidden */
  99548. export var defaultFragmentDeclaration: {
  99549. name: string;
  99550. shader: string;
  99551. };
  99552. }
  99553. declare module BABYLON {
  99554. /** @hidden */
  99555. export var defaultUboDeclaration: {
  99556. name: string;
  99557. shader: string;
  99558. };
  99559. }
  99560. declare module BABYLON {
  99561. /** @hidden */
  99562. export var lightFragmentDeclaration: {
  99563. name: string;
  99564. shader: string;
  99565. };
  99566. }
  99567. declare module BABYLON {
  99568. /** @hidden */
  99569. export var lightUboDeclaration: {
  99570. name: string;
  99571. shader: string;
  99572. };
  99573. }
  99574. declare module BABYLON {
  99575. /** @hidden */
  99576. export var lightsFragmentFunctions: {
  99577. name: string;
  99578. shader: string;
  99579. };
  99580. }
  99581. declare module BABYLON {
  99582. /** @hidden */
  99583. export var shadowsFragmentFunctions: {
  99584. name: string;
  99585. shader: string;
  99586. };
  99587. }
  99588. declare module BABYLON {
  99589. /** @hidden */
  99590. export var fresnelFunction: {
  99591. name: string;
  99592. shader: string;
  99593. };
  99594. }
  99595. declare module BABYLON {
  99596. /** @hidden */
  99597. export var reflectionFunction: {
  99598. name: string;
  99599. shader: string;
  99600. };
  99601. }
  99602. declare module BABYLON {
  99603. /** @hidden */
  99604. export var bumpFragmentFunctions: {
  99605. name: string;
  99606. shader: string;
  99607. };
  99608. }
  99609. declare module BABYLON {
  99610. /** @hidden */
  99611. export var logDepthDeclaration: {
  99612. name: string;
  99613. shader: string;
  99614. };
  99615. }
  99616. declare module BABYLON {
  99617. /** @hidden */
  99618. export var bumpFragment: {
  99619. name: string;
  99620. shader: string;
  99621. };
  99622. }
  99623. declare module BABYLON {
  99624. /** @hidden */
  99625. export var depthPrePass: {
  99626. name: string;
  99627. shader: string;
  99628. };
  99629. }
  99630. declare module BABYLON {
  99631. /** @hidden */
  99632. export var lightFragment: {
  99633. name: string;
  99634. shader: string;
  99635. };
  99636. }
  99637. declare module BABYLON {
  99638. /** @hidden */
  99639. export var logDepthFragment: {
  99640. name: string;
  99641. shader: string;
  99642. };
  99643. }
  99644. declare module BABYLON {
  99645. /** @hidden */
  99646. export var defaultPixelShader: {
  99647. name: string;
  99648. shader: string;
  99649. };
  99650. }
  99651. declare module BABYLON {
  99652. /** @hidden */
  99653. export var defaultVertexDeclaration: {
  99654. name: string;
  99655. shader: string;
  99656. };
  99657. }
  99658. declare module BABYLON {
  99659. /** @hidden */
  99660. export var bumpVertexDeclaration: {
  99661. name: string;
  99662. shader: string;
  99663. };
  99664. }
  99665. declare module BABYLON {
  99666. /** @hidden */
  99667. export var bumpVertex: {
  99668. name: string;
  99669. shader: string;
  99670. };
  99671. }
  99672. declare module BABYLON {
  99673. /** @hidden */
  99674. export var fogVertex: {
  99675. name: string;
  99676. shader: string;
  99677. };
  99678. }
  99679. declare module BABYLON {
  99680. /** @hidden */
  99681. export var shadowsVertex: {
  99682. name: string;
  99683. shader: string;
  99684. };
  99685. }
  99686. declare module BABYLON {
  99687. /** @hidden */
  99688. export var pointCloudVertex: {
  99689. name: string;
  99690. shader: string;
  99691. };
  99692. }
  99693. declare module BABYLON {
  99694. /** @hidden */
  99695. export var logDepthVertex: {
  99696. name: string;
  99697. shader: string;
  99698. };
  99699. }
  99700. declare module BABYLON {
  99701. /** @hidden */
  99702. export var defaultVertexShader: {
  99703. name: string;
  99704. shader: string;
  99705. };
  99706. }
  99707. declare module BABYLON {
  99708. /** @hidden */
  99709. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99710. MAINUV1: boolean;
  99711. MAINUV2: boolean;
  99712. DIFFUSE: boolean;
  99713. DIFFUSEDIRECTUV: number;
  99714. AMBIENT: boolean;
  99715. AMBIENTDIRECTUV: number;
  99716. OPACITY: boolean;
  99717. OPACITYDIRECTUV: number;
  99718. OPACITYRGB: boolean;
  99719. REFLECTION: boolean;
  99720. EMISSIVE: boolean;
  99721. EMISSIVEDIRECTUV: number;
  99722. SPECULAR: boolean;
  99723. SPECULARDIRECTUV: number;
  99724. BUMP: boolean;
  99725. BUMPDIRECTUV: number;
  99726. PARALLAX: boolean;
  99727. PARALLAXOCCLUSION: boolean;
  99728. SPECULAROVERALPHA: boolean;
  99729. CLIPPLANE: boolean;
  99730. CLIPPLANE2: boolean;
  99731. CLIPPLANE3: boolean;
  99732. CLIPPLANE4: boolean;
  99733. CLIPPLANE5: boolean;
  99734. CLIPPLANE6: boolean;
  99735. ALPHATEST: boolean;
  99736. DEPTHPREPASS: boolean;
  99737. ALPHAFROMDIFFUSE: boolean;
  99738. POINTSIZE: boolean;
  99739. FOG: boolean;
  99740. SPECULARTERM: boolean;
  99741. DIFFUSEFRESNEL: boolean;
  99742. OPACITYFRESNEL: boolean;
  99743. REFLECTIONFRESNEL: boolean;
  99744. REFRACTIONFRESNEL: boolean;
  99745. EMISSIVEFRESNEL: boolean;
  99746. FRESNEL: boolean;
  99747. NORMAL: boolean;
  99748. UV1: boolean;
  99749. UV2: boolean;
  99750. VERTEXCOLOR: boolean;
  99751. VERTEXALPHA: boolean;
  99752. NUM_BONE_INFLUENCERS: number;
  99753. BonesPerMesh: number;
  99754. BONETEXTURE: boolean;
  99755. INSTANCES: boolean;
  99756. GLOSSINESS: boolean;
  99757. ROUGHNESS: boolean;
  99758. EMISSIVEASILLUMINATION: boolean;
  99759. LINKEMISSIVEWITHDIFFUSE: boolean;
  99760. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99761. LIGHTMAP: boolean;
  99762. LIGHTMAPDIRECTUV: number;
  99763. OBJECTSPACE_NORMALMAP: boolean;
  99764. USELIGHTMAPASSHADOWMAP: boolean;
  99765. REFLECTIONMAP_3D: boolean;
  99766. REFLECTIONMAP_SPHERICAL: boolean;
  99767. REFLECTIONMAP_PLANAR: boolean;
  99768. REFLECTIONMAP_CUBIC: boolean;
  99769. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99770. REFLECTIONMAP_PROJECTION: boolean;
  99771. REFLECTIONMAP_SKYBOX: boolean;
  99772. REFLECTIONMAP_EXPLICIT: boolean;
  99773. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99774. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99775. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99776. INVERTCUBICMAP: boolean;
  99777. LOGARITHMICDEPTH: boolean;
  99778. REFRACTION: boolean;
  99779. REFRACTIONMAP_3D: boolean;
  99780. REFLECTIONOVERALPHA: boolean;
  99781. TWOSIDEDLIGHTING: boolean;
  99782. SHADOWFLOAT: boolean;
  99783. MORPHTARGETS: boolean;
  99784. MORPHTARGETS_NORMAL: boolean;
  99785. MORPHTARGETS_TANGENT: boolean;
  99786. MORPHTARGETS_UV: boolean;
  99787. NUM_MORPH_INFLUENCERS: number;
  99788. NONUNIFORMSCALING: boolean;
  99789. PREMULTIPLYALPHA: boolean;
  99790. IMAGEPROCESSING: boolean;
  99791. VIGNETTE: boolean;
  99792. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99793. VIGNETTEBLENDMODEOPAQUE: boolean;
  99794. TONEMAPPING: boolean;
  99795. TONEMAPPING_ACES: boolean;
  99796. CONTRAST: boolean;
  99797. COLORCURVES: boolean;
  99798. COLORGRADING: boolean;
  99799. COLORGRADING3D: boolean;
  99800. SAMPLER3DGREENDEPTH: boolean;
  99801. SAMPLER3DBGRMAP: boolean;
  99802. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99803. MULTIVIEW: boolean;
  99804. /**
  99805. * If the reflection texture on this material is in linear color space
  99806. * @hidden
  99807. */
  99808. IS_REFLECTION_LINEAR: boolean;
  99809. /**
  99810. * If the refraction texture on this material is in linear color space
  99811. * @hidden
  99812. */
  99813. IS_REFRACTION_LINEAR: boolean;
  99814. EXPOSURE: boolean;
  99815. constructor();
  99816. setReflectionMode(modeToEnable: string): void;
  99817. }
  99818. /**
  99819. * This is the default material used in Babylon. It is the best trade off between quality
  99820. * and performances.
  99821. * @see http://doc.babylonjs.com/babylon101/materials
  99822. */
  99823. export class StandardMaterial extends PushMaterial {
  99824. private _diffuseTexture;
  99825. /**
  99826. * The basic texture of the material as viewed under a light.
  99827. */
  99828. diffuseTexture: Nullable<BaseTexture>;
  99829. private _ambientTexture;
  99830. /**
  99831. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99832. */
  99833. ambientTexture: Nullable<BaseTexture>;
  99834. private _opacityTexture;
  99835. /**
  99836. * Define the transparency of the material from a texture.
  99837. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99838. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99839. */
  99840. opacityTexture: Nullable<BaseTexture>;
  99841. private _reflectionTexture;
  99842. /**
  99843. * Define the texture used to display the reflection.
  99844. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99845. */
  99846. reflectionTexture: Nullable<BaseTexture>;
  99847. private _emissiveTexture;
  99848. /**
  99849. * Define texture of the material as if self lit.
  99850. * This will be mixed in the final result even in the absence of light.
  99851. */
  99852. emissiveTexture: Nullable<BaseTexture>;
  99853. private _specularTexture;
  99854. /**
  99855. * Define how the color and intensity of the highlight given by the light in the material.
  99856. */
  99857. specularTexture: Nullable<BaseTexture>;
  99858. private _bumpTexture;
  99859. /**
  99860. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99861. * 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.
  99862. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99863. */
  99864. bumpTexture: Nullable<BaseTexture>;
  99865. private _lightmapTexture;
  99866. /**
  99867. * Complex lighting can be computationally expensive to compute at runtime.
  99868. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99869. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99870. */
  99871. lightmapTexture: Nullable<BaseTexture>;
  99872. private _refractionTexture;
  99873. /**
  99874. * Define the texture used to display the refraction.
  99875. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99876. */
  99877. refractionTexture: Nullable<BaseTexture>;
  99878. /**
  99879. * The color of the material lit by the environmental background lighting.
  99880. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99881. */
  99882. ambientColor: Color3;
  99883. /**
  99884. * The basic color of the material as viewed under a light.
  99885. */
  99886. diffuseColor: Color3;
  99887. /**
  99888. * Define how the color and intensity of the highlight given by the light in the material.
  99889. */
  99890. specularColor: Color3;
  99891. /**
  99892. * Define the color of the material as if self lit.
  99893. * This will be mixed in the final result even in the absence of light.
  99894. */
  99895. emissiveColor: Color3;
  99896. /**
  99897. * Defines how sharp are the highlights in the material.
  99898. * The bigger the value the sharper giving a more glossy feeling to the result.
  99899. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99900. */
  99901. specularPower: number;
  99902. private _useAlphaFromDiffuseTexture;
  99903. /**
  99904. * Does the transparency come from the diffuse texture alpha channel.
  99905. */
  99906. useAlphaFromDiffuseTexture: boolean;
  99907. private _useEmissiveAsIllumination;
  99908. /**
  99909. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99910. */
  99911. useEmissiveAsIllumination: boolean;
  99912. private _linkEmissiveWithDiffuse;
  99913. /**
  99914. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99915. * the emissive level when the final color is close to one.
  99916. */
  99917. linkEmissiveWithDiffuse: boolean;
  99918. private _useSpecularOverAlpha;
  99919. /**
  99920. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99921. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99922. */
  99923. useSpecularOverAlpha: boolean;
  99924. private _useReflectionOverAlpha;
  99925. /**
  99926. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99927. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99928. */
  99929. useReflectionOverAlpha: boolean;
  99930. private _disableLighting;
  99931. /**
  99932. * Does lights from the scene impacts this material.
  99933. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99934. */
  99935. disableLighting: boolean;
  99936. private _useObjectSpaceNormalMap;
  99937. /**
  99938. * Allows using an object space normal map (instead of tangent space).
  99939. */
  99940. useObjectSpaceNormalMap: boolean;
  99941. private _useParallax;
  99942. /**
  99943. * Is parallax enabled or not.
  99944. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99945. */
  99946. useParallax: boolean;
  99947. private _useParallaxOcclusion;
  99948. /**
  99949. * Is parallax occlusion enabled or not.
  99950. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99951. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99952. */
  99953. useParallaxOcclusion: boolean;
  99954. /**
  99955. * 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.
  99956. */
  99957. parallaxScaleBias: number;
  99958. private _roughness;
  99959. /**
  99960. * Helps to define how blurry the reflections should appears in the material.
  99961. */
  99962. roughness: number;
  99963. /**
  99964. * In case of refraction, define the value of the index of refraction.
  99965. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99966. */
  99967. indexOfRefraction: number;
  99968. /**
  99969. * Invert the refraction texture alongside the y axis.
  99970. * It can be useful with procedural textures or probe for instance.
  99971. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99972. */
  99973. invertRefractionY: boolean;
  99974. /**
  99975. * Defines the alpha limits in alpha test mode.
  99976. */
  99977. alphaCutOff: number;
  99978. private _useLightmapAsShadowmap;
  99979. /**
  99980. * In case of light mapping, define whether the map contains light or shadow informations.
  99981. */
  99982. useLightmapAsShadowmap: boolean;
  99983. private _diffuseFresnelParameters;
  99984. /**
  99985. * Define the diffuse fresnel parameters of the material.
  99986. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99987. */
  99988. diffuseFresnelParameters: FresnelParameters;
  99989. private _opacityFresnelParameters;
  99990. /**
  99991. * Define the opacity fresnel parameters of the material.
  99992. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99993. */
  99994. opacityFresnelParameters: FresnelParameters;
  99995. private _reflectionFresnelParameters;
  99996. /**
  99997. * Define the reflection fresnel parameters of the material.
  99998. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99999. */
  100000. reflectionFresnelParameters: FresnelParameters;
  100001. private _refractionFresnelParameters;
  100002. /**
  100003. * Define the refraction fresnel parameters of the material.
  100004. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100005. */
  100006. refractionFresnelParameters: FresnelParameters;
  100007. private _emissiveFresnelParameters;
  100008. /**
  100009. * Define the emissive fresnel parameters of the material.
  100010. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100011. */
  100012. emissiveFresnelParameters: FresnelParameters;
  100013. private _useReflectionFresnelFromSpecular;
  100014. /**
  100015. * If true automatically deducts the fresnels values from the material specularity.
  100016. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100017. */
  100018. useReflectionFresnelFromSpecular: boolean;
  100019. private _useGlossinessFromSpecularMapAlpha;
  100020. /**
  100021. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100022. */
  100023. useGlossinessFromSpecularMapAlpha: boolean;
  100024. private _maxSimultaneousLights;
  100025. /**
  100026. * Defines the maximum number of lights that can be used in the material
  100027. */
  100028. maxSimultaneousLights: number;
  100029. private _invertNormalMapX;
  100030. /**
  100031. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100032. */
  100033. invertNormalMapX: boolean;
  100034. private _invertNormalMapY;
  100035. /**
  100036. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100037. */
  100038. invertNormalMapY: boolean;
  100039. private _twoSidedLighting;
  100040. /**
  100041. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100042. */
  100043. twoSidedLighting: boolean;
  100044. /**
  100045. * Default configuration related to image processing available in the standard Material.
  100046. */
  100047. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100048. /**
  100049. * Gets the image processing configuration used either in this material.
  100050. */
  100051. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100052. /**
  100053. * Sets the Default image processing configuration used either in the this material.
  100054. *
  100055. * If sets to null, the scene one is in use.
  100056. */
  100057. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100058. /**
  100059. * Keep track of the image processing observer to allow dispose and replace.
  100060. */
  100061. private _imageProcessingObserver;
  100062. /**
  100063. * Attaches a new image processing configuration to the Standard Material.
  100064. * @param configuration
  100065. */
  100066. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100067. /**
  100068. * Gets wether the color curves effect is enabled.
  100069. */
  100070. get cameraColorCurvesEnabled(): boolean;
  100071. /**
  100072. * Sets wether the color curves effect is enabled.
  100073. */
  100074. set cameraColorCurvesEnabled(value: boolean);
  100075. /**
  100076. * Gets wether the color grading effect is enabled.
  100077. */
  100078. get cameraColorGradingEnabled(): boolean;
  100079. /**
  100080. * Gets wether the color grading effect is enabled.
  100081. */
  100082. set cameraColorGradingEnabled(value: boolean);
  100083. /**
  100084. * Gets wether tonemapping is enabled or not.
  100085. */
  100086. get cameraToneMappingEnabled(): boolean;
  100087. /**
  100088. * Sets wether tonemapping is enabled or not
  100089. */
  100090. set cameraToneMappingEnabled(value: boolean);
  100091. /**
  100092. * The camera exposure used on this material.
  100093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100094. * This corresponds to a photographic exposure.
  100095. */
  100096. get cameraExposure(): number;
  100097. /**
  100098. * The camera exposure used on this material.
  100099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100100. * This corresponds to a photographic exposure.
  100101. */
  100102. set cameraExposure(value: number);
  100103. /**
  100104. * Gets The camera contrast used on this material.
  100105. */
  100106. get cameraContrast(): number;
  100107. /**
  100108. * Sets The camera contrast used on this material.
  100109. */
  100110. set cameraContrast(value: number);
  100111. /**
  100112. * Gets the Color Grading 2D Lookup Texture.
  100113. */
  100114. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100115. /**
  100116. * Sets the Color Grading 2D Lookup Texture.
  100117. */
  100118. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100119. /**
  100120. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100121. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100122. * 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;
  100123. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100124. */
  100125. get cameraColorCurves(): Nullable<ColorCurves>;
  100126. /**
  100127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100129. * 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;
  100130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100131. */
  100132. set cameraColorCurves(value: Nullable<ColorCurves>);
  100133. /**
  100134. * Custom callback helping to override the default shader used in the material.
  100135. */
  100136. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100137. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100138. protected _worldViewProjectionMatrix: Matrix;
  100139. protected _globalAmbientColor: Color3;
  100140. protected _useLogarithmicDepth: boolean;
  100141. protected _rebuildInParallel: boolean;
  100142. /**
  100143. * Instantiates a new standard material.
  100144. * This is the default material used in Babylon. It is the best trade off between quality
  100145. * and performances.
  100146. * @see http://doc.babylonjs.com/babylon101/materials
  100147. * @param name Define the name of the material in the scene
  100148. * @param scene Define the scene the material belong to
  100149. */
  100150. constructor(name: string, scene: Scene);
  100151. /**
  100152. * Gets a boolean indicating that current material needs to register RTT
  100153. */
  100154. get hasRenderTargetTextures(): boolean;
  100155. /**
  100156. * Gets the current class name of the material e.g. "StandardMaterial"
  100157. * Mainly use in serialization.
  100158. * @returns the class name
  100159. */
  100160. getClassName(): string;
  100161. /**
  100162. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100163. * You can try switching to logarithmic depth.
  100164. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100165. */
  100166. get useLogarithmicDepth(): boolean;
  100167. set useLogarithmicDepth(value: boolean);
  100168. /**
  100169. * Specifies if the material will require alpha blending
  100170. * @returns a boolean specifying if alpha blending is needed
  100171. */
  100172. needAlphaBlending(): boolean;
  100173. /**
  100174. * Specifies if this material should be rendered in alpha test mode
  100175. * @returns a boolean specifying if an alpha test is needed.
  100176. */
  100177. needAlphaTesting(): boolean;
  100178. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100179. /**
  100180. * Get the texture used for alpha test purpose.
  100181. * @returns the diffuse texture in case of the standard material.
  100182. */
  100183. getAlphaTestTexture(): Nullable<BaseTexture>;
  100184. /**
  100185. * Get if the submesh is ready to be used and all its information available.
  100186. * Child classes can use it to update shaders
  100187. * @param mesh defines the mesh to check
  100188. * @param subMesh defines which submesh to check
  100189. * @param useInstances specifies that instances should be used
  100190. * @returns a boolean indicating that the submesh is ready or not
  100191. */
  100192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100193. /**
  100194. * Builds the material UBO layouts.
  100195. * Used internally during the effect preparation.
  100196. */
  100197. buildUniformLayout(): void;
  100198. /**
  100199. * Unbinds the material from the mesh
  100200. */
  100201. unbind(): void;
  100202. /**
  100203. * Binds the submesh to this material by preparing the effect and shader to draw
  100204. * @param world defines the world transformation matrix
  100205. * @param mesh defines the mesh containing the submesh
  100206. * @param subMesh defines the submesh to bind the material to
  100207. */
  100208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100209. /**
  100210. * Get the list of animatables in the material.
  100211. * @returns the list of animatables object used in the material
  100212. */
  100213. getAnimatables(): IAnimatable[];
  100214. /**
  100215. * Gets the active textures from the material
  100216. * @returns an array of textures
  100217. */
  100218. getActiveTextures(): BaseTexture[];
  100219. /**
  100220. * Specifies if the material uses a texture
  100221. * @param texture defines the texture to check against the material
  100222. * @returns a boolean specifying if the material uses the texture
  100223. */
  100224. hasTexture(texture: BaseTexture): boolean;
  100225. /**
  100226. * Disposes the material
  100227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100229. */
  100230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100231. /**
  100232. * Makes a duplicate of the material, and gives it a new name
  100233. * @param name defines the new name for the duplicated material
  100234. * @returns the cloned material
  100235. */
  100236. clone(name: string): StandardMaterial;
  100237. /**
  100238. * Serializes this material in a JSON representation
  100239. * @returns the serialized material object
  100240. */
  100241. serialize(): any;
  100242. /**
  100243. * Creates a standard material from parsed material data
  100244. * @param source defines the JSON representation of the material
  100245. * @param scene defines the hosting scene
  100246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100247. * @returns a new standard material
  100248. */
  100249. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100250. /**
  100251. * Are diffuse textures enabled in the application.
  100252. */
  100253. static get DiffuseTextureEnabled(): boolean;
  100254. static set DiffuseTextureEnabled(value: boolean);
  100255. /**
  100256. * Are ambient textures enabled in the application.
  100257. */
  100258. static get AmbientTextureEnabled(): boolean;
  100259. static set AmbientTextureEnabled(value: boolean);
  100260. /**
  100261. * Are opacity textures enabled in the application.
  100262. */
  100263. static get OpacityTextureEnabled(): boolean;
  100264. static set OpacityTextureEnabled(value: boolean);
  100265. /**
  100266. * Are reflection textures enabled in the application.
  100267. */
  100268. static get ReflectionTextureEnabled(): boolean;
  100269. static set ReflectionTextureEnabled(value: boolean);
  100270. /**
  100271. * Are emissive textures enabled in the application.
  100272. */
  100273. static get EmissiveTextureEnabled(): boolean;
  100274. static set EmissiveTextureEnabled(value: boolean);
  100275. /**
  100276. * Are specular textures enabled in the application.
  100277. */
  100278. static get SpecularTextureEnabled(): boolean;
  100279. static set SpecularTextureEnabled(value: boolean);
  100280. /**
  100281. * Are bump textures enabled in the application.
  100282. */
  100283. static get BumpTextureEnabled(): boolean;
  100284. static set BumpTextureEnabled(value: boolean);
  100285. /**
  100286. * Are lightmap textures enabled in the application.
  100287. */
  100288. static get LightmapTextureEnabled(): boolean;
  100289. static set LightmapTextureEnabled(value: boolean);
  100290. /**
  100291. * Are refraction textures enabled in the application.
  100292. */
  100293. static get RefractionTextureEnabled(): boolean;
  100294. static set RefractionTextureEnabled(value: boolean);
  100295. /**
  100296. * Are color grading textures enabled in the application.
  100297. */
  100298. static get ColorGradingTextureEnabled(): boolean;
  100299. static set ColorGradingTextureEnabled(value: boolean);
  100300. /**
  100301. * Are fresnels enabled in the application.
  100302. */
  100303. static get FresnelEnabled(): boolean;
  100304. static set FresnelEnabled(value: boolean);
  100305. }
  100306. }
  100307. declare module BABYLON {
  100308. /**
  100309. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100310. *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.
  100311. * The SPS is also a particle system. It provides some methods to manage the particles.
  100312. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100313. *
  100314. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100315. */
  100316. export class SolidParticleSystem implements IDisposable {
  100317. /**
  100318. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100319. * Example : var p = SPS.particles[i];
  100320. */
  100321. particles: SolidParticle[];
  100322. /**
  100323. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100324. */
  100325. nbParticles: number;
  100326. /**
  100327. * If the particles must ever face the camera (default false). Useful for planar particles.
  100328. */
  100329. billboard: boolean;
  100330. /**
  100331. * Recompute normals when adding a shape
  100332. */
  100333. recomputeNormals: boolean;
  100334. /**
  100335. * This a counter ofr your own usage. It's not set by any SPS functions.
  100336. */
  100337. counter: number;
  100338. /**
  100339. * The SPS name. This name is also given to the underlying mesh.
  100340. */
  100341. name: string;
  100342. /**
  100343. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100344. */
  100345. mesh: Mesh;
  100346. /**
  100347. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100348. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100349. */
  100350. vars: any;
  100351. /**
  100352. * This array is populated when the SPS is set as 'pickable'.
  100353. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100354. * Each element of this array is an object `{idx: int, faceId: int}`.
  100355. * `idx` is the picked particle index in the `SPS.particles` array
  100356. * `faceId` is the picked face index counted within this particle.
  100357. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100358. */
  100359. pickedParticles: {
  100360. idx: number;
  100361. faceId: number;
  100362. }[];
  100363. /**
  100364. * This array is populated when `enableDepthSort` is set to true.
  100365. * Each element of this array is an instance of the class DepthSortedParticle.
  100366. */
  100367. depthSortedParticles: DepthSortedParticle[];
  100368. /**
  100369. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100370. * @hidden
  100371. */
  100372. _bSphereOnly: boolean;
  100373. /**
  100374. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100375. * @hidden
  100376. */
  100377. _bSphereRadiusFactor: number;
  100378. private _scene;
  100379. private _positions;
  100380. private _indices;
  100381. private _normals;
  100382. private _colors;
  100383. private _uvs;
  100384. private _indices32;
  100385. private _positions32;
  100386. private _normals32;
  100387. private _fixedNormal32;
  100388. private _colors32;
  100389. private _uvs32;
  100390. private _index;
  100391. private _updatable;
  100392. private _pickable;
  100393. private _isVisibilityBoxLocked;
  100394. private _alwaysVisible;
  100395. private _depthSort;
  100396. private _expandable;
  100397. private _shapeCounter;
  100398. private _copy;
  100399. private _color;
  100400. private _computeParticleColor;
  100401. private _computeParticleTexture;
  100402. private _computeParticleRotation;
  100403. private _computeParticleVertex;
  100404. private _computeBoundingBox;
  100405. private _depthSortParticles;
  100406. private _camera;
  100407. private _mustUnrotateFixedNormals;
  100408. private _particlesIntersect;
  100409. private _needs32Bits;
  100410. private _isNotBuilt;
  100411. private _lastParticleId;
  100412. private _idxOfId;
  100413. private _multimaterialEnabled;
  100414. private _useModelMaterial;
  100415. private _indicesByMaterial;
  100416. private _materialIndexes;
  100417. private _depthSortFunction;
  100418. private _materialSortFunction;
  100419. private _materials;
  100420. private _multimaterial;
  100421. private _materialIndexesById;
  100422. private _defaultMaterial;
  100423. private _autoUpdateSubMeshes;
  100424. /**
  100425. * Creates a SPS (Solid Particle System) object.
  100426. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100427. * @param scene (Scene) is the scene in which the SPS is added.
  100428. * @param options defines the options of the sps e.g.
  100429. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100430. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100431. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100432. * * 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.
  100433. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100434. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100435. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100436. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100437. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100438. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100439. */
  100440. constructor(name: string, scene: Scene, options?: {
  100441. updatable?: boolean;
  100442. isPickable?: boolean;
  100443. enableDepthSort?: boolean;
  100444. particleIntersection?: boolean;
  100445. boundingSphereOnly?: boolean;
  100446. bSphereRadiusFactor?: number;
  100447. expandable?: boolean;
  100448. useModelMaterial?: boolean;
  100449. enableMultiMaterial?: boolean;
  100450. });
  100451. /**
  100452. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100453. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100454. * @returns the created mesh
  100455. */
  100456. buildMesh(): Mesh;
  100457. /**
  100458. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100459. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100460. * Thus the particles generated from `digest()` have their property `position` set yet.
  100461. * @param mesh ( Mesh ) is the mesh to be digested
  100462. * @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
  100463. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100464. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100465. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100466. * @returns the current SPS
  100467. */
  100468. digest(mesh: Mesh, options?: {
  100469. facetNb?: number;
  100470. number?: number;
  100471. delta?: number;
  100472. storage?: [];
  100473. }): SolidParticleSystem;
  100474. /**
  100475. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100476. * @hidden
  100477. */
  100478. private _unrotateFixedNormals;
  100479. /**
  100480. * Resets the temporary working copy particle
  100481. * @hidden
  100482. */
  100483. private _resetCopy;
  100484. /**
  100485. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100486. * @param p the current index in the positions array to be updated
  100487. * @param ind the current index in the indices array
  100488. * @param shape a Vector3 array, the shape geometry
  100489. * @param positions the positions array to be updated
  100490. * @param meshInd the shape indices array
  100491. * @param indices the indices array to be updated
  100492. * @param meshUV the shape uv array
  100493. * @param uvs the uv array to be updated
  100494. * @param meshCol the shape color array
  100495. * @param colors the color array to be updated
  100496. * @param meshNor the shape normals array
  100497. * @param normals the normals array to be updated
  100498. * @param idx the particle index
  100499. * @param idxInShape the particle index in its shape
  100500. * @param options the addShape() method passed options
  100501. * @model the particle model
  100502. * @hidden
  100503. */
  100504. private _meshBuilder;
  100505. /**
  100506. * Returns a shape Vector3 array from positions float array
  100507. * @param positions float array
  100508. * @returns a vector3 array
  100509. * @hidden
  100510. */
  100511. private _posToShape;
  100512. /**
  100513. * Returns a shapeUV array from a float uvs (array deep copy)
  100514. * @param uvs as a float array
  100515. * @returns a shapeUV array
  100516. * @hidden
  100517. */
  100518. private _uvsToShapeUV;
  100519. /**
  100520. * Adds a new particle object in the particles array
  100521. * @param idx particle index in particles array
  100522. * @param id particle id
  100523. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100524. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100525. * @param model particle ModelShape object
  100526. * @param shapeId model shape identifier
  100527. * @param idxInShape index of the particle in the current model
  100528. * @param bInfo model bounding info object
  100529. * @param storage target storage array, if any
  100530. * @hidden
  100531. */
  100532. private _addParticle;
  100533. /**
  100534. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100535. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100536. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100537. * @param nb (positive integer) the number of particles to be created from this model
  100538. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100539. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100540. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100541. * @returns the number of shapes in the system
  100542. */
  100543. addShape(mesh: Mesh, nb: number, options?: {
  100544. positionFunction?: any;
  100545. vertexFunction?: any;
  100546. storage?: [];
  100547. }): number;
  100548. /**
  100549. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100550. * @hidden
  100551. */
  100552. private _rebuildParticle;
  100553. /**
  100554. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100555. * @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.
  100556. * @returns the SPS.
  100557. */
  100558. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100559. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100560. * Returns an array with the removed particles.
  100561. * 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.
  100562. * The SPS can't be empty so at least one particle needs to remain in place.
  100563. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100564. * @param start index of the first particle to remove
  100565. * @param end index of the last particle to remove (included)
  100566. * @returns an array populated with the removed particles
  100567. */
  100568. removeParticles(start: number, end: number): SolidParticle[];
  100569. /**
  100570. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100571. * @param solidParticleArray an array populated with Solid Particles objects
  100572. * @returns the SPS
  100573. */
  100574. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100575. /**
  100576. * Creates a new particle and modifies the SPS mesh geometry :
  100577. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100578. * - calls _addParticle() to populate the particle array
  100579. * factorized code from addShape() and insertParticlesFromArray()
  100580. * @param idx particle index in the particles array
  100581. * @param i particle index in its shape
  100582. * @param modelShape particle ModelShape object
  100583. * @param shape shape vertex array
  100584. * @param meshInd shape indices array
  100585. * @param meshUV shape uv array
  100586. * @param meshCol shape color array
  100587. * @param meshNor shape normals array
  100588. * @param bbInfo shape bounding info
  100589. * @param storage target particle storage
  100590. * @options addShape() passed options
  100591. * @hidden
  100592. */
  100593. private _insertNewParticle;
  100594. /**
  100595. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100596. * This method calls `updateParticle()` for each particle of the SPS.
  100597. * For an animated SPS, it is usually called within the render loop.
  100598. * 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.
  100599. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100600. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100601. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100602. * @returns the SPS.
  100603. */
  100604. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100605. /**
  100606. * Disposes the SPS.
  100607. */
  100608. dispose(): void;
  100609. /**
  100610. * Returns a SolidParticle object from its identifier : particle.id
  100611. * @param id (integer) the particle Id
  100612. * @returns the searched particle or null if not found in the SPS.
  100613. */
  100614. getParticleById(id: number): Nullable<SolidParticle>;
  100615. /**
  100616. * Returns a new array populated with the particles having the passed shapeId.
  100617. * @param shapeId (integer) the shape identifier
  100618. * @returns a new solid particle array
  100619. */
  100620. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100621. /**
  100622. * Populates the passed array "ref" with the particles having the passed shapeId.
  100623. * @param shapeId the shape identifier
  100624. * @returns the SPS
  100625. * @param ref
  100626. */
  100627. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100628. /**
  100629. * Computes the required SubMeshes according the materials assigned to the particles.
  100630. * @returns the solid particle system.
  100631. * Does nothing if called before the SPS mesh is built.
  100632. */
  100633. computeSubMeshes(): SolidParticleSystem;
  100634. /**
  100635. * Sorts the solid particles by material when MultiMaterial is enabled.
  100636. * Updates the indices32 array.
  100637. * Updates the indicesByMaterial array.
  100638. * Updates the mesh indices array.
  100639. * @returns the SPS
  100640. * @hidden
  100641. */
  100642. private _sortParticlesByMaterial;
  100643. /**
  100644. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100645. * @hidden
  100646. */
  100647. private _setMaterialIndexesById;
  100648. /**
  100649. * Returns an array with unique values of Materials from the passed array
  100650. * @param array the material array to be checked and filtered
  100651. * @hidden
  100652. */
  100653. private _filterUniqueMaterialId;
  100654. /**
  100655. * Sets a new Standard Material as _defaultMaterial if not already set.
  100656. * @hidden
  100657. */
  100658. private _setDefaultMaterial;
  100659. /**
  100660. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100661. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100662. * @returns the SPS.
  100663. */
  100664. refreshVisibleSize(): SolidParticleSystem;
  100665. /**
  100666. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100667. * @param size the size (float) of the visibility box
  100668. * note : this doesn't lock the SPS mesh bounding box.
  100669. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100670. */
  100671. setVisibilityBox(size: number): void;
  100672. /**
  100673. * Gets whether the SPS as always visible or not
  100674. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100675. */
  100676. get isAlwaysVisible(): boolean;
  100677. /**
  100678. * Sets the SPS as always visible or not
  100679. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100680. */
  100681. set isAlwaysVisible(val: boolean);
  100682. /**
  100683. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100684. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100685. */
  100686. set isVisibilityBoxLocked(val: boolean);
  100687. /**
  100688. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100689. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100690. */
  100691. get isVisibilityBoxLocked(): boolean;
  100692. /**
  100693. * Tells to `setParticles()` to compute the particle rotations or not.
  100694. * Default value : true. The SPS is faster when it's set to false.
  100695. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100696. */
  100697. set computeParticleRotation(val: boolean);
  100698. /**
  100699. * Tells to `setParticles()` to compute the particle colors or not.
  100700. * Default value : true. The SPS is faster when it's set to false.
  100701. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100702. */
  100703. set computeParticleColor(val: boolean);
  100704. set computeParticleTexture(val: boolean);
  100705. /**
  100706. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100707. * Default value : false. The SPS is faster when it's set to false.
  100708. * Note : the particle custom vertex positions aren't stored values.
  100709. */
  100710. set computeParticleVertex(val: boolean);
  100711. /**
  100712. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100713. */
  100714. set computeBoundingBox(val: boolean);
  100715. /**
  100716. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100717. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100718. * Default : `true`
  100719. */
  100720. set depthSortParticles(val: boolean);
  100721. /**
  100722. * Gets if `setParticles()` computes the particle rotations or not.
  100723. * Default value : true. The SPS is faster when it's set to false.
  100724. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100725. */
  100726. get computeParticleRotation(): boolean;
  100727. /**
  100728. * Gets if `setParticles()` computes the particle colors or not.
  100729. * Default value : true. The SPS is faster when it's set to false.
  100730. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100731. */
  100732. get computeParticleColor(): boolean;
  100733. /**
  100734. * Gets if `setParticles()` computes the particle textures or not.
  100735. * Default value : true. The SPS is faster when it's set to false.
  100736. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100737. */
  100738. get computeParticleTexture(): boolean;
  100739. /**
  100740. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100741. * Default value : false. The SPS is faster when it's set to false.
  100742. * Note : the particle custom vertex positions aren't stored values.
  100743. */
  100744. get computeParticleVertex(): boolean;
  100745. /**
  100746. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100747. */
  100748. get computeBoundingBox(): boolean;
  100749. /**
  100750. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100751. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100752. * Default : `true`
  100753. */
  100754. get depthSortParticles(): boolean;
  100755. /**
  100756. * Gets if the SPS is created as expandable at construction time.
  100757. * Default : `false`
  100758. */
  100759. get expandable(): boolean;
  100760. /**
  100761. * Gets if the SPS supports the Multi Materials
  100762. */
  100763. get multimaterialEnabled(): boolean;
  100764. /**
  100765. * Gets if the SPS uses the model materials for its own multimaterial.
  100766. */
  100767. get useModelMaterial(): boolean;
  100768. /**
  100769. * The SPS used material array.
  100770. */
  100771. get materials(): Material[];
  100772. /**
  100773. * Sets the SPS MultiMaterial from the passed materials.
  100774. * Note : the passed array is internally copied and not used then by reference.
  100775. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100776. */
  100777. setMultiMaterial(materials: Material[]): void;
  100778. /**
  100779. * The SPS computed multimaterial object
  100780. */
  100781. get multimaterial(): MultiMaterial;
  100782. set multimaterial(mm: MultiMaterial);
  100783. /**
  100784. * If the subMeshes must be updated on the next call to setParticles()
  100785. */
  100786. get autoUpdateSubMeshes(): boolean;
  100787. set autoUpdateSubMeshes(val: boolean);
  100788. /**
  100789. * This function does nothing. It may be overwritten to set all the particle first values.
  100790. * The SPS doesn't call this function, you may have to call it by your own.
  100791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100792. */
  100793. initParticles(): void;
  100794. /**
  100795. * This function does nothing. It may be overwritten to recycle a particle.
  100796. * The SPS doesn't call this function, you may have to call it by your own.
  100797. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100798. * @param particle The particle to recycle
  100799. * @returns the recycled particle
  100800. */
  100801. recycleParticle(particle: SolidParticle): SolidParticle;
  100802. /**
  100803. * Updates a particle : this function should be overwritten by the user.
  100804. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100805. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100806. * @example : just set a particle position or velocity and recycle conditions
  100807. * @param particle The particle to update
  100808. * @returns the updated particle
  100809. */
  100810. updateParticle(particle: SolidParticle): SolidParticle;
  100811. /**
  100812. * Updates a vertex of a particle : it can be overwritten by the user.
  100813. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100814. * @param particle the current particle
  100815. * @param vertex the current index of the current particle
  100816. * @param pt the index of the current vertex in the particle shape
  100817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100818. * @example : just set a vertex particle position
  100819. * @returns the updated vertex
  100820. */
  100821. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100822. /**
  100823. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100824. * This does nothing and may be overwritten by the user.
  100825. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100826. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100827. * @param update the boolean update value actually passed to setParticles()
  100828. */
  100829. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100830. /**
  100831. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100832. * This will be passed three parameters.
  100833. * This does nothing and may be overwritten by the user.
  100834. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100835. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100836. * @param update the boolean update value actually passed to setParticles()
  100837. */
  100838. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100839. }
  100840. }
  100841. declare module BABYLON {
  100842. /**
  100843. * Represents one particle of a solid particle system.
  100844. */
  100845. export class SolidParticle {
  100846. /**
  100847. * particle global index
  100848. */
  100849. idx: number;
  100850. /**
  100851. * particle identifier
  100852. */
  100853. id: number;
  100854. /**
  100855. * The color of the particle
  100856. */
  100857. color: Nullable<Color4>;
  100858. /**
  100859. * The world space position of the particle.
  100860. */
  100861. position: Vector3;
  100862. /**
  100863. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100864. */
  100865. rotation: Vector3;
  100866. /**
  100867. * The world space rotation quaternion of the particle.
  100868. */
  100869. rotationQuaternion: Nullable<Quaternion>;
  100870. /**
  100871. * The scaling of the particle.
  100872. */
  100873. scaling: Vector3;
  100874. /**
  100875. * The uvs of the particle.
  100876. */
  100877. uvs: Vector4;
  100878. /**
  100879. * The current speed of the particle.
  100880. */
  100881. velocity: Vector3;
  100882. /**
  100883. * The pivot point in the particle local space.
  100884. */
  100885. pivot: Vector3;
  100886. /**
  100887. * Must the particle be translated from its pivot point in its local space ?
  100888. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100889. * Default : false
  100890. */
  100891. translateFromPivot: boolean;
  100892. /**
  100893. * Is the particle active or not ?
  100894. */
  100895. alive: boolean;
  100896. /**
  100897. * Is the particle visible or not ?
  100898. */
  100899. isVisible: boolean;
  100900. /**
  100901. * Index of this particle in the global "positions" array (Internal use)
  100902. * @hidden
  100903. */
  100904. _pos: number;
  100905. /**
  100906. * @hidden Index of this particle in the global "indices" array (Internal use)
  100907. */
  100908. _ind: number;
  100909. /**
  100910. * @hidden ModelShape of this particle (Internal use)
  100911. */
  100912. _model: ModelShape;
  100913. /**
  100914. * ModelShape id of this particle
  100915. */
  100916. shapeId: number;
  100917. /**
  100918. * Index of the particle in its shape id
  100919. */
  100920. idxInShape: number;
  100921. /**
  100922. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100923. */
  100924. _modelBoundingInfo: BoundingInfo;
  100925. /**
  100926. * @hidden Particle BoundingInfo object (Internal use)
  100927. */
  100928. _boundingInfo: BoundingInfo;
  100929. /**
  100930. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100931. */
  100932. _sps: SolidParticleSystem;
  100933. /**
  100934. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100935. */
  100936. _stillInvisible: boolean;
  100937. /**
  100938. * @hidden Last computed particle rotation matrix
  100939. */
  100940. _rotationMatrix: number[];
  100941. /**
  100942. * Parent particle Id, if any.
  100943. * Default null.
  100944. */
  100945. parentId: Nullable<number>;
  100946. /**
  100947. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100948. */
  100949. materialIndex: Nullable<number>;
  100950. /**
  100951. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100952. * The possible values are :
  100953. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100954. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100955. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100956. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100957. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100958. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100959. * */
  100960. cullingStrategy: number;
  100961. /**
  100962. * @hidden Internal global position in the SPS.
  100963. */
  100964. _globalPosition: Vector3;
  100965. /**
  100966. * Creates a Solid Particle object.
  100967. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100968. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100969. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100970. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100971. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100972. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100973. * @param shapeId (integer) is the model shape identifier in the SPS.
  100974. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100975. * @param sps defines the sps it is associated to
  100976. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100977. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100978. */
  100979. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100980. /**
  100981. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100982. * @param target the particle target
  100983. * @returns the current particle
  100984. */
  100985. copyToRef(target: SolidParticle): SolidParticle;
  100986. /**
  100987. * Legacy support, changed scale to scaling
  100988. */
  100989. get scale(): Vector3;
  100990. /**
  100991. * Legacy support, changed scale to scaling
  100992. */
  100993. set scale(scale: Vector3);
  100994. /**
  100995. * Legacy support, changed quaternion to rotationQuaternion
  100996. */
  100997. get quaternion(): Nullable<Quaternion>;
  100998. /**
  100999. * Legacy support, changed quaternion to rotationQuaternion
  101000. */
  101001. set quaternion(q: Nullable<Quaternion>);
  101002. /**
  101003. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101004. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101005. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101006. * @returns true if it intersects
  101007. */
  101008. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101009. /**
  101010. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101011. * A particle is in the frustum if its bounding box intersects the frustum
  101012. * @param frustumPlanes defines the frustum to test
  101013. * @returns true if the particle is in the frustum planes
  101014. */
  101015. isInFrustum(frustumPlanes: Plane[]): boolean;
  101016. /**
  101017. * get the rotation matrix of the particle
  101018. * @hidden
  101019. */
  101020. getRotationMatrix(m: Matrix): void;
  101021. }
  101022. /**
  101023. * Represents the shape of the model used by one particle of a solid particle system.
  101024. * SPS internal tool, don't use it manually.
  101025. */
  101026. export class ModelShape {
  101027. /**
  101028. * The shape id
  101029. * @hidden
  101030. */
  101031. shapeID: number;
  101032. /**
  101033. * flat array of model positions (internal use)
  101034. * @hidden
  101035. */
  101036. _shape: Vector3[];
  101037. /**
  101038. * flat array of model UVs (internal use)
  101039. * @hidden
  101040. */
  101041. _shapeUV: number[];
  101042. /**
  101043. * color array of the model
  101044. * @hidden
  101045. */
  101046. _shapeColors: number[];
  101047. /**
  101048. * indices array of the model
  101049. * @hidden
  101050. */
  101051. _indices: number[];
  101052. /**
  101053. * normals array of the model
  101054. * @hidden
  101055. */
  101056. _normals: number[];
  101057. /**
  101058. * length of the shape in the model indices array (internal use)
  101059. * @hidden
  101060. */
  101061. _indicesLength: number;
  101062. /**
  101063. * Custom position function (internal use)
  101064. * @hidden
  101065. */
  101066. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  101067. /**
  101068. * Custom vertex function (internal use)
  101069. * @hidden
  101070. */
  101071. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  101072. /**
  101073. * Model material (internal use)
  101074. * @hidden
  101075. */
  101076. _material: Nullable<Material>;
  101077. /**
  101078. * 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.
  101079. * SPS internal tool, don't use it manually.
  101080. * @hidden
  101081. */
  101082. 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>);
  101083. }
  101084. /**
  101085. * Represents a Depth Sorted Particle in the solid particle system.
  101086. * @hidden
  101087. */
  101088. export class DepthSortedParticle {
  101089. /**
  101090. * Index of the particle in the "indices" array
  101091. */
  101092. ind: number;
  101093. /**
  101094. * Length of the particle shape in the "indices" array
  101095. */
  101096. indicesLength: number;
  101097. /**
  101098. * Squared distance from the particle to the camera
  101099. */
  101100. sqDistance: number;
  101101. /**
  101102. * Material index when used with MultiMaterials
  101103. */
  101104. materialIndex: number;
  101105. /**
  101106. * Creates a new sorted particle
  101107. * @param materialIndex
  101108. */
  101109. constructor(ind: number, indLength: number, materialIndex: number);
  101110. }
  101111. }
  101112. declare module BABYLON {
  101113. /**
  101114. * @hidden
  101115. */
  101116. export class _MeshCollisionData {
  101117. _checkCollisions: boolean;
  101118. _collisionMask: number;
  101119. _collisionGroup: number;
  101120. _collider: Nullable<Collider>;
  101121. _oldPositionForCollisions: Vector3;
  101122. _diffPositionForCollisions: Vector3;
  101123. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101124. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101125. }
  101126. }
  101127. declare module BABYLON {
  101128. /** @hidden */
  101129. class _FacetDataStorage {
  101130. facetPositions: Vector3[];
  101131. facetNormals: Vector3[];
  101132. facetPartitioning: number[][];
  101133. facetNb: number;
  101134. partitioningSubdivisions: number;
  101135. partitioningBBoxRatio: number;
  101136. facetDataEnabled: boolean;
  101137. facetParameters: any;
  101138. bbSize: Vector3;
  101139. subDiv: {
  101140. max: number;
  101141. X: number;
  101142. Y: number;
  101143. Z: number;
  101144. };
  101145. facetDepthSort: boolean;
  101146. facetDepthSortEnabled: boolean;
  101147. depthSortedIndices: IndicesArray;
  101148. depthSortedFacets: {
  101149. ind: number;
  101150. sqDistance: number;
  101151. }[];
  101152. facetDepthSortFunction: (f1: {
  101153. ind: number;
  101154. sqDistance: number;
  101155. }, f2: {
  101156. ind: number;
  101157. sqDistance: number;
  101158. }) => number;
  101159. facetDepthSortFrom: Vector3;
  101160. facetDepthSortOrigin: Vector3;
  101161. invertedMatrix: Matrix;
  101162. }
  101163. /**
  101164. * @hidden
  101165. **/
  101166. class _InternalAbstractMeshDataInfo {
  101167. _hasVertexAlpha: boolean;
  101168. _useVertexColors: boolean;
  101169. _numBoneInfluencers: number;
  101170. _applyFog: boolean;
  101171. _receiveShadows: boolean;
  101172. _facetData: _FacetDataStorage;
  101173. _visibility: number;
  101174. _skeleton: Nullable<Skeleton>;
  101175. _layerMask: number;
  101176. _computeBonesUsingShaders: boolean;
  101177. _isActive: boolean;
  101178. _onlyForInstances: boolean;
  101179. _isActiveIntermediate: boolean;
  101180. _onlyForInstancesIntermediate: boolean;
  101181. _actAsRegularMesh: boolean;
  101182. }
  101183. /**
  101184. * Class used to store all common mesh properties
  101185. */
  101186. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101187. /** No occlusion */
  101188. static OCCLUSION_TYPE_NONE: number;
  101189. /** Occlusion set to optimisitic */
  101190. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101191. /** Occlusion set to strict */
  101192. static OCCLUSION_TYPE_STRICT: number;
  101193. /** Use an accurante occlusion algorithm */
  101194. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101195. /** Use a conservative occlusion algorithm */
  101196. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101197. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101198. * Test order :
  101199. * Is the bounding sphere outside the frustum ?
  101200. * If not, are the bounding box vertices outside the frustum ?
  101201. * It not, then the cullable object is in the frustum.
  101202. */
  101203. static readonly CULLINGSTRATEGY_STANDARD: number;
  101204. /** Culling strategy : Bounding Sphere Only.
  101205. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101206. * It's also less accurate than the standard because some not visible objects can still be selected.
  101207. * Test : is the bounding sphere outside the frustum ?
  101208. * If not, then the cullable object is in the frustum.
  101209. */
  101210. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101211. /** Culling strategy : Optimistic Inclusion.
  101212. * This in an inclusion test first, then the standard exclusion test.
  101213. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101214. * 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.
  101215. * Anyway, it's as accurate as the standard strategy.
  101216. * Test :
  101217. * Is the cullable object bounding sphere center in the frustum ?
  101218. * If not, apply the default culling strategy.
  101219. */
  101220. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101221. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101222. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101223. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101224. * 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.
  101225. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101226. * Test :
  101227. * Is the cullable object bounding sphere center in the frustum ?
  101228. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101229. */
  101230. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101231. /**
  101232. * No billboard
  101233. */
  101234. static get BILLBOARDMODE_NONE(): number;
  101235. /** Billboard on X axis */
  101236. static get BILLBOARDMODE_X(): number;
  101237. /** Billboard on Y axis */
  101238. static get BILLBOARDMODE_Y(): number;
  101239. /** Billboard on Z axis */
  101240. static get BILLBOARDMODE_Z(): number;
  101241. /** Billboard on all axes */
  101242. static get BILLBOARDMODE_ALL(): number;
  101243. /** Billboard on using position instead of orientation */
  101244. static get BILLBOARDMODE_USE_POSITION(): number;
  101245. /** @hidden */
  101246. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101247. /**
  101248. * The culling strategy to use to check whether the mesh must be rendered or not.
  101249. * This value can be changed at any time and will be used on the next render mesh selection.
  101250. * The possible values are :
  101251. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101252. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101253. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101254. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101255. * Please read each static variable documentation to get details about the culling process.
  101256. * */
  101257. cullingStrategy: number;
  101258. /**
  101259. * Gets the number of facets in the mesh
  101260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101261. */
  101262. get facetNb(): number;
  101263. /**
  101264. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101266. */
  101267. get partitioningSubdivisions(): number;
  101268. set partitioningSubdivisions(nb: number);
  101269. /**
  101270. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101271. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101273. */
  101274. get partitioningBBoxRatio(): number;
  101275. set partitioningBBoxRatio(ratio: number);
  101276. /**
  101277. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101278. * Works only for updatable meshes.
  101279. * Doesn't work with multi-materials
  101280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101281. */
  101282. get mustDepthSortFacets(): boolean;
  101283. set mustDepthSortFacets(sort: boolean);
  101284. /**
  101285. * The location (Vector3) where the facet depth sort must be computed from.
  101286. * By default, the active camera position.
  101287. * Used only when facet depth sort is enabled
  101288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101289. */
  101290. get facetDepthSortFrom(): Vector3;
  101291. set facetDepthSortFrom(location: Vector3);
  101292. /**
  101293. * gets a boolean indicating if facetData is enabled
  101294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101295. */
  101296. get isFacetDataEnabled(): boolean;
  101297. /** @hidden */
  101298. _updateNonUniformScalingState(value: boolean): boolean;
  101299. /**
  101300. * An event triggered when this mesh collides with another one
  101301. */
  101302. onCollideObservable: Observable<AbstractMesh>;
  101303. /** Set a function to call when this mesh collides with another one */
  101304. set onCollide(callback: () => void);
  101305. /**
  101306. * An event triggered when the collision's position changes
  101307. */
  101308. onCollisionPositionChangeObservable: Observable<Vector3>;
  101309. /** Set a function to call when the collision's position changes */
  101310. set onCollisionPositionChange(callback: () => void);
  101311. /**
  101312. * An event triggered when material is changed
  101313. */
  101314. onMaterialChangedObservable: Observable<AbstractMesh>;
  101315. /**
  101316. * Gets or sets the orientation for POV movement & rotation
  101317. */
  101318. definedFacingForward: boolean;
  101319. /** @hidden */
  101320. _occlusionQuery: Nullable<WebGLQuery>;
  101321. /** @hidden */
  101322. _renderingGroup: Nullable<RenderingGroup>;
  101323. /**
  101324. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101325. */
  101326. get visibility(): number;
  101327. /**
  101328. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101329. */
  101330. set visibility(value: number);
  101331. /** Gets or sets the alpha index used to sort transparent meshes
  101332. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101333. */
  101334. alphaIndex: number;
  101335. /**
  101336. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101337. */
  101338. isVisible: boolean;
  101339. /**
  101340. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101341. */
  101342. isPickable: boolean;
  101343. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101344. showSubMeshesBoundingBox: boolean;
  101345. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101346. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101347. */
  101348. isBlocker: boolean;
  101349. /**
  101350. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101351. */
  101352. enablePointerMoveEvents: boolean;
  101353. /**
  101354. * Specifies the rendering group id for this mesh (0 by default)
  101355. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101356. */
  101357. renderingGroupId: number;
  101358. private _material;
  101359. /** Gets or sets current material */
  101360. get material(): Nullable<Material>;
  101361. set material(value: Nullable<Material>);
  101362. /**
  101363. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101364. * @see http://doc.babylonjs.com/babylon101/shadows
  101365. */
  101366. get receiveShadows(): boolean;
  101367. set receiveShadows(value: boolean);
  101368. /** Defines color to use when rendering outline */
  101369. outlineColor: Color3;
  101370. /** Define width to use when rendering outline */
  101371. outlineWidth: number;
  101372. /** Defines color to use when rendering overlay */
  101373. overlayColor: Color3;
  101374. /** Defines alpha to use when rendering overlay */
  101375. overlayAlpha: number;
  101376. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101377. get hasVertexAlpha(): boolean;
  101378. set hasVertexAlpha(value: boolean);
  101379. /** 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) */
  101380. get useVertexColors(): boolean;
  101381. set useVertexColors(value: boolean);
  101382. /**
  101383. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101384. */
  101385. get computeBonesUsingShaders(): boolean;
  101386. set computeBonesUsingShaders(value: boolean);
  101387. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101388. get numBoneInfluencers(): number;
  101389. set numBoneInfluencers(value: number);
  101390. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101391. get applyFog(): boolean;
  101392. set applyFog(value: boolean);
  101393. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101394. useOctreeForRenderingSelection: boolean;
  101395. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101396. useOctreeForPicking: boolean;
  101397. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101398. useOctreeForCollisions: boolean;
  101399. /**
  101400. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101401. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101402. */
  101403. get layerMask(): number;
  101404. set layerMask(value: number);
  101405. /**
  101406. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101407. */
  101408. alwaysSelectAsActiveMesh: boolean;
  101409. /**
  101410. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101411. */
  101412. doNotSyncBoundingInfo: boolean;
  101413. /**
  101414. * Gets or sets the current action manager
  101415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101416. */
  101417. actionManager: Nullable<AbstractActionManager>;
  101418. private _meshCollisionData;
  101419. /**
  101420. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101421. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101422. */
  101423. ellipsoid: Vector3;
  101424. /**
  101425. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101426. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101427. */
  101428. ellipsoidOffset: Vector3;
  101429. /**
  101430. * Gets or sets a collision mask used to mask collisions (default is -1).
  101431. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101432. */
  101433. get collisionMask(): number;
  101434. set collisionMask(mask: number);
  101435. /**
  101436. * Gets or sets the current collision group mask (-1 by default).
  101437. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101438. */
  101439. get collisionGroup(): number;
  101440. set collisionGroup(mask: number);
  101441. /**
  101442. * Defines edge width used when edgesRenderer is enabled
  101443. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101444. */
  101445. edgesWidth: number;
  101446. /**
  101447. * Defines edge color used when edgesRenderer is enabled
  101448. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101449. */
  101450. edgesColor: Color4;
  101451. /** @hidden */
  101452. _edgesRenderer: Nullable<IEdgesRenderer>;
  101453. /** @hidden */
  101454. _masterMesh: Nullable<AbstractMesh>;
  101455. /** @hidden */
  101456. _boundingInfo: Nullable<BoundingInfo>;
  101457. /** @hidden */
  101458. _renderId: number;
  101459. /**
  101460. * Gets or sets the list of subMeshes
  101461. * @see http://doc.babylonjs.com/how_to/multi_materials
  101462. */
  101463. subMeshes: SubMesh[];
  101464. /** @hidden */
  101465. _intersectionsInProgress: AbstractMesh[];
  101466. /** @hidden */
  101467. _unIndexed: boolean;
  101468. /** @hidden */
  101469. _lightSources: Light[];
  101470. /** Gets the list of lights affecting that mesh */
  101471. get lightSources(): Light[];
  101472. /** @hidden */
  101473. get _positions(): Nullable<Vector3[]>;
  101474. /** @hidden */
  101475. _waitingData: {
  101476. lods: Nullable<any>;
  101477. actions: Nullable<any>;
  101478. freezeWorldMatrix: Nullable<boolean>;
  101479. };
  101480. /** @hidden */
  101481. _bonesTransformMatrices: Nullable<Float32Array>;
  101482. /** @hidden */
  101483. _transformMatrixTexture: Nullable<RawTexture>;
  101484. /**
  101485. * Gets or sets a skeleton to apply skining transformations
  101486. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101487. */
  101488. set skeleton(value: Nullable<Skeleton>);
  101489. get skeleton(): Nullable<Skeleton>;
  101490. /**
  101491. * An event triggered when the mesh is rebuilt.
  101492. */
  101493. onRebuildObservable: Observable<AbstractMesh>;
  101494. /**
  101495. * Creates a new AbstractMesh
  101496. * @param name defines the name of the mesh
  101497. * @param scene defines the hosting scene
  101498. */
  101499. constructor(name: string, scene?: Nullable<Scene>);
  101500. /**
  101501. * Returns the string "AbstractMesh"
  101502. * @returns "AbstractMesh"
  101503. */
  101504. getClassName(): string;
  101505. /**
  101506. * Gets a string representation of the current mesh
  101507. * @param fullDetails defines a boolean indicating if full details must be included
  101508. * @returns a string representation of the current mesh
  101509. */
  101510. toString(fullDetails?: boolean): string;
  101511. /**
  101512. * @hidden
  101513. */
  101514. protected _getEffectiveParent(): Nullable<Node>;
  101515. /** @hidden */
  101516. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101517. /** @hidden */
  101518. _rebuild(): void;
  101519. /** @hidden */
  101520. _resyncLightSources(): void;
  101521. /** @hidden */
  101522. _resyncLightSource(light: Light): void;
  101523. /** @hidden */
  101524. _unBindEffect(): void;
  101525. /** @hidden */
  101526. _removeLightSource(light: Light, dispose: boolean): void;
  101527. private _markSubMeshesAsDirty;
  101528. /** @hidden */
  101529. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101530. /** @hidden */
  101531. _markSubMeshesAsAttributesDirty(): void;
  101532. /** @hidden */
  101533. _markSubMeshesAsMiscDirty(): void;
  101534. /**
  101535. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101536. */
  101537. get scaling(): Vector3;
  101538. set scaling(newScaling: Vector3);
  101539. /**
  101540. * Returns true if the mesh is blocked. Implemented by child classes
  101541. */
  101542. get isBlocked(): boolean;
  101543. /**
  101544. * Returns the mesh itself by default. Implemented by child classes
  101545. * @param camera defines the camera to use to pick the right LOD level
  101546. * @returns the currentAbstractMesh
  101547. */
  101548. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101549. /**
  101550. * Returns 0 by default. Implemented by child classes
  101551. * @returns an integer
  101552. */
  101553. getTotalVertices(): number;
  101554. /**
  101555. * Returns a positive integer : the total number of indices in this mesh geometry.
  101556. * @returns the numner of indices or zero if the mesh has no geometry.
  101557. */
  101558. getTotalIndices(): number;
  101559. /**
  101560. * Returns null by default. Implemented by child classes
  101561. * @returns null
  101562. */
  101563. getIndices(): Nullable<IndicesArray>;
  101564. /**
  101565. * Returns the array of the requested vertex data kind. Implemented by child classes
  101566. * @param kind defines the vertex data kind to use
  101567. * @returns null
  101568. */
  101569. getVerticesData(kind: string): Nullable<FloatArray>;
  101570. /**
  101571. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101572. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101573. * Note that a new underlying VertexBuffer object is created each call.
  101574. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101575. * @param kind defines vertex data kind:
  101576. * * VertexBuffer.PositionKind
  101577. * * VertexBuffer.UVKind
  101578. * * VertexBuffer.UV2Kind
  101579. * * VertexBuffer.UV3Kind
  101580. * * VertexBuffer.UV4Kind
  101581. * * VertexBuffer.UV5Kind
  101582. * * VertexBuffer.UV6Kind
  101583. * * VertexBuffer.ColorKind
  101584. * * VertexBuffer.MatricesIndicesKind
  101585. * * VertexBuffer.MatricesIndicesExtraKind
  101586. * * VertexBuffer.MatricesWeightsKind
  101587. * * VertexBuffer.MatricesWeightsExtraKind
  101588. * @param data defines the data source
  101589. * @param updatable defines if the data must be flagged as updatable (or static)
  101590. * @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
  101591. * @returns the current mesh
  101592. */
  101593. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101594. /**
  101595. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101596. * If the mesh has no geometry, it is simply returned as it is.
  101597. * @param kind defines vertex data kind:
  101598. * * VertexBuffer.PositionKind
  101599. * * VertexBuffer.UVKind
  101600. * * VertexBuffer.UV2Kind
  101601. * * VertexBuffer.UV3Kind
  101602. * * VertexBuffer.UV4Kind
  101603. * * VertexBuffer.UV5Kind
  101604. * * VertexBuffer.UV6Kind
  101605. * * VertexBuffer.ColorKind
  101606. * * VertexBuffer.MatricesIndicesKind
  101607. * * VertexBuffer.MatricesIndicesExtraKind
  101608. * * VertexBuffer.MatricesWeightsKind
  101609. * * VertexBuffer.MatricesWeightsExtraKind
  101610. * @param data defines the data source
  101611. * @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
  101612. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101613. * @returns the current mesh
  101614. */
  101615. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101616. /**
  101617. * Sets the mesh indices,
  101618. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101619. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101620. * @param totalVertices Defines the total number of vertices
  101621. * @returns the current mesh
  101622. */
  101623. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101624. /**
  101625. * Gets a boolean indicating if specific vertex data is present
  101626. * @param kind defines the vertex data kind to use
  101627. * @returns true is data kind is present
  101628. */
  101629. isVerticesDataPresent(kind: string): boolean;
  101630. /**
  101631. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101632. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101633. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101634. * @returns a BoundingInfo
  101635. */
  101636. getBoundingInfo(): BoundingInfo;
  101637. /**
  101638. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101639. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101640. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101641. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101642. * @returns the current mesh
  101643. */
  101644. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101645. /**
  101646. * Overwrite the current bounding info
  101647. * @param boundingInfo defines the new bounding info
  101648. * @returns the current mesh
  101649. */
  101650. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101651. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101652. get useBones(): boolean;
  101653. /** @hidden */
  101654. _preActivate(): void;
  101655. /** @hidden */
  101656. _preActivateForIntermediateRendering(renderId: number): void;
  101657. /** @hidden */
  101658. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101659. /** @hidden */
  101660. _postActivate(): void;
  101661. /** @hidden */
  101662. _freeze(): void;
  101663. /** @hidden */
  101664. _unFreeze(): void;
  101665. /**
  101666. * Gets the current world matrix
  101667. * @returns a Matrix
  101668. */
  101669. getWorldMatrix(): Matrix;
  101670. /** @hidden */
  101671. _getWorldMatrixDeterminant(): number;
  101672. /**
  101673. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101674. */
  101675. get isAnInstance(): boolean;
  101676. /**
  101677. * Gets a boolean indicating if this mesh has instances
  101678. */
  101679. get hasInstances(): boolean;
  101680. /**
  101681. * Perform relative position change from the point of view of behind the front of the mesh.
  101682. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101683. * Supports definition of mesh facing forward or backward
  101684. * @param amountRight defines the distance on the right axis
  101685. * @param amountUp defines the distance on the up axis
  101686. * @param amountForward defines the distance on the forward axis
  101687. * @returns the current mesh
  101688. */
  101689. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101690. /**
  101691. * Calculate relative position change from the point of view of behind the front of the mesh.
  101692. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101693. * Supports definition of mesh facing forward or backward
  101694. * @param amountRight defines the distance on the right axis
  101695. * @param amountUp defines the distance on the up axis
  101696. * @param amountForward defines the distance on the forward axis
  101697. * @returns the new displacement vector
  101698. */
  101699. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101700. /**
  101701. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101702. * Supports definition of mesh facing forward or backward
  101703. * @param flipBack defines the flip
  101704. * @param twirlClockwise defines the twirl
  101705. * @param tiltRight defines the tilt
  101706. * @returns the current mesh
  101707. */
  101708. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101709. /**
  101710. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101711. * Supports definition of mesh facing forward or backward.
  101712. * @param flipBack defines the flip
  101713. * @param twirlClockwise defines the twirl
  101714. * @param tiltRight defines the tilt
  101715. * @returns the new rotation vector
  101716. */
  101717. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101718. /**
  101719. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101720. * This means the mesh underlying bounding box and sphere are recomputed.
  101721. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101722. * @returns the current mesh
  101723. */
  101724. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101725. /** @hidden */
  101726. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101727. /** @hidden */
  101728. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101729. /** @hidden */
  101730. _updateBoundingInfo(): AbstractMesh;
  101731. /** @hidden */
  101732. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101733. /** @hidden */
  101734. protected _afterComputeWorldMatrix(): void;
  101735. /** @hidden */
  101736. get _effectiveMesh(): AbstractMesh;
  101737. /**
  101738. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101739. * A mesh is in the frustum if its bounding box intersects the frustum
  101740. * @param frustumPlanes defines the frustum to test
  101741. * @returns true if the mesh is in the frustum planes
  101742. */
  101743. isInFrustum(frustumPlanes: Plane[]): boolean;
  101744. /**
  101745. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101746. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101747. * @param frustumPlanes defines the frustum to test
  101748. * @returns true if the mesh is completely in the frustum planes
  101749. */
  101750. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101751. /**
  101752. * True if the mesh intersects another mesh or a SolidParticle object
  101753. * @param mesh defines a target mesh or SolidParticle to test
  101754. * @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)
  101755. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101756. * @returns true if there is an intersection
  101757. */
  101758. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101759. /**
  101760. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101761. * @param point defines the point to test
  101762. * @returns true if there is an intersection
  101763. */
  101764. intersectsPoint(point: Vector3): boolean;
  101765. /**
  101766. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101767. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101768. */
  101769. get checkCollisions(): boolean;
  101770. set checkCollisions(collisionEnabled: boolean);
  101771. /**
  101772. * Gets Collider object used to compute collisions (not physics)
  101773. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101774. */
  101775. get collider(): Nullable<Collider>;
  101776. /**
  101777. * Move the mesh using collision engine
  101778. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101779. * @param displacement defines the requested displacement vector
  101780. * @returns the current mesh
  101781. */
  101782. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101783. private _onCollisionPositionChange;
  101784. /** @hidden */
  101785. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101786. /** @hidden */
  101787. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101788. /** @hidden */
  101789. _checkCollision(collider: Collider): AbstractMesh;
  101790. /** @hidden */
  101791. _generatePointsArray(): boolean;
  101792. /**
  101793. * Checks if the passed Ray intersects with the mesh
  101794. * @param ray defines the ray to use
  101795. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101796. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101797. * @returns the picking info
  101798. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101799. */
  101800. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101801. /**
  101802. * Clones the current mesh
  101803. * @param name defines the mesh name
  101804. * @param newParent defines the new mesh parent
  101805. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101806. * @returns the new mesh
  101807. */
  101808. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101809. /**
  101810. * Disposes all the submeshes of the current meshnp
  101811. * @returns the current mesh
  101812. */
  101813. releaseSubMeshes(): AbstractMesh;
  101814. /**
  101815. * Releases resources associated with this abstract mesh.
  101816. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101817. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101818. */
  101819. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101820. /**
  101821. * Adds the passed mesh as a child to the current mesh
  101822. * @param mesh defines the child mesh
  101823. * @returns the current mesh
  101824. */
  101825. addChild(mesh: AbstractMesh): AbstractMesh;
  101826. /**
  101827. * Removes the passed mesh from the current mesh children list
  101828. * @param mesh defines the child mesh
  101829. * @returns the current mesh
  101830. */
  101831. removeChild(mesh: AbstractMesh): AbstractMesh;
  101832. /** @hidden */
  101833. private _initFacetData;
  101834. /**
  101835. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101836. * This method can be called within the render loop.
  101837. * 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
  101838. * @returns the current mesh
  101839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101840. */
  101841. updateFacetData(): AbstractMesh;
  101842. /**
  101843. * Returns the facetLocalNormals array.
  101844. * The normals are expressed in the mesh local spac
  101845. * @returns an array of Vector3
  101846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101847. */
  101848. getFacetLocalNormals(): Vector3[];
  101849. /**
  101850. * Returns the facetLocalPositions array.
  101851. * The facet positions are expressed in the mesh local space
  101852. * @returns an array of Vector3
  101853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101854. */
  101855. getFacetLocalPositions(): Vector3[];
  101856. /**
  101857. * Returns the facetLocalPartioning array
  101858. * @returns an array of array of numbers
  101859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101860. */
  101861. getFacetLocalPartitioning(): number[][];
  101862. /**
  101863. * Returns the i-th facet position in the world system.
  101864. * This method allocates a new Vector3 per call
  101865. * @param i defines the facet index
  101866. * @returns a new Vector3
  101867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101868. */
  101869. getFacetPosition(i: number): Vector3;
  101870. /**
  101871. * Sets the reference Vector3 with the i-th facet position in the world system
  101872. * @param i defines the facet index
  101873. * @param ref defines the target vector
  101874. * @returns the current mesh
  101875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101876. */
  101877. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101878. /**
  101879. * Returns the i-th facet normal in the world system.
  101880. * This method allocates a new Vector3 per call
  101881. * @param i defines the facet index
  101882. * @returns a new Vector3
  101883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101884. */
  101885. getFacetNormal(i: number): Vector3;
  101886. /**
  101887. * Sets the reference Vector3 with the i-th facet normal in the world system
  101888. * @param i defines the facet index
  101889. * @param ref defines the target vector
  101890. * @returns the current mesh
  101891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101892. */
  101893. getFacetNormalToRef(i: number, ref: Vector3): this;
  101894. /**
  101895. * 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)
  101896. * @param x defines x coordinate
  101897. * @param y defines y coordinate
  101898. * @param z defines z coordinate
  101899. * @returns the array of facet indexes
  101900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101901. */
  101902. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101903. /**
  101904. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101905. * @param projected sets as the (x,y,z) world projection on the facet
  101906. * @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
  101907. * @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
  101908. * @param x defines x coordinate
  101909. * @param y defines y coordinate
  101910. * @param z defines z coordinate
  101911. * @returns the face index if found (or null instead)
  101912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101913. */
  101914. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101915. /**
  101916. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101917. * @param projected sets as the (x,y,z) local projection on the facet
  101918. * @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
  101919. * @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
  101920. * @param x defines x coordinate
  101921. * @param y defines y coordinate
  101922. * @param z defines z coordinate
  101923. * @returns the face index if found (or null instead)
  101924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101925. */
  101926. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101927. /**
  101928. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101929. * @returns the parameters
  101930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101931. */
  101932. getFacetDataParameters(): any;
  101933. /**
  101934. * Disables the feature FacetData and frees the related memory
  101935. * @returns the current mesh
  101936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101937. */
  101938. disableFacetData(): AbstractMesh;
  101939. /**
  101940. * Updates the AbstractMesh indices array
  101941. * @param indices defines the data source
  101942. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101943. * @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)
  101944. * @returns the current mesh
  101945. */
  101946. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101947. /**
  101948. * Creates new normals data for the mesh
  101949. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101950. * @returns the current mesh
  101951. */
  101952. createNormals(updatable: boolean): AbstractMesh;
  101953. /**
  101954. * Align the mesh with a normal
  101955. * @param normal defines the normal to use
  101956. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101957. * @returns the current mesh
  101958. */
  101959. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101960. /** @hidden */
  101961. _checkOcclusionQuery(): boolean;
  101962. /**
  101963. * Disables the mesh edge rendering mode
  101964. * @returns the currentAbstractMesh
  101965. */
  101966. disableEdgesRendering(): AbstractMesh;
  101967. /**
  101968. * Enables the edge rendering mode on the mesh.
  101969. * This mode makes the mesh edges visible
  101970. * @param epsilon defines the maximal distance between two angles to detect a face
  101971. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101972. * @returns the currentAbstractMesh
  101973. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101974. */
  101975. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101976. }
  101977. }
  101978. declare module BABYLON {
  101979. /**
  101980. * Interface used to define ActionEvent
  101981. */
  101982. export interface IActionEvent {
  101983. /** The mesh or sprite that triggered the action */
  101984. source: any;
  101985. /** The X mouse cursor position at the time of the event */
  101986. pointerX: number;
  101987. /** The Y mouse cursor position at the time of the event */
  101988. pointerY: number;
  101989. /** The mesh that is currently pointed at (can be null) */
  101990. meshUnderPointer: Nullable<AbstractMesh>;
  101991. /** the original (browser) event that triggered the ActionEvent */
  101992. sourceEvent?: any;
  101993. /** additional data for the event */
  101994. additionalData?: any;
  101995. }
  101996. /**
  101997. * ActionEvent is the event being sent when an action is triggered.
  101998. */
  101999. export class ActionEvent implements IActionEvent {
  102000. /** The mesh or sprite that triggered the action */
  102001. source: any;
  102002. /** The X mouse cursor position at the time of the event */
  102003. pointerX: number;
  102004. /** The Y mouse cursor position at the time of the event */
  102005. pointerY: number;
  102006. /** The mesh that is currently pointed at (can be null) */
  102007. meshUnderPointer: Nullable<AbstractMesh>;
  102008. /** the original (browser) event that triggered the ActionEvent */
  102009. sourceEvent?: any;
  102010. /** additional data for the event */
  102011. additionalData?: any;
  102012. /**
  102013. * Creates a new ActionEvent
  102014. * @param source The mesh or sprite that triggered the action
  102015. * @param pointerX The X mouse cursor position at the time of the event
  102016. * @param pointerY The Y mouse cursor position at the time of the event
  102017. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102018. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102019. * @param additionalData additional data for the event
  102020. */
  102021. constructor(
  102022. /** The mesh or sprite that triggered the action */
  102023. source: any,
  102024. /** The X mouse cursor position at the time of the event */
  102025. pointerX: number,
  102026. /** The Y mouse cursor position at the time of the event */
  102027. pointerY: number,
  102028. /** The mesh that is currently pointed at (can be null) */
  102029. meshUnderPointer: Nullable<AbstractMesh>,
  102030. /** the original (browser) event that triggered the ActionEvent */
  102031. sourceEvent?: any,
  102032. /** additional data for the event */
  102033. additionalData?: any);
  102034. /**
  102035. * Helper function to auto-create an ActionEvent from a source mesh.
  102036. * @param source The source mesh that triggered the event
  102037. * @param evt The original (browser) event
  102038. * @param additionalData additional data for the event
  102039. * @returns the new ActionEvent
  102040. */
  102041. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  102042. /**
  102043. * Helper function to auto-create an ActionEvent from a source sprite
  102044. * @param source The source sprite that triggered the event
  102045. * @param scene Scene associated with the sprite
  102046. * @param evt The original (browser) event
  102047. * @param additionalData additional data for the event
  102048. * @returns the new ActionEvent
  102049. */
  102050. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  102051. /**
  102052. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  102053. * @param scene the scene where the event occurred
  102054. * @param evt The original (browser) event
  102055. * @returns the new ActionEvent
  102056. */
  102057. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  102058. /**
  102059. * Helper function to auto-create an ActionEvent from a primitive
  102060. * @param prim defines the target primitive
  102061. * @param pointerPos defines the pointer position
  102062. * @param evt The original (browser) event
  102063. * @param additionalData additional data for the event
  102064. * @returns the new ActionEvent
  102065. */
  102066. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  102067. }
  102068. }
  102069. declare module BABYLON {
  102070. /**
  102071. * Abstract class used to decouple action Manager from scene and meshes.
  102072. * Do not instantiate.
  102073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102074. */
  102075. export abstract class AbstractActionManager implements IDisposable {
  102076. /** Gets the list of active triggers */
  102077. static Triggers: {
  102078. [key: string]: number;
  102079. };
  102080. /** Gets the cursor to use when hovering items */
  102081. hoverCursor: string;
  102082. /** Gets the list of actions */
  102083. actions: IAction[];
  102084. /**
  102085. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  102086. */
  102087. isRecursive: boolean;
  102088. /**
  102089. * Releases all associated resources
  102090. */
  102091. abstract dispose(): void;
  102092. /**
  102093. * Does this action manager has pointer triggers
  102094. */
  102095. abstract get hasPointerTriggers(): boolean;
  102096. /**
  102097. * Does this action manager has pick triggers
  102098. */
  102099. abstract get hasPickTriggers(): boolean;
  102100. /**
  102101. * Process a specific trigger
  102102. * @param trigger defines the trigger to process
  102103. * @param evt defines the event details to be processed
  102104. */
  102105. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102106. /**
  102107. * Does this action manager handles actions of any of the given triggers
  102108. * @param triggers defines the triggers to be tested
  102109. * @return a boolean indicating whether one (or more) of the triggers is handled
  102110. */
  102111. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102112. /**
  102113. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102114. * speed.
  102115. * @param triggerA defines the trigger to be tested
  102116. * @param triggerB defines the trigger to be tested
  102117. * @return a boolean indicating whether one (or more) of the triggers is handled
  102118. */
  102119. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102120. /**
  102121. * Does this action manager handles actions of a given trigger
  102122. * @param trigger defines the trigger to be tested
  102123. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102124. * @return whether the trigger is handled
  102125. */
  102126. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102127. /**
  102128. * Serialize this manager to a JSON object
  102129. * @param name defines the property name to store this manager
  102130. * @returns a JSON representation of this manager
  102131. */
  102132. abstract serialize(name: string): any;
  102133. /**
  102134. * Registers an action to this action manager
  102135. * @param action defines the action to be registered
  102136. * @return the action amended (prepared) after registration
  102137. */
  102138. abstract registerAction(action: IAction): Nullable<IAction>;
  102139. /**
  102140. * Unregisters an action to this action manager
  102141. * @param action defines the action to be unregistered
  102142. * @return a boolean indicating whether the action has been unregistered
  102143. */
  102144. abstract unregisterAction(action: IAction): Boolean;
  102145. /**
  102146. * Does exist one action manager with at least one trigger
  102147. **/
  102148. static get HasTriggers(): boolean;
  102149. /**
  102150. * Does exist one action manager with at least one pick trigger
  102151. **/
  102152. static get HasPickTriggers(): boolean;
  102153. /**
  102154. * Does exist one action manager that handles actions of a given trigger
  102155. * @param trigger defines the trigger to be tested
  102156. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102157. **/
  102158. static HasSpecificTrigger(trigger: number): boolean;
  102159. }
  102160. }
  102161. declare module BABYLON {
  102162. /**
  102163. * Defines how a node can be built from a string name.
  102164. */
  102165. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102166. /**
  102167. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102168. */
  102169. export class Node implements IBehaviorAware<Node> {
  102170. /** @hidden */
  102171. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102172. private static _NodeConstructors;
  102173. /**
  102174. * Add a new node constructor
  102175. * @param type defines the type name of the node to construct
  102176. * @param constructorFunc defines the constructor function
  102177. */
  102178. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102179. /**
  102180. * Returns a node constructor based on type name
  102181. * @param type defines the type name
  102182. * @param name defines the new node name
  102183. * @param scene defines the hosting scene
  102184. * @param options defines optional options to transmit to constructors
  102185. * @returns the new constructor or null
  102186. */
  102187. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102188. /**
  102189. * Gets or sets the name of the node
  102190. */
  102191. name: string;
  102192. /**
  102193. * Gets or sets the id of the node
  102194. */
  102195. id: string;
  102196. /**
  102197. * Gets or sets the unique id of the node
  102198. */
  102199. uniqueId: number;
  102200. /**
  102201. * Gets or sets a string used to store user defined state for the node
  102202. */
  102203. state: string;
  102204. /**
  102205. * Gets or sets an object used to store user defined information for the node
  102206. */
  102207. metadata: any;
  102208. /**
  102209. * For internal use only. Please do not use.
  102210. */
  102211. reservedDataStore: any;
  102212. /**
  102213. * List of inspectable custom properties (used by the Inspector)
  102214. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102215. */
  102216. inspectableCustomProperties: IInspectable[];
  102217. private _doNotSerialize;
  102218. /**
  102219. * Gets or sets a boolean used to define if the node must be serialized
  102220. */
  102221. get doNotSerialize(): boolean;
  102222. set doNotSerialize(value: boolean);
  102223. /** @hidden */
  102224. _isDisposed: boolean;
  102225. /**
  102226. * Gets a list of Animations associated with the node
  102227. */
  102228. animations: Animation[];
  102229. protected _ranges: {
  102230. [name: string]: Nullable<AnimationRange>;
  102231. };
  102232. /**
  102233. * Callback raised when the node is ready to be used
  102234. */
  102235. onReady: Nullable<(node: Node) => void>;
  102236. private _isEnabled;
  102237. private _isParentEnabled;
  102238. private _isReady;
  102239. /** @hidden */
  102240. _currentRenderId: number;
  102241. private _parentUpdateId;
  102242. /** @hidden */
  102243. _childUpdateId: number;
  102244. /** @hidden */
  102245. _waitingParentId: Nullable<string>;
  102246. /** @hidden */
  102247. _scene: Scene;
  102248. /** @hidden */
  102249. _cache: any;
  102250. private _parentNode;
  102251. private _children;
  102252. /** @hidden */
  102253. _worldMatrix: Matrix;
  102254. /** @hidden */
  102255. _worldMatrixDeterminant: number;
  102256. /** @hidden */
  102257. _worldMatrixDeterminantIsDirty: boolean;
  102258. /** @hidden */
  102259. private _sceneRootNodesIndex;
  102260. /**
  102261. * Gets a boolean indicating if the node has been disposed
  102262. * @returns true if the node was disposed
  102263. */
  102264. isDisposed(): boolean;
  102265. /**
  102266. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102267. * @see https://doc.babylonjs.com/how_to/parenting
  102268. */
  102269. set parent(parent: Nullable<Node>);
  102270. get parent(): Nullable<Node>;
  102271. /** @hidden */
  102272. _addToSceneRootNodes(): void;
  102273. /** @hidden */
  102274. _removeFromSceneRootNodes(): void;
  102275. private _animationPropertiesOverride;
  102276. /**
  102277. * Gets or sets the animation properties override
  102278. */
  102279. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102280. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102281. /**
  102282. * Gets a string idenfifying the name of the class
  102283. * @returns "Node" string
  102284. */
  102285. getClassName(): string;
  102286. /** @hidden */
  102287. readonly _isNode: boolean;
  102288. /**
  102289. * An event triggered when the mesh is disposed
  102290. */
  102291. onDisposeObservable: Observable<Node>;
  102292. private _onDisposeObserver;
  102293. /**
  102294. * Sets a callback that will be raised when the node will be disposed
  102295. */
  102296. set onDispose(callback: () => void);
  102297. /**
  102298. * Creates a new Node
  102299. * @param name the name and id to be given to this node
  102300. * @param scene the scene this node will be added to
  102301. */
  102302. constructor(name: string, scene?: Nullable<Scene>);
  102303. /**
  102304. * Gets the scene of the node
  102305. * @returns a scene
  102306. */
  102307. getScene(): Scene;
  102308. /**
  102309. * Gets the engine of the node
  102310. * @returns a Engine
  102311. */
  102312. getEngine(): Engine;
  102313. private _behaviors;
  102314. /**
  102315. * Attach a behavior to the node
  102316. * @see http://doc.babylonjs.com/features/behaviour
  102317. * @param behavior defines the behavior to attach
  102318. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102319. * @returns the current Node
  102320. */
  102321. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102322. /**
  102323. * Remove an attached behavior
  102324. * @see http://doc.babylonjs.com/features/behaviour
  102325. * @param behavior defines the behavior to attach
  102326. * @returns the current Node
  102327. */
  102328. removeBehavior(behavior: Behavior<Node>): Node;
  102329. /**
  102330. * Gets the list of attached behaviors
  102331. * @see http://doc.babylonjs.com/features/behaviour
  102332. */
  102333. get behaviors(): Behavior<Node>[];
  102334. /**
  102335. * Gets an attached behavior by name
  102336. * @param name defines the name of the behavior to look for
  102337. * @see http://doc.babylonjs.com/features/behaviour
  102338. * @returns null if behavior was not found else the requested behavior
  102339. */
  102340. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102341. /**
  102342. * Returns the latest update of the World matrix
  102343. * @returns a Matrix
  102344. */
  102345. getWorldMatrix(): Matrix;
  102346. /** @hidden */
  102347. _getWorldMatrixDeterminant(): number;
  102348. /**
  102349. * Returns directly the latest state of the mesh World matrix.
  102350. * A Matrix is returned.
  102351. */
  102352. get worldMatrixFromCache(): Matrix;
  102353. /** @hidden */
  102354. _initCache(): void;
  102355. /** @hidden */
  102356. updateCache(force?: boolean): void;
  102357. /** @hidden */
  102358. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102359. /** @hidden */
  102360. _updateCache(ignoreParentClass?: boolean): void;
  102361. /** @hidden */
  102362. _isSynchronized(): boolean;
  102363. /** @hidden */
  102364. _markSyncedWithParent(): void;
  102365. /** @hidden */
  102366. isSynchronizedWithParent(): boolean;
  102367. /** @hidden */
  102368. isSynchronized(): boolean;
  102369. /**
  102370. * Is this node ready to be used/rendered
  102371. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102372. * @return true if the node is ready
  102373. */
  102374. isReady(completeCheck?: boolean): boolean;
  102375. /**
  102376. * Is this node enabled?
  102377. * 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
  102378. * @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
  102379. * @return whether this node (and its parent) is enabled
  102380. */
  102381. isEnabled(checkAncestors?: boolean): boolean;
  102382. /** @hidden */
  102383. protected _syncParentEnabledState(): void;
  102384. /**
  102385. * Set the enabled state of this node
  102386. * @param value defines the new enabled state
  102387. */
  102388. setEnabled(value: boolean): void;
  102389. /**
  102390. * Is this node a descendant of the given node?
  102391. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102392. * @param ancestor defines the parent node to inspect
  102393. * @returns a boolean indicating if this node is a descendant of the given node
  102394. */
  102395. isDescendantOf(ancestor: Node): boolean;
  102396. /** @hidden */
  102397. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102398. /**
  102399. * Will return all nodes that have this node as ascendant
  102400. * @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
  102401. * @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
  102402. * @return all children nodes of all types
  102403. */
  102404. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102405. /**
  102406. * Get all child-meshes of this node
  102407. * @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)
  102408. * @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
  102409. * @returns an array of AbstractMesh
  102410. */
  102411. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102412. /**
  102413. * Get all direct children of this node
  102414. * @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
  102415. * @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)
  102416. * @returns an array of Node
  102417. */
  102418. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102419. /** @hidden */
  102420. _setReady(state: boolean): void;
  102421. /**
  102422. * Get an animation by name
  102423. * @param name defines the name of the animation to look for
  102424. * @returns null if not found else the requested animation
  102425. */
  102426. getAnimationByName(name: string): Nullable<Animation>;
  102427. /**
  102428. * Creates an animation range for this node
  102429. * @param name defines the name of the range
  102430. * @param from defines the starting key
  102431. * @param to defines the end key
  102432. */
  102433. createAnimationRange(name: string, from: number, to: number): void;
  102434. /**
  102435. * Delete a specific animation range
  102436. * @param name defines the name of the range to delete
  102437. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102438. */
  102439. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102440. /**
  102441. * Get an animation range by name
  102442. * @param name defines the name of the animation range to look for
  102443. * @returns null if not found else the requested animation range
  102444. */
  102445. getAnimationRange(name: string): Nullable<AnimationRange>;
  102446. /**
  102447. * Gets the list of all animation ranges defined on this node
  102448. * @returns an array
  102449. */
  102450. getAnimationRanges(): Nullable<AnimationRange>[];
  102451. /**
  102452. * Will start the animation sequence
  102453. * @param name defines the range frames for animation sequence
  102454. * @param loop defines if the animation should loop (false by default)
  102455. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102456. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102457. * @returns the object created for this animation. If range does not exist, it will return null
  102458. */
  102459. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102460. /**
  102461. * Serialize animation ranges into a JSON compatible object
  102462. * @returns serialization object
  102463. */
  102464. serializeAnimationRanges(): any;
  102465. /**
  102466. * Computes the world matrix of the node
  102467. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102468. * @returns the world matrix
  102469. */
  102470. computeWorldMatrix(force?: boolean): Matrix;
  102471. /**
  102472. * Releases resources associated with this node.
  102473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102475. */
  102476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102477. /**
  102478. * Parse animation range data from a serialization object and store them into a given node
  102479. * @param node defines where to store the animation ranges
  102480. * @param parsedNode defines the serialization object to read data from
  102481. * @param scene defines the hosting scene
  102482. */
  102483. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102484. /**
  102485. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102486. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102487. * @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
  102488. * @returns the new bounding vectors
  102489. */
  102490. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102491. min: Vector3;
  102492. max: Vector3;
  102493. };
  102494. }
  102495. }
  102496. declare module BABYLON {
  102497. /**
  102498. * @hidden
  102499. */
  102500. export class _IAnimationState {
  102501. key: number;
  102502. repeatCount: number;
  102503. workValue?: any;
  102504. loopMode?: number;
  102505. offsetValue?: any;
  102506. highLimitValue?: any;
  102507. }
  102508. /**
  102509. * Class used to store any kind of animation
  102510. */
  102511. export class Animation {
  102512. /**Name of the animation */
  102513. name: string;
  102514. /**Property to animate */
  102515. targetProperty: string;
  102516. /**The frames per second of the animation */
  102517. framePerSecond: number;
  102518. /**The data type of the animation */
  102519. dataType: number;
  102520. /**The loop mode of the animation */
  102521. loopMode?: number | undefined;
  102522. /**Specifies if blending should be enabled */
  102523. enableBlending?: boolean | undefined;
  102524. /**
  102525. * Use matrix interpolation instead of using direct key value when animating matrices
  102526. */
  102527. static AllowMatricesInterpolation: boolean;
  102528. /**
  102529. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102530. */
  102531. static AllowMatrixDecomposeForInterpolation: boolean;
  102532. /**
  102533. * Stores the key frames of the animation
  102534. */
  102535. private _keys;
  102536. /**
  102537. * Stores the easing function of the animation
  102538. */
  102539. private _easingFunction;
  102540. /**
  102541. * @hidden Internal use only
  102542. */
  102543. _runtimeAnimations: RuntimeAnimation[];
  102544. /**
  102545. * The set of event that will be linked to this animation
  102546. */
  102547. private _events;
  102548. /**
  102549. * Stores an array of target property paths
  102550. */
  102551. targetPropertyPath: string[];
  102552. /**
  102553. * Stores the blending speed of the animation
  102554. */
  102555. blendingSpeed: number;
  102556. /**
  102557. * Stores the animation ranges for the animation
  102558. */
  102559. private _ranges;
  102560. /**
  102561. * @hidden Internal use
  102562. */
  102563. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102564. /**
  102565. * Sets up an animation
  102566. * @param property The property to animate
  102567. * @param animationType The animation type to apply
  102568. * @param framePerSecond The frames per second of the animation
  102569. * @param easingFunction The easing function used in the animation
  102570. * @returns The created animation
  102571. */
  102572. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102573. /**
  102574. * Create and start an animation on a node
  102575. * @param name defines the name of the global animation that will be run on all nodes
  102576. * @param node defines the root node where the animation will take place
  102577. * @param targetProperty defines property to animate
  102578. * @param framePerSecond defines the number of frame per second yo use
  102579. * @param totalFrame defines the number of frames in total
  102580. * @param from defines the initial value
  102581. * @param to defines the final value
  102582. * @param loopMode defines which loop mode you want to use (off by default)
  102583. * @param easingFunction defines the easing function to use (linear by default)
  102584. * @param onAnimationEnd defines the callback to call when animation end
  102585. * @returns the animatable created for this animation
  102586. */
  102587. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102588. /**
  102589. * Create and start an animation on a node and its descendants
  102590. * @param name defines the name of the global animation that will be run on all nodes
  102591. * @param node defines the root node where the animation will take place
  102592. * @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
  102593. * @param targetProperty defines property to animate
  102594. * @param framePerSecond defines the number of frame per second to use
  102595. * @param totalFrame defines the number of frames in total
  102596. * @param from defines the initial value
  102597. * @param to defines the final value
  102598. * @param loopMode defines which loop mode you want to use (off by default)
  102599. * @param easingFunction defines the easing function to use (linear by default)
  102600. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102601. * @returns the list of animatables created for all nodes
  102602. * @example https://www.babylonjs-playground.com/#MH0VLI
  102603. */
  102604. 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[]>;
  102605. /**
  102606. * Creates a new animation, merges it with the existing animations and starts it
  102607. * @param name Name of the animation
  102608. * @param node Node which contains the scene that begins the animations
  102609. * @param targetProperty Specifies which property to animate
  102610. * @param framePerSecond The frames per second of the animation
  102611. * @param totalFrame The total number of frames
  102612. * @param from The frame at the beginning of the animation
  102613. * @param to The frame at the end of the animation
  102614. * @param loopMode Specifies the loop mode of the animation
  102615. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102616. * @param onAnimationEnd Callback to run once the animation is complete
  102617. * @returns Nullable animation
  102618. */
  102619. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102620. /**
  102621. * Transition property of an host to the target Value
  102622. * @param property The property to transition
  102623. * @param targetValue The target Value of the property
  102624. * @param host The object where the property to animate belongs
  102625. * @param scene Scene used to run the animation
  102626. * @param frameRate Framerate (in frame/s) to use
  102627. * @param transition The transition type we want to use
  102628. * @param duration The duration of the animation, in milliseconds
  102629. * @param onAnimationEnd Callback trigger at the end of the animation
  102630. * @returns Nullable animation
  102631. */
  102632. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102633. /**
  102634. * Return the array of runtime animations currently using this animation
  102635. */
  102636. get runtimeAnimations(): RuntimeAnimation[];
  102637. /**
  102638. * Specifies if any of the runtime animations are currently running
  102639. */
  102640. get hasRunningRuntimeAnimations(): boolean;
  102641. /**
  102642. * Initializes the animation
  102643. * @param name Name of the animation
  102644. * @param targetProperty Property to animate
  102645. * @param framePerSecond The frames per second of the animation
  102646. * @param dataType The data type of the animation
  102647. * @param loopMode The loop mode of the animation
  102648. * @param enableBlending Specifies if blending should be enabled
  102649. */
  102650. constructor(
  102651. /**Name of the animation */
  102652. name: string,
  102653. /**Property to animate */
  102654. targetProperty: string,
  102655. /**The frames per second of the animation */
  102656. framePerSecond: number,
  102657. /**The data type of the animation */
  102658. dataType: number,
  102659. /**The loop mode of the animation */
  102660. loopMode?: number | undefined,
  102661. /**Specifies if blending should be enabled */
  102662. enableBlending?: boolean | undefined);
  102663. /**
  102664. * Converts the animation to a string
  102665. * @param fullDetails support for multiple levels of logging within scene loading
  102666. * @returns String form of the animation
  102667. */
  102668. toString(fullDetails?: boolean): string;
  102669. /**
  102670. * Add an event to this animation
  102671. * @param event Event to add
  102672. */
  102673. addEvent(event: AnimationEvent): void;
  102674. /**
  102675. * Remove all events found at the given frame
  102676. * @param frame The frame to remove events from
  102677. */
  102678. removeEvents(frame: number): void;
  102679. /**
  102680. * Retrieves all the events from the animation
  102681. * @returns Events from the animation
  102682. */
  102683. getEvents(): AnimationEvent[];
  102684. /**
  102685. * Creates an animation range
  102686. * @param name Name of the animation range
  102687. * @param from Starting frame of the animation range
  102688. * @param to Ending frame of the animation
  102689. */
  102690. createRange(name: string, from: number, to: number): void;
  102691. /**
  102692. * Deletes an animation range by name
  102693. * @param name Name of the animation range to delete
  102694. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102695. */
  102696. deleteRange(name: string, deleteFrames?: boolean): void;
  102697. /**
  102698. * Gets the animation range by name, or null if not defined
  102699. * @param name Name of the animation range
  102700. * @returns Nullable animation range
  102701. */
  102702. getRange(name: string): Nullable<AnimationRange>;
  102703. /**
  102704. * Gets the key frames from the animation
  102705. * @returns The key frames of the animation
  102706. */
  102707. getKeys(): Array<IAnimationKey>;
  102708. /**
  102709. * Gets the highest frame rate of the animation
  102710. * @returns Highest frame rate of the animation
  102711. */
  102712. getHighestFrame(): number;
  102713. /**
  102714. * Gets the easing function of the animation
  102715. * @returns Easing function of the animation
  102716. */
  102717. getEasingFunction(): IEasingFunction;
  102718. /**
  102719. * Sets the easing function of the animation
  102720. * @param easingFunction A custom mathematical formula for animation
  102721. */
  102722. setEasingFunction(easingFunction: EasingFunction): void;
  102723. /**
  102724. * Interpolates a scalar linearly
  102725. * @param startValue Start value of the animation curve
  102726. * @param endValue End value of the animation curve
  102727. * @param gradient Scalar amount to interpolate
  102728. * @returns Interpolated scalar value
  102729. */
  102730. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102731. /**
  102732. * Interpolates a scalar cubically
  102733. * @param startValue Start value of the animation curve
  102734. * @param outTangent End tangent of the animation
  102735. * @param endValue End value of the animation curve
  102736. * @param inTangent Start tangent of the animation curve
  102737. * @param gradient Scalar amount to interpolate
  102738. * @returns Interpolated scalar value
  102739. */
  102740. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102741. /**
  102742. * Interpolates a quaternion using a spherical linear interpolation
  102743. * @param startValue Start value of the animation curve
  102744. * @param endValue End value of the animation curve
  102745. * @param gradient Scalar amount to interpolate
  102746. * @returns Interpolated quaternion value
  102747. */
  102748. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102749. /**
  102750. * Interpolates a quaternion cubically
  102751. * @param startValue Start value of the animation curve
  102752. * @param outTangent End tangent of the animation curve
  102753. * @param endValue End value of the animation curve
  102754. * @param inTangent Start tangent of the animation curve
  102755. * @param gradient Scalar amount to interpolate
  102756. * @returns Interpolated quaternion value
  102757. */
  102758. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102759. /**
  102760. * Interpolates a Vector3 linearl
  102761. * @param startValue Start value of the animation curve
  102762. * @param endValue End value of the animation curve
  102763. * @param gradient Scalar amount to interpolate
  102764. * @returns Interpolated scalar value
  102765. */
  102766. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102767. /**
  102768. * Interpolates a Vector3 cubically
  102769. * @param startValue Start value of the animation curve
  102770. * @param outTangent End tangent of the animation
  102771. * @param endValue End value of the animation curve
  102772. * @param inTangent Start tangent of the animation curve
  102773. * @param gradient Scalar amount to interpolate
  102774. * @returns InterpolatedVector3 value
  102775. */
  102776. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102777. /**
  102778. * Interpolates a Vector2 linearly
  102779. * @param startValue Start value of the animation curve
  102780. * @param endValue End value of the animation curve
  102781. * @param gradient Scalar amount to interpolate
  102782. * @returns Interpolated Vector2 value
  102783. */
  102784. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102785. /**
  102786. * Interpolates a Vector2 cubically
  102787. * @param startValue Start value of the animation curve
  102788. * @param outTangent End tangent of the animation
  102789. * @param endValue End value of the animation curve
  102790. * @param inTangent Start tangent of the animation curve
  102791. * @param gradient Scalar amount to interpolate
  102792. * @returns Interpolated Vector2 value
  102793. */
  102794. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102795. /**
  102796. * Interpolates a size linearly
  102797. * @param startValue Start value of the animation curve
  102798. * @param endValue End value of the animation curve
  102799. * @param gradient Scalar amount to interpolate
  102800. * @returns Interpolated Size value
  102801. */
  102802. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102803. /**
  102804. * Interpolates a Color3 linearly
  102805. * @param startValue Start value of the animation curve
  102806. * @param endValue End value of the animation curve
  102807. * @param gradient Scalar amount to interpolate
  102808. * @returns Interpolated Color3 value
  102809. */
  102810. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102811. /**
  102812. * Interpolates a Color4 linearly
  102813. * @param startValue Start value of the animation curve
  102814. * @param endValue End value of the animation curve
  102815. * @param gradient Scalar amount to interpolate
  102816. * @returns Interpolated Color3 value
  102817. */
  102818. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102819. /**
  102820. * @hidden Internal use only
  102821. */
  102822. _getKeyValue(value: any): any;
  102823. /**
  102824. * @hidden Internal use only
  102825. */
  102826. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102827. /**
  102828. * Defines the function to use to interpolate matrices
  102829. * @param startValue defines the start matrix
  102830. * @param endValue defines the end matrix
  102831. * @param gradient defines the gradient between both matrices
  102832. * @param result defines an optional target matrix where to store the interpolation
  102833. * @returns the interpolated matrix
  102834. */
  102835. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102836. /**
  102837. * Makes a copy of the animation
  102838. * @returns Cloned animation
  102839. */
  102840. clone(): Animation;
  102841. /**
  102842. * Sets the key frames of the animation
  102843. * @param values The animation key frames to set
  102844. */
  102845. setKeys(values: Array<IAnimationKey>): void;
  102846. /**
  102847. * Serializes the animation to an object
  102848. * @returns Serialized object
  102849. */
  102850. serialize(): any;
  102851. /**
  102852. * Float animation type
  102853. */
  102854. static readonly ANIMATIONTYPE_FLOAT: number;
  102855. /**
  102856. * Vector3 animation type
  102857. */
  102858. static readonly ANIMATIONTYPE_VECTOR3: number;
  102859. /**
  102860. * Quaternion animation type
  102861. */
  102862. static readonly ANIMATIONTYPE_QUATERNION: number;
  102863. /**
  102864. * Matrix animation type
  102865. */
  102866. static readonly ANIMATIONTYPE_MATRIX: number;
  102867. /**
  102868. * Color3 animation type
  102869. */
  102870. static readonly ANIMATIONTYPE_COLOR3: number;
  102871. /**
  102872. * Color3 animation type
  102873. */
  102874. static readonly ANIMATIONTYPE_COLOR4: number;
  102875. /**
  102876. * Vector2 animation type
  102877. */
  102878. static readonly ANIMATIONTYPE_VECTOR2: number;
  102879. /**
  102880. * Size animation type
  102881. */
  102882. static readonly ANIMATIONTYPE_SIZE: number;
  102883. /**
  102884. * Relative Loop Mode
  102885. */
  102886. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102887. /**
  102888. * Cycle Loop Mode
  102889. */
  102890. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102891. /**
  102892. * Constant Loop Mode
  102893. */
  102894. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102895. /** @hidden */
  102896. static _UniversalLerp(left: any, right: any, amount: number): any;
  102897. /**
  102898. * Parses an animation object and creates an animation
  102899. * @param parsedAnimation Parsed animation object
  102900. * @returns Animation object
  102901. */
  102902. static Parse(parsedAnimation: any): Animation;
  102903. /**
  102904. * Appends the serialized animations from the source animations
  102905. * @param source Source containing the animations
  102906. * @param destination Target to store the animations
  102907. */
  102908. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102909. }
  102910. }
  102911. declare module BABYLON {
  102912. /**
  102913. * Interface containing an array of animations
  102914. */
  102915. export interface IAnimatable {
  102916. /**
  102917. * Array of animations
  102918. */
  102919. animations: Nullable<Array<Animation>>;
  102920. }
  102921. }
  102922. declare module BABYLON {
  102923. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102924. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102925. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102926. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102927. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102928. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102929. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102930. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102931. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102932. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102933. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102934. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102935. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102936. /**
  102937. * Decorator used to define property that can be serialized as reference to a camera
  102938. * @param sourceName defines the name of the property to decorate
  102939. */
  102940. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102941. /**
  102942. * Class used to help serialization objects
  102943. */
  102944. export class SerializationHelper {
  102945. /** @hidden */
  102946. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102947. /** @hidden */
  102948. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102949. /** @hidden */
  102950. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102951. /** @hidden */
  102952. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102953. /**
  102954. * Appends the serialized animations from the source animations
  102955. * @param source Source containing the animations
  102956. * @param destination Target to store the animations
  102957. */
  102958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102959. /**
  102960. * Static function used to serialized a specific entity
  102961. * @param entity defines the entity to serialize
  102962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102963. * @returns a JSON compatible object representing the serialization of the entity
  102964. */
  102965. static Serialize<T>(entity: T, serializationObject?: any): any;
  102966. /**
  102967. * Creates a new entity from a serialization data object
  102968. * @param creationFunction defines a function used to instanciated the new entity
  102969. * @param source defines the source serialization data
  102970. * @param scene defines the hosting scene
  102971. * @param rootUrl defines the root url for resources
  102972. * @returns a new entity
  102973. */
  102974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102975. /**
  102976. * Clones an object
  102977. * @param creationFunction defines the function used to instanciate the new object
  102978. * @param source defines the source object
  102979. * @returns the cloned object
  102980. */
  102981. static Clone<T>(creationFunction: () => T, source: T): T;
  102982. /**
  102983. * Instanciates a new object based on a source one (some data will be shared between both object)
  102984. * @param creationFunction defines the function used to instanciate the new object
  102985. * @param source defines the source object
  102986. * @returns the new object
  102987. */
  102988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102989. }
  102990. }
  102991. declare module BABYLON {
  102992. /**
  102993. * Class used to manipulate GUIDs
  102994. */
  102995. export class GUID {
  102996. /**
  102997. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102998. * Be aware Math.random() could cause collisions, but:
  102999. * "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"
  103000. * @returns a pseudo random id
  103001. */
  103002. static RandomId(): string;
  103003. }
  103004. }
  103005. declare module BABYLON {
  103006. /**
  103007. * Base class of all the textures in babylon.
  103008. * It groups all the common properties the materials, post process, lights... might need
  103009. * in order to make a correct use of the texture.
  103010. */
  103011. export class BaseTexture implements IAnimatable {
  103012. /**
  103013. * Default anisotropic filtering level for the application.
  103014. * It is set to 4 as a good tradeoff between perf and quality.
  103015. */
  103016. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  103017. /**
  103018. * Gets or sets the unique id of the texture
  103019. */
  103020. uniqueId: number;
  103021. /**
  103022. * Define the name of the texture.
  103023. */
  103024. name: string;
  103025. /**
  103026. * Gets or sets an object used to store user defined information.
  103027. */
  103028. metadata: any;
  103029. /**
  103030. * For internal use only. Please do not use.
  103031. */
  103032. reservedDataStore: any;
  103033. private _hasAlpha;
  103034. /**
  103035. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  103036. */
  103037. set hasAlpha(value: boolean);
  103038. get hasAlpha(): boolean;
  103039. /**
  103040. * Defines if the alpha value should be determined via the rgb values.
  103041. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  103042. */
  103043. getAlphaFromRGB: boolean;
  103044. /**
  103045. * Intensity or strength of the texture.
  103046. * It is commonly used by materials to fine tune the intensity of the texture
  103047. */
  103048. level: number;
  103049. /**
  103050. * Define the UV chanel to use starting from 0 and defaulting to 0.
  103051. * This is part of the texture as textures usually maps to one uv set.
  103052. */
  103053. coordinatesIndex: number;
  103054. private _coordinatesMode;
  103055. /**
  103056. * How a texture is mapped.
  103057. *
  103058. * | Value | Type | Description |
  103059. * | ----- | ----------------------------------- | ----------- |
  103060. * | 0 | EXPLICIT_MODE | |
  103061. * | 1 | SPHERICAL_MODE | |
  103062. * | 2 | PLANAR_MODE | |
  103063. * | 3 | CUBIC_MODE | |
  103064. * | 4 | PROJECTION_MODE | |
  103065. * | 5 | SKYBOX_MODE | |
  103066. * | 6 | INVCUBIC_MODE | |
  103067. * | 7 | EQUIRECTANGULAR_MODE | |
  103068. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  103069. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  103070. */
  103071. set coordinatesMode(value: number);
  103072. get coordinatesMode(): number;
  103073. /**
  103074. * | Value | Type | Description |
  103075. * | ----- | ------------------ | ----------- |
  103076. * | 0 | CLAMP_ADDRESSMODE | |
  103077. * | 1 | WRAP_ADDRESSMODE | |
  103078. * | 2 | MIRROR_ADDRESSMODE | |
  103079. */
  103080. wrapU: number;
  103081. /**
  103082. * | Value | Type | Description |
  103083. * | ----- | ------------------ | ----------- |
  103084. * | 0 | CLAMP_ADDRESSMODE | |
  103085. * | 1 | WRAP_ADDRESSMODE | |
  103086. * | 2 | MIRROR_ADDRESSMODE | |
  103087. */
  103088. wrapV: number;
  103089. /**
  103090. * | Value | Type | Description |
  103091. * | ----- | ------------------ | ----------- |
  103092. * | 0 | CLAMP_ADDRESSMODE | |
  103093. * | 1 | WRAP_ADDRESSMODE | |
  103094. * | 2 | MIRROR_ADDRESSMODE | |
  103095. */
  103096. wrapR: number;
  103097. /**
  103098. * With compliant hardware and browser (supporting anisotropic filtering)
  103099. * this defines the level of anisotropic filtering in the texture.
  103100. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103101. */
  103102. anisotropicFilteringLevel: number;
  103103. /**
  103104. * Define if the texture is a cube texture or if false a 2d texture.
  103105. */
  103106. get isCube(): boolean;
  103107. set isCube(value: boolean);
  103108. /**
  103109. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103110. */
  103111. get is3D(): boolean;
  103112. set is3D(value: boolean);
  103113. /**
  103114. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103115. */
  103116. get is2DArray(): boolean;
  103117. set is2DArray(value: boolean);
  103118. /**
  103119. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103120. * HDR texture are usually stored in linear space.
  103121. * This only impacts the PBR and Background materials
  103122. */
  103123. gammaSpace: boolean;
  103124. /**
  103125. * Gets or sets whether or not the texture contains RGBD data.
  103126. */
  103127. get isRGBD(): boolean;
  103128. set isRGBD(value: boolean);
  103129. /**
  103130. * Is Z inverted in the texture (useful in a cube texture).
  103131. */
  103132. invertZ: boolean;
  103133. /**
  103134. * Are mip maps generated for this texture or not.
  103135. */
  103136. get noMipmap(): boolean;
  103137. /**
  103138. * @hidden
  103139. */
  103140. lodLevelInAlpha: boolean;
  103141. /**
  103142. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103143. */
  103144. get lodGenerationOffset(): number;
  103145. set lodGenerationOffset(value: number);
  103146. /**
  103147. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103148. */
  103149. get lodGenerationScale(): number;
  103150. set lodGenerationScale(value: number);
  103151. /**
  103152. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103153. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103154. * average roughness values.
  103155. */
  103156. get linearSpecularLOD(): boolean;
  103157. set linearSpecularLOD(value: boolean);
  103158. /**
  103159. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103160. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103161. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103162. */
  103163. get irradianceTexture(): Nullable<BaseTexture>;
  103164. set irradianceTexture(value: Nullable<BaseTexture>);
  103165. /**
  103166. * Define if the texture is a render target.
  103167. */
  103168. isRenderTarget: boolean;
  103169. /**
  103170. * Define the unique id of the texture in the scene.
  103171. */
  103172. get uid(): string;
  103173. /**
  103174. * Return a string representation of the texture.
  103175. * @returns the texture as a string
  103176. */
  103177. toString(): string;
  103178. /**
  103179. * Get the class name of the texture.
  103180. * @returns "BaseTexture"
  103181. */
  103182. getClassName(): string;
  103183. /**
  103184. * Define the list of animation attached to the texture.
  103185. */
  103186. animations: Animation[];
  103187. /**
  103188. * An event triggered when the texture is disposed.
  103189. */
  103190. onDisposeObservable: Observable<BaseTexture>;
  103191. private _onDisposeObserver;
  103192. /**
  103193. * Callback triggered when the texture has been disposed.
  103194. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103195. */
  103196. set onDispose(callback: () => void);
  103197. /**
  103198. * Define the current state of the loading sequence when in delayed load mode.
  103199. */
  103200. delayLoadState: number;
  103201. private _scene;
  103202. /** @hidden */
  103203. _texture: Nullable<InternalTexture>;
  103204. private _uid;
  103205. /**
  103206. * Define if the texture is preventinga material to render or not.
  103207. * If not and the texture is not ready, the engine will use a default black texture instead.
  103208. */
  103209. get isBlocking(): boolean;
  103210. /**
  103211. * Instantiates a new BaseTexture.
  103212. * Base class of all the textures in babylon.
  103213. * It groups all the common properties the materials, post process, lights... might need
  103214. * in order to make a correct use of the texture.
  103215. * @param scene Define the scene the texture blongs to
  103216. */
  103217. constructor(scene: Nullable<Scene>);
  103218. /**
  103219. * Get the scene the texture belongs to.
  103220. * @returns the scene or null if undefined
  103221. */
  103222. getScene(): Nullable<Scene>;
  103223. /**
  103224. * Get the texture transform matrix used to offset tile the texture for istance.
  103225. * @returns the transformation matrix
  103226. */
  103227. getTextureMatrix(): Matrix;
  103228. /**
  103229. * Get the texture reflection matrix used to rotate/transform the reflection.
  103230. * @returns the reflection matrix
  103231. */
  103232. getReflectionTextureMatrix(): Matrix;
  103233. /**
  103234. * Get the underlying lower level texture from Babylon.
  103235. * @returns the insternal texture
  103236. */
  103237. getInternalTexture(): Nullable<InternalTexture>;
  103238. /**
  103239. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103240. * @returns true if ready or not blocking
  103241. */
  103242. isReadyOrNotBlocking(): boolean;
  103243. /**
  103244. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103245. * @returns true if fully ready
  103246. */
  103247. isReady(): boolean;
  103248. private _cachedSize;
  103249. /**
  103250. * Get the size of the texture.
  103251. * @returns the texture size.
  103252. */
  103253. getSize(): ISize;
  103254. /**
  103255. * Get the base size of the texture.
  103256. * It can be different from the size if the texture has been resized for POT for instance
  103257. * @returns the base size
  103258. */
  103259. getBaseSize(): ISize;
  103260. /**
  103261. * Update the sampling mode of the texture.
  103262. * Default is Trilinear mode.
  103263. *
  103264. * | Value | Type | Description |
  103265. * | ----- | ------------------ | ----------- |
  103266. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103267. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103268. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103269. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103270. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103271. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103272. * | 7 | NEAREST_LINEAR | |
  103273. * | 8 | NEAREST_NEAREST | |
  103274. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103275. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103276. * | 11 | LINEAR_LINEAR | |
  103277. * | 12 | LINEAR_NEAREST | |
  103278. *
  103279. * > _mag_: magnification filter (close to the viewer)
  103280. * > _min_: minification filter (far from the viewer)
  103281. * > _mip_: filter used between mip map levels
  103282. *@param samplingMode Define the new sampling mode of the texture
  103283. */
  103284. updateSamplingMode(samplingMode: number): void;
  103285. /**
  103286. * Scales the texture if is `canRescale()`
  103287. * @param ratio the resize factor we want to use to rescale
  103288. */
  103289. scale(ratio: number): void;
  103290. /**
  103291. * Get if the texture can rescale.
  103292. */
  103293. get canRescale(): boolean;
  103294. /** @hidden */
  103295. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103296. /** @hidden */
  103297. _rebuild(): void;
  103298. /**
  103299. * Triggers the load sequence in delayed load mode.
  103300. */
  103301. delayLoad(): void;
  103302. /**
  103303. * Clones the texture.
  103304. * @returns the cloned texture
  103305. */
  103306. clone(): Nullable<BaseTexture>;
  103307. /**
  103308. * Get the texture underlying type (INT, FLOAT...)
  103309. */
  103310. get textureType(): number;
  103311. /**
  103312. * Get the texture underlying format (RGB, RGBA...)
  103313. */
  103314. get textureFormat(): number;
  103315. /**
  103316. * Indicates that textures need to be re-calculated for all materials
  103317. */
  103318. protected _markAllSubMeshesAsTexturesDirty(): void;
  103319. /**
  103320. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103321. * This will returns an RGBA array buffer containing either in values (0-255) or
  103322. * float values (0-1) depending of the underlying buffer type.
  103323. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103324. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103325. * @param buffer defines a user defined buffer to fill with data (can be null)
  103326. * @returns The Array buffer containing the pixels data.
  103327. */
  103328. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103329. /**
  103330. * Release and destroy the underlying lower level texture aka internalTexture.
  103331. */
  103332. releaseInternalTexture(): void;
  103333. /** @hidden */
  103334. get _lodTextureHigh(): Nullable<BaseTexture>;
  103335. /** @hidden */
  103336. get _lodTextureMid(): Nullable<BaseTexture>;
  103337. /** @hidden */
  103338. get _lodTextureLow(): Nullable<BaseTexture>;
  103339. /**
  103340. * Dispose the texture and release its associated resources.
  103341. */
  103342. dispose(): void;
  103343. /**
  103344. * Serialize the texture into a JSON representation that can be parsed later on.
  103345. * @returns the JSON representation of the texture
  103346. */
  103347. serialize(): any;
  103348. /**
  103349. * Helper function to be called back once a list of texture contains only ready textures.
  103350. * @param textures Define the list of textures to wait for
  103351. * @param callback Define the callback triggered once the entire list will be ready
  103352. */
  103353. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103354. }
  103355. }
  103356. declare module BABYLON {
  103357. /**
  103358. * Options to be used when creating an effect.
  103359. */
  103360. export interface IEffectCreationOptions {
  103361. /**
  103362. * Atrributes that will be used in the shader.
  103363. */
  103364. attributes: string[];
  103365. /**
  103366. * Uniform varible names that will be set in the shader.
  103367. */
  103368. uniformsNames: string[];
  103369. /**
  103370. * Uniform buffer variable names that will be set in the shader.
  103371. */
  103372. uniformBuffersNames: string[];
  103373. /**
  103374. * Sampler texture variable names that will be set in the shader.
  103375. */
  103376. samplers: string[];
  103377. /**
  103378. * Define statements that will be set in the shader.
  103379. */
  103380. defines: any;
  103381. /**
  103382. * Possible fallbacks for this effect to improve performance when needed.
  103383. */
  103384. fallbacks: Nullable<IEffectFallbacks>;
  103385. /**
  103386. * Callback that will be called when the shader is compiled.
  103387. */
  103388. onCompiled: Nullable<(effect: Effect) => void>;
  103389. /**
  103390. * Callback that will be called if an error occurs during shader compilation.
  103391. */
  103392. onError: Nullable<(effect: Effect, errors: string) => void>;
  103393. /**
  103394. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103395. */
  103396. indexParameters?: any;
  103397. /**
  103398. * Max number of lights that can be used in the shader.
  103399. */
  103400. maxSimultaneousLights?: number;
  103401. /**
  103402. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103403. */
  103404. transformFeedbackVaryings?: Nullable<string[]>;
  103405. }
  103406. /**
  103407. * Effect containing vertex and fragment shader that can be executed on an object.
  103408. */
  103409. export class Effect implements IDisposable {
  103410. /**
  103411. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103412. */
  103413. static ShadersRepository: string;
  103414. /**
  103415. * Enable logging of the shader code when a compilation error occurs
  103416. */
  103417. static LogShaderCodeOnCompilationError: boolean;
  103418. /**
  103419. * Name of the effect.
  103420. */
  103421. name: any;
  103422. /**
  103423. * String container all the define statements that should be set on the shader.
  103424. */
  103425. defines: string;
  103426. /**
  103427. * Callback that will be called when the shader is compiled.
  103428. */
  103429. onCompiled: Nullable<(effect: Effect) => void>;
  103430. /**
  103431. * Callback that will be called if an error occurs during shader compilation.
  103432. */
  103433. onError: Nullable<(effect: Effect, errors: string) => void>;
  103434. /**
  103435. * Callback that will be called when effect is bound.
  103436. */
  103437. onBind: Nullable<(effect: Effect) => void>;
  103438. /**
  103439. * Unique ID of the effect.
  103440. */
  103441. uniqueId: number;
  103442. /**
  103443. * Observable that will be called when the shader is compiled.
  103444. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103445. */
  103446. onCompileObservable: Observable<Effect>;
  103447. /**
  103448. * Observable that will be called if an error occurs during shader compilation.
  103449. */
  103450. onErrorObservable: Observable<Effect>;
  103451. /** @hidden */
  103452. _onBindObservable: Nullable<Observable<Effect>>;
  103453. /**
  103454. * @hidden
  103455. * Specifies if the effect was previously ready
  103456. */
  103457. _wasPreviouslyReady: boolean;
  103458. /**
  103459. * Observable that will be called when effect is bound.
  103460. */
  103461. get onBindObservable(): Observable<Effect>;
  103462. /** @hidden */
  103463. _bonesComputationForcedToCPU: boolean;
  103464. private static _uniqueIdSeed;
  103465. private _engine;
  103466. private _uniformBuffersNames;
  103467. private _uniformsNames;
  103468. private _samplerList;
  103469. private _samplers;
  103470. private _isReady;
  103471. private _compilationError;
  103472. private _allFallbacksProcessed;
  103473. private _attributesNames;
  103474. private _attributes;
  103475. private _attributeLocationByName;
  103476. private _uniforms;
  103477. /**
  103478. * Key for the effect.
  103479. * @hidden
  103480. */
  103481. _key: string;
  103482. private _indexParameters;
  103483. private _fallbacks;
  103484. private _vertexSourceCode;
  103485. private _fragmentSourceCode;
  103486. private _vertexSourceCodeOverride;
  103487. private _fragmentSourceCodeOverride;
  103488. private _transformFeedbackVaryings;
  103489. /**
  103490. * Compiled shader to webGL program.
  103491. * @hidden
  103492. */
  103493. _pipelineContext: Nullable<IPipelineContext>;
  103494. private _valueCache;
  103495. private static _baseCache;
  103496. /**
  103497. * Instantiates an effect.
  103498. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103499. * @param baseName Name of the effect.
  103500. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103501. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103502. * @param samplers List of sampler variables that will be passed to the shader.
  103503. * @param engine Engine to be used to render the effect
  103504. * @param defines Define statements to be added to the shader.
  103505. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103506. * @param onCompiled Callback that will be called when the shader is compiled.
  103507. * @param onError Callback that will be called if an error occurs during shader compilation.
  103508. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103509. */
  103510. 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);
  103511. private _useFinalCode;
  103512. /**
  103513. * Unique key for this effect
  103514. */
  103515. get key(): string;
  103516. /**
  103517. * If the effect has been compiled and prepared.
  103518. * @returns if the effect is compiled and prepared.
  103519. */
  103520. isReady(): boolean;
  103521. private _isReadyInternal;
  103522. /**
  103523. * The engine the effect was initialized with.
  103524. * @returns the engine.
  103525. */
  103526. getEngine(): Engine;
  103527. /**
  103528. * The pipeline context for this effect
  103529. * @returns the associated pipeline context
  103530. */
  103531. getPipelineContext(): Nullable<IPipelineContext>;
  103532. /**
  103533. * The set of names of attribute variables for the shader.
  103534. * @returns An array of attribute names.
  103535. */
  103536. getAttributesNames(): string[];
  103537. /**
  103538. * Returns the attribute at the given index.
  103539. * @param index The index of the attribute.
  103540. * @returns The location of the attribute.
  103541. */
  103542. getAttributeLocation(index: number): number;
  103543. /**
  103544. * Returns the attribute based on the name of the variable.
  103545. * @param name of the attribute to look up.
  103546. * @returns the attribute location.
  103547. */
  103548. getAttributeLocationByName(name: string): number;
  103549. /**
  103550. * The number of attributes.
  103551. * @returns the numnber of attributes.
  103552. */
  103553. getAttributesCount(): number;
  103554. /**
  103555. * Gets the index of a uniform variable.
  103556. * @param uniformName of the uniform to look up.
  103557. * @returns the index.
  103558. */
  103559. getUniformIndex(uniformName: string): number;
  103560. /**
  103561. * Returns the attribute based on the name of the variable.
  103562. * @param uniformName of the uniform to look up.
  103563. * @returns the location of the uniform.
  103564. */
  103565. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103566. /**
  103567. * Returns an array of sampler variable names
  103568. * @returns The array of sampler variable neames.
  103569. */
  103570. getSamplers(): string[];
  103571. /**
  103572. * The error from the last compilation.
  103573. * @returns the error string.
  103574. */
  103575. getCompilationError(): string;
  103576. /**
  103577. * Gets a boolean indicating that all fallbacks were used during compilation
  103578. * @returns true if all fallbacks were used
  103579. */
  103580. allFallbacksProcessed(): boolean;
  103581. /**
  103582. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103583. * @param func The callback to be used.
  103584. */
  103585. executeWhenCompiled(func: (effect: Effect) => void): void;
  103586. private _checkIsReady;
  103587. private _loadShader;
  103588. /**
  103589. * Recompiles the webGL program
  103590. * @param vertexSourceCode The source code for the vertex shader.
  103591. * @param fragmentSourceCode The source code for the fragment shader.
  103592. * @param onCompiled Callback called when completed.
  103593. * @param onError Callback called on error.
  103594. * @hidden
  103595. */
  103596. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103597. /**
  103598. * Prepares the effect
  103599. * @hidden
  103600. */
  103601. _prepareEffect(): void;
  103602. private _getShaderCodeAndErrorLine;
  103603. private _processCompilationErrors;
  103604. /**
  103605. * Checks if the effect is supported. (Must be called after compilation)
  103606. */
  103607. get isSupported(): boolean;
  103608. /**
  103609. * Binds a texture to the engine to be used as output of the shader.
  103610. * @param channel Name of the output variable.
  103611. * @param texture Texture to bind.
  103612. * @hidden
  103613. */
  103614. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103615. /**
  103616. * Sets a texture on the engine to be used in the shader.
  103617. * @param channel Name of the sampler variable.
  103618. * @param texture Texture to set.
  103619. */
  103620. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103621. /**
  103622. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103623. * @param channel Name of the sampler variable.
  103624. * @param texture Texture to set.
  103625. */
  103626. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103627. /**
  103628. * Sets an array of textures on the engine to be used in the shader.
  103629. * @param channel Name of the variable.
  103630. * @param textures Textures to set.
  103631. */
  103632. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103633. /**
  103634. * 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)
  103635. * @param channel Name of the sampler variable.
  103636. * @param postProcess Post process to get the input texture from.
  103637. */
  103638. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103639. /**
  103640. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103641. * 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)
  103642. * @param channel Name of the sampler variable.
  103643. * @param postProcess Post process to get the output texture from.
  103644. */
  103645. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103646. /** @hidden */
  103647. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103648. /** @hidden */
  103649. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103650. /** @hidden */
  103651. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103652. /** @hidden */
  103653. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103654. /**
  103655. * Binds a buffer to a uniform.
  103656. * @param buffer Buffer to bind.
  103657. * @param name Name of the uniform variable to bind to.
  103658. */
  103659. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103660. /**
  103661. * Binds block to a uniform.
  103662. * @param blockName Name of the block to bind.
  103663. * @param index Index to bind.
  103664. */
  103665. bindUniformBlock(blockName: string, index: number): void;
  103666. /**
  103667. * Sets an interger value on a uniform variable.
  103668. * @param uniformName Name of the variable.
  103669. * @param value Value to be set.
  103670. * @returns this effect.
  103671. */
  103672. setInt(uniformName: string, value: number): Effect;
  103673. /**
  103674. * Sets an int array on a uniform variable.
  103675. * @param uniformName Name of the variable.
  103676. * @param array array to be set.
  103677. * @returns this effect.
  103678. */
  103679. setIntArray(uniformName: string, array: Int32Array): Effect;
  103680. /**
  103681. * 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)
  103682. * @param uniformName Name of the variable.
  103683. * @param array array to be set.
  103684. * @returns this effect.
  103685. */
  103686. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103687. /**
  103688. * 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)
  103689. * @param uniformName Name of the variable.
  103690. * @param array array to be set.
  103691. * @returns this effect.
  103692. */
  103693. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103694. /**
  103695. * 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)
  103696. * @param uniformName Name of the variable.
  103697. * @param array array to be set.
  103698. * @returns this effect.
  103699. */
  103700. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103701. /**
  103702. * Sets an float array on a uniform variable.
  103703. * @param uniformName Name of the variable.
  103704. * @param array array to be set.
  103705. * @returns this effect.
  103706. */
  103707. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103708. /**
  103709. * 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)
  103710. * @param uniformName Name of the variable.
  103711. * @param array array to be set.
  103712. * @returns this effect.
  103713. */
  103714. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103715. /**
  103716. * 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)
  103717. * @param uniformName Name of the variable.
  103718. * @param array array to be set.
  103719. * @returns this effect.
  103720. */
  103721. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103722. /**
  103723. * 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)
  103724. * @param uniformName Name of the variable.
  103725. * @param array array to be set.
  103726. * @returns this effect.
  103727. */
  103728. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103729. /**
  103730. * Sets an array on a uniform variable.
  103731. * @param uniformName Name of the variable.
  103732. * @param array array to be set.
  103733. * @returns this effect.
  103734. */
  103735. setArray(uniformName: string, array: number[]): Effect;
  103736. /**
  103737. * 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)
  103738. * @param uniformName Name of the variable.
  103739. * @param array array to be set.
  103740. * @returns this effect.
  103741. */
  103742. setArray2(uniformName: string, array: number[]): Effect;
  103743. /**
  103744. * 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)
  103745. * @param uniformName Name of the variable.
  103746. * @param array array to be set.
  103747. * @returns this effect.
  103748. */
  103749. setArray3(uniformName: string, array: number[]): Effect;
  103750. /**
  103751. * 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)
  103752. * @param uniformName Name of the variable.
  103753. * @param array array to be set.
  103754. * @returns this effect.
  103755. */
  103756. setArray4(uniformName: string, array: number[]): Effect;
  103757. /**
  103758. * Sets matrices on a uniform variable.
  103759. * @param uniformName Name of the variable.
  103760. * @param matrices matrices to be set.
  103761. * @returns this effect.
  103762. */
  103763. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103764. /**
  103765. * Sets matrix on a uniform variable.
  103766. * @param uniformName Name of the variable.
  103767. * @param matrix matrix to be set.
  103768. * @returns this effect.
  103769. */
  103770. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103771. /**
  103772. * 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)
  103773. * @param uniformName Name of the variable.
  103774. * @param matrix matrix to be set.
  103775. * @returns this effect.
  103776. */
  103777. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103778. /**
  103779. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103780. * @param uniformName Name of the variable.
  103781. * @param matrix matrix to be set.
  103782. * @returns this effect.
  103783. */
  103784. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103785. /**
  103786. * Sets a float on a uniform variable.
  103787. * @param uniformName Name of the variable.
  103788. * @param value value to be set.
  103789. * @returns this effect.
  103790. */
  103791. setFloat(uniformName: string, value: number): Effect;
  103792. /**
  103793. * Sets a boolean on a uniform variable.
  103794. * @param uniformName Name of the variable.
  103795. * @param bool value to be set.
  103796. * @returns this effect.
  103797. */
  103798. setBool(uniformName: string, bool: boolean): Effect;
  103799. /**
  103800. * Sets a Vector2 on a uniform variable.
  103801. * @param uniformName Name of the variable.
  103802. * @param vector2 vector2 to be set.
  103803. * @returns this effect.
  103804. */
  103805. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103806. /**
  103807. * Sets a float2 on a uniform variable.
  103808. * @param uniformName Name of the variable.
  103809. * @param x First float in float2.
  103810. * @param y Second float in float2.
  103811. * @returns this effect.
  103812. */
  103813. setFloat2(uniformName: string, x: number, y: number): Effect;
  103814. /**
  103815. * Sets a Vector3 on a uniform variable.
  103816. * @param uniformName Name of the variable.
  103817. * @param vector3 Value to be set.
  103818. * @returns this effect.
  103819. */
  103820. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103821. /**
  103822. * Sets a float3 on a uniform variable.
  103823. * @param uniformName Name of the variable.
  103824. * @param x First float in float3.
  103825. * @param y Second float in float3.
  103826. * @param z Third float in float3.
  103827. * @returns this effect.
  103828. */
  103829. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103830. /**
  103831. * Sets a Vector4 on a uniform variable.
  103832. * @param uniformName Name of the variable.
  103833. * @param vector4 Value to be set.
  103834. * @returns this effect.
  103835. */
  103836. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103837. /**
  103838. * Sets a float4 on a uniform variable.
  103839. * @param uniformName Name of the variable.
  103840. * @param x First float in float4.
  103841. * @param y Second float in float4.
  103842. * @param z Third float in float4.
  103843. * @param w Fourth float in float4.
  103844. * @returns this effect.
  103845. */
  103846. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103847. /**
  103848. * Sets a Color3 on a uniform variable.
  103849. * @param uniformName Name of the variable.
  103850. * @param color3 Value to be set.
  103851. * @returns this effect.
  103852. */
  103853. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103854. /**
  103855. * Sets a Color4 on a uniform variable.
  103856. * @param uniformName Name of the variable.
  103857. * @param color3 Value to be set.
  103858. * @param alpha Alpha value to be set.
  103859. * @returns this effect.
  103860. */
  103861. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103862. /**
  103863. * Sets a Color4 on a uniform variable
  103864. * @param uniformName defines the name of the variable
  103865. * @param color4 defines the value to be set
  103866. * @returns this effect.
  103867. */
  103868. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103869. /** Release all associated resources */
  103870. dispose(): void;
  103871. /**
  103872. * This function will add a new shader to the shader store
  103873. * @param name the name of the shader
  103874. * @param pixelShader optional pixel shader content
  103875. * @param vertexShader optional vertex shader content
  103876. */
  103877. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103878. /**
  103879. * Store of each shader (The can be looked up using effect.key)
  103880. */
  103881. static ShadersStore: {
  103882. [key: string]: string;
  103883. };
  103884. /**
  103885. * Store of each included file for a shader (The can be looked up using effect.key)
  103886. */
  103887. static IncludesShadersStore: {
  103888. [key: string]: string;
  103889. };
  103890. /**
  103891. * Resets the cache of effects.
  103892. */
  103893. static ResetCache(): void;
  103894. }
  103895. }
  103896. declare module BABYLON {
  103897. /**
  103898. * Interface used to describe the capabilities of the engine relatively to the current browser
  103899. */
  103900. export interface EngineCapabilities {
  103901. /** Maximum textures units per fragment shader */
  103902. maxTexturesImageUnits: number;
  103903. /** Maximum texture units per vertex shader */
  103904. maxVertexTextureImageUnits: number;
  103905. /** Maximum textures units in the entire pipeline */
  103906. maxCombinedTexturesImageUnits: number;
  103907. /** Maximum texture size */
  103908. maxTextureSize: number;
  103909. /** Maximum texture samples */
  103910. maxSamples?: number;
  103911. /** Maximum cube texture size */
  103912. maxCubemapTextureSize: number;
  103913. /** Maximum render texture size */
  103914. maxRenderTextureSize: number;
  103915. /** Maximum number of vertex attributes */
  103916. maxVertexAttribs: number;
  103917. /** Maximum number of varyings */
  103918. maxVaryingVectors: number;
  103919. /** Maximum number of uniforms per vertex shader */
  103920. maxVertexUniformVectors: number;
  103921. /** Maximum number of uniforms per fragment shader */
  103922. maxFragmentUniformVectors: number;
  103923. /** Defines if standard derivates (dx/dy) are supported */
  103924. standardDerivatives: boolean;
  103925. /** Defines if s3tc texture compression is supported */
  103926. s3tc?: WEBGL_compressed_texture_s3tc;
  103927. /** Defines if pvrtc texture compression is supported */
  103928. pvrtc: any;
  103929. /** Defines if etc1 texture compression is supported */
  103930. etc1: any;
  103931. /** Defines if etc2 texture compression is supported */
  103932. etc2: any;
  103933. /** Defines if astc texture compression is supported */
  103934. astc: any;
  103935. /** Defines if float textures are supported */
  103936. textureFloat: boolean;
  103937. /** Defines if vertex array objects are supported */
  103938. vertexArrayObject: boolean;
  103939. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103940. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103941. /** Gets the maximum level of anisotropy supported */
  103942. maxAnisotropy: number;
  103943. /** Defines if instancing is supported */
  103944. instancedArrays: boolean;
  103945. /** Defines if 32 bits indices are supported */
  103946. uintIndices: boolean;
  103947. /** Defines if high precision shaders are supported */
  103948. highPrecisionShaderSupported: boolean;
  103949. /** Defines if depth reading in the fragment shader is supported */
  103950. fragmentDepthSupported: boolean;
  103951. /** Defines if float texture linear filtering is supported*/
  103952. textureFloatLinearFiltering: boolean;
  103953. /** Defines if rendering to float textures is supported */
  103954. textureFloatRender: boolean;
  103955. /** Defines if half float textures are supported*/
  103956. textureHalfFloat: boolean;
  103957. /** Defines if half float texture linear filtering is supported*/
  103958. textureHalfFloatLinearFiltering: boolean;
  103959. /** Defines if rendering to half float textures is supported */
  103960. textureHalfFloatRender: boolean;
  103961. /** Defines if textureLOD shader command is supported */
  103962. textureLOD: boolean;
  103963. /** Defines if draw buffers extension is supported */
  103964. drawBuffersExtension: boolean;
  103965. /** Defines if depth textures are supported */
  103966. depthTextureExtension: boolean;
  103967. /** Defines if float color buffer are supported */
  103968. colorBufferFloat: boolean;
  103969. /** Gets disjoint timer query extension (null if not supported) */
  103970. timerQuery?: EXT_disjoint_timer_query;
  103971. /** Defines if timestamp can be used with timer query */
  103972. canUseTimestampForTimerQuery: boolean;
  103973. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103974. multiview?: any;
  103975. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103976. oculusMultiview?: any;
  103977. /** Function used to let the system compiles shaders in background */
  103978. parallelShaderCompile?: {
  103979. COMPLETION_STATUS_KHR: number;
  103980. };
  103981. /** Max number of texture samples for MSAA */
  103982. maxMSAASamples: number;
  103983. /** Defines if the blend min max extension is supported */
  103984. blendMinMax: boolean;
  103985. }
  103986. }
  103987. declare module BABYLON {
  103988. /**
  103989. * @hidden
  103990. **/
  103991. export class DepthCullingState {
  103992. private _isDepthTestDirty;
  103993. private _isDepthMaskDirty;
  103994. private _isDepthFuncDirty;
  103995. private _isCullFaceDirty;
  103996. private _isCullDirty;
  103997. private _isZOffsetDirty;
  103998. private _isFrontFaceDirty;
  103999. private _depthTest;
  104000. private _depthMask;
  104001. private _depthFunc;
  104002. private _cull;
  104003. private _cullFace;
  104004. private _zOffset;
  104005. private _frontFace;
  104006. /**
  104007. * Initializes the state.
  104008. */
  104009. constructor();
  104010. get isDirty(): boolean;
  104011. get zOffset(): number;
  104012. set zOffset(value: number);
  104013. get cullFace(): Nullable<number>;
  104014. set cullFace(value: Nullable<number>);
  104015. get cull(): Nullable<boolean>;
  104016. set cull(value: Nullable<boolean>);
  104017. get depthFunc(): Nullable<number>;
  104018. set depthFunc(value: Nullable<number>);
  104019. get depthMask(): boolean;
  104020. set depthMask(value: boolean);
  104021. get depthTest(): boolean;
  104022. set depthTest(value: boolean);
  104023. get frontFace(): Nullable<number>;
  104024. set frontFace(value: Nullable<number>);
  104025. reset(): void;
  104026. apply(gl: WebGLRenderingContext): void;
  104027. }
  104028. }
  104029. declare module BABYLON {
  104030. /**
  104031. * @hidden
  104032. **/
  104033. export class StencilState {
  104034. /** 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 */
  104035. static readonly ALWAYS: number;
  104036. /** Passed to stencilOperation to specify that stencil value must be kept */
  104037. static readonly KEEP: number;
  104038. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104039. static readonly REPLACE: number;
  104040. private _isStencilTestDirty;
  104041. private _isStencilMaskDirty;
  104042. private _isStencilFuncDirty;
  104043. private _isStencilOpDirty;
  104044. private _stencilTest;
  104045. private _stencilMask;
  104046. private _stencilFunc;
  104047. private _stencilFuncRef;
  104048. private _stencilFuncMask;
  104049. private _stencilOpStencilFail;
  104050. private _stencilOpDepthFail;
  104051. private _stencilOpStencilDepthPass;
  104052. get isDirty(): boolean;
  104053. get stencilFunc(): number;
  104054. set stencilFunc(value: number);
  104055. get stencilFuncRef(): number;
  104056. set stencilFuncRef(value: number);
  104057. get stencilFuncMask(): number;
  104058. set stencilFuncMask(value: number);
  104059. get stencilOpStencilFail(): number;
  104060. set stencilOpStencilFail(value: number);
  104061. get stencilOpDepthFail(): number;
  104062. set stencilOpDepthFail(value: number);
  104063. get stencilOpStencilDepthPass(): number;
  104064. set stencilOpStencilDepthPass(value: number);
  104065. get stencilMask(): number;
  104066. set stencilMask(value: number);
  104067. get stencilTest(): boolean;
  104068. set stencilTest(value: boolean);
  104069. constructor();
  104070. reset(): void;
  104071. apply(gl: WebGLRenderingContext): void;
  104072. }
  104073. }
  104074. declare module BABYLON {
  104075. /**
  104076. * @hidden
  104077. **/
  104078. export class AlphaState {
  104079. private _isAlphaBlendDirty;
  104080. private _isBlendFunctionParametersDirty;
  104081. private _isBlendEquationParametersDirty;
  104082. private _isBlendConstantsDirty;
  104083. private _alphaBlend;
  104084. private _blendFunctionParameters;
  104085. private _blendEquationParameters;
  104086. private _blendConstants;
  104087. /**
  104088. * Initializes the state.
  104089. */
  104090. constructor();
  104091. get isDirty(): boolean;
  104092. get alphaBlend(): boolean;
  104093. set alphaBlend(value: boolean);
  104094. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  104095. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  104096. setAlphaEquationParameters(rgb: number, alpha: number): void;
  104097. reset(): void;
  104098. apply(gl: WebGLRenderingContext): void;
  104099. }
  104100. }
  104101. declare module BABYLON {
  104102. /** @hidden */
  104103. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104104. attributeProcessor(attribute: string): string;
  104105. varyingProcessor(varying: string, isFragment: boolean): string;
  104106. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104107. }
  104108. }
  104109. declare module BABYLON {
  104110. /**
  104111. * Interface for attribute information associated with buffer instanciation
  104112. */
  104113. export interface InstancingAttributeInfo {
  104114. /**
  104115. * Name of the GLSL attribute
  104116. * if attribute index is not specified, this is used to retrieve the index from the effect
  104117. */
  104118. attributeName: string;
  104119. /**
  104120. * Index/offset of the attribute in the vertex shader
  104121. * if not specified, this will be computes from the name.
  104122. */
  104123. index?: number;
  104124. /**
  104125. * size of the attribute, 1, 2, 3 or 4
  104126. */
  104127. attributeSize: number;
  104128. /**
  104129. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104130. */
  104131. offset: number;
  104132. /**
  104133. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104134. * default to 1
  104135. */
  104136. divisor?: number;
  104137. /**
  104138. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104139. * default is FLOAT
  104140. */
  104141. attributeType?: number;
  104142. /**
  104143. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104144. */
  104145. normalized?: boolean;
  104146. }
  104147. }
  104148. declare module BABYLON {
  104149. interface ThinEngine {
  104150. /**
  104151. * Update a video texture
  104152. * @param texture defines the texture to update
  104153. * @param video defines the video element to use
  104154. * @param invertY defines if data must be stored with Y axis inverted
  104155. */
  104156. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104157. }
  104158. }
  104159. declare module BABYLON {
  104160. /**
  104161. * Settings for finer control over video usage
  104162. */
  104163. export interface VideoTextureSettings {
  104164. /**
  104165. * Applies `autoplay` to video, if specified
  104166. */
  104167. autoPlay?: boolean;
  104168. /**
  104169. * Applies `loop` to video, if specified
  104170. */
  104171. loop?: boolean;
  104172. /**
  104173. * Automatically updates internal texture from video at every frame in the render loop
  104174. */
  104175. autoUpdateTexture: boolean;
  104176. /**
  104177. * Image src displayed during the video loading or until the user interacts with the video.
  104178. */
  104179. poster?: string;
  104180. }
  104181. /**
  104182. * If you want to display a video in your scene, this is the special texture for that.
  104183. * This special texture works similar to other textures, with the exception of a few parameters.
  104184. * @see https://doc.babylonjs.com/how_to/video_texture
  104185. */
  104186. export class VideoTexture extends Texture {
  104187. /**
  104188. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104189. */
  104190. readonly autoUpdateTexture: boolean;
  104191. /**
  104192. * The video instance used by the texture internally
  104193. */
  104194. readonly video: HTMLVideoElement;
  104195. private _onUserActionRequestedObservable;
  104196. /**
  104197. * Event triggerd when a dom action is required by the user to play the video.
  104198. * This happens due to recent changes in browser policies preventing video to auto start.
  104199. */
  104200. get onUserActionRequestedObservable(): Observable<Texture>;
  104201. private _generateMipMaps;
  104202. private _engine;
  104203. private _stillImageCaptured;
  104204. private _displayingPosterTexture;
  104205. private _settings;
  104206. private _createInternalTextureOnEvent;
  104207. private _frameId;
  104208. private _currentSrc;
  104209. /**
  104210. * Creates a video texture.
  104211. * If you want to display a video in your scene, this is the special texture for that.
  104212. * This special texture works similar to other textures, with the exception of a few parameters.
  104213. * @see https://doc.babylonjs.com/how_to/video_texture
  104214. * @param name optional name, will detect from video source, if not defined
  104215. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104216. * @param scene is obviously the current scene.
  104217. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104218. * @param invertY is false by default but can be used to invert video on Y axis
  104219. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104220. * @param settings allows finer control over video usage
  104221. */
  104222. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104223. private _getName;
  104224. private _getVideo;
  104225. private _createInternalTexture;
  104226. private reset;
  104227. /**
  104228. * @hidden Internal method to initiate `update`.
  104229. */
  104230. _rebuild(): void;
  104231. /**
  104232. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104233. */
  104234. update(): void;
  104235. /**
  104236. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104237. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104238. */
  104239. updateTexture(isVisible: boolean): void;
  104240. protected _updateInternalTexture: () => void;
  104241. /**
  104242. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104243. * @param url New url.
  104244. */
  104245. updateURL(url: string): void;
  104246. /**
  104247. * Clones the texture.
  104248. * @returns the cloned texture
  104249. */
  104250. clone(): VideoTexture;
  104251. /**
  104252. * Dispose the texture and release its associated resources.
  104253. */
  104254. dispose(): void;
  104255. /**
  104256. * Creates a video texture straight from a stream.
  104257. * @param scene Define the scene the texture should be created in
  104258. * @param stream Define the stream the texture should be created from
  104259. * @returns The created video texture as a promise
  104260. */
  104261. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104262. /**
  104263. * Creates a video texture straight from your WebCam video feed.
  104264. * @param scene Define the scene the texture should be created in
  104265. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104266. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104267. * @returns The created video texture as a promise
  104268. */
  104269. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104270. minWidth: number;
  104271. maxWidth: number;
  104272. minHeight: number;
  104273. maxHeight: number;
  104274. deviceId: string;
  104275. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104276. /**
  104277. * Creates a video texture straight from your WebCam video feed.
  104278. * @param scene Define the scene the texture should be created in
  104279. * @param onReady Define a callback to triggered once the texture will be ready
  104280. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104281. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104282. */
  104283. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104284. minWidth: number;
  104285. maxWidth: number;
  104286. minHeight: number;
  104287. maxHeight: number;
  104288. deviceId: string;
  104289. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104290. }
  104291. }
  104292. declare module BABYLON {
  104293. /**
  104294. * Defines the interface used by objects working like Scene
  104295. * @hidden
  104296. */
  104297. export interface ISceneLike {
  104298. _addPendingData(data: any): void;
  104299. _removePendingData(data: any): void;
  104300. offlineProvider: IOfflineProvider;
  104301. }
  104302. /** Interface defining initialization parameters for Engine class */
  104303. export interface EngineOptions extends WebGLContextAttributes {
  104304. /**
  104305. * Defines if the engine should no exceed a specified device ratio
  104306. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104307. */
  104308. limitDeviceRatio?: number;
  104309. /**
  104310. * Defines if webvr should be enabled automatically
  104311. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104312. */
  104313. autoEnableWebVR?: boolean;
  104314. /**
  104315. * Defines if webgl2 should be turned off even if supported
  104316. * @see http://doc.babylonjs.com/features/webgl2
  104317. */
  104318. disableWebGL2Support?: boolean;
  104319. /**
  104320. * Defines if webaudio should be initialized as well
  104321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104322. */
  104323. audioEngine?: boolean;
  104324. /**
  104325. * Defines if animations should run using a deterministic lock step
  104326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104327. */
  104328. deterministicLockstep?: boolean;
  104329. /** Defines the maximum steps to use with deterministic lock step mode */
  104330. lockstepMaxSteps?: number;
  104331. /** Defines the seconds between each deterministic lock step */
  104332. timeStep?: number;
  104333. /**
  104334. * Defines that engine should ignore context lost events
  104335. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104336. */
  104337. doNotHandleContextLost?: boolean;
  104338. /**
  104339. * Defines that engine should ignore modifying touch action attribute and style
  104340. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104341. */
  104342. doNotHandleTouchAction?: boolean;
  104343. /**
  104344. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104345. */
  104346. useHighPrecisionFloats?: boolean;
  104347. }
  104348. /**
  104349. * The base engine class (root of all engines)
  104350. */
  104351. export class ThinEngine {
  104352. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104353. static ExceptionList: ({
  104354. key: string;
  104355. capture: string;
  104356. captureConstraint: number;
  104357. targets: string[];
  104358. } | {
  104359. key: string;
  104360. capture: null;
  104361. captureConstraint: null;
  104362. targets: string[];
  104363. })[];
  104364. /** @hidden */
  104365. static _TextureLoaders: IInternalTextureLoader[];
  104366. /**
  104367. * Returns the current npm package of the sdk
  104368. */
  104369. static get NpmPackage(): string;
  104370. /**
  104371. * Returns the current version of the framework
  104372. */
  104373. static get Version(): string;
  104374. /**
  104375. * Returns a string describing the current engine
  104376. */
  104377. get description(): string;
  104378. /**
  104379. * Gets or sets the epsilon value used by collision engine
  104380. */
  104381. static CollisionsEpsilon: number;
  104382. /**
  104383. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104384. */
  104385. static get ShadersRepository(): string;
  104386. static set ShadersRepository(value: string);
  104387. /** @hidden */
  104388. _shaderProcessor: IShaderProcessor;
  104389. /**
  104390. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104391. */
  104392. forcePOTTextures: boolean;
  104393. /**
  104394. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104395. */
  104396. isFullscreen: boolean;
  104397. /**
  104398. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104399. */
  104400. cullBackFaces: boolean;
  104401. /**
  104402. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104403. */
  104404. renderEvenInBackground: boolean;
  104405. /**
  104406. * Gets or sets a boolean indicating that cache can be kept between frames
  104407. */
  104408. preventCacheWipeBetweenFrames: boolean;
  104409. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104410. validateShaderPrograms: boolean;
  104411. /**
  104412. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104413. * This can provide greater z depth for distant objects.
  104414. */
  104415. useReverseDepthBuffer: boolean;
  104416. /**
  104417. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104418. */
  104419. disableUniformBuffers: boolean;
  104420. /** @hidden */
  104421. _uniformBuffers: UniformBuffer[];
  104422. /**
  104423. * Gets a boolean indicating that the engine supports uniform buffers
  104424. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104425. */
  104426. get supportsUniformBuffers(): boolean;
  104427. /** @hidden */
  104428. _gl: WebGLRenderingContext;
  104429. /** @hidden */
  104430. _webGLVersion: number;
  104431. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104432. protected _windowIsBackground: boolean;
  104433. protected _creationOptions: EngineOptions;
  104434. protected _highPrecisionShadersAllowed: boolean;
  104435. /** @hidden */
  104436. get _shouldUseHighPrecisionShader(): boolean;
  104437. /**
  104438. * Gets a boolean indicating that only power of 2 textures are supported
  104439. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104440. */
  104441. get needPOTTextures(): boolean;
  104442. /** @hidden */
  104443. _badOS: boolean;
  104444. /** @hidden */
  104445. _badDesktopOS: boolean;
  104446. private _hardwareScalingLevel;
  104447. /** @hidden */
  104448. _caps: EngineCapabilities;
  104449. private _isStencilEnable;
  104450. private _glVersion;
  104451. private _glRenderer;
  104452. private _glVendor;
  104453. /** @hidden */
  104454. _videoTextureSupported: boolean;
  104455. protected _renderingQueueLaunched: boolean;
  104456. protected _activeRenderLoops: (() => void)[];
  104457. /**
  104458. * Observable signaled when a context lost event is raised
  104459. */
  104460. onContextLostObservable: Observable<ThinEngine>;
  104461. /**
  104462. * Observable signaled when a context restored event is raised
  104463. */
  104464. onContextRestoredObservable: Observable<ThinEngine>;
  104465. private _onContextLost;
  104466. private _onContextRestored;
  104467. protected _contextWasLost: boolean;
  104468. /** @hidden */
  104469. _doNotHandleContextLost: boolean;
  104470. /**
  104471. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104473. */
  104474. get doNotHandleContextLost(): boolean;
  104475. set doNotHandleContextLost(value: boolean);
  104476. /**
  104477. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104478. */
  104479. disableVertexArrayObjects: boolean;
  104480. /** @hidden */
  104481. protected _colorWrite: boolean;
  104482. /** @hidden */
  104483. protected _colorWriteChanged: boolean;
  104484. /** @hidden */
  104485. protected _depthCullingState: DepthCullingState;
  104486. /** @hidden */
  104487. protected _stencilState: StencilState;
  104488. /** @hidden */
  104489. _alphaState: AlphaState;
  104490. /** @hidden */
  104491. _alphaMode: number;
  104492. /** @hidden */
  104493. _alphaEquation: number;
  104494. /** @hidden */
  104495. _internalTexturesCache: InternalTexture[];
  104496. /** @hidden */
  104497. protected _activeChannel: number;
  104498. private _currentTextureChannel;
  104499. /** @hidden */
  104500. protected _boundTexturesCache: {
  104501. [key: string]: Nullable<InternalTexture>;
  104502. };
  104503. /** @hidden */
  104504. protected _currentEffect: Nullable<Effect>;
  104505. /** @hidden */
  104506. protected _currentProgram: Nullable<WebGLProgram>;
  104507. private _compiledEffects;
  104508. private _vertexAttribArraysEnabled;
  104509. /** @hidden */
  104510. protected _cachedViewport: Nullable<IViewportLike>;
  104511. private _cachedVertexArrayObject;
  104512. /** @hidden */
  104513. protected _cachedVertexBuffers: any;
  104514. /** @hidden */
  104515. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104516. /** @hidden */
  104517. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104518. /** @hidden */
  104519. _currentRenderTarget: Nullable<InternalTexture>;
  104520. private _uintIndicesCurrentlySet;
  104521. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104522. /** @hidden */
  104523. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104524. private _currentBufferPointers;
  104525. private _currentInstanceLocations;
  104526. private _currentInstanceBuffers;
  104527. private _textureUnits;
  104528. /** @hidden */
  104529. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104530. /** @hidden */
  104531. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104532. /** @hidden */
  104533. _boundRenderFunction: any;
  104534. private _vaoRecordInProgress;
  104535. private _mustWipeVertexAttributes;
  104536. private _emptyTexture;
  104537. private _emptyCubeTexture;
  104538. private _emptyTexture3D;
  104539. private _emptyTexture2DArray;
  104540. /** @hidden */
  104541. _frameHandler: number;
  104542. private _nextFreeTextureSlots;
  104543. private _maxSimultaneousTextures;
  104544. private _activeRequests;
  104545. protected _texturesSupported: string[];
  104546. /** @hidden */
  104547. _textureFormatInUse: Nullable<string>;
  104548. protected get _supportsHardwareTextureRescaling(): boolean;
  104549. private _framebufferDimensionsObject;
  104550. /**
  104551. * sets the object from which width and height will be taken from when getting render width and height
  104552. * Will fallback to the gl object
  104553. * @param dimensions the framebuffer width and height that will be used.
  104554. */
  104555. set framebufferDimensionsObject(dimensions: Nullable<{
  104556. framebufferWidth: number;
  104557. framebufferHeight: number;
  104558. }>);
  104559. /**
  104560. * Gets the list of texture formats supported
  104561. */
  104562. get texturesSupported(): Array<string>;
  104563. /**
  104564. * Gets the list of texture formats in use
  104565. */
  104566. get textureFormatInUse(): Nullable<string>;
  104567. /**
  104568. * Gets the current viewport
  104569. */
  104570. get currentViewport(): Nullable<IViewportLike>;
  104571. /**
  104572. * Gets the default empty texture
  104573. */
  104574. get emptyTexture(): InternalTexture;
  104575. /**
  104576. * Gets the default empty 3D texture
  104577. */
  104578. get emptyTexture3D(): InternalTexture;
  104579. /**
  104580. * Gets the default empty 2D array texture
  104581. */
  104582. get emptyTexture2DArray(): InternalTexture;
  104583. /**
  104584. * Gets the default empty cube texture
  104585. */
  104586. get emptyCubeTexture(): InternalTexture;
  104587. /**
  104588. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104589. */
  104590. readonly premultipliedAlpha: boolean;
  104591. /**
  104592. * Observable event triggered before each texture is initialized
  104593. */
  104594. onBeforeTextureInitObservable: Observable<Texture>;
  104595. /**
  104596. * Creates a new engine
  104597. * @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
  104598. * @param antialias defines enable antialiasing (default: false)
  104599. * @param options defines further options to be sent to the getContext() function
  104600. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104601. */
  104602. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104603. private _rebuildInternalTextures;
  104604. private _rebuildEffects;
  104605. /**
  104606. * Gets a boolean indicating if all created effects are ready
  104607. * @returns true if all effects are ready
  104608. */
  104609. areAllEffectsReady(): boolean;
  104610. protected _rebuildBuffers(): void;
  104611. private _initGLContext;
  104612. /**
  104613. * Gets version of the current webGL context
  104614. */
  104615. get webGLVersion(): number;
  104616. /**
  104617. * Gets a string idenfifying the name of the class
  104618. * @returns "Engine" string
  104619. */
  104620. getClassName(): string;
  104621. /**
  104622. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104623. */
  104624. get isStencilEnable(): boolean;
  104625. /** @hidden */
  104626. _prepareWorkingCanvas(): void;
  104627. /**
  104628. * Reset the texture cache to empty state
  104629. */
  104630. resetTextureCache(): void;
  104631. /**
  104632. * Gets an object containing information about the current webGL context
  104633. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104634. */
  104635. getGlInfo(): {
  104636. vendor: string;
  104637. renderer: string;
  104638. version: string;
  104639. };
  104640. /**
  104641. * Defines the hardware scaling level.
  104642. * By default the hardware scaling level is computed from the window device ratio.
  104643. * 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.
  104644. * @param level defines the level to use
  104645. */
  104646. setHardwareScalingLevel(level: number): void;
  104647. /**
  104648. * Gets the current hardware scaling level.
  104649. * By default the hardware scaling level is computed from the window device ratio.
  104650. * 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.
  104651. * @returns a number indicating the current hardware scaling level
  104652. */
  104653. getHardwareScalingLevel(): number;
  104654. /**
  104655. * Gets the list of loaded textures
  104656. * @returns an array containing all loaded textures
  104657. */
  104658. getLoadedTexturesCache(): InternalTexture[];
  104659. /**
  104660. * Gets the object containing all engine capabilities
  104661. * @returns the EngineCapabilities object
  104662. */
  104663. getCaps(): EngineCapabilities;
  104664. /**
  104665. * stop executing a render loop function and remove it from the execution array
  104666. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104667. */
  104668. stopRenderLoop(renderFunction?: () => void): void;
  104669. /** @hidden */
  104670. _renderLoop(): void;
  104671. /**
  104672. * Gets the HTML canvas attached with the current webGL context
  104673. * @returns a HTML canvas
  104674. */
  104675. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104676. /**
  104677. * Gets host window
  104678. * @returns the host window object
  104679. */
  104680. getHostWindow(): Nullable<Window>;
  104681. /**
  104682. * Gets the current render width
  104683. * @param useScreen defines if screen size must be used (or the current render target if any)
  104684. * @returns a number defining the current render width
  104685. */
  104686. getRenderWidth(useScreen?: boolean): number;
  104687. /**
  104688. * Gets the current render height
  104689. * @param useScreen defines if screen size must be used (or the current render target if any)
  104690. * @returns a number defining the current render height
  104691. */
  104692. getRenderHeight(useScreen?: boolean): number;
  104693. /**
  104694. * Can be used to override the current requestAnimationFrame requester.
  104695. * @hidden
  104696. */
  104697. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104698. /**
  104699. * Register and execute a render loop. The engine can have more than one render function
  104700. * @param renderFunction defines the function to continuously execute
  104701. */
  104702. runRenderLoop(renderFunction: () => void): void;
  104703. /**
  104704. * Clear the current render buffer or the current render target (if any is set up)
  104705. * @param color defines the color to use
  104706. * @param backBuffer defines if the back buffer must be cleared
  104707. * @param depth defines if the depth buffer must be cleared
  104708. * @param stencil defines if the stencil buffer must be cleared
  104709. */
  104710. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104711. private _viewportCached;
  104712. /** @hidden */
  104713. _viewport(x: number, y: number, width: number, height: number): void;
  104714. /**
  104715. * Set the WebGL's viewport
  104716. * @param viewport defines the viewport element to be used
  104717. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104718. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104719. */
  104720. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104721. /**
  104722. * Begin a new frame
  104723. */
  104724. beginFrame(): void;
  104725. /**
  104726. * Enf the current frame
  104727. */
  104728. endFrame(): void;
  104729. /**
  104730. * Resize the view according to the canvas' size
  104731. */
  104732. resize(): void;
  104733. /**
  104734. * Force a specific size of the canvas
  104735. * @param width defines the new canvas' width
  104736. * @param height defines the new canvas' height
  104737. */
  104738. setSize(width: number, height: number): void;
  104739. /**
  104740. * Binds the frame buffer to the specified texture.
  104741. * @param texture The texture to render to or null for the default canvas
  104742. * @param faceIndex The face of the texture to render to in case of cube texture
  104743. * @param requiredWidth The width of the target to render to
  104744. * @param requiredHeight The height of the target to render to
  104745. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104746. * @param lodLevel defines the lod level to bind to the frame buffer
  104747. * @param layer defines the 2d array index to bind to frame buffer to
  104748. */
  104749. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104750. /** @hidden */
  104751. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104752. /**
  104753. * Unbind the current render target texture from the webGL context
  104754. * @param texture defines the render target texture to unbind
  104755. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104756. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104757. */
  104758. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104759. /**
  104760. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104761. */
  104762. flushFramebuffer(): void;
  104763. /**
  104764. * Unbind the current render target and bind the default framebuffer
  104765. */
  104766. restoreDefaultFramebuffer(): void;
  104767. /** @hidden */
  104768. protected _resetVertexBufferBinding(): void;
  104769. /**
  104770. * Creates a vertex buffer
  104771. * @param data the data for the vertex buffer
  104772. * @returns the new WebGL static buffer
  104773. */
  104774. createVertexBuffer(data: DataArray): DataBuffer;
  104775. private _createVertexBuffer;
  104776. /**
  104777. * Creates a dynamic vertex buffer
  104778. * @param data the data for the dynamic vertex buffer
  104779. * @returns the new WebGL dynamic buffer
  104780. */
  104781. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104782. protected _resetIndexBufferBinding(): void;
  104783. /**
  104784. * Creates a new index buffer
  104785. * @param indices defines the content of the index buffer
  104786. * @param updatable defines if the index buffer must be updatable
  104787. * @returns a new webGL buffer
  104788. */
  104789. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104790. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104791. /**
  104792. * Bind a webGL buffer to the webGL context
  104793. * @param buffer defines the buffer to bind
  104794. */
  104795. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104796. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104797. private bindBuffer;
  104798. /**
  104799. * update the bound buffer with the given data
  104800. * @param data defines the data to update
  104801. */
  104802. updateArrayBuffer(data: Float32Array): void;
  104803. private _vertexAttribPointer;
  104804. /** @hidden */
  104805. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104806. private _bindVertexBuffersAttributes;
  104807. /**
  104808. * Records a vertex array object
  104809. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104810. * @param vertexBuffers defines the list of vertex buffers to store
  104811. * @param indexBuffer defines the index buffer to store
  104812. * @param effect defines the effect to store
  104813. * @returns the new vertex array object
  104814. */
  104815. recordVertexArrayObject(vertexBuffers: {
  104816. [key: string]: VertexBuffer;
  104817. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104818. /**
  104819. * Bind a specific vertex array object
  104820. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104821. * @param vertexArrayObject defines the vertex array object to bind
  104822. * @param indexBuffer defines the index buffer to bind
  104823. */
  104824. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104825. /**
  104826. * Bind webGl buffers directly to the webGL context
  104827. * @param vertexBuffer defines the vertex buffer to bind
  104828. * @param indexBuffer defines the index buffer to bind
  104829. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104830. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104831. * @param effect defines the effect associated with the vertex buffer
  104832. */
  104833. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104834. private _unbindVertexArrayObject;
  104835. /**
  104836. * Bind a list of vertex buffers to the webGL context
  104837. * @param vertexBuffers defines the list of vertex buffers to bind
  104838. * @param indexBuffer defines the index buffer to bind
  104839. * @param effect defines the effect associated with the vertex buffers
  104840. */
  104841. bindBuffers(vertexBuffers: {
  104842. [key: string]: Nullable<VertexBuffer>;
  104843. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104844. /**
  104845. * Unbind all instance attributes
  104846. */
  104847. unbindInstanceAttributes(): void;
  104848. /**
  104849. * Release and free the memory of a vertex array object
  104850. * @param vao defines the vertex array object to delete
  104851. */
  104852. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104853. /** @hidden */
  104854. _releaseBuffer(buffer: DataBuffer): boolean;
  104855. protected _deleteBuffer(buffer: DataBuffer): void;
  104856. /**
  104857. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104858. * @param instancesBuffer defines the webGL buffer to update and bind
  104859. * @param data defines the data to store in the buffer
  104860. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104861. */
  104862. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104863. /**
  104864. * Bind the content of a webGL buffer used with instantiation
  104865. * @param instancesBuffer defines the webGL buffer to bind
  104866. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104867. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104868. */
  104869. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104870. /**
  104871. * Disable the instance attribute corresponding to the name in parameter
  104872. * @param name defines the name of the attribute to disable
  104873. */
  104874. disableInstanceAttributeByName(name: string): void;
  104875. /**
  104876. * Disable the instance attribute corresponding to the location in parameter
  104877. * @param attributeLocation defines the attribute location of the attribute to disable
  104878. */
  104879. disableInstanceAttribute(attributeLocation: number): void;
  104880. /**
  104881. * Disable the attribute corresponding to the location in parameter
  104882. * @param attributeLocation defines the attribute location of the attribute to disable
  104883. */
  104884. disableAttributeByIndex(attributeLocation: number): void;
  104885. /**
  104886. * Send a draw order
  104887. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104888. * @param indexStart defines the starting index
  104889. * @param indexCount defines the number of index to draw
  104890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104891. */
  104892. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104893. /**
  104894. * Draw a list of points
  104895. * @param verticesStart defines the index of first vertex to draw
  104896. * @param verticesCount defines the count of vertices to draw
  104897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104898. */
  104899. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104900. /**
  104901. * Draw a list of unindexed primitives
  104902. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104903. * @param verticesStart defines the index of first vertex to draw
  104904. * @param verticesCount defines the count of vertices to draw
  104905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104906. */
  104907. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104908. /**
  104909. * Draw a list of indexed primitives
  104910. * @param fillMode defines the primitive to use
  104911. * @param indexStart defines the starting index
  104912. * @param indexCount defines the number of index to draw
  104913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104914. */
  104915. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104916. /**
  104917. * Draw a list of unindexed primitives
  104918. * @param fillMode defines the primitive to use
  104919. * @param verticesStart defines the index of first vertex to draw
  104920. * @param verticesCount defines the count of vertices to draw
  104921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104922. */
  104923. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104924. private _drawMode;
  104925. /** @hidden */
  104926. protected _reportDrawCall(): void;
  104927. /** @hidden */
  104928. _releaseEffect(effect: Effect): void;
  104929. /** @hidden */
  104930. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104931. /**
  104932. * Create a new effect (used to store vertex/fragment shaders)
  104933. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104934. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104935. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104936. * @param samplers defines an array of string used to represent textures
  104937. * @param defines defines the string containing the defines to use to compile the shaders
  104938. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104939. * @param onCompiled defines a function to call when the effect creation is successful
  104940. * @param onError defines a function to call when the effect creation has failed
  104941. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104942. * @returns the new Effect
  104943. */
  104944. 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;
  104945. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104946. private _compileShader;
  104947. private _compileRawShader;
  104948. /** @hidden */
  104949. _getShaderSource(shader: WebGLShader): Nullable<string>;
  104950. /**
  104951. * Directly creates a webGL program
  104952. * @param pipelineContext defines the pipeline context to attach to
  104953. * @param vertexCode defines the vertex shader code to use
  104954. * @param fragmentCode defines the fragment shader code to use
  104955. * @param context defines the webGL context to use (if not set, the current one will be used)
  104956. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104957. * @returns the new webGL program
  104958. */
  104959. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104960. /**
  104961. * Creates a webGL program
  104962. * @param pipelineContext defines the pipeline context to attach to
  104963. * @param vertexCode defines the vertex shader code to use
  104964. * @param fragmentCode defines the fragment shader code to use
  104965. * @param defines defines the string containing the defines to use to compile the shaders
  104966. * @param context defines the webGL context to use (if not set, the current one will be used)
  104967. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104968. * @returns the new webGL program
  104969. */
  104970. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104971. /**
  104972. * Creates a new pipeline context
  104973. * @returns the new pipeline
  104974. */
  104975. createPipelineContext(): IPipelineContext;
  104976. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104977. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104978. /** @hidden */
  104979. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104980. /** @hidden */
  104981. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104982. /** @hidden */
  104983. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104984. /**
  104985. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104986. * @param pipelineContext defines the pipeline context to use
  104987. * @param uniformsNames defines the list of uniform names
  104988. * @returns an array of webGL uniform locations
  104989. */
  104990. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104991. /**
  104992. * Gets the lsit of active attributes for a given webGL program
  104993. * @param pipelineContext defines the pipeline context to use
  104994. * @param attributesNames defines the list of attribute names to get
  104995. * @returns an array of indices indicating the offset of each attribute
  104996. */
  104997. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104998. /**
  104999. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105000. * @param effect defines the effect to activate
  105001. */
  105002. enableEffect(effect: Nullable<Effect>): void;
  105003. /**
  105004. * Set the value of an uniform to a number (int)
  105005. * @param uniform defines the webGL uniform location where to store the value
  105006. * @param value defines the int number to store
  105007. */
  105008. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105009. /**
  105010. * Set the value of an uniform to an array of int32
  105011. * @param uniform defines the webGL uniform location where to store the value
  105012. * @param array defines the array of int32 to store
  105013. */
  105014. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105015. /**
  105016. * Set the value of an uniform to an array of int32 (stored as vec2)
  105017. * @param uniform defines the webGL uniform location where to store the value
  105018. * @param array defines the array of int32 to store
  105019. */
  105020. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105021. /**
  105022. * Set the value of an uniform to an array of int32 (stored as vec3)
  105023. * @param uniform defines the webGL uniform location where to store the value
  105024. * @param array defines the array of int32 to store
  105025. */
  105026. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105027. /**
  105028. * Set the value of an uniform to an array of int32 (stored as vec4)
  105029. * @param uniform defines the webGL uniform location where to store the value
  105030. * @param array defines the array of int32 to store
  105031. */
  105032. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105033. /**
  105034. * Set the value of an uniform to an array of number
  105035. * @param uniform defines the webGL uniform location where to store the value
  105036. * @param array defines the array of number to store
  105037. */
  105038. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105039. /**
  105040. * Set the value of an uniform to an array of number (stored as vec2)
  105041. * @param uniform defines the webGL uniform location where to store the value
  105042. * @param array defines the array of number to store
  105043. */
  105044. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105045. /**
  105046. * Set the value of an uniform to an array of number (stored as vec3)
  105047. * @param uniform defines the webGL uniform location where to store the value
  105048. * @param array defines the array of number to store
  105049. */
  105050. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105051. /**
  105052. * Set the value of an uniform to an array of number (stored as vec4)
  105053. * @param uniform defines the webGL uniform location where to store the value
  105054. * @param array defines the array of number to store
  105055. */
  105056. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105057. /**
  105058. * Set the value of an uniform to an array of float32 (stored as matrices)
  105059. * @param uniform defines the webGL uniform location where to store the value
  105060. * @param matrices defines the array of float32 to store
  105061. */
  105062. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  105063. /**
  105064. * Set the value of an uniform to a matrix (3x3)
  105065. * @param uniform defines the webGL uniform location where to store the value
  105066. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  105067. */
  105068. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105069. /**
  105070. * Set the value of an uniform to a matrix (2x2)
  105071. * @param uniform defines the webGL uniform location where to store the value
  105072. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  105073. */
  105074. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105075. /**
  105076. * Set the value of an uniform to a number (float)
  105077. * @param uniform defines the webGL uniform location where to store the value
  105078. * @param value defines the float number to store
  105079. */
  105080. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105081. /**
  105082. * Set the value of an uniform to a vec2
  105083. * @param uniform defines the webGL uniform location where to store the value
  105084. * @param x defines the 1st component of the value
  105085. * @param y defines the 2nd component of the value
  105086. */
  105087. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  105088. /**
  105089. * Set the value of an uniform to a vec3
  105090. * @param uniform defines the webGL uniform location where to store the value
  105091. * @param x defines the 1st component of the value
  105092. * @param y defines the 2nd component of the value
  105093. * @param z defines the 3rd component of the value
  105094. */
  105095. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  105096. /**
  105097. * Set the value of an uniform to a vec4
  105098. * @param uniform defines the webGL uniform location where to store the value
  105099. * @param x defines the 1st component of the value
  105100. * @param y defines the 2nd component of the value
  105101. * @param z defines the 3rd component of the value
  105102. * @param w defines the 4th component of the value
  105103. */
  105104. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105105. /**
  105106. * Apply all cached states (depth, culling, stencil and alpha)
  105107. */
  105108. applyStates(): void;
  105109. /**
  105110. * Enable or disable color writing
  105111. * @param enable defines the state to set
  105112. */
  105113. setColorWrite(enable: boolean): void;
  105114. /**
  105115. * Gets a boolean indicating if color writing is enabled
  105116. * @returns the current color writing state
  105117. */
  105118. getColorWrite(): boolean;
  105119. /**
  105120. * Gets the depth culling state manager
  105121. */
  105122. get depthCullingState(): DepthCullingState;
  105123. /**
  105124. * Gets the alpha state manager
  105125. */
  105126. get alphaState(): AlphaState;
  105127. /**
  105128. * Gets the stencil state manager
  105129. */
  105130. get stencilState(): StencilState;
  105131. /**
  105132. * Clears the list of texture accessible through engine.
  105133. * This can help preventing texture load conflict due to name collision.
  105134. */
  105135. clearInternalTexturesCache(): void;
  105136. /**
  105137. * Force the entire cache to be cleared
  105138. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105139. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105140. */
  105141. wipeCaches(bruteForce?: boolean): void;
  105142. /** @hidden */
  105143. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105144. min: number;
  105145. mag: number;
  105146. };
  105147. /** @hidden */
  105148. _createTexture(): WebGLTexture;
  105149. /**
  105150. * Usually called from Texture.ts.
  105151. * Passed information to create a WebGLTexture
  105152. * @param urlArg defines a value which contains one of the following:
  105153. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105154. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105155. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105156. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105157. * @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)
  105158. * @param scene needed for loading to the correct scene
  105159. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105160. * @param onLoad optional callback to be called upon successful completion
  105161. * @param onError optional callback to be called upon failure
  105162. * @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
  105163. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105164. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105165. * @param forcedExtension defines the extension to use to pick the right loader
  105166. * @param mimeType defines an optional mime type
  105167. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105168. */
  105169. 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;
  105170. /**
  105171. * Loads an image as an HTMLImageElement.
  105172. * @param input url string, ArrayBuffer, or Blob to load
  105173. * @param onLoad callback called when the image successfully loads
  105174. * @param onError callback called when the image fails to load
  105175. * @param offlineProvider offline provider for caching
  105176. * @param mimeType optional mime type
  105177. * @returns the HTMLImageElement of the loaded image
  105178. * @hidden
  105179. */
  105180. 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>;
  105181. /**
  105182. * @hidden
  105183. */
  105184. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105185. /**
  105186. * Creates a raw texture
  105187. * @param data defines the data to store in the texture
  105188. * @param width defines the width of the texture
  105189. * @param height defines the height of the texture
  105190. * @param format defines the format of the data
  105191. * @param generateMipMaps defines if the engine should generate the mip levels
  105192. * @param invertY defines if data must be stored with Y axis inverted
  105193. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105194. * @param compression defines the compression used (null by default)
  105195. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105196. * @returns the raw texture inside an InternalTexture
  105197. */
  105198. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105199. /**
  105200. * Creates a new raw cube texture
  105201. * @param data defines the array of data to use to create each face
  105202. * @param size defines the size of the textures
  105203. * @param format defines the format of the data
  105204. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105205. * @param generateMipMaps defines if the engine should generate the mip levels
  105206. * @param invertY defines if data must be stored with Y axis inverted
  105207. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105208. * @param compression defines the compression used (null by default)
  105209. * @returns the cube texture as an InternalTexture
  105210. */
  105211. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105212. /**
  105213. * Creates a new raw 3D texture
  105214. * @param data defines the data used to create the texture
  105215. * @param width defines the width of the texture
  105216. * @param height defines the height of the texture
  105217. * @param depth defines the depth of the texture
  105218. * @param format defines the format of the texture
  105219. * @param generateMipMaps defines if the engine must generate mip levels
  105220. * @param invertY defines if data must be stored with Y axis inverted
  105221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105222. * @param compression defines the compressed used (can be null)
  105223. * @param textureType defines the compressed used (can be null)
  105224. * @returns a new raw 3D texture (stored in an InternalTexture)
  105225. */
  105226. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105227. /**
  105228. * Creates a new raw 2D array texture
  105229. * @param data defines the data used to create the texture
  105230. * @param width defines the width of the texture
  105231. * @param height defines the height of the texture
  105232. * @param depth defines the number of layers of the texture
  105233. * @param format defines the format of the texture
  105234. * @param generateMipMaps defines if the engine must generate mip levels
  105235. * @param invertY defines if data must be stored with Y axis inverted
  105236. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105237. * @param compression defines the compressed used (can be null)
  105238. * @param textureType defines the compressed used (can be null)
  105239. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105240. */
  105241. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105242. private _unpackFlipYCached;
  105243. /**
  105244. * In case you are sharing the context with other applications, it might
  105245. * be interested to not cache the unpack flip y state to ensure a consistent
  105246. * value would be set.
  105247. */
  105248. enableUnpackFlipYCached: boolean;
  105249. /** @hidden */
  105250. _unpackFlipY(value: boolean): void;
  105251. /** @hidden */
  105252. _getUnpackAlignement(): number;
  105253. private _getTextureTarget;
  105254. /**
  105255. * Update the sampling mode of a given texture
  105256. * @param samplingMode defines the required sampling mode
  105257. * @param texture defines the texture to update
  105258. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105259. */
  105260. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105261. /**
  105262. * Update the sampling mode of a given texture
  105263. * @param texture defines the texture to update
  105264. * @param wrapU defines the texture wrap mode of the u coordinates
  105265. * @param wrapV defines the texture wrap mode of the v coordinates
  105266. * @param wrapR defines the texture wrap mode of the r coordinates
  105267. */
  105268. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105269. /** @hidden */
  105270. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105271. width: number;
  105272. height: number;
  105273. layers?: number;
  105274. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105275. /** @hidden */
  105276. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105277. /** @hidden */
  105278. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105279. /**
  105280. * Update a portion of an internal texture
  105281. * @param texture defines the texture to update
  105282. * @param imageData defines the data to store into the texture
  105283. * @param xOffset defines the x coordinates of the update rectangle
  105284. * @param yOffset defines the y coordinates of the update rectangle
  105285. * @param width defines the width of the update rectangle
  105286. * @param height defines the height of the update rectangle
  105287. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105288. * @param lod defines the lod level to update (0 by default)
  105289. */
  105290. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105291. /** @hidden */
  105292. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105293. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105294. private _prepareWebGLTexture;
  105295. /** @hidden */
  105296. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105297. private _getDepthStencilBuffer;
  105298. /** @hidden */
  105299. _releaseFramebufferObjects(texture: InternalTexture): void;
  105300. /** @hidden */
  105301. _releaseTexture(texture: InternalTexture): void;
  105302. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105303. protected _setProgram(program: WebGLProgram): void;
  105304. protected _boundUniforms: {
  105305. [key: number]: WebGLUniformLocation;
  105306. };
  105307. /**
  105308. * Binds an effect to the webGL context
  105309. * @param effect defines the effect to bind
  105310. */
  105311. bindSamplers(effect: Effect): void;
  105312. private _activateCurrentTexture;
  105313. /** @hidden */
  105314. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105315. /** @hidden */
  105316. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105317. /**
  105318. * Unbind all textures from the webGL context
  105319. */
  105320. unbindAllTextures(): void;
  105321. /**
  105322. * Sets a texture to the according uniform.
  105323. * @param channel The texture channel
  105324. * @param uniform The uniform to set
  105325. * @param texture The texture to apply
  105326. */
  105327. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105328. private _bindSamplerUniformToChannel;
  105329. private _getTextureWrapMode;
  105330. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105331. /**
  105332. * Sets an array of texture to the webGL context
  105333. * @param channel defines the channel where the texture array must be set
  105334. * @param uniform defines the associated uniform location
  105335. * @param textures defines the array of textures to bind
  105336. */
  105337. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105338. /** @hidden */
  105339. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105340. private _setTextureParameterFloat;
  105341. private _setTextureParameterInteger;
  105342. /**
  105343. * Unbind all vertex attributes from the webGL context
  105344. */
  105345. unbindAllAttributes(): void;
  105346. /**
  105347. * 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
  105348. */
  105349. releaseEffects(): void;
  105350. /**
  105351. * Dispose and release all associated resources
  105352. */
  105353. dispose(): void;
  105354. /**
  105355. * Attach a new callback raised when context lost event is fired
  105356. * @param callback defines the callback to call
  105357. */
  105358. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105359. /**
  105360. * Attach a new callback raised when context restored event is fired
  105361. * @param callback defines the callback to call
  105362. */
  105363. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105364. /**
  105365. * Get the current error code of the webGL context
  105366. * @returns the error code
  105367. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105368. */
  105369. getError(): number;
  105370. private _canRenderToFloatFramebuffer;
  105371. private _canRenderToHalfFloatFramebuffer;
  105372. private _canRenderToFramebuffer;
  105373. /** @hidden */
  105374. _getWebGLTextureType(type: number): number;
  105375. /** @hidden */
  105376. _getInternalFormat(format: number): number;
  105377. /** @hidden */
  105378. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105379. /** @hidden */
  105380. _getRGBAMultiSampleBufferFormat(type: number): number;
  105381. /** @hidden */
  105382. _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;
  105383. /**
  105384. * Loads a file from a url
  105385. * @param url url to load
  105386. * @param onSuccess callback called when the file successfully loads
  105387. * @param onProgress callback called while file is loading (if the server supports this mode)
  105388. * @param offlineProvider defines the offline provider for caching
  105389. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105390. * @param onError callback called when the file fails to load
  105391. * @returns a file request object
  105392. * @hidden
  105393. */
  105394. 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;
  105395. /**
  105396. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105397. * @param x defines the x coordinate of the rectangle where pixels must be read
  105398. * @param y defines the y coordinate of the rectangle where pixels must be read
  105399. * @param width defines the width of the rectangle where pixels must be read
  105400. * @param height defines the height of the rectangle where pixels must be read
  105401. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105402. * @returns a Uint8Array containing RGBA colors
  105403. */
  105404. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105405. private static _isSupported;
  105406. /**
  105407. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105408. * @returns true if the engine can be created
  105409. * @ignorenaming
  105410. */
  105411. static isSupported(): boolean;
  105412. /**
  105413. * Find the next highest power of two.
  105414. * @param x Number to start search from.
  105415. * @return Next highest power of two.
  105416. */
  105417. static CeilingPOT(x: number): number;
  105418. /**
  105419. * Find the next lowest power of two.
  105420. * @param x Number to start search from.
  105421. * @return Next lowest power of two.
  105422. */
  105423. static FloorPOT(x: number): number;
  105424. /**
  105425. * Find the nearest power of two.
  105426. * @param x Number to start search from.
  105427. * @return Next nearest power of two.
  105428. */
  105429. static NearestPOT(x: number): number;
  105430. /**
  105431. * Get the closest exponent of two
  105432. * @param value defines the value to approximate
  105433. * @param max defines the maximum value to return
  105434. * @param mode defines how to define the closest value
  105435. * @returns closest exponent of two of the given value
  105436. */
  105437. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105438. /**
  105439. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105440. * @param func - the function to be called
  105441. * @param requester - the object that will request the next frame. Falls back to window.
  105442. * @returns frame number
  105443. */
  105444. static QueueNewFrame(func: () => void, requester?: any): number;
  105445. /**
  105446. * Gets host document
  105447. * @returns the host document object
  105448. */
  105449. getHostDocument(): Nullable<Document>;
  105450. }
  105451. }
  105452. declare module BABYLON {
  105453. /**
  105454. * Class representing spherical harmonics coefficients to the 3rd degree
  105455. */
  105456. export class SphericalHarmonics {
  105457. /**
  105458. * Defines whether or not the harmonics have been prescaled for rendering.
  105459. */
  105460. preScaled: boolean;
  105461. /**
  105462. * The l0,0 coefficients of the spherical harmonics
  105463. */
  105464. l00: Vector3;
  105465. /**
  105466. * The l1,-1 coefficients of the spherical harmonics
  105467. */
  105468. l1_1: Vector3;
  105469. /**
  105470. * The l1,0 coefficients of the spherical harmonics
  105471. */
  105472. l10: Vector3;
  105473. /**
  105474. * The l1,1 coefficients of the spherical harmonics
  105475. */
  105476. l11: Vector3;
  105477. /**
  105478. * The l2,-2 coefficients of the spherical harmonics
  105479. */
  105480. l2_2: Vector3;
  105481. /**
  105482. * The l2,-1 coefficients of the spherical harmonics
  105483. */
  105484. l2_1: Vector3;
  105485. /**
  105486. * The l2,0 coefficients of the spherical harmonics
  105487. */
  105488. l20: Vector3;
  105489. /**
  105490. * The l2,1 coefficients of the spherical harmonics
  105491. */
  105492. l21: Vector3;
  105493. /**
  105494. * The l2,2 coefficients of the spherical harmonics
  105495. */
  105496. l22: Vector3;
  105497. /**
  105498. * Adds a light to the spherical harmonics
  105499. * @param direction the direction of the light
  105500. * @param color the color of the light
  105501. * @param deltaSolidAngle the delta solid angle of the light
  105502. */
  105503. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105504. /**
  105505. * Scales the spherical harmonics by the given amount
  105506. * @param scale the amount to scale
  105507. */
  105508. scaleInPlace(scale: number): void;
  105509. /**
  105510. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105511. *
  105512. * ```
  105513. * E_lm = A_l * L_lm
  105514. * ```
  105515. *
  105516. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105517. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105518. * the scaling factors are given in equation 9.
  105519. */
  105520. convertIncidentRadianceToIrradiance(): void;
  105521. /**
  105522. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105523. *
  105524. * ```
  105525. * L = (1/pi) * E * rho
  105526. * ```
  105527. *
  105528. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105529. */
  105530. convertIrradianceToLambertianRadiance(): void;
  105531. /**
  105532. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105533. * required operations at run time.
  105534. *
  105535. * This is simply done by scaling back the SH with Ylm constants parameter.
  105536. * The trigonometric part being applied by the shader at run time.
  105537. */
  105538. preScaleForRendering(): void;
  105539. /**
  105540. * Constructs a spherical harmonics from an array.
  105541. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105542. * @returns the spherical harmonics
  105543. */
  105544. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105545. /**
  105546. * Gets the spherical harmonics from polynomial
  105547. * @param polynomial the spherical polynomial
  105548. * @returns the spherical harmonics
  105549. */
  105550. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105551. }
  105552. /**
  105553. * Class representing spherical polynomial coefficients to the 3rd degree
  105554. */
  105555. export class SphericalPolynomial {
  105556. private _harmonics;
  105557. /**
  105558. * The spherical harmonics used to create the polynomials.
  105559. */
  105560. get preScaledHarmonics(): SphericalHarmonics;
  105561. /**
  105562. * The x coefficients of the spherical polynomial
  105563. */
  105564. x: Vector3;
  105565. /**
  105566. * The y coefficients of the spherical polynomial
  105567. */
  105568. y: Vector3;
  105569. /**
  105570. * The z coefficients of the spherical polynomial
  105571. */
  105572. z: Vector3;
  105573. /**
  105574. * The xx coefficients of the spherical polynomial
  105575. */
  105576. xx: Vector3;
  105577. /**
  105578. * The yy coefficients of the spherical polynomial
  105579. */
  105580. yy: Vector3;
  105581. /**
  105582. * The zz coefficients of the spherical polynomial
  105583. */
  105584. zz: Vector3;
  105585. /**
  105586. * The xy coefficients of the spherical polynomial
  105587. */
  105588. xy: Vector3;
  105589. /**
  105590. * The yz coefficients of the spherical polynomial
  105591. */
  105592. yz: Vector3;
  105593. /**
  105594. * The zx coefficients of the spherical polynomial
  105595. */
  105596. zx: Vector3;
  105597. /**
  105598. * Adds an ambient color to the spherical polynomial
  105599. * @param color the color to add
  105600. */
  105601. addAmbient(color: Color3): void;
  105602. /**
  105603. * Scales the spherical polynomial by the given amount
  105604. * @param scale the amount to scale
  105605. */
  105606. scaleInPlace(scale: number): void;
  105607. /**
  105608. * Gets the spherical polynomial from harmonics
  105609. * @param harmonics the spherical harmonics
  105610. * @returns the spherical polynomial
  105611. */
  105612. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105613. /**
  105614. * Constructs a spherical polynomial from an array.
  105615. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105616. * @returns the spherical polynomial
  105617. */
  105618. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105619. }
  105620. }
  105621. declare module BABYLON {
  105622. /**
  105623. * Defines the source of the internal texture
  105624. */
  105625. export enum InternalTextureSource {
  105626. /**
  105627. * The source of the texture data is unknown
  105628. */
  105629. Unknown = 0,
  105630. /**
  105631. * Texture data comes from an URL
  105632. */
  105633. Url = 1,
  105634. /**
  105635. * Texture data is only used for temporary storage
  105636. */
  105637. Temp = 2,
  105638. /**
  105639. * Texture data comes from raw data (ArrayBuffer)
  105640. */
  105641. Raw = 3,
  105642. /**
  105643. * Texture content is dynamic (video or dynamic texture)
  105644. */
  105645. Dynamic = 4,
  105646. /**
  105647. * Texture content is generated by rendering to it
  105648. */
  105649. RenderTarget = 5,
  105650. /**
  105651. * Texture content is part of a multi render target process
  105652. */
  105653. MultiRenderTarget = 6,
  105654. /**
  105655. * Texture data comes from a cube data file
  105656. */
  105657. Cube = 7,
  105658. /**
  105659. * Texture data comes from a raw cube data
  105660. */
  105661. CubeRaw = 8,
  105662. /**
  105663. * Texture data come from a prefiltered cube data file
  105664. */
  105665. CubePrefiltered = 9,
  105666. /**
  105667. * Texture content is raw 3D data
  105668. */
  105669. Raw3D = 10,
  105670. /**
  105671. * Texture content is raw 2D array data
  105672. */
  105673. Raw2DArray = 11,
  105674. /**
  105675. * Texture content is a depth texture
  105676. */
  105677. Depth = 12,
  105678. /**
  105679. * Texture data comes from a raw cube data encoded with RGBD
  105680. */
  105681. CubeRawRGBD = 13
  105682. }
  105683. /**
  105684. * Class used to store data associated with WebGL texture data for the engine
  105685. * This class should not be used directly
  105686. */
  105687. export class InternalTexture {
  105688. /** @hidden */
  105689. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105690. /**
  105691. * Defines if the texture is ready
  105692. */
  105693. isReady: boolean;
  105694. /**
  105695. * Defines if the texture is a cube texture
  105696. */
  105697. isCube: boolean;
  105698. /**
  105699. * Defines if the texture contains 3D data
  105700. */
  105701. is3D: boolean;
  105702. /**
  105703. * Defines if the texture contains 2D array data
  105704. */
  105705. is2DArray: boolean;
  105706. /**
  105707. * Defines if the texture contains multiview data
  105708. */
  105709. isMultiview: boolean;
  105710. /**
  105711. * Gets the URL used to load this texture
  105712. */
  105713. url: string;
  105714. /**
  105715. * Gets the sampling mode of the texture
  105716. */
  105717. samplingMode: number;
  105718. /**
  105719. * Gets a boolean indicating if the texture needs mipmaps generation
  105720. */
  105721. generateMipMaps: boolean;
  105722. /**
  105723. * Gets the number of samples used by the texture (WebGL2+ only)
  105724. */
  105725. samples: number;
  105726. /**
  105727. * Gets the type of the texture (int, float...)
  105728. */
  105729. type: number;
  105730. /**
  105731. * Gets the format of the texture (RGB, RGBA...)
  105732. */
  105733. format: number;
  105734. /**
  105735. * Observable called when the texture is loaded
  105736. */
  105737. onLoadedObservable: Observable<InternalTexture>;
  105738. /**
  105739. * Gets the width of the texture
  105740. */
  105741. width: number;
  105742. /**
  105743. * Gets the height of the texture
  105744. */
  105745. height: number;
  105746. /**
  105747. * Gets the depth of the texture
  105748. */
  105749. depth: number;
  105750. /**
  105751. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105752. */
  105753. baseWidth: number;
  105754. /**
  105755. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105756. */
  105757. baseHeight: number;
  105758. /**
  105759. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105760. */
  105761. baseDepth: number;
  105762. /**
  105763. * Gets a boolean indicating if the texture is inverted on Y axis
  105764. */
  105765. invertY: boolean;
  105766. /** @hidden */
  105767. _invertVScale: boolean;
  105768. /** @hidden */
  105769. _associatedChannel: number;
  105770. /** @hidden */
  105771. _source: InternalTextureSource;
  105772. /** @hidden */
  105773. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105774. /** @hidden */
  105775. _bufferView: Nullable<ArrayBufferView>;
  105776. /** @hidden */
  105777. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105778. /** @hidden */
  105779. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105780. /** @hidden */
  105781. _size: number;
  105782. /** @hidden */
  105783. _extension: string;
  105784. /** @hidden */
  105785. _files: Nullable<string[]>;
  105786. /** @hidden */
  105787. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105788. /** @hidden */
  105789. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105790. /** @hidden */
  105791. _framebuffer: Nullable<WebGLFramebuffer>;
  105792. /** @hidden */
  105793. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105794. /** @hidden */
  105795. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105796. /** @hidden */
  105797. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105798. /** @hidden */
  105799. _attachments: Nullable<number[]>;
  105800. /** @hidden */
  105801. _cachedCoordinatesMode: Nullable<number>;
  105802. /** @hidden */
  105803. _cachedWrapU: Nullable<number>;
  105804. /** @hidden */
  105805. _cachedWrapV: Nullable<number>;
  105806. /** @hidden */
  105807. _cachedWrapR: Nullable<number>;
  105808. /** @hidden */
  105809. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105810. /** @hidden */
  105811. _isDisabled: boolean;
  105812. /** @hidden */
  105813. _compression: Nullable<string>;
  105814. /** @hidden */
  105815. _generateStencilBuffer: boolean;
  105816. /** @hidden */
  105817. _generateDepthBuffer: boolean;
  105818. /** @hidden */
  105819. _comparisonFunction: number;
  105820. /** @hidden */
  105821. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105822. /** @hidden */
  105823. _lodGenerationScale: number;
  105824. /** @hidden */
  105825. _lodGenerationOffset: number;
  105826. /** @hidden */
  105827. _depthStencilTexture: Nullable<InternalTexture>;
  105828. /** @hidden */
  105829. _colorTextureArray: Nullable<WebGLTexture>;
  105830. /** @hidden */
  105831. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105832. /** @hidden */
  105833. _lodTextureHigh: Nullable<BaseTexture>;
  105834. /** @hidden */
  105835. _lodTextureMid: Nullable<BaseTexture>;
  105836. /** @hidden */
  105837. _lodTextureLow: Nullable<BaseTexture>;
  105838. /** @hidden */
  105839. _isRGBD: boolean;
  105840. /** @hidden */
  105841. _linearSpecularLOD: boolean;
  105842. /** @hidden */
  105843. _irradianceTexture: Nullable<BaseTexture>;
  105844. /** @hidden */
  105845. _webGLTexture: Nullable<WebGLTexture>;
  105846. /** @hidden */
  105847. _references: number;
  105848. private _engine;
  105849. /**
  105850. * Gets the Engine the texture belongs to.
  105851. * @returns The babylon engine
  105852. */
  105853. getEngine(): ThinEngine;
  105854. /**
  105855. * Gets the data source type of the texture
  105856. */
  105857. get source(): InternalTextureSource;
  105858. /**
  105859. * Creates a new InternalTexture
  105860. * @param engine defines the engine to use
  105861. * @param source defines the type of data that will be used
  105862. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105863. */
  105864. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105865. /**
  105866. * Increments the number of references (ie. the number of Texture that point to it)
  105867. */
  105868. incrementReferences(): void;
  105869. /**
  105870. * Change the size of the texture (not the size of the content)
  105871. * @param width defines the new width
  105872. * @param height defines the new height
  105873. * @param depth defines the new depth (1 by default)
  105874. */
  105875. updateSize(width: int, height: int, depth?: int): void;
  105876. /** @hidden */
  105877. _rebuild(): void;
  105878. /** @hidden */
  105879. _swapAndDie(target: InternalTexture): void;
  105880. /**
  105881. * Dispose the current allocated resources
  105882. */
  105883. dispose(): void;
  105884. }
  105885. }
  105886. declare module BABYLON {
  105887. /**
  105888. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105890. */
  105891. export class Analyser {
  105892. /**
  105893. * Gets or sets the smoothing
  105894. * @ignorenaming
  105895. */
  105896. SMOOTHING: number;
  105897. /**
  105898. * Gets or sets the FFT table size
  105899. * @ignorenaming
  105900. */
  105901. FFT_SIZE: number;
  105902. /**
  105903. * Gets or sets the bar graph amplitude
  105904. * @ignorenaming
  105905. */
  105906. BARGRAPHAMPLITUDE: number;
  105907. /**
  105908. * Gets or sets the position of the debug canvas
  105909. * @ignorenaming
  105910. */
  105911. DEBUGCANVASPOS: {
  105912. x: number;
  105913. y: number;
  105914. };
  105915. /**
  105916. * Gets or sets the debug canvas size
  105917. * @ignorenaming
  105918. */
  105919. DEBUGCANVASSIZE: {
  105920. width: number;
  105921. height: number;
  105922. };
  105923. private _byteFreqs;
  105924. private _byteTime;
  105925. private _floatFreqs;
  105926. private _webAudioAnalyser;
  105927. private _debugCanvas;
  105928. private _debugCanvasContext;
  105929. private _scene;
  105930. private _registerFunc;
  105931. private _audioEngine;
  105932. /**
  105933. * Creates a new analyser
  105934. * @param scene defines hosting scene
  105935. */
  105936. constructor(scene: Scene);
  105937. /**
  105938. * Get the number of data values you will have to play with for the visualization
  105939. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105940. * @returns a number
  105941. */
  105942. getFrequencyBinCount(): number;
  105943. /**
  105944. * Gets the current frequency data as a byte array
  105945. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105946. * @returns a Uint8Array
  105947. */
  105948. getByteFrequencyData(): Uint8Array;
  105949. /**
  105950. * Gets the current waveform as a byte array
  105951. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105952. * @returns a Uint8Array
  105953. */
  105954. getByteTimeDomainData(): Uint8Array;
  105955. /**
  105956. * Gets the current frequency data as a float array
  105957. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105958. * @returns a Float32Array
  105959. */
  105960. getFloatFrequencyData(): Float32Array;
  105961. /**
  105962. * Renders the debug canvas
  105963. */
  105964. drawDebugCanvas(): void;
  105965. /**
  105966. * Stops rendering the debug canvas and removes it
  105967. */
  105968. stopDebugCanvas(): void;
  105969. /**
  105970. * Connects two audio nodes
  105971. * @param inputAudioNode defines first node to connect
  105972. * @param outputAudioNode defines second node to connect
  105973. */
  105974. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105975. /**
  105976. * Releases all associated resources
  105977. */
  105978. dispose(): void;
  105979. }
  105980. }
  105981. declare module BABYLON {
  105982. /**
  105983. * This represents an audio engine and it is responsible
  105984. * to play, synchronize and analyse sounds throughout the application.
  105985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105986. */
  105987. export interface IAudioEngine extends IDisposable {
  105988. /**
  105989. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105990. */
  105991. readonly canUseWebAudio: boolean;
  105992. /**
  105993. * Gets the current AudioContext if available.
  105994. */
  105995. readonly audioContext: Nullable<AudioContext>;
  105996. /**
  105997. * The master gain node defines the global audio volume of your audio engine.
  105998. */
  105999. readonly masterGain: GainNode;
  106000. /**
  106001. * Gets whether or not mp3 are supported by your browser.
  106002. */
  106003. readonly isMP3supported: boolean;
  106004. /**
  106005. * Gets whether or not ogg are supported by your browser.
  106006. */
  106007. readonly isOGGsupported: boolean;
  106008. /**
  106009. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106010. * @ignoreNaming
  106011. */
  106012. WarnedWebAudioUnsupported: boolean;
  106013. /**
  106014. * Defines if the audio engine relies on a custom unlocked button.
  106015. * In this case, the embedded button will not be displayed.
  106016. */
  106017. useCustomUnlockedButton: boolean;
  106018. /**
  106019. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  106020. */
  106021. readonly unlocked: boolean;
  106022. /**
  106023. * Event raised when audio has been unlocked on the browser.
  106024. */
  106025. onAudioUnlockedObservable: Observable<AudioEngine>;
  106026. /**
  106027. * Event raised when audio has been locked on the browser.
  106028. */
  106029. onAudioLockedObservable: Observable<AudioEngine>;
  106030. /**
  106031. * Flags the audio engine in Locked state.
  106032. * This happens due to new browser policies preventing audio to autoplay.
  106033. */
  106034. lock(): void;
  106035. /**
  106036. * Unlocks the audio engine once a user action has been done on the dom.
  106037. * This is helpful to resume play once browser policies have been satisfied.
  106038. */
  106039. unlock(): void;
  106040. /**
  106041. * Gets the global volume sets on the master gain.
  106042. * @returns the global volume if set or -1 otherwise
  106043. */
  106044. getGlobalVolume(): number;
  106045. /**
  106046. * Sets the global volume of your experience (sets on the master gain).
  106047. * @param newVolume Defines the new global volume of the application
  106048. */
  106049. setGlobalVolume(newVolume: number): void;
  106050. /**
  106051. * Connect the audio engine to an audio analyser allowing some amazing
  106052. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106054. * @param analyser The analyser to connect to the engine
  106055. */
  106056. connectToAnalyser(analyser: Analyser): void;
  106057. }
  106058. /**
  106059. * This represents the default audio engine used in babylon.
  106060. * It is responsible to play, synchronize and analyse sounds throughout the application.
  106061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106062. */
  106063. export class AudioEngine implements IAudioEngine {
  106064. private _audioContext;
  106065. private _audioContextInitialized;
  106066. private _muteButton;
  106067. private _hostElement;
  106068. /**
  106069. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106070. */
  106071. canUseWebAudio: boolean;
  106072. /**
  106073. * The master gain node defines the global audio volume of your audio engine.
  106074. */
  106075. masterGain: GainNode;
  106076. /**
  106077. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106078. * @ignoreNaming
  106079. */
  106080. WarnedWebAudioUnsupported: boolean;
  106081. /**
  106082. * Gets whether or not mp3 are supported by your browser.
  106083. */
  106084. isMP3supported: boolean;
  106085. /**
  106086. * Gets whether or not ogg are supported by your browser.
  106087. */
  106088. isOGGsupported: boolean;
  106089. /**
  106090. * Gets whether audio has been unlocked on the device.
  106091. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  106092. * a user interaction has happened.
  106093. */
  106094. unlocked: boolean;
  106095. /**
  106096. * Defines if the audio engine relies on a custom unlocked button.
  106097. * In this case, the embedded button will not be displayed.
  106098. */
  106099. useCustomUnlockedButton: boolean;
  106100. /**
  106101. * Event raised when audio has been unlocked on the browser.
  106102. */
  106103. onAudioUnlockedObservable: Observable<AudioEngine>;
  106104. /**
  106105. * Event raised when audio has been locked on the browser.
  106106. */
  106107. onAudioLockedObservable: Observable<AudioEngine>;
  106108. /**
  106109. * Gets the current AudioContext if available.
  106110. */
  106111. get audioContext(): Nullable<AudioContext>;
  106112. private _connectedAnalyser;
  106113. /**
  106114. * Instantiates a new audio engine.
  106115. *
  106116. * There should be only one per page as some browsers restrict the number
  106117. * of audio contexts you can create.
  106118. * @param hostElement defines the host element where to display the mute icon if necessary
  106119. */
  106120. constructor(hostElement?: Nullable<HTMLElement>);
  106121. /**
  106122. * Flags the audio engine in Locked state.
  106123. * This happens due to new browser policies preventing audio to autoplay.
  106124. */
  106125. lock(): void;
  106126. /**
  106127. * Unlocks the audio engine once a user action has been done on the dom.
  106128. * This is helpful to resume play once browser policies have been satisfied.
  106129. */
  106130. unlock(): void;
  106131. private _resumeAudioContext;
  106132. private _initializeAudioContext;
  106133. private _tryToRun;
  106134. private _triggerRunningState;
  106135. private _triggerSuspendedState;
  106136. private _displayMuteButton;
  106137. private _moveButtonToTopLeft;
  106138. private _onResize;
  106139. private _hideMuteButton;
  106140. /**
  106141. * Destroy and release the resources associated with the audio ccontext.
  106142. */
  106143. dispose(): void;
  106144. /**
  106145. * Gets the global volume sets on the master gain.
  106146. * @returns the global volume if set or -1 otherwise
  106147. */
  106148. getGlobalVolume(): number;
  106149. /**
  106150. * Sets the global volume of your experience (sets on the master gain).
  106151. * @param newVolume Defines the new global volume of the application
  106152. */
  106153. setGlobalVolume(newVolume: number): void;
  106154. /**
  106155. * Connect the audio engine to an audio analyser allowing some amazing
  106156. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106158. * @param analyser The analyser to connect to the engine
  106159. */
  106160. connectToAnalyser(analyser: Analyser): void;
  106161. }
  106162. }
  106163. declare module BABYLON {
  106164. /**
  106165. * Interface used to present a loading screen while loading a scene
  106166. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106167. */
  106168. export interface ILoadingScreen {
  106169. /**
  106170. * Function called to display the loading screen
  106171. */
  106172. displayLoadingUI: () => void;
  106173. /**
  106174. * Function called to hide the loading screen
  106175. */
  106176. hideLoadingUI: () => void;
  106177. /**
  106178. * Gets or sets the color to use for the background
  106179. */
  106180. loadingUIBackgroundColor: string;
  106181. /**
  106182. * Gets or sets the text to display while loading
  106183. */
  106184. loadingUIText: string;
  106185. }
  106186. /**
  106187. * Class used for the default loading screen
  106188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106189. */
  106190. export class DefaultLoadingScreen implements ILoadingScreen {
  106191. private _renderingCanvas;
  106192. private _loadingText;
  106193. private _loadingDivBackgroundColor;
  106194. private _loadingDiv;
  106195. private _loadingTextDiv;
  106196. /** Gets or sets the logo url to use for the default loading screen */
  106197. static DefaultLogoUrl: string;
  106198. /** Gets or sets the spinner url to use for the default loading screen */
  106199. static DefaultSpinnerUrl: string;
  106200. /**
  106201. * Creates a new default loading screen
  106202. * @param _renderingCanvas defines the canvas used to render the scene
  106203. * @param _loadingText defines the default text to display
  106204. * @param _loadingDivBackgroundColor defines the default background color
  106205. */
  106206. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106207. /**
  106208. * Function called to display the loading screen
  106209. */
  106210. displayLoadingUI(): void;
  106211. /**
  106212. * Function called to hide the loading screen
  106213. */
  106214. hideLoadingUI(): void;
  106215. /**
  106216. * Gets or sets the text to display while loading
  106217. */
  106218. set loadingUIText(text: string);
  106219. get loadingUIText(): string;
  106220. /**
  106221. * Gets or sets the color to use for the background
  106222. */
  106223. get loadingUIBackgroundColor(): string;
  106224. set loadingUIBackgroundColor(color: string);
  106225. private _resizeLoadingUI;
  106226. }
  106227. }
  106228. declare module BABYLON {
  106229. /**
  106230. * Interface for any object that can request an animation frame
  106231. */
  106232. export interface ICustomAnimationFrameRequester {
  106233. /**
  106234. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106235. */
  106236. renderFunction?: Function;
  106237. /**
  106238. * Called to request the next frame to render to
  106239. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106240. */
  106241. requestAnimationFrame: Function;
  106242. /**
  106243. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106244. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106245. */
  106246. requestID?: number;
  106247. }
  106248. }
  106249. declare module BABYLON {
  106250. /**
  106251. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106252. */
  106253. export class PerformanceMonitor {
  106254. private _enabled;
  106255. private _rollingFrameTime;
  106256. private _lastFrameTimeMs;
  106257. /**
  106258. * constructor
  106259. * @param frameSampleSize The number of samples required to saturate the sliding window
  106260. */
  106261. constructor(frameSampleSize?: number);
  106262. /**
  106263. * Samples current frame
  106264. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106265. */
  106266. sampleFrame(timeMs?: number): void;
  106267. /**
  106268. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106269. */
  106270. get averageFrameTime(): number;
  106271. /**
  106272. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106273. */
  106274. get averageFrameTimeVariance(): number;
  106275. /**
  106276. * Returns the frame time of the most recent frame
  106277. */
  106278. get instantaneousFrameTime(): number;
  106279. /**
  106280. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106281. */
  106282. get averageFPS(): number;
  106283. /**
  106284. * Returns the average framerate in frames per second using the most recent frame time
  106285. */
  106286. get instantaneousFPS(): number;
  106287. /**
  106288. * Returns true if enough samples have been taken to completely fill the sliding window
  106289. */
  106290. get isSaturated(): boolean;
  106291. /**
  106292. * Enables contributions to the sliding window sample set
  106293. */
  106294. enable(): void;
  106295. /**
  106296. * Disables contributions to the sliding window sample set
  106297. * Samples will not be interpolated over the disabled period
  106298. */
  106299. disable(): void;
  106300. /**
  106301. * Returns true if sampling is enabled
  106302. */
  106303. get isEnabled(): boolean;
  106304. /**
  106305. * Resets performance monitor
  106306. */
  106307. reset(): void;
  106308. }
  106309. /**
  106310. * RollingAverage
  106311. *
  106312. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106313. */
  106314. export class RollingAverage {
  106315. /**
  106316. * Current average
  106317. */
  106318. average: number;
  106319. /**
  106320. * Current variance
  106321. */
  106322. variance: number;
  106323. protected _samples: Array<number>;
  106324. protected _sampleCount: number;
  106325. protected _pos: number;
  106326. protected _m2: number;
  106327. /**
  106328. * constructor
  106329. * @param length The number of samples required to saturate the sliding window
  106330. */
  106331. constructor(length: number);
  106332. /**
  106333. * Adds a sample to the sample set
  106334. * @param v The sample value
  106335. */
  106336. add(v: number): void;
  106337. /**
  106338. * Returns previously added values or null if outside of history or outside the sliding window domain
  106339. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106340. * @return Value previously recorded with add() or null if outside of range
  106341. */
  106342. history(i: number): number;
  106343. /**
  106344. * Returns true if enough samples have been taken to completely fill the sliding window
  106345. * @return true if sample-set saturated
  106346. */
  106347. isSaturated(): boolean;
  106348. /**
  106349. * Resets the rolling average (equivalent to 0 samples taken so far)
  106350. */
  106351. reset(): void;
  106352. /**
  106353. * Wraps a value around the sample range boundaries
  106354. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106355. * @return Wrapped position in sample range
  106356. */
  106357. protected _wrapPosition(i: number): number;
  106358. }
  106359. }
  106360. declare module BABYLON {
  106361. /**
  106362. * This class is used to track a performance counter which is number based.
  106363. * The user has access to many properties which give statistics of different nature.
  106364. *
  106365. * The implementer can track two kinds of Performance Counter: time and count.
  106366. * 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.
  106367. * 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.
  106368. */
  106369. export class PerfCounter {
  106370. /**
  106371. * Gets or sets a global boolean to turn on and off all the counters
  106372. */
  106373. static Enabled: boolean;
  106374. /**
  106375. * Returns the smallest value ever
  106376. */
  106377. get min(): number;
  106378. /**
  106379. * Returns the biggest value ever
  106380. */
  106381. get max(): number;
  106382. /**
  106383. * Returns the average value since the performance counter is running
  106384. */
  106385. get average(): number;
  106386. /**
  106387. * Returns the average value of the last second the counter was monitored
  106388. */
  106389. get lastSecAverage(): number;
  106390. /**
  106391. * Returns the current value
  106392. */
  106393. get current(): number;
  106394. /**
  106395. * Gets the accumulated total
  106396. */
  106397. get total(): number;
  106398. /**
  106399. * Gets the total value count
  106400. */
  106401. get count(): number;
  106402. /**
  106403. * Creates a new counter
  106404. */
  106405. constructor();
  106406. /**
  106407. * Call this method to start monitoring a new frame.
  106408. * 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.
  106409. */
  106410. fetchNewFrame(): void;
  106411. /**
  106412. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106413. * @param newCount the count value to add to the monitored count
  106414. * @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.
  106415. */
  106416. addCount(newCount: number, fetchResult: boolean): void;
  106417. /**
  106418. * Start monitoring this performance counter
  106419. */
  106420. beginMonitoring(): void;
  106421. /**
  106422. * Compute the time lapsed since the previous beginMonitoring() call.
  106423. * @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
  106424. */
  106425. endMonitoring(newFrame?: boolean): void;
  106426. private _fetchResult;
  106427. private _startMonitoringTime;
  106428. private _min;
  106429. private _max;
  106430. private _average;
  106431. private _current;
  106432. private _totalValueCount;
  106433. private _totalAccumulated;
  106434. private _lastSecAverage;
  106435. private _lastSecAccumulated;
  106436. private _lastSecTime;
  106437. private _lastSecValueCount;
  106438. }
  106439. }
  106440. declare module BABYLON {
  106441. interface ThinEngine {
  106442. /**
  106443. * Sets alpha constants used by some alpha blending modes
  106444. * @param r defines the red component
  106445. * @param g defines the green component
  106446. * @param b defines the blue component
  106447. * @param a defines the alpha component
  106448. */
  106449. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106450. /**
  106451. * Sets the current alpha mode
  106452. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106453. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106454. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106455. */
  106456. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106457. /**
  106458. * Gets the current alpha mode
  106459. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106460. * @returns the current alpha mode
  106461. */
  106462. getAlphaMode(): number;
  106463. /**
  106464. * Sets the current alpha equation
  106465. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106466. */
  106467. setAlphaEquation(equation: number): void;
  106468. /**
  106469. * Gets the current alpha equation.
  106470. * @returns the current alpha equation
  106471. */
  106472. getAlphaEquation(): number;
  106473. }
  106474. }
  106475. declare module BABYLON {
  106476. /**
  106477. * Defines the interface used by display changed events
  106478. */
  106479. export interface IDisplayChangedEventArgs {
  106480. /** Gets the vrDisplay object (if any) */
  106481. vrDisplay: Nullable<any>;
  106482. /** Gets a boolean indicating if webVR is supported */
  106483. vrSupported: boolean;
  106484. }
  106485. /**
  106486. * Defines the interface used by objects containing a viewport (like a camera)
  106487. */
  106488. interface IViewportOwnerLike {
  106489. /**
  106490. * Gets or sets the viewport
  106491. */
  106492. viewport: IViewportLike;
  106493. }
  106494. /**
  106495. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106496. */
  106497. export class Engine extends ThinEngine {
  106498. /** Defines that alpha blending is disabled */
  106499. static readonly ALPHA_DISABLE: number;
  106500. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106501. static readonly ALPHA_ADD: number;
  106502. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106503. static readonly ALPHA_COMBINE: number;
  106504. /** Defines that alpha blending to DEST - SRC * DEST */
  106505. static readonly ALPHA_SUBTRACT: number;
  106506. /** Defines that alpha blending to SRC * DEST */
  106507. static readonly ALPHA_MULTIPLY: number;
  106508. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106509. static readonly ALPHA_MAXIMIZED: number;
  106510. /** Defines that alpha blending to SRC + DEST */
  106511. static readonly ALPHA_ONEONE: number;
  106512. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106513. static readonly ALPHA_PREMULTIPLIED: number;
  106514. /**
  106515. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106516. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106517. */
  106518. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106519. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106520. static readonly ALPHA_INTERPOLATE: number;
  106521. /**
  106522. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106523. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106524. */
  106525. static readonly ALPHA_SCREENMODE: number;
  106526. /** Defines that the ressource is not delayed*/
  106527. static readonly DELAYLOADSTATE_NONE: number;
  106528. /** Defines that the ressource was successfully delay loaded */
  106529. static readonly DELAYLOADSTATE_LOADED: number;
  106530. /** Defines that the ressource is currently delay loading */
  106531. static readonly DELAYLOADSTATE_LOADING: number;
  106532. /** Defines that the ressource is delayed and has not started loading */
  106533. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106534. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106535. static readonly NEVER: number;
  106536. /** 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 */
  106537. static readonly ALWAYS: number;
  106538. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106539. static readonly LESS: number;
  106540. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106541. static readonly EQUAL: number;
  106542. /** 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 */
  106543. static readonly LEQUAL: number;
  106544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106545. static readonly GREATER: number;
  106546. /** 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 */
  106547. static readonly GEQUAL: number;
  106548. /** 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 */
  106549. static readonly NOTEQUAL: number;
  106550. /** Passed to stencilOperation to specify that stencil value must be kept */
  106551. static readonly KEEP: number;
  106552. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106553. static readonly REPLACE: number;
  106554. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106555. static readonly INCR: number;
  106556. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106557. static readonly DECR: number;
  106558. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106559. static readonly INVERT: number;
  106560. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106561. static readonly INCR_WRAP: number;
  106562. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106563. static readonly DECR_WRAP: number;
  106564. /** Texture is not repeating outside of 0..1 UVs */
  106565. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106566. /** Texture is repeating outside of 0..1 UVs */
  106567. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106568. /** Texture is repeating and mirrored */
  106569. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106570. /** ALPHA */
  106571. static readonly TEXTUREFORMAT_ALPHA: number;
  106572. /** LUMINANCE */
  106573. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106574. /** LUMINANCE_ALPHA */
  106575. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106576. /** RGB */
  106577. static readonly TEXTUREFORMAT_RGB: number;
  106578. /** RGBA */
  106579. static readonly TEXTUREFORMAT_RGBA: number;
  106580. /** RED */
  106581. static readonly TEXTUREFORMAT_RED: number;
  106582. /** RED (2nd reference) */
  106583. static readonly TEXTUREFORMAT_R: number;
  106584. /** RG */
  106585. static readonly TEXTUREFORMAT_RG: number;
  106586. /** RED_INTEGER */
  106587. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106588. /** RED_INTEGER (2nd reference) */
  106589. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106590. /** RG_INTEGER */
  106591. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106592. /** RGB_INTEGER */
  106593. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106594. /** RGBA_INTEGER */
  106595. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106596. /** UNSIGNED_BYTE */
  106597. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106598. /** UNSIGNED_BYTE (2nd reference) */
  106599. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106600. /** FLOAT */
  106601. static readonly TEXTURETYPE_FLOAT: number;
  106602. /** HALF_FLOAT */
  106603. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106604. /** BYTE */
  106605. static readonly TEXTURETYPE_BYTE: number;
  106606. /** SHORT */
  106607. static readonly TEXTURETYPE_SHORT: number;
  106608. /** UNSIGNED_SHORT */
  106609. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106610. /** INT */
  106611. static readonly TEXTURETYPE_INT: number;
  106612. /** UNSIGNED_INT */
  106613. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106614. /** UNSIGNED_SHORT_4_4_4_4 */
  106615. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106616. /** UNSIGNED_SHORT_5_5_5_1 */
  106617. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106618. /** UNSIGNED_SHORT_5_6_5 */
  106619. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106620. /** UNSIGNED_INT_2_10_10_10_REV */
  106621. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106622. /** UNSIGNED_INT_24_8 */
  106623. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106624. /** UNSIGNED_INT_10F_11F_11F_REV */
  106625. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106626. /** UNSIGNED_INT_5_9_9_9_REV */
  106627. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106628. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106629. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106630. /** nearest is mag = nearest and min = nearest and mip = linear */
  106631. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106632. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106633. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106634. /** Trilinear is mag = linear and min = linear and mip = linear */
  106635. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106636. /** nearest is mag = nearest and min = nearest and mip = linear */
  106637. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106638. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106639. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106640. /** Trilinear is mag = linear and min = linear and mip = linear */
  106641. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106642. /** mag = nearest and min = nearest and mip = nearest */
  106643. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106644. /** mag = nearest and min = linear and mip = nearest */
  106645. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106646. /** mag = nearest and min = linear and mip = linear */
  106647. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106648. /** mag = nearest and min = linear and mip = none */
  106649. static readonly TEXTURE_NEAREST_LINEAR: number;
  106650. /** mag = nearest and min = nearest and mip = none */
  106651. static readonly TEXTURE_NEAREST_NEAREST: number;
  106652. /** mag = linear and min = nearest and mip = nearest */
  106653. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106654. /** mag = linear and min = nearest and mip = linear */
  106655. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106656. /** mag = linear and min = linear and mip = none */
  106657. static readonly TEXTURE_LINEAR_LINEAR: number;
  106658. /** mag = linear and min = nearest and mip = none */
  106659. static readonly TEXTURE_LINEAR_NEAREST: number;
  106660. /** Explicit coordinates mode */
  106661. static readonly TEXTURE_EXPLICIT_MODE: number;
  106662. /** Spherical coordinates mode */
  106663. static readonly TEXTURE_SPHERICAL_MODE: number;
  106664. /** Planar coordinates mode */
  106665. static readonly TEXTURE_PLANAR_MODE: number;
  106666. /** Cubic coordinates mode */
  106667. static readonly TEXTURE_CUBIC_MODE: number;
  106668. /** Projection coordinates mode */
  106669. static readonly TEXTURE_PROJECTION_MODE: number;
  106670. /** Skybox coordinates mode */
  106671. static readonly TEXTURE_SKYBOX_MODE: number;
  106672. /** Inverse Cubic coordinates mode */
  106673. static readonly TEXTURE_INVCUBIC_MODE: number;
  106674. /** Equirectangular coordinates mode */
  106675. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106676. /** Equirectangular Fixed coordinates mode */
  106677. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106678. /** Equirectangular Fixed Mirrored coordinates mode */
  106679. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106680. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106681. static readonly SCALEMODE_FLOOR: number;
  106682. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106683. static readonly SCALEMODE_NEAREST: number;
  106684. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106685. static readonly SCALEMODE_CEILING: number;
  106686. /**
  106687. * Returns the current npm package of the sdk
  106688. */
  106689. static get NpmPackage(): string;
  106690. /**
  106691. * Returns the current version of the framework
  106692. */
  106693. static get Version(): string;
  106694. /** Gets the list of created engines */
  106695. static get Instances(): Engine[];
  106696. /**
  106697. * Gets the latest created engine
  106698. */
  106699. static get LastCreatedEngine(): Nullable<Engine>;
  106700. /**
  106701. * Gets the latest created scene
  106702. */
  106703. static get LastCreatedScene(): Nullable<Scene>;
  106704. /**
  106705. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106706. * @param flag defines which part of the materials must be marked as dirty
  106707. * @param predicate defines a predicate used to filter which materials should be affected
  106708. */
  106709. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106710. /**
  106711. * Method called to create the default loading screen.
  106712. * This can be overriden in your own app.
  106713. * @param canvas The rendering canvas element
  106714. * @returns The loading screen
  106715. */
  106716. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106717. /**
  106718. * Method called to create the default rescale post process on each engine.
  106719. */
  106720. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106721. /**
  106722. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106723. **/
  106724. enableOfflineSupport: boolean;
  106725. /**
  106726. * 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)
  106727. **/
  106728. disableManifestCheck: boolean;
  106729. /**
  106730. * Gets the list of created scenes
  106731. */
  106732. scenes: Scene[];
  106733. /**
  106734. * Event raised when a new scene is created
  106735. */
  106736. onNewSceneAddedObservable: Observable<Scene>;
  106737. /**
  106738. * Gets the list of created postprocesses
  106739. */
  106740. postProcesses: PostProcess[];
  106741. /**
  106742. * Gets a boolean indicating if the pointer is currently locked
  106743. */
  106744. isPointerLock: boolean;
  106745. /**
  106746. * Observable event triggered each time the rendering canvas is resized
  106747. */
  106748. onResizeObservable: Observable<Engine>;
  106749. /**
  106750. * Observable event triggered each time the canvas loses focus
  106751. */
  106752. onCanvasBlurObservable: Observable<Engine>;
  106753. /**
  106754. * Observable event triggered each time the canvas gains focus
  106755. */
  106756. onCanvasFocusObservable: Observable<Engine>;
  106757. /**
  106758. * Observable event triggered each time the canvas receives pointerout event
  106759. */
  106760. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106761. /**
  106762. * Observable raised when the engine begins a new frame
  106763. */
  106764. onBeginFrameObservable: Observable<Engine>;
  106765. /**
  106766. * If set, will be used to request the next animation frame for the render loop
  106767. */
  106768. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106769. /**
  106770. * Observable raised when the engine ends the current frame
  106771. */
  106772. onEndFrameObservable: Observable<Engine>;
  106773. /**
  106774. * Observable raised when the engine is about to compile a shader
  106775. */
  106776. onBeforeShaderCompilationObservable: Observable<Engine>;
  106777. /**
  106778. * Observable raised when the engine has jsut compiled a shader
  106779. */
  106780. onAfterShaderCompilationObservable: Observable<Engine>;
  106781. /**
  106782. * Gets the audio engine
  106783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106784. * @ignorenaming
  106785. */
  106786. static audioEngine: IAudioEngine;
  106787. /**
  106788. * Default AudioEngine factory responsible of creating the Audio Engine.
  106789. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106790. */
  106791. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106792. /**
  106793. * Default offline support factory responsible of creating a tool used to store data locally.
  106794. * By default, this will create a Database object if the workload has been embedded.
  106795. */
  106796. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106797. private _loadingScreen;
  106798. private _pointerLockRequested;
  106799. private _dummyFramebuffer;
  106800. private _rescalePostProcess;
  106801. private _deterministicLockstep;
  106802. private _lockstepMaxSteps;
  106803. private _timeStep;
  106804. protected get _supportsHardwareTextureRescaling(): boolean;
  106805. private _fps;
  106806. private _deltaTime;
  106807. /** @hidden */
  106808. _drawCalls: PerfCounter;
  106809. /** 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 */
  106810. canvasTabIndex: number;
  106811. /**
  106812. * Turn this value on if you want to pause FPS computation when in background
  106813. */
  106814. disablePerformanceMonitorInBackground: boolean;
  106815. private _performanceMonitor;
  106816. /**
  106817. * Gets the performance monitor attached to this engine
  106818. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106819. */
  106820. get performanceMonitor(): PerformanceMonitor;
  106821. private _onFocus;
  106822. private _onBlur;
  106823. private _onCanvasPointerOut;
  106824. private _onCanvasBlur;
  106825. private _onCanvasFocus;
  106826. private _onFullscreenChange;
  106827. private _onPointerLockChange;
  106828. /**
  106829. * Gets the HTML element used to attach event listeners
  106830. * @returns a HTML element
  106831. */
  106832. getInputElement(): Nullable<HTMLElement>;
  106833. /**
  106834. * Creates a new engine
  106835. * @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
  106836. * @param antialias defines enable antialiasing (default: false)
  106837. * @param options defines further options to be sent to the getContext() function
  106838. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106839. */
  106840. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106841. /**
  106842. * Gets current aspect ratio
  106843. * @param viewportOwner defines the camera to use to get the aspect ratio
  106844. * @param useScreen defines if screen size must be used (or the current render target if any)
  106845. * @returns a number defining the aspect ratio
  106846. */
  106847. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106848. /**
  106849. * Gets current screen aspect ratio
  106850. * @returns a number defining the aspect ratio
  106851. */
  106852. getScreenAspectRatio(): number;
  106853. /**
  106854. * Gets the client rect of the HTML canvas attached with the current webGL context
  106855. * @returns a client rectanglee
  106856. */
  106857. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106858. /**
  106859. * Gets the client rect of the HTML element used for events
  106860. * @returns a client rectanglee
  106861. */
  106862. getInputElementClientRect(): Nullable<ClientRect>;
  106863. /**
  106864. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106865. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106866. * @returns true if engine is in deterministic lock step mode
  106867. */
  106868. isDeterministicLockStep(): boolean;
  106869. /**
  106870. * Gets the max steps when engine is running in deterministic lock step
  106871. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106872. * @returns the max steps
  106873. */
  106874. getLockstepMaxSteps(): number;
  106875. /**
  106876. * Returns the time in ms between steps when using deterministic lock step.
  106877. * @returns time step in (ms)
  106878. */
  106879. getTimeStep(): number;
  106880. /**
  106881. * Force the mipmap generation for the given render target texture
  106882. * @param texture defines the render target texture to use
  106883. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106884. */
  106885. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106886. /** States */
  106887. /**
  106888. * Set various states to the webGL context
  106889. * @param culling defines backface culling state
  106890. * @param zOffset defines the value to apply to zOffset (0 by default)
  106891. * @param force defines if states must be applied even if cache is up to date
  106892. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106893. */
  106894. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106895. /**
  106896. * Set the z offset to apply to current rendering
  106897. * @param value defines the offset to apply
  106898. */
  106899. setZOffset(value: number): void;
  106900. /**
  106901. * Gets the current value of the zOffset
  106902. * @returns the current zOffset state
  106903. */
  106904. getZOffset(): number;
  106905. /**
  106906. * Enable or disable depth buffering
  106907. * @param enable defines the state to set
  106908. */
  106909. setDepthBuffer(enable: boolean): void;
  106910. /**
  106911. * Gets a boolean indicating if depth writing is enabled
  106912. * @returns the current depth writing state
  106913. */
  106914. getDepthWrite(): boolean;
  106915. /**
  106916. * Enable or disable depth writing
  106917. * @param enable defines the state to set
  106918. */
  106919. setDepthWrite(enable: boolean): void;
  106920. /**
  106921. * Gets a boolean indicating if stencil buffer is enabled
  106922. * @returns the current stencil buffer state
  106923. */
  106924. getStencilBuffer(): boolean;
  106925. /**
  106926. * Enable or disable the stencil buffer
  106927. * @param enable defines if the stencil buffer must be enabled or disabled
  106928. */
  106929. setStencilBuffer(enable: boolean): void;
  106930. /**
  106931. * Gets the current stencil mask
  106932. * @returns a number defining the new stencil mask to use
  106933. */
  106934. getStencilMask(): number;
  106935. /**
  106936. * Sets the current stencil mask
  106937. * @param mask defines the new stencil mask to use
  106938. */
  106939. setStencilMask(mask: number): void;
  106940. /**
  106941. * Gets the current stencil function
  106942. * @returns a number defining the stencil function to use
  106943. */
  106944. getStencilFunction(): number;
  106945. /**
  106946. * Gets the current stencil reference value
  106947. * @returns a number defining the stencil reference value to use
  106948. */
  106949. getStencilFunctionReference(): number;
  106950. /**
  106951. * Gets the current stencil mask
  106952. * @returns a number defining the stencil mask to use
  106953. */
  106954. getStencilFunctionMask(): number;
  106955. /**
  106956. * Sets the current stencil function
  106957. * @param stencilFunc defines the new stencil function to use
  106958. */
  106959. setStencilFunction(stencilFunc: number): void;
  106960. /**
  106961. * Sets the current stencil reference
  106962. * @param reference defines the new stencil reference to use
  106963. */
  106964. setStencilFunctionReference(reference: number): void;
  106965. /**
  106966. * Sets the current stencil mask
  106967. * @param mask defines the new stencil mask to use
  106968. */
  106969. setStencilFunctionMask(mask: number): void;
  106970. /**
  106971. * Gets the current stencil operation when stencil fails
  106972. * @returns a number defining stencil operation to use when stencil fails
  106973. */
  106974. getStencilOperationFail(): number;
  106975. /**
  106976. * Gets the current stencil operation when depth fails
  106977. * @returns a number defining stencil operation to use when depth fails
  106978. */
  106979. getStencilOperationDepthFail(): number;
  106980. /**
  106981. * Gets the current stencil operation when stencil passes
  106982. * @returns a number defining stencil operation to use when stencil passes
  106983. */
  106984. getStencilOperationPass(): number;
  106985. /**
  106986. * Sets the stencil operation to use when stencil fails
  106987. * @param operation defines the stencil operation to use when stencil fails
  106988. */
  106989. setStencilOperationFail(operation: number): void;
  106990. /**
  106991. * Sets the stencil operation to use when depth fails
  106992. * @param operation defines the stencil operation to use when depth fails
  106993. */
  106994. setStencilOperationDepthFail(operation: number): void;
  106995. /**
  106996. * Sets the stencil operation to use when stencil passes
  106997. * @param operation defines the stencil operation to use when stencil passes
  106998. */
  106999. setStencilOperationPass(operation: number): void;
  107000. /**
  107001. * Sets a boolean indicating if the dithering state is enabled or disabled
  107002. * @param value defines the dithering state
  107003. */
  107004. setDitheringState(value: boolean): void;
  107005. /**
  107006. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107007. * @param value defines the rasterizer state
  107008. */
  107009. setRasterizerState(value: boolean): void;
  107010. /**
  107011. * Gets the current depth function
  107012. * @returns a number defining the depth function
  107013. */
  107014. getDepthFunction(): Nullable<number>;
  107015. /**
  107016. * Sets the current depth function
  107017. * @param depthFunc defines the function to use
  107018. */
  107019. setDepthFunction(depthFunc: number): void;
  107020. /**
  107021. * Sets the current depth function to GREATER
  107022. */
  107023. setDepthFunctionToGreater(): void;
  107024. /**
  107025. * Sets the current depth function to GEQUAL
  107026. */
  107027. setDepthFunctionToGreaterOrEqual(): void;
  107028. /**
  107029. * Sets the current depth function to LESS
  107030. */
  107031. setDepthFunctionToLess(): void;
  107032. /**
  107033. * Sets the current depth function to LEQUAL
  107034. */
  107035. setDepthFunctionToLessOrEqual(): void;
  107036. private _cachedStencilBuffer;
  107037. private _cachedStencilFunction;
  107038. private _cachedStencilMask;
  107039. private _cachedStencilOperationPass;
  107040. private _cachedStencilOperationFail;
  107041. private _cachedStencilOperationDepthFail;
  107042. private _cachedStencilReference;
  107043. /**
  107044. * Caches the the state of the stencil buffer
  107045. */
  107046. cacheStencilState(): void;
  107047. /**
  107048. * Restores the state of the stencil buffer
  107049. */
  107050. restoreStencilState(): void;
  107051. /**
  107052. * Directly set the WebGL Viewport
  107053. * @param x defines the x coordinate of the viewport (in screen space)
  107054. * @param y defines the y coordinate of the viewport (in screen space)
  107055. * @param width defines the width of the viewport (in screen space)
  107056. * @param height defines the height of the viewport (in screen space)
  107057. * @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
  107058. */
  107059. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  107060. /**
  107061. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  107062. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107063. * @param y defines the y-coordinate of the corner of the clear rectangle
  107064. * @param width defines the width of the clear rectangle
  107065. * @param height defines the height of the clear rectangle
  107066. * @param clearColor defines the clear color
  107067. */
  107068. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  107069. /**
  107070. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  107071. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107072. * @param y defines the y-coordinate of the corner of the clear rectangle
  107073. * @param width defines the width of the clear rectangle
  107074. * @param height defines the height of the clear rectangle
  107075. */
  107076. enableScissor(x: number, y: number, width: number, height: number): void;
  107077. /**
  107078. * Disable previously set scissor test rectangle
  107079. */
  107080. disableScissor(): void;
  107081. protected _reportDrawCall(): void;
  107082. /**
  107083. * Initializes a webVR display and starts listening to display change events
  107084. * The onVRDisplayChangedObservable will be notified upon these changes
  107085. * @returns The onVRDisplayChangedObservable
  107086. */
  107087. initWebVR(): Observable<IDisplayChangedEventArgs>;
  107088. /** @hidden */
  107089. _prepareVRComponent(): void;
  107090. /** @hidden */
  107091. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  107092. /** @hidden */
  107093. _submitVRFrame(): void;
  107094. /**
  107095. * Call this function to leave webVR mode
  107096. * Will do nothing if webVR is not supported or if there is no webVR device
  107097. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107098. */
  107099. disableVR(): void;
  107100. /**
  107101. * Gets a boolean indicating that the system is in VR mode and is presenting
  107102. * @returns true if VR mode is engaged
  107103. */
  107104. isVRPresenting(): boolean;
  107105. /** @hidden */
  107106. _requestVRFrame(): void;
  107107. /** @hidden */
  107108. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107109. /**
  107110. * Gets the source code of the vertex shader associated with a specific webGL program
  107111. * @param program defines the program to use
  107112. * @returns a string containing the source code of the vertex shader associated with the program
  107113. */
  107114. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107115. /**
  107116. * Gets the source code of the fragment shader associated with a specific webGL program
  107117. * @param program defines the program to use
  107118. * @returns a string containing the source code of the fragment shader associated with the program
  107119. */
  107120. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107121. /**
  107122. * Sets a depth stencil texture from a render target to the according uniform.
  107123. * @param channel The texture channel
  107124. * @param uniform The uniform to set
  107125. * @param texture The render target texture containing the depth stencil texture to apply
  107126. */
  107127. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107128. /**
  107129. * Sets a texture to the webGL context from a postprocess
  107130. * @param channel defines the channel to use
  107131. * @param postProcess defines the source postprocess
  107132. */
  107133. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107134. /**
  107135. * Binds the output of the passed in post process to the texture channel specified
  107136. * @param channel The channel the texture should be bound to
  107137. * @param postProcess The post process which's output should be bound
  107138. */
  107139. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107140. /** @hidden */
  107141. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107142. protected _rebuildBuffers(): void;
  107143. /** @hidden */
  107144. _renderFrame(): void;
  107145. _renderLoop(): void;
  107146. /** @hidden */
  107147. _renderViews(): boolean;
  107148. /**
  107149. * Toggle full screen mode
  107150. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107151. */
  107152. switchFullscreen(requestPointerLock: boolean): void;
  107153. /**
  107154. * Enters full screen mode
  107155. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107156. */
  107157. enterFullscreen(requestPointerLock: boolean): void;
  107158. /**
  107159. * Exits full screen mode
  107160. */
  107161. exitFullscreen(): void;
  107162. /**
  107163. * Enters Pointerlock mode
  107164. */
  107165. enterPointerlock(): void;
  107166. /**
  107167. * Exits Pointerlock mode
  107168. */
  107169. exitPointerlock(): void;
  107170. /**
  107171. * Begin a new frame
  107172. */
  107173. beginFrame(): void;
  107174. /**
  107175. * Enf the current frame
  107176. */
  107177. endFrame(): void;
  107178. resize(): void;
  107179. /**
  107180. * Force a specific size of the canvas
  107181. * @param width defines the new canvas' width
  107182. * @param height defines the new canvas' height
  107183. */
  107184. setSize(width: number, height: number): void;
  107185. /**
  107186. * Updates a dynamic vertex buffer.
  107187. * @param vertexBuffer the vertex buffer to update
  107188. * @param data the data used to update the vertex buffer
  107189. * @param byteOffset the byte offset of the data
  107190. * @param byteLength the byte length of the data
  107191. */
  107192. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107193. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107194. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107195. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107196. _releaseTexture(texture: InternalTexture): void;
  107197. /**
  107198. * @hidden
  107199. * Rescales a texture
  107200. * @param source input texutre
  107201. * @param destination destination texture
  107202. * @param scene scene to use to render the resize
  107203. * @param internalFormat format to use when resizing
  107204. * @param onComplete callback to be called when resize has completed
  107205. */
  107206. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107207. /**
  107208. * Gets the current framerate
  107209. * @returns a number representing the framerate
  107210. */
  107211. getFps(): number;
  107212. /**
  107213. * Gets the time spent between current and previous frame
  107214. * @returns a number representing the delta time in ms
  107215. */
  107216. getDeltaTime(): number;
  107217. private _measureFps;
  107218. /** @hidden */
  107219. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107220. /**
  107221. * Update a dynamic index buffer
  107222. * @param indexBuffer defines the target index buffer
  107223. * @param indices defines the data to update
  107224. * @param offset defines the offset in the target index buffer where update should start
  107225. */
  107226. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107227. /**
  107228. * Updates the sample count of a render target texture
  107229. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107230. * @param texture defines the texture to update
  107231. * @param samples defines the sample count to set
  107232. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107233. */
  107234. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107235. /**
  107236. * Updates a depth texture Comparison Mode and Function.
  107237. * If the comparison Function is equal to 0, the mode will be set to none.
  107238. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107239. * @param texture The texture to set the comparison function for
  107240. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107241. */
  107242. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107243. /**
  107244. * Creates a webGL buffer to use with instanciation
  107245. * @param capacity defines the size of the buffer
  107246. * @returns the webGL buffer
  107247. */
  107248. createInstancesBuffer(capacity: number): DataBuffer;
  107249. /**
  107250. * Delete a webGL buffer used with instanciation
  107251. * @param buffer defines the webGL buffer to delete
  107252. */
  107253. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107254. private _clientWaitAsync;
  107255. /** @hidden */
  107256. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107257. /** @hidden */
  107258. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107259. dispose(): void;
  107260. private _disableTouchAction;
  107261. /**
  107262. * Display the loading screen
  107263. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107264. */
  107265. displayLoadingUI(): void;
  107266. /**
  107267. * Hide the loading screen
  107268. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107269. */
  107270. hideLoadingUI(): void;
  107271. /**
  107272. * Gets the current loading screen object
  107273. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107274. */
  107275. get loadingScreen(): ILoadingScreen;
  107276. /**
  107277. * Sets the current loading screen object
  107278. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107279. */
  107280. set loadingScreen(loadingScreen: ILoadingScreen);
  107281. /**
  107282. * Sets the current loading screen text
  107283. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107284. */
  107285. set loadingUIText(text: string);
  107286. /**
  107287. * Sets the current loading screen background color
  107288. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107289. */
  107290. set loadingUIBackgroundColor(color: string);
  107291. /** Pointerlock and fullscreen */
  107292. /**
  107293. * Ask the browser to promote the current element to pointerlock mode
  107294. * @param element defines the DOM element to promote
  107295. */
  107296. static _RequestPointerlock(element: HTMLElement): void;
  107297. /**
  107298. * Asks the browser to exit pointerlock mode
  107299. */
  107300. static _ExitPointerlock(): void;
  107301. /**
  107302. * Ask the browser to promote the current element to fullscreen rendering mode
  107303. * @param element defines the DOM element to promote
  107304. */
  107305. static _RequestFullscreen(element: HTMLElement): void;
  107306. /**
  107307. * Asks the browser to exit fullscreen mode
  107308. */
  107309. static _ExitFullscreen(): void;
  107310. }
  107311. }
  107312. declare module BABYLON {
  107313. /**
  107314. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107315. * during the life time of the application.
  107316. */
  107317. export class EngineStore {
  107318. /** Gets the list of created engines */
  107319. static Instances: Engine[];
  107320. /** @hidden */
  107321. static _LastCreatedScene: Nullable<Scene>;
  107322. /**
  107323. * Gets the latest created engine
  107324. */
  107325. static get LastCreatedEngine(): Nullable<Engine>;
  107326. /**
  107327. * Gets the latest created scene
  107328. */
  107329. static get LastCreatedScene(): Nullable<Scene>;
  107330. /**
  107331. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107332. * @ignorenaming
  107333. */
  107334. static UseFallbackTexture: boolean;
  107335. /**
  107336. * Texture content used if a texture cannot loaded
  107337. * @ignorenaming
  107338. */
  107339. static FallbackTexture: string;
  107340. }
  107341. }
  107342. declare module BABYLON {
  107343. /**
  107344. * Helper class that provides a small promise polyfill
  107345. */
  107346. export class PromisePolyfill {
  107347. /**
  107348. * Static function used to check if the polyfill is required
  107349. * If this is the case then the function will inject the polyfill to window.Promise
  107350. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107351. */
  107352. static Apply(force?: boolean): void;
  107353. }
  107354. }
  107355. declare module BABYLON {
  107356. /**
  107357. * Interface for screenshot methods with describe argument called `size` as object with options
  107358. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107359. */
  107360. export interface IScreenshotSize {
  107361. /**
  107362. * number in pixels for canvas height
  107363. */
  107364. height?: number;
  107365. /**
  107366. * multiplier allowing render at a higher or lower resolution
  107367. * If value is defined then height and width will be ignored and taken from camera
  107368. */
  107369. precision?: number;
  107370. /**
  107371. * number in pixels for canvas width
  107372. */
  107373. width?: number;
  107374. }
  107375. }
  107376. declare module BABYLON {
  107377. interface IColor4Like {
  107378. r: float;
  107379. g: float;
  107380. b: float;
  107381. a: float;
  107382. }
  107383. /**
  107384. * Class containing a set of static utilities functions
  107385. */
  107386. export class Tools {
  107387. /**
  107388. * Gets or sets the base URL to use to load assets
  107389. */
  107390. static get BaseUrl(): string;
  107391. static set BaseUrl(value: string);
  107392. /**
  107393. * Enable/Disable Custom HTTP Request Headers globally.
  107394. * default = false
  107395. * @see CustomRequestHeaders
  107396. */
  107397. static UseCustomRequestHeaders: boolean;
  107398. /**
  107399. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107400. * i.e. when loading files, where the server/service expects an Authorization header
  107401. */
  107402. static CustomRequestHeaders: {
  107403. [key: string]: string;
  107404. };
  107405. /**
  107406. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107407. */
  107408. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107409. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107410. /**
  107411. * Default behaviour for cors in the application.
  107412. * It can be a string if the expected behavior is identical in the entire app.
  107413. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107414. */
  107415. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107416. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107417. /**
  107418. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107419. * @ignorenaming
  107420. */
  107421. static get UseFallbackTexture(): boolean;
  107422. static set UseFallbackTexture(value: boolean);
  107423. /**
  107424. * Use this object to register external classes like custom textures or material
  107425. * to allow the laoders to instantiate them
  107426. */
  107427. static get RegisteredExternalClasses(): {
  107428. [key: string]: Object;
  107429. };
  107430. static set RegisteredExternalClasses(classes: {
  107431. [key: string]: Object;
  107432. });
  107433. /**
  107434. * Texture content used if a texture cannot loaded
  107435. * @ignorenaming
  107436. */
  107437. static get fallbackTexture(): string;
  107438. static set fallbackTexture(value: string);
  107439. /**
  107440. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107441. * @param u defines the coordinate on X axis
  107442. * @param v defines the coordinate on Y axis
  107443. * @param width defines the width of the source data
  107444. * @param height defines the height of the source data
  107445. * @param pixels defines the source byte array
  107446. * @param color defines the output color
  107447. */
  107448. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107449. /**
  107450. * Interpolates between a and b via alpha
  107451. * @param a The lower value (returned when alpha = 0)
  107452. * @param b The upper value (returned when alpha = 1)
  107453. * @param alpha The interpolation-factor
  107454. * @return The mixed value
  107455. */
  107456. static Mix(a: number, b: number, alpha: number): number;
  107457. /**
  107458. * Tries to instantiate a new object from a given class name
  107459. * @param className defines the class name to instantiate
  107460. * @returns the new object or null if the system was not able to do the instantiation
  107461. */
  107462. static Instantiate(className: string): any;
  107463. /**
  107464. * Provides a slice function that will work even on IE
  107465. * @param data defines the array to slice
  107466. * @param start defines the start of the data (optional)
  107467. * @param end defines the end of the data (optional)
  107468. * @returns the new sliced array
  107469. */
  107470. static Slice<T>(data: T, start?: number, end?: number): T;
  107471. /**
  107472. * Polyfill for setImmediate
  107473. * @param action defines the action to execute after the current execution block
  107474. */
  107475. static SetImmediate(action: () => void): void;
  107476. /**
  107477. * Function indicating if a number is an exponent of 2
  107478. * @param value defines the value to test
  107479. * @returns true if the value is an exponent of 2
  107480. */
  107481. static IsExponentOfTwo(value: number): boolean;
  107482. private static _tmpFloatArray;
  107483. /**
  107484. * Returns the nearest 32-bit single precision float representation of a Number
  107485. * @param value A Number. If the parameter is of a different type, it will get converted
  107486. * to a number or to NaN if it cannot be converted
  107487. * @returns number
  107488. */
  107489. static FloatRound(value: number): number;
  107490. /**
  107491. * Extracts the filename from a path
  107492. * @param path defines the path to use
  107493. * @returns the filename
  107494. */
  107495. static GetFilename(path: string): string;
  107496. /**
  107497. * Extracts the "folder" part of a path (everything before the filename).
  107498. * @param uri The URI to extract the info from
  107499. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107500. * @returns The "folder" part of the path
  107501. */
  107502. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107503. /**
  107504. * Extracts text content from a DOM element hierarchy
  107505. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107506. */
  107507. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107508. /**
  107509. * Convert an angle in radians to degrees
  107510. * @param angle defines the angle to convert
  107511. * @returns the angle in degrees
  107512. */
  107513. static ToDegrees(angle: number): number;
  107514. /**
  107515. * Convert an angle in degrees to radians
  107516. * @param angle defines the angle to convert
  107517. * @returns the angle in radians
  107518. */
  107519. static ToRadians(angle: number): number;
  107520. /**
  107521. * Returns an array if obj is not an array
  107522. * @param obj defines the object to evaluate as an array
  107523. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107524. * @returns either obj directly if obj is an array or a new array containing obj
  107525. */
  107526. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107527. /**
  107528. * Gets the pointer prefix to use
  107529. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107530. */
  107531. static GetPointerPrefix(): string;
  107532. /**
  107533. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107534. * @param url define the url we are trying
  107535. * @param element define the dom element where to configure the cors policy
  107536. */
  107537. static SetCorsBehavior(url: string | string[], element: {
  107538. crossOrigin: string | null;
  107539. }): void;
  107540. /**
  107541. * Removes unwanted characters from an url
  107542. * @param url defines the url to clean
  107543. * @returns the cleaned url
  107544. */
  107545. static CleanUrl(url: string): string;
  107546. /**
  107547. * Gets or sets a function used to pre-process url before using them to load assets
  107548. */
  107549. static get PreprocessUrl(): (url: string) => string;
  107550. static set PreprocessUrl(processor: (url: string) => string);
  107551. /**
  107552. * Loads an image as an HTMLImageElement.
  107553. * @param input url string, ArrayBuffer, or Blob to load
  107554. * @param onLoad callback called when the image successfully loads
  107555. * @param onError callback called when the image fails to load
  107556. * @param offlineProvider offline provider for caching
  107557. * @param mimeType optional mime type
  107558. * @returns the HTMLImageElement of the loaded image
  107559. */
  107560. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107561. /**
  107562. * Loads a file from a url
  107563. * @param url url string, ArrayBuffer, or Blob to load
  107564. * @param onSuccess callback called when the file successfully loads
  107565. * @param onProgress callback called while file is loading (if the server supports this mode)
  107566. * @param offlineProvider defines the offline provider for caching
  107567. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107568. * @param onError callback called when the file fails to load
  107569. * @returns a file request object
  107570. */
  107571. 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;
  107572. /**
  107573. * Loads a file from a url
  107574. * @param url the file url to load
  107575. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107576. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107577. */
  107578. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107579. /**
  107580. * Load a script (identified by an url). When the url returns, the
  107581. * content of this file is added into a new script element, attached to the DOM (body element)
  107582. * @param scriptUrl defines the url of the script to laod
  107583. * @param onSuccess defines the callback called when the script is loaded
  107584. * @param onError defines the callback to call if an error occurs
  107585. * @param scriptId defines the id of the script element
  107586. */
  107587. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107588. /**
  107589. * Load an asynchronous script (identified by an url). When the url returns, the
  107590. * content of this file is added into a new script element, attached to the DOM (body element)
  107591. * @param scriptUrl defines the url of the script to laod
  107592. * @param scriptId defines the id of the script element
  107593. * @returns a promise request object
  107594. */
  107595. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107596. /**
  107597. * Loads a file from a blob
  107598. * @param fileToLoad defines the blob to use
  107599. * @param callback defines the callback to call when data is loaded
  107600. * @param progressCallback defines the callback to call during loading process
  107601. * @returns a file request object
  107602. */
  107603. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107604. /**
  107605. * Reads a file from a File object
  107606. * @param file defines the file to load
  107607. * @param onSuccess defines the callback to call when data is loaded
  107608. * @param onProgress defines the callback to call during loading process
  107609. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107610. * @param onError defines the callback to call when an error occurs
  107611. * @returns a file request object
  107612. */
  107613. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107614. /**
  107615. * Creates a data url from a given string content
  107616. * @param content defines the content to convert
  107617. * @returns the new data url link
  107618. */
  107619. static FileAsURL(content: string): string;
  107620. /**
  107621. * Format the given number to a specific decimal format
  107622. * @param value defines the number to format
  107623. * @param decimals defines the number of decimals to use
  107624. * @returns the formatted string
  107625. */
  107626. static Format(value: number, decimals?: number): string;
  107627. /**
  107628. * Tries to copy an object by duplicating every property
  107629. * @param source defines the source object
  107630. * @param destination defines the target object
  107631. * @param doNotCopyList defines a list of properties to avoid
  107632. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107633. */
  107634. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107635. /**
  107636. * Gets a boolean indicating if the given object has no own property
  107637. * @param obj defines the object to test
  107638. * @returns true if object has no own property
  107639. */
  107640. static IsEmpty(obj: any): boolean;
  107641. /**
  107642. * Function used to register events at window level
  107643. * @param windowElement defines the Window object to use
  107644. * @param events defines the events to register
  107645. */
  107646. static RegisterTopRootEvents(windowElement: Window, events: {
  107647. name: string;
  107648. handler: Nullable<(e: FocusEvent) => any>;
  107649. }[]): void;
  107650. /**
  107651. * Function used to unregister events from window level
  107652. * @param windowElement defines the Window object to use
  107653. * @param events defines the events to unregister
  107654. */
  107655. static UnregisterTopRootEvents(windowElement: Window, events: {
  107656. name: string;
  107657. handler: Nullable<(e: FocusEvent) => any>;
  107658. }[]): void;
  107659. /**
  107660. * @ignore
  107661. */
  107662. static _ScreenshotCanvas: HTMLCanvasElement;
  107663. /**
  107664. * Dumps the current bound framebuffer
  107665. * @param width defines the rendering width
  107666. * @param height defines the rendering height
  107667. * @param engine defines the hosting engine
  107668. * @param successCallback defines the callback triggered once the data are available
  107669. * @param mimeType defines the mime type of the result
  107670. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107671. */
  107672. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107673. /**
  107674. * Converts the canvas data to blob.
  107675. * This acts as a polyfill for browsers not supporting the to blob function.
  107676. * @param canvas Defines the canvas to extract the data from
  107677. * @param successCallback Defines the callback triggered once the data are available
  107678. * @param mimeType Defines the mime type of the result
  107679. */
  107680. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107681. /**
  107682. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107683. * @param successCallback defines the callback triggered once the data are available
  107684. * @param mimeType defines the mime type of the result
  107685. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107686. */
  107687. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107688. /**
  107689. * Downloads a blob in the browser
  107690. * @param blob defines the blob to download
  107691. * @param fileName defines the name of the downloaded file
  107692. */
  107693. static Download(blob: Blob, fileName: string): void;
  107694. /**
  107695. * Captures a screenshot of the current rendering
  107696. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107697. * @param engine defines the rendering engine
  107698. * @param camera defines the source camera
  107699. * @param size This parameter can be set to a single number or to an object with the
  107700. * following (optional) properties: precision, width, height. If a single number is passed,
  107701. * it will be used for both width and height. If an object is passed, the screenshot size
  107702. * will be derived from the parameters. The precision property is a multiplier allowing
  107703. * rendering at a higher or lower resolution
  107704. * @param successCallback defines the callback receives a single parameter which contains the
  107705. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107706. * src parameter of an <img> to display it
  107707. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107708. * Check your browser for supported MIME types
  107709. */
  107710. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107711. /**
  107712. * Captures a screenshot of the current rendering
  107713. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107714. * @param engine defines the rendering engine
  107715. * @param camera defines the source camera
  107716. * @param size This parameter can be set to a single number or to an object with the
  107717. * following (optional) properties: precision, width, height. If a single number is passed,
  107718. * it will be used for both width and height. If an object is passed, the screenshot size
  107719. * will be derived from the parameters. The precision property is a multiplier allowing
  107720. * rendering at a higher or lower resolution
  107721. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107722. * Check your browser for supported MIME types
  107723. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107724. * to the src parameter of an <img> to display it
  107725. */
  107726. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107727. /**
  107728. * Generates an image screenshot from the specified camera.
  107729. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107730. * @param engine The engine to use for rendering
  107731. * @param camera The camera to use for rendering
  107732. * @param size This parameter can be set to a single number or to an object with the
  107733. * following (optional) properties: precision, width, height. If a single number is passed,
  107734. * it will be used for both width and height. If an object is passed, the screenshot size
  107735. * will be derived from the parameters. The precision property is a multiplier allowing
  107736. * rendering at a higher or lower resolution
  107737. * @param successCallback The callback receives a single parameter which contains the
  107738. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107739. * src parameter of an <img> to display it
  107740. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107741. * Check your browser for supported MIME types
  107742. * @param samples Texture samples (default: 1)
  107743. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107744. * @param fileName A name for for the downloaded file.
  107745. */
  107746. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107747. /**
  107748. * Generates an image screenshot from the specified camera.
  107749. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107750. * @param engine The engine to use for rendering
  107751. * @param camera The camera to use for rendering
  107752. * @param size This parameter can be set to a single number or to an object with the
  107753. * following (optional) properties: precision, width, height. If a single number is passed,
  107754. * it will be used for both width and height. If an object is passed, the screenshot size
  107755. * will be derived from the parameters. The precision property is a multiplier allowing
  107756. * rendering at a higher or lower resolution
  107757. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107758. * Check your browser for supported MIME types
  107759. * @param samples Texture samples (default: 1)
  107760. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107761. * @param fileName A name for for the downloaded file.
  107762. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107763. * to the src parameter of an <img> to display it
  107764. */
  107765. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107766. /**
  107767. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107768. * Be aware Math.random() could cause collisions, but:
  107769. * "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"
  107770. * @returns a pseudo random id
  107771. */
  107772. static RandomId(): string;
  107773. /**
  107774. * Test if the given uri is a base64 string
  107775. * @param uri The uri to test
  107776. * @return True if the uri is a base64 string or false otherwise
  107777. */
  107778. static IsBase64(uri: string): boolean;
  107779. /**
  107780. * Decode the given base64 uri.
  107781. * @param uri The uri to decode
  107782. * @return The decoded base64 data.
  107783. */
  107784. static DecodeBase64(uri: string): ArrayBuffer;
  107785. /**
  107786. * Gets the absolute url.
  107787. * @param url the input url
  107788. * @return the absolute url
  107789. */
  107790. static GetAbsoluteUrl(url: string): string;
  107791. /**
  107792. * No log
  107793. */
  107794. static readonly NoneLogLevel: number;
  107795. /**
  107796. * Only message logs
  107797. */
  107798. static readonly MessageLogLevel: number;
  107799. /**
  107800. * Only warning logs
  107801. */
  107802. static readonly WarningLogLevel: number;
  107803. /**
  107804. * Only error logs
  107805. */
  107806. static readonly ErrorLogLevel: number;
  107807. /**
  107808. * All logs
  107809. */
  107810. static readonly AllLogLevel: number;
  107811. /**
  107812. * Gets a value indicating the number of loading errors
  107813. * @ignorenaming
  107814. */
  107815. static get errorsCount(): number;
  107816. /**
  107817. * Callback called when a new log is added
  107818. */
  107819. static OnNewCacheEntry: (entry: string) => void;
  107820. /**
  107821. * Log a message to the console
  107822. * @param message defines the message to log
  107823. */
  107824. static Log(message: string): void;
  107825. /**
  107826. * Write a warning message to the console
  107827. * @param message defines the message to log
  107828. */
  107829. static Warn(message: string): void;
  107830. /**
  107831. * Write an error message to the console
  107832. * @param message defines the message to log
  107833. */
  107834. static Error(message: string): void;
  107835. /**
  107836. * Gets current log cache (list of logs)
  107837. */
  107838. static get LogCache(): string;
  107839. /**
  107840. * Clears the log cache
  107841. */
  107842. static ClearLogCache(): void;
  107843. /**
  107844. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107845. */
  107846. static set LogLevels(level: number);
  107847. /**
  107848. * Checks if the window object exists
  107849. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107850. */
  107851. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107852. /**
  107853. * No performance log
  107854. */
  107855. static readonly PerformanceNoneLogLevel: number;
  107856. /**
  107857. * Use user marks to log performance
  107858. */
  107859. static readonly PerformanceUserMarkLogLevel: number;
  107860. /**
  107861. * Log performance to the console
  107862. */
  107863. static readonly PerformanceConsoleLogLevel: number;
  107864. private static _performance;
  107865. /**
  107866. * Sets the current performance log level
  107867. */
  107868. static set PerformanceLogLevel(level: number);
  107869. private static _StartPerformanceCounterDisabled;
  107870. private static _EndPerformanceCounterDisabled;
  107871. private static _StartUserMark;
  107872. private static _EndUserMark;
  107873. private static _StartPerformanceConsole;
  107874. private static _EndPerformanceConsole;
  107875. /**
  107876. * Starts a performance counter
  107877. */
  107878. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107879. /**
  107880. * Ends a specific performance coutner
  107881. */
  107882. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107883. /**
  107884. * Gets either window.performance.now() if supported or Date.now() else
  107885. */
  107886. static get Now(): number;
  107887. /**
  107888. * This method will return the name of the class used to create the instance of the given object.
  107889. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107890. * @param object the object to get the class name from
  107891. * @param isType defines if the object is actually a type
  107892. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107893. */
  107894. static GetClassName(object: any, isType?: boolean): string;
  107895. /**
  107896. * Gets the first element of an array satisfying a given predicate
  107897. * @param array defines the array to browse
  107898. * @param predicate defines the predicate to use
  107899. * @returns null if not found or the element
  107900. */
  107901. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107902. /**
  107903. * This method will return the name of the full name of the class, including its owning module (if any).
  107904. * 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).
  107905. * @param object the object to get the class name from
  107906. * @param isType defines if the object is actually a type
  107907. * @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.
  107908. * @ignorenaming
  107909. */
  107910. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107911. /**
  107912. * Returns a promise that resolves after the given amount of time.
  107913. * @param delay Number of milliseconds to delay
  107914. * @returns Promise that resolves after the given amount of time
  107915. */
  107916. static DelayAsync(delay: number): Promise<void>;
  107917. /**
  107918. * Utility function to detect if the current user agent is Safari
  107919. * @returns whether or not the current user agent is safari
  107920. */
  107921. static IsSafari(): boolean;
  107922. }
  107923. /**
  107924. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107925. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107926. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107927. * @param name The name of the class, case should be preserved
  107928. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107929. */
  107930. export function className(name: string, module?: string): (target: Object) => void;
  107931. /**
  107932. * An implementation of a loop for asynchronous functions.
  107933. */
  107934. export class AsyncLoop {
  107935. /**
  107936. * Defines the number of iterations for the loop
  107937. */
  107938. iterations: number;
  107939. /**
  107940. * Defines the current index of the loop.
  107941. */
  107942. index: number;
  107943. private _done;
  107944. private _fn;
  107945. private _successCallback;
  107946. /**
  107947. * Constructor.
  107948. * @param iterations the number of iterations.
  107949. * @param func the function to run each iteration
  107950. * @param successCallback the callback that will be called upon succesful execution
  107951. * @param offset starting offset.
  107952. */
  107953. constructor(
  107954. /**
  107955. * Defines the number of iterations for the loop
  107956. */
  107957. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107958. /**
  107959. * Execute the next iteration. Must be called after the last iteration was finished.
  107960. */
  107961. executeNext(): void;
  107962. /**
  107963. * Break the loop and run the success callback.
  107964. */
  107965. breakLoop(): void;
  107966. /**
  107967. * Create and run an async loop.
  107968. * @param iterations the number of iterations.
  107969. * @param fn the function to run each iteration
  107970. * @param successCallback the callback that will be called upon succesful execution
  107971. * @param offset starting offset.
  107972. * @returns the created async loop object
  107973. */
  107974. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107975. /**
  107976. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107977. * @param iterations total number of iterations
  107978. * @param syncedIterations number of synchronous iterations in each async iteration.
  107979. * @param fn the function to call each iteration.
  107980. * @param callback a success call back that will be called when iterating stops.
  107981. * @param breakFunction a break condition (optional)
  107982. * @param timeout timeout settings for the setTimeout function. default - 0.
  107983. * @returns the created async loop object
  107984. */
  107985. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107986. }
  107987. }
  107988. declare module BABYLON {
  107989. /**
  107990. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107991. * The underlying implementation relies on an associative array to ensure the best performances.
  107992. * The value can be anything including 'null' but except 'undefined'
  107993. */
  107994. export class StringDictionary<T> {
  107995. /**
  107996. * This will clear this dictionary and copy the content from the 'source' one.
  107997. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107998. * @param source the dictionary to take the content from and copy to this dictionary
  107999. */
  108000. copyFrom(source: StringDictionary<T>): void;
  108001. /**
  108002. * Get a value based from its key
  108003. * @param key the given key to get the matching value from
  108004. * @return the value if found, otherwise undefined is returned
  108005. */
  108006. get(key: string): T | undefined;
  108007. /**
  108008. * Get a value from its key or add it if it doesn't exist.
  108009. * This method will ensure you that a given key/data will be present in the dictionary.
  108010. * @param key the given key to get the matching value from
  108011. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108012. * The factory will only be invoked if there's no data for the given key.
  108013. * @return the value corresponding to the key.
  108014. */
  108015. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108016. /**
  108017. * Get a value from its key if present in the dictionary otherwise add it
  108018. * @param key the key to get the value from
  108019. * @param val if there's no such key/value pair in the dictionary add it with this value
  108020. * @return the value corresponding to the key
  108021. */
  108022. getOrAdd(key: string, val: T): T;
  108023. /**
  108024. * Check if there's a given key in the dictionary
  108025. * @param key the key to check for
  108026. * @return true if the key is present, false otherwise
  108027. */
  108028. contains(key: string): boolean;
  108029. /**
  108030. * Add a new key and its corresponding value
  108031. * @param key the key to add
  108032. * @param value the value corresponding to the key
  108033. * @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
  108034. */
  108035. add(key: string, value: T): boolean;
  108036. /**
  108037. * Update a specific value associated to a key
  108038. * @param key defines the key to use
  108039. * @param value defines the value to store
  108040. * @returns true if the value was updated (or false if the key was not found)
  108041. */
  108042. set(key: string, value: T): boolean;
  108043. /**
  108044. * Get the element of the given key and remove it from the dictionary
  108045. * @param key defines the key to search
  108046. * @returns the value associated with the key or null if not found
  108047. */
  108048. getAndRemove(key: string): Nullable<T>;
  108049. /**
  108050. * Remove a key/value from the dictionary.
  108051. * @param key the key to remove
  108052. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  108053. */
  108054. remove(key: string): boolean;
  108055. /**
  108056. * Clear the whole content of the dictionary
  108057. */
  108058. clear(): void;
  108059. /**
  108060. * Gets the current count
  108061. */
  108062. get count(): number;
  108063. /**
  108064. * Execute a callback on each key/val of the dictionary.
  108065. * Note that you can remove any element in this dictionary in the callback implementation
  108066. * @param callback the callback to execute on a given key/value pair
  108067. */
  108068. forEach(callback: (key: string, val: T) => void): void;
  108069. /**
  108070. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  108071. * If the callback returns null or undefined the method will iterate to the next key/value pair
  108072. * Note that you can remove any element in this dictionary in the callback implementation
  108073. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  108074. * @returns the first item
  108075. */
  108076. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  108077. private _count;
  108078. private _data;
  108079. }
  108080. }
  108081. declare module BABYLON {
  108082. /** @hidden */
  108083. export interface ICollisionCoordinator {
  108084. createCollider(): Collider;
  108085. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108086. init(scene: Scene): void;
  108087. }
  108088. /** @hidden */
  108089. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108090. private _scene;
  108091. private _scaledPosition;
  108092. private _scaledVelocity;
  108093. private _finalPosition;
  108094. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108095. createCollider(): Collider;
  108096. init(scene: Scene): void;
  108097. private _collideWithWorld;
  108098. }
  108099. }
  108100. declare module BABYLON {
  108101. /**
  108102. * Class used to manage all inputs for the scene.
  108103. */
  108104. export class InputManager {
  108105. /** The distance in pixel that you have to move to prevent some events */
  108106. static DragMovementThreshold: number;
  108107. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108108. static LongPressDelay: number;
  108109. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108110. static DoubleClickDelay: number;
  108111. /** If you need to check double click without raising a single click at first click, enable this flag */
  108112. static ExclusiveDoubleClickMode: boolean;
  108113. private _wheelEventName;
  108114. private _onPointerMove;
  108115. private _onPointerDown;
  108116. private _onPointerUp;
  108117. private _initClickEvent;
  108118. private _initActionManager;
  108119. private _delayedSimpleClick;
  108120. private _delayedSimpleClickTimeout;
  108121. private _previousDelayedSimpleClickTimeout;
  108122. private _meshPickProceed;
  108123. private _previousButtonPressed;
  108124. private _currentPickResult;
  108125. private _previousPickResult;
  108126. private _totalPointersPressed;
  108127. private _doubleClickOccured;
  108128. private _pointerOverMesh;
  108129. private _pickedDownMesh;
  108130. private _pickedUpMesh;
  108131. private _pointerX;
  108132. private _pointerY;
  108133. private _unTranslatedPointerX;
  108134. private _unTranslatedPointerY;
  108135. private _startingPointerPosition;
  108136. private _previousStartingPointerPosition;
  108137. private _startingPointerTime;
  108138. private _previousStartingPointerTime;
  108139. private _pointerCaptures;
  108140. private _onKeyDown;
  108141. private _onKeyUp;
  108142. private _onCanvasFocusObserver;
  108143. private _onCanvasBlurObserver;
  108144. private _scene;
  108145. /**
  108146. * Creates a new InputManager
  108147. * @param scene defines the hosting scene
  108148. */
  108149. constructor(scene: Scene);
  108150. /**
  108151. * Gets the mesh that is currently under the pointer
  108152. */
  108153. get meshUnderPointer(): Nullable<AbstractMesh>;
  108154. /**
  108155. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108156. */
  108157. get unTranslatedPointer(): Vector2;
  108158. /**
  108159. * Gets or sets the current on-screen X position of the pointer
  108160. */
  108161. get pointerX(): number;
  108162. set pointerX(value: number);
  108163. /**
  108164. * Gets or sets the current on-screen Y position of the pointer
  108165. */
  108166. get pointerY(): number;
  108167. set pointerY(value: number);
  108168. private _updatePointerPosition;
  108169. private _processPointerMove;
  108170. private _setRayOnPointerInfo;
  108171. private _checkPrePointerObservable;
  108172. /**
  108173. * Use this method to simulate a pointer move on a mesh
  108174. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108175. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108176. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108177. */
  108178. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108179. /**
  108180. * Use this method to simulate a pointer down on a mesh
  108181. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108182. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108183. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108184. */
  108185. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108186. private _processPointerDown;
  108187. /** @hidden */
  108188. _isPointerSwiping(): boolean;
  108189. /**
  108190. * Use this method to simulate a pointer up on a mesh
  108191. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108192. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108193. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108194. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108195. */
  108196. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108197. private _processPointerUp;
  108198. /**
  108199. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108200. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108201. * @returns true if the pointer was captured
  108202. */
  108203. isPointerCaptured(pointerId?: number): boolean;
  108204. /**
  108205. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108206. * @param attachUp defines if you want to attach events to pointerup
  108207. * @param attachDown defines if you want to attach events to pointerdown
  108208. * @param attachMove defines if you want to attach events to pointermove
  108209. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108210. */
  108211. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108212. /**
  108213. * Detaches all event handlers
  108214. */
  108215. detachControl(): void;
  108216. /**
  108217. * Force the value of meshUnderPointer
  108218. * @param mesh defines the mesh to use
  108219. */
  108220. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108221. /**
  108222. * Gets the mesh under the pointer
  108223. * @returns a Mesh or null if no mesh is under the pointer
  108224. */
  108225. getPointerOverMesh(): Nullable<AbstractMesh>;
  108226. }
  108227. }
  108228. declare module BABYLON {
  108229. /**
  108230. * Helper class used to generate session unique ID
  108231. */
  108232. export class UniqueIdGenerator {
  108233. private static _UniqueIdCounter;
  108234. /**
  108235. * Gets an unique (relatively to the current scene) Id
  108236. */
  108237. static get UniqueId(): number;
  108238. }
  108239. }
  108240. declare module BABYLON {
  108241. /**
  108242. * This class defines the direct association between an animation and a target
  108243. */
  108244. export class TargetedAnimation {
  108245. /**
  108246. * Animation to perform
  108247. */
  108248. animation: Animation;
  108249. /**
  108250. * Target to animate
  108251. */
  108252. target: any;
  108253. /**
  108254. * Serialize the object
  108255. * @returns the JSON object representing the current entity
  108256. */
  108257. serialize(): any;
  108258. }
  108259. /**
  108260. * Use this class to create coordinated animations on multiple targets
  108261. */
  108262. export class AnimationGroup implements IDisposable {
  108263. /** The name of the animation group */
  108264. name: string;
  108265. private _scene;
  108266. private _targetedAnimations;
  108267. private _animatables;
  108268. private _from;
  108269. private _to;
  108270. private _isStarted;
  108271. private _isPaused;
  108272. private _speedRatio;
  108273. private _loopAnimation;
  108274. /**
  108275. * Gets or sets the unique id of the node
  108276. */
  108277. uniqueId: number;
  108278. /**
  108279. * This observable will notify when one animation have ended
  108280. */
  108281. onAnimationEndObservable: Observable<TargetedAnimation>;
  108282. /**
  108283. * Observer raised when one animation loops
  108284. */
  108285. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108286. /**
  108287. * Observer raised when all animations have looped
  108288. */
  108289. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108290. /**
  108291. * This observable will notify when all animations have ended.
  108292. */
  108293. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108294. /**
  108295. * This observable will notify when all animations have paused.
  108296. */
  108297. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108298. /**
  108299. * This observable will notify when all animations are playing.
  108300. */
  108301. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108302. /**
  108303. * Gets the first frame
  108304. */
  108305. get from(): number;
  108306. /**
  108307. * Gets the last frame
  108308. */
  108309. get to(): number;
  108310. /**
  108311. * Define if the animations are started
  108312. */
  108313. get isStarted(): boolean;
  108314. /**
  108315. * Gets a value indicating that the current group is playing
  108316. */
  108317. get isPlaying(): boolean;
  108318. /**
  108319. * Gets or sets the speed ratio to use for all animations
  108320. */
  108321. get speedRatio(): number;
  108322. /**
  108323. * Gets or sets the speed ratio to use for all animations
  108324. */
  108325. set speedRatio(value: number);
  108326. /**
  108327. * Gets or sets if all animations should loop or not
  108328. */
  108329. get loopAnimation(): boolean;
  108330. set loopAnimation(value: boolean);
  108331. /**
  108332. * Gets the targeted animations for this animation group
  108333. */
  108334. get targetedAnimations(): Array<TargetedAnimation>;
  108335. /**
  108336. * returning the list of animatables controlled by this animation group.
  108337. */
  108338. get animatables(): Array<Animatable>;
  108339. /**
  108340. * Instantiates a new Animation Group.
  108341. * This helps managing several animations at once.
  108342. * @see http://doc.babylonjs.com/how_to/group
  108343. * @param name Defines the name of the group
  108344. * @param scene Defines the scene the group belongs to
  108345. */
  108346. constructor(
  108347. /** The name of the animation group */
  108348. name: string, scene?: Nullable<Scene>);
  108349. /**
  108350. * Add an animation (with its target) in the group
  108351. * @param animation defines the animation we want to add
  108352. * @param target defines the target of the animation
  108353. * @returns the TargetedAnimation object
  108354. */
  108355. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108356. /**
  108357. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108358. * It can add constant keys at begin or end
  108359. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108360. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108361. * @returns the animation group
  108362. */
  108363. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108364. private _animationLoopCount;
  108365. private _animationLoopFlags;
  108366. private _processLoop;
  108367. /**
  108368. * Start all animations on given targets
  108369. * @param loop defines if animations must loop
  108370. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108371. * @param from defines the from key (optional)
  108372. * @param to defines the to key (optional)
  108373. * @returns the current animation group
  108374. */
  108375. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108376. /**
  108377. * Pause all animations
  108378. * @returns the animation group
  108379. */
  108380. pause(): AnimationGroup;
  108381. /**
  108382. * Play all animations to initial state
  108383. * This function will start() the animations if they were not started or will restart() them if they were paused
  108384. * @param loop defines if animations must loop
  108385. * @returns the animation group
  108386. */
  108387. play(loop?: boolean): AnimationGroup;
  108388. /**
  108389. * Reset all animations to initial state
  108390. * @returns the animation group
  108391. */
  108392. reset(): AnimationGroup;
  108393. /**
  108394. * Restart animations from key 0
  108395. * @returns the animation group
  108396. */
  108397. restart(): AnimationGroup;
  108398. /**
  108399. * Stop all animations
  108400. * @returns the animation group
  108401. */
  108402. stop(): AnimationGroup;
  108403. /**
  108404. * Set animation weight for all animatables
  108405. * @param weight defines the weight to use
  108406. * @return the animationGroup
  108407. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108408. */
  108409. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108410. /**
  108411. * Synchronize and normalize all animatables with a source animatable
  108412. * @param root defines the root animatable to synchronize with
  108413. * @return the animationGroup
  108414. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108415. */
  108416. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108417. /**
  108418. * Goes to a specific frame in this animation group
  108419. * @param frame the frame number to go to
  108420. * @return the animationGroup
  108421. */
  108422. goToFrame(frame: number): AnimationGroup;
  108423. /**
  108424. * Dispose all associated resources
  108425. */
  108426. dispose(): void;
  108427. private _checkAnimationGroupEnded;
  108428. /**
  108429. * Clone the current animation group and returns a copy
  108430. * @param newName defines the name of the new group
  108431. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108432. * @returns the new aniamtion group
  108433. */
  108434. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108435. /**
  108436. * Serializes the animationGroup to an object
  108437. * @returns Serialized object
  108438. */
  108439. serialize(): any;
  108440. /**
  108441. * Returns a new AnimationGroup object parsed from the source provided.
  108442. * @param parsedAnimationGroup defines the source
  108443. * @param scene defines the scene that will receive the animationGroup
  108444. * @returns a new AnimationGroup
  108445. */
  108446. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108447. /**
  108448. * Returns the string "AnimationGroup"
  108449. * @returns "AnimationGroup"
  108450. */
  108451. getClassName(): string;
  108452. /**
  108453. * Creates a detailled string about the object
  108454. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108455. * @returns a string representing the object
  108456. */
  108457. toString(fullDetails?: boolean): string;
  108458. }
  108459. }
  108460. declare module BABYLON {
  108461. /**
  108462. * Define an interface for all classes that will hold resources
  108463. */
  108464. export interface IDisposable {
  108465. /**
  108466. * Releases all held resources
  108467. */
  108468. dispose(): void;
  108469. }
  108470. /** Interface defining initialization parameters for Scene class */
  108471. export interface SceneOptions {
  108472. /**
  108473. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108474. * It will improve performance when the number of geometries becomes important.
  108475. */
  108476. useGeometryUniqueIdsMap?: boolean;
  108477. /**
  108478. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108479. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108480. */
  108481. useMaterialMeshMap?: boolean;
  108482. /**
  108483. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108484. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108485. */
  108486. useClonedMeshMap?: boolean;
  108487. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108488. virtual?: boolean;
  108489. }
  108490. /**
  108491. * Represents a scene to be rendered by the engine.
  108492. * @see http://doc.babylonjs.com/features/scene
  108493. */
  108494. export class Scene extends AbstractScene implements IAnimatable {
  108495. /** The fog is deactivated */
  108496. static readonly FOGMODE_NONE: number;
  108497. /** The fog density is following an exponential function */
  108498. static readonly FOGMODE_EXP: number;
  108499. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108500. static readonly FOGMODE_EXP2: number;
  108501. /** The fog density is following a linear function. */
  108502. static readonly FOGMODE_LINEAR: number;
  108503. /**
  108504. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108506. */
  108507. static MinDeltaTime: number;
  108508. /**
  108509. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108510. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108511. */
  108512. static MaxDeltaTime: number;
  108513. /**
  108514. * Factory used to create the default material.
  108515. * @param name The name of the material to create
  108516. * @param scene The scene to create the material for
  108517. * @returns The default material
  108518. */
  108519. static DefaultMaterialFactory(scene: Scene): Material;
  108520. /**
  108521. * Factory used to create the a collision coordinator.
  108522. * @returns The collision coordinator
  108523. */
  108524. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108525. /** @hidden */
  108526. _inputManager: InputManager;
  108527. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108528. cameraToUseForPointers: Nullable<Camera>;
  108529. /** @hidden */
  108530. readonly _isScene: boolean;
  108531. /** @hidden */
  108532. _blockEntityCollection: boolean;
  108533. /**
  108534. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108535. */
  108536. autoClear: boolean;
  108537. /**
  108538. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108539. */
  108540. autoClearDepthAndStencil: boolean;
  108541. /**
  108542. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108543. */
  108544. clearColor: Color4;
  108545. /**
  108546. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108547. */
  108548. ambientColor: Color3;
  108549. /**
  108550. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108551. * It should only be one of the following (if not the default embedded one):
  108552. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108553. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108554. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108555. * The material properties need to be setup according to the type of texture in use.
  108556. */
  108557. environmentBRDFTexture: BaseTexture;
  108558. /** @hidden */
  108559. protected _environmentTexture: Nullable<BaseTexture>;
  108560. /**
  108561. * Texture used in all pbr material as the reflection texture.
  108562. * As in the majority of the scene they are the same (exception for multi room and so on),
  108563. * this is easier to reference from here than from all the materials.
  108564. */
  108565. get environmentTexture(): Nullable<BaseTexture>;
  108566. /**
  108567. * Texture used in all pbr material as the reflection texture.
  108568. * As in the majority of the scene they are the same (exception for multi room and so on),
  108569. * this is easier to set here than in all the materials.
  108570. */
  108571. set environmentTexture(value: Nullable<BaseTexture>);
  108572. /** @hidden */
  108573. protected _environmentIntensity: number;
  108574. /**
  108575. * Intensity of the environment in all pbr material.
  108576. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108577. * As in the majority of the scene they are the same (exception for multi room and so on),
  108578. * this is easier to reference from here than from all the materials.
  108579. */
  108580. get environmentIntensity(): number;
  108581. /**
  108582. * Intensity of the environment in all pbr material.
  108583. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108584. * As in the majority of the scene they are the same (exception for multi room and so on),
  108585. * this is easier to set here than in all the materials.
  108586. */
  108587. set environmentIntensity(value: number);
  108588. /** @hidden */
  108589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108590. /**
  108591. * Default image processing configuration used either in the rendering
  108592. * Forward main pass or through the imageProcessingPostProcess if present.
  108593. * As in the majority of the scene they are the same (exception for multi camera),
  108594. * this is easier to reference from here than from all the materials and post process.
  108595. *
  108596. * No setter as we it is a shared configuration, you can set the values instead.
  108597. */
  108598. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108599. private _forceWireframe;
  108600. /**
  108601. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108602. */
  108603. set forceWireframe(value: boolean);
  108604. get forceWireframe(): boolean;
  108605. private _skipFrustumClipping;
  108606. /**
  108607. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108608. */
  108609. set skipFrustumClipping(value: boolean);
  108610. get skipFrustumClipping(): boolean;
  108611. private _forcePointsCloud;
  108612. /**
  108613. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108614. */
  108615. set forcePointsCloud(value: boolean);
  108616. get forcePointsCloud(): boolean;
  108617. /**
  108618. * Gets or sets the active clipplane 1
  108619. */
  108620. clipPlane: Nullable<Plane>;
  108621. /**
  108622. * Gets or sets the active clipplane 2
  108623. */
  108624. clipPlane2: Nullable<Plane>;
  108625. /**
  108626. * Gets or sets the active clipplane 3
  108627. */
  108628. clipPlane3: Nullable<Plane>;
  108629. /**
  108630. * Gets or sets the active clipplane 4
  108631. */
  108632. clipPlane4: Nullable<Plane>;
  108633. /**
  108634. * Gets or sets the active clipplane 5
  108635. */
  108636. clipPlane5: Nullable<Plane>;
  108637. /**
  108638. * Gets or sets the active clipplane 6
  108639. */
  108640. clipPlane6: Nullable<Plane>;
  108641. /**
  108642. * Gets or sets a boolean indicating if animations are enabled
  108643. */
  108644. animationsEnabled: boolean;
  108645. private _animationPropertiesOverride;
  108646. /**
  108647. * Gets or sets the animation properties override
  108648. */
  108649. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108650. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108651. /**
  108652. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108653. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108654. */
  108655. useConstantAnimationDeltaTime: boolean;
  108656. /**
  108657. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108658. * Please note that it requires to run a ray cast through the scene on every frame
  108659. */
  108660. constantlyUpdateMeshUnderPointer: boolean;
  108661. /**
  108662. * Defines the HTML cursor to use when hovering over interactive elements
  108663. */
  108664. hoverCursor: string;
  108665. /**
  108666. * Defines the HTML default cursor to use (empty by default)
  108667. */
  108668. defaultCursor: string;
  108669. /**
  108670. * Defines whether cursors are handled by the scene.
  108671. */
  108672. doNotHandleCursors: boolean;
  108673. /**
  108674. * This is used to call preventDefault() on pointer down
  108675. * in order to block unwanted artifacts like system double clicks
  108676. */
  108677. preventDefaultOnPointerDown: boolean;
  108678. /**
  108679. * This is used to call preventDefault() on pointer up
  108680. * in order to block unwanted artifacts like system double clicks
  108681. */
  108682. preventDefaultOnPointerUp: boolean;
  108683. /**
  108684. * Gets or sets user defined metadata
  108685. */
  108686. metadata: any;
  108687. /**
  108688. * For internal use only. Please do not use.
  108689. */
  108690. reservedDataStore: any;
  108691. /**
  108692. * Gets the name of the plugin used to load this scene (null by default)
  108693. */
  108694. loadingPluginName: string;
  108695. /**
  108696. * Use this array to add regular expressions used to disable offline support for specific urls
  108697. */
  108698. disableOfflineSupportExceptionRules: RegExp[];
  108699. /**
  108700. * An event triggered when the scene is disposed.
  108701. */
  108702. onDisposeObservable: Observable<Scene>;
  108703. private _onDisposeObserver;
  108704. /** Sets a function to be executed when this scene is disposed. */
  108705. set onDispose(callback: () => void);
  108706. /**
  108707. * An event triggered before rendering the scene (right after animations and physics)
  108708. */
  108709. onBeforeRenderObservable: Observable<Scene>;
  108710. private _onBeforeRenderObserver;
  108711. /** Sets a function to be executed before rendering this scene */
  108712. set beforeRender(callback: Nullable<() => void>);
  108713. /**
  108714. * An event triggered after rendering the scene
  108715. */
  108716. onAfterRenderObservable: Observable<Scene>;
  108717. /**
  108718. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108719. */
  108720. onAfterRenderCameraObservable: Observable<Camera>;
  108721. private _onAfterRenderObserver;
  108722. /** Sets a function to be executed after rendering this scene */
  108723. set afterRender(callback: Nullable<() => void>);
  108724. /**
  108725. * An event triggered before animating the scene
  108726. */
  108727. onBeforeAnimationsObservable: Observable<Scene>;
  108728. /**
  108729. * An event triggered after animations processing
  108730. */
  108731. onAfterAnimationsObservable: Observable<Scene>;
  108732. /**
  108733. * An event triggered before draw calls are ready to be sent
  108734. */
  108735. onBeforeDrawPhaseObservable: Observable<Scene>;
  108736. /**
  108737. * An event triggered after draw calls have been sent
  108738. */
  108739. onAfterDrawPhaseObservable: Observable<Scene>;
  108740. /**
  108741. * An event triggered when the scene is ready
  108742. */
  108743. onReadyObservable: Observable<Scene>;
  108744. /**
  108745. * An event triggered before rendering a camera
  108746. */
  108747. onBeforeCameraRenderObservable: Observable<Camera>;
  108748. private _onBeforeCameraRenderObserver;
  108749. /** Sets a function to be executed before rendering a camera*/
  108750. set beforeCameraRender(callback: () => void);
  108751. /**
  108752. * An event triggered after rendering a camera
  108753. */
  108754. onAfterCameraRenderObservable: Observable<Camera>;
  108755. private _onAfterCameraRenderObserver;
  108756. /** Sets a function to be executed after rendering a camera*/
  108757. set afterCameraRender(callback: () => void);
  108758. /**
  108759. * An event triggered when active meshes evaluation is about to start
  108760. */
  108761. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108762. /**
  108763. * An event triggered when active meshes evaluation is done
  108764. */
  108765. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108766. /**
  108767. * An event triggered when particles rendering is about to start
  108768. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108769. */
  108770. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108771. /**
  108772. * An event triggered when particles rendering is done
  108773. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108774. */
  108775. onAfterParticlesRenderingObservable: Observable<Scene>;
  108776. /**
  108777. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108778. */
  108779. onDataLoadedObservable: Observable<Scene>;
  108780. /**
  108781. * An event triggered when a camera is created
  108782. */
  108783. onNewCameraAddedObservable: Observable<Camera>;
  108784. /**
  108785. * An event triggered when a camera is removed
  108786. */
  108787. onCameraRemovedObservable: Observable<Camera>;
  108788. /**
  108789. * An event triggered when a light is created
  108790. */
  108791. onNewLightAddedObservable: Observable<Light>;
  108792. /**
  108793. * An event triggered when a light is removed
  108794. */
  108795. onLightRemovedObservable: Observable<Light>;
  108796. /**
  108797. * An event triggered when a geometry is created
  108798. */
  108799. onNewGeometryAddedObservable: Observable<Geometry>;
  108800. /**
  108801. * An event triggered when a geometry is removed
  108802. */
  108803. onGeometryRemovedObservable: Observable<Geometry>;
  108804. /**
  108805. * An event triggered when a transform node is created
  108806. */
  108807. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108808. /**
  108809. * An event triggered when a transform node is removed
  108810. */
  108811. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108812. /**
  108813. * An event triggered when a mesh is created
  108814. */
  108815. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108816. /**
  108817. * An event triggered when a mesh is removed
  108818. */
  108819. onMeshRemovedObservable: Observable<AbstractMesh>;
  108820. /**
  108821. * An event triggered when a skeleton is created
  108822. */
  108823. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108824. /**
  108825. * An event triggered when a skeleton is removed
  108826. */
  108827. onSkeletonRemovedObservable: Observable<Skeleton>;
  108828. /**
  108829. * An event triggered when a material is created
  108830. */
  108831. onNewMaterialAddedObservable: Observable<Material>;
  108832. /**
  108833. * An event triggered when a material is removed
  108834. */
  108835. onMaterialRemovedObservable: Observable<Material>;
  108836. /**
  108837. * An event triggered when a texture is created
  108838. */
  108839. onNewTextureAddedObservable: Observable<BaseTexture>;
  108840. /**
  108841. * An event triggered when a texture is removed
  108842. */
  108843. onTextureRemovedObservable: Observable<BaseTexture>;
  108844. /**
  108845. * An event triggered when render targets are about to be rendered
  108846. * Can happen multiple times per frame.
  108847. */
  108848. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108849. /**
  108850. * An event triggered when render targets were rendered.
  108851. * Can happen multiple times per frame.
  108852. */
  108853. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108854. /**
  108855. * An event triggered before calculating deterministic simulation step
  108856. */
  108857. onBeforeStepObservable: Observable<Scene>;
  108858. /**
  108859. * An event triggered after calculating deterministic simulation step
  108860. */
  108861. onAfterStepObservable: Observable<Scene>;
  108862. /**
  108863. * An event triggered when the activeCamera property is updated
  108864. */
  108865. onActiveCameraChanged: Observable<Scene>;
  108866. /**
  108867. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108868. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108869. * 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)
  108870. */
  108871. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108872. /**
  108873. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108874. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108875. * 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)
  108876. */
  108877. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108878. /**
  108879. * This Observable will when a mesh has been imported into the scene.
  108880. */
  108881. onMeshImportedObservable: Observable<AbstractMesh>;
  108882. /**
  108883. * This Observable will when an animation file has been imported into the scene.
  108884. */
  108885. onAnimationFileImportedObservable: Observable<Scene>;
  108886. /**
  108887. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108888. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108889. */
  108890. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108891. /** @hidden */
  108892. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108893. /**
  108894. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108895. */
  108896. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108897. /**
  108898. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108899. */
  108900. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108901. /**
  108902. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108903. */
  108904. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108905. /** Callback called when a pointer move is detected */
  108906. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108907. /** Callback called when a pointer down is detected */
  108908. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108909. /** Callback called when a pointer up is detected */
  108910. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108911. /** Callback called when a pointer pick is detected */
  108912. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108913. /**
  108914. * 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).
  108915. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108916. */
  108917. onPrePointerObservable: Observable<PointerInfoPre>;
  108918. /**
  108919. * Observable event triggered each time an input event is received from the rendering canvas
  108920. */
  108921. onPointerObservable: Observable<PointerInfo>;
  108922. /**
  108923. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108924. */
  108925. get unTranslatedPointer(): Vector2;
  108926. /**
  108927. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108928. */
  108929. static get DragMovementThreshold(): number;
  108930. static set DragMovementThreshold(value: number);
  108931. /**
  108932. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108933. */
  108934. static get LongPressDelay(): number;
  108935. static set LongPressDelay(value: number);
  108936. /**
  108937. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108938. */
  108939. static get DoubleClickDelay(): number;
  108940. static set DoubleClickDelay(value: number);
  108941. /** If you need to check double click without raising a single click at first click, enable this flag */
  108942. static get ExclusiveDoubleClickMode(): boolean;
  108943. static set ExclusiveDoubleClickMode(value: boolean);
  108944. /** @hidden */
  108945. _mirroredCameraPosition: Nullable<Vector3>;
  108946. /**
  108947. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108948. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108949. */
  108950. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108951. /**
  108952. * Observable event triggered each time an keyboard event is received from the hosting window
  108953. */
  108954. onKeyboardObservable: Observable<KeyboardInfo>;
  108955. private _useRightHandedSystem;
  108956. /**
  108957. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108958. */
  108959. set useRightHandedSystem(value: boolean);
  108960. get useRightHandedSystem(): boolean;
  108961. private _timeAccumulator;
  108962. private _currentStepId;
  108963. private _currentInternalStep;
  108964. /**
  108965. * Sets the step Id used by deterministic lock step
  108966. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108967. * @param newStepId defines the step Id
  108968. */
  108969. setStepId(newStepId: number): void;
  108970. /**
  108971. * Gets the step Id used by deterministic lock step
  108972. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108973. * @returns the step Id
  108974. */
  108975. getStepId(): number;
  108976. /**
  108977. * Gets the internal step used by deterministic lock step
  108978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108979. * @returns the internal step
  108980. */
  108981. getInternalStep(): number;
  108982. private _fogEnabled;
  108983. /**
  108984. * Gets or sets a boolean indicating if fog is enabled on this scene
  108985. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108986. * (Default is true)
  108987. */
  108988. set fogEnabled(value: boolean);
  108989. get fogEnabled(): boolean;
  108990. private _fogMode;
  108991. /**
  108992. * Gets or sets the fog mode to use
  108993. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108994. * | mode | value |
  108995. * | --- | --- |
  108996. * | FOGMODE_NONE | 0 |
  108997. * | FOGMODE_EXP | 1 |
  108998. * | FOGMODE_EXP2 | 2 |
  108999. * | FOGMODE_LINEAR | 3 |
  109000. */
  109001. set fogMode(value: number);
  109002. get fogMode(): number;
  109003. /**
  109004. * Gets or sets the fog color to use
  109005. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109006. * (Default is Color3(0.2, 0.2, 0.3))
  109007. */
  109008. fogColor: Color3;
  109009. /**
  109010. * Gets or sets the fog density to use
  109011. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109012. * (Default is 0.1)
  109013. */
  109014. fogDensity: number;
  109015. /**
  109016. * Gets or sets the fog start distance to use
  109017. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109018. * (Default is 0)
  109019. */
  109020. fogStart: number;
  109021. /**
  109022. * Gets or sets the fog end distance to use
  109023. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109024. * (Default is 1000)
  109025. */
  109026. fogEnd: number;
  109027. private _shadowsEnabled;
  109028. /**
  109029. * Gets or sets a boolean indicating if shadows are enabled on this scene
  109030. */
  109031. set shadowsEnabled(value: boolean);
  109032. get shadowsEnabled(): boolean;
  109033. private _lightsEnabled;
  109034. /**
  109035. * Gets or sets a boolean indicating if lights are enabled on this scene
  109036. */
  109037. set lightsEnabled(value: boolean);
  109038. get lightsEnabled(): boolean;
  109039. /** All of the active cameras added to this scene. */
  109040. activeCameras: Camera[];
  109041. /** @hidden */
  109042. _activeCamera: Nullable<Camera>;
  109043. /** Gets or sets the current active camera */
  109044. get activeCamera(): Nullable<Camera>;
  109045. set activeCamera(value: Nullable<Camera>);
  109046. private _defaultMaterial;
  109047. /** The default material used on meshes when no material is affected */
  109048. get defaultMaterial(): Material;
  109049. /** The default material used on meshes when no material is affected */
  109050. set defaultMaterial(value: Material);
  109051. private _texturesEnabled;
  109052. /**
  109053. * Gets or sets a boolean indicating if textures are enabled on this scene
  109054. */
  109055. set texturesEnabled(value: boolean);
  109056. get texturesEnabled(): boolean;
  109057. /**
  109058. * Gets or sets a boolean indicating if particles are enabled on this scene
  109059. */
  109060. particlesEnabled: boolean;
  109061. /**
  109062. * Gets or sets a boolean indicating if sprites are enabled on this scene
  109063. */
  109064. spritesEnabled: boolean;
  109065. private _skeletonsEnabled;
  109066. /**
  109067. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  109068. */
  109069. set skeletonsEnabled(value: boolean);
  109070. get skeletonsEnabled(): boolean;
  109071. /**
  109072. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  109073. */
  109074. lensFlaresEnabled: boolean;
  109075. /**
  109076. * Gets or sets a boolean indicating if collisions are enabled on this scene
  109077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109078. */
  109079. collisionsEnabled: boolean;
  109080. private _collisionCoordinator;
  109081. /** @hidden */
  109082. get collisionCoordinator(): ICollisionCoordinator;
  109083. /**
  109084. * Defines the gravity applied to this scene (used only for collisions)
  109085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109086. */
  109087. gravity: Vector3;
  109088. /**
  109089. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109090. */
  109091. postProcessesEnabled: boolean;
  109092. /**
  109093. * The list of postprocesses added to the scene
  109094. */
  109095. postProcesses: PostProcess[];
  109096. /**
  109097. * Gets the current postprocess manager
  109098. */
  109099. postProcessManager: PostProcessManager;
  109100. /**
  109101. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109102. */
  109103. renderTargetsEnabled: boolean;
  109104. /**
  109105. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109106. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109107. */
  109108. dumpNextRenderTargets: boolean;
  109109. /**
  109110. * The list of user defined render targets added to the scene
  109111. */
  109112. customRenderTargets: RenderTargetTexture[];
  109113. /**
  109114. * Defines if texture loading must be delayed
  109115. * If true, textures will only be loaded when they need to be rendered
  109116. */
  109117. useDelayedTextureLoading: boolean;
  109118. /**
  109119. * Gets the list of meshes imported to the scene through SceneLoader
  109120. */
  109121. importedMeshesFiles: String[];
  109122. /**
  109123. * Gets or sets a boolean indicating if probes are enabled on this scene
  109124. */
  109125. probesEnabled: boolean;
  109126. /**
  109127. * Gets or sets the current offline provider to use to store scene data
  109128. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109129. */
  109130. offlineProvider: IOfflineProvider;
  109131. /**
  109132. * Gets or sets the action manager associated with the scene
  109133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109134. */
  109135. actionManager: AbstractActionManager;
  109136. private _meshesForIntersections;
  109137. /**
  109138. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109139. */
  109140. proceduralTexturesEnabled: boolean;
  109141. private _engine;
  109142. private _totalVertices;
  109143. /** @hidden */
  109144. _activeIndices: PerfCounter;
  109145. /** @hidden */
  109146. _activeParticles: PerfCounter;
  109147. /** @hidden */
  109148. _activeBones: PerfCounter;
  109149. private _animationRatio;
  109150. /** @hidden */
  109151. _animationTimeLast: number;
  109152. /** @hidden */
  109153. _animationTime: number;
  109154. /**
  109155. * Gets or sets a general scale for animation speed
  109156. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109157. */
  109158. animationTimeScale: number;
  109159. /** @hidden */
  109160. _cachedMaterial: Nullable<Material>;
  109161. /** @hidden */
  109162. _cachedEffect: Nullable<Effect>;
  109163. /** @hidden */
  109164. _cachedVisibility: Nullable<number>;
  109165. private _renderId;
  109166. private _frameId;
  109167. private _executeWhenReadyTimeoutId;
  109168. private _intermediateRendering;
  109169. private _viewUpdateFlag;
  109170. private _projectionUpdateFlag;
  109171. /** @hidden */
  109172. _toBeDisposed: Nullable<IDisposable>[];
  109173. private _activeRequests;
  109174. /** @hidden */
  109175. _pendingData: any[];
  109176. private _isDisposed;
  109177. /**
  109178. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109179. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109180. */
  109181. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109182. private _activeMeshes;
  109183. private _processedMaterials;
  109184. private _renderTargets;
  109185. /** @hidden */
  109186. _activeParticleSystems: SmartArray<IParticleSystem>;
  109187. private _activeSkeletons;
  109188. private _softwareSkinnedMeshes;
  109189. private _renderingManager;
  109190. /** @hidden */
  109191. _activeAnimatables: Animatable[];
  109192. private _transformMatrix;
  109193. private _sceneUbo;
  109194. /** @hidden */
  109195. _viewMatrix: Matrix;
  109196. private _projectionMatrix;
  109197. /** @hidden */
  109198. _forcedViewPosition: Nullable<Vector3>;
  109199. /** @hidden */
  109200. _frustumPlanes: Plane[];
  109201. /**
  109202. * Gets the list of frustum planes (built from the active camera)
  109203. */
  109204. get frustumPlanes(): Plane[];
  109205. /**
  109206. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109207. * This is useful if there are more lights that the maximum simulteanous authorized
  109208. */
  109209. requireLightSorting: boolean;
  109210. /** @hidden */
  109211. readonly useMaterialMeshMap: boolean;
  109212. /** @hidden */
  109213. readonly useClonedMeshMap: boolean;
  109214. private _externalData;
  109215. private _uid;
  109216. /**
  109217. * @hidden
  109218. * Backing store of defined scene components.
  109219. */
  109220. _components: ISceneComponent[];
  109221. /**
  109222. * @hidden
  109223. * Backing store of defined scene components.
  109224. */
  109225. _serializableComponents: ISceneSerializableComponent[];
  109226. /**
  109227. * List of components to register on the next registration step.
  109228. */
  109229. private _transientComponents;
  109230. /**
  109231. * Registers the transient components if needed.
  109232. */
  109233. private _registerTransientComponents;
  109234. /**
  109235. * @hidden
  109236. * Add a component to the scene.
  109237. * Note that the ccomponent could be registered on th next frame if this is called after
  109238. * the register component stage.
  109239. * @param component Defines the component to add to the scene
  109240. */
  109241. _addComponent(component: ISceneComponent): void;
  109242. /**
  109243. * @hidden
  109244. * Gets a component from the scene.
  109245. * @param name defines the name of the component to retrieve
  109246. * @returns the component or null if not present
  109247. */
  109248. _getComponent(name: string): Nullable<ISceneComponent>;
  109249. /**
  109250. * @hidden
  109251. * Defines the actions happening before camera updates.
  109252. */
  109253. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109254. /**
  109255. * @hidden
  109256. * Defines the actions happening before clear the canvas.
  109257. */
  109258. _beforeClearStage: Stage<SimpleStageAction>;
  109259. /**
  109260. * @hidden
  109261. * Defines the actions when collecting render targets for the frame.
  109262. */
  109263. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109264. /**
  109265. * @hidden
  109266. * Defines the actions happening for one camera in the frame.
  109267. */
  109268. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109269. /**
  109270. * @hidden
  109271. * Defines the actions happening during the per mesh ready checks.
  109272. */
  109273. _isReadyForMeshStage: Stage<MeshStageAction>;
  109274. /**
  109275. * @hidden
  109276. * Defines the actions happening before evaluate active mesh checks.
  109277. */
  109278. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109279. /**
  109280. * @hidden
  109281. * Defines the actions happening during the evaluate sub mesh checks.
  109282. */
  109283. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109284. /**
  109285. * @hidden
  109286. * Defines the actions happening during the active mesh stage.
  109287. */
  109288. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109289. /**
  109290. * @hidden
  109291. * Defines the actions happening during the per camera render target step.
  109292. */
  109293. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109294. /**
  109295. * @hidden
  109296. * Defines the actions happening just before the active camera is drawing.
  109297. */
  109298. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109299. /**
  109300. * @hidden
  109301. * Defines the actions happening just before a render target is drawing.
  109302. */
  109303. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109304. /**
  109305. * @hidden
  109306. * Defines the actions happening just before a rendering group is drawing.
  109307. */
  109308. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109309. /**
  109310. * @hidden
  109311. * Defines the actions happening just before a mesh is drawing.
  109312. */
  109313. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109314. /**
  109315. * @hidden
  109316. * Defines the actions happening just after a mesh has been drawn.
  109317. */
  109318. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109319. /**
  109320. * @hidden
  109321. * Defines the actions happening just after a rendering group has been drawn.
  109322. */
  109323. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109324. /**
  109325. * @hidden
  109326. * Defines the actions happening just after the active camera has been drawn.
  109327. */
  109328. _afterCameraDrawStage: Stage<CameraStageAction>;
  109329. /**
  109330. * @hidden
  109331. * Defines the actions happening just after a render target has been drawn.
  109332. */
  109333. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109334. /**
  109335. * @hidden
  109336. * Defines the actions happening just after rendering all cameras and computing intersections.
  109337. */
  109338. _afterRenderStage: Stage<SimpleStageAction>;
  109339. /**
  109340. * @hidden
  109341. * Defines the actions happening when a pointer move event happens.
  109342. */
  109343. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109344. /**
  109345. * @hidden
  109346. * Defines the actions happening when a pointer down event happens.
  109347. */
  109348. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109349. /**
  109350. * @hidden
  109351. * Defines the actions happening when a pointer up event happens.
  109352. */
  109353. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109354. /**
  109355. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109356. */
  109357. private geometriesByUniqueId;
  109358. /**
  109359. * Creates a new Scene
  109360. * @param engine defines the engine to use to render this scene
  109361. * @param options defines the scene options
  109362. */
  109363. constructor(engine: Engine, options?: SceneOptions);
  109364. /**
  109365. * Gets a string idenfifying the name of the class
  109366. * @returns "Scene" string
  109367. */
  109368. getClassName(): string;
  109369. private _defaultMeshCandidates;
  109370. /**
  109371. * @hidden
  109372. */
  109373. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109374. private _defaultSubMeshCandidates;
  109375. /**
  109376. * @hidden
  109377. */
  109378. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109379. /**
  109380. * Sets the default candidate providers for the scene.
  109381. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109382. * and getCollidingSubMeshCandidates to their default function
  109383. */
  109384. setDefaultCandidateProviders(): void;
  109385. /**
  109386. * Gets the mesh that is currently under the pointer
  109387. */
  109388. get meshUnderPointer(): Nullable<AbstractMesh>;
  109389. /**
  109390. * Gets or sets the current on-screen X position of the pointer
  109391. */
  109392. get pointerX(): number;
  109393. set pointerX(value: number);
  109394. /**
  109395. * Gets or sets the current on-screen Y position of the pointer
  109396. */
  109397. get pointerY(): number;
  109398. set pointerY(value: number);
  109399. /**
  109400. * Gets the cached material (ie. the latest rendered one)
  109401. * @returns the cached material
  109402. */
  109403. getCachedMaterial(): Nullable<Material>;
  109404. /**
  109405. * Gets the cached effect (ie. the latest rendered one)
  109406. * @returns the cached effect
  109407. */
  109408. getCachedEffect(): Nullable<Effect>;
  109409. /**
  109410. * Gets the cached visibility state (ie. the latest rendered one)
  109411. * @returns the cached visibility state
  109412. */
  109413. getCachedVisibility(): Nullable<number>;
  109414. /**
  109415. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109416. * @param material defines the current material
  109417. * @param effect defines the current effect
  109418. * @param visibility defines the current visibility state
  109419. * @returns true if one parameter is not cached
  109420. */
  109421. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109422. /**
  109423. * Gets the engine associated with the scene
  109424. * @returns an Engine
  109425. */
  109426. getEngine(): Engine;
  109427. /**
  109428. * Gets the total number of vertices rendered per frame
  109429. * @returns the total number of vertices rendered per frame
  109430. */
  109431. getTotalVertices(): number;
  109432. /**
  109433. * Gets the performance counter for total vertices
  109434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109435. */
  109436. get totalVerticesPerfCounter(): PerfCounter;
  109437. /**
  109438. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109439. * @returns the total number of active indices rendered per frame
  109440. */
  109441. getActiveIndices(): number;
  109442. /**
  109443. * Gets the performance counter for active indices
  109444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109445. */
  109446. get totalActiveIndicesPerfCounter(): PerfCounter;
  109447. /**
  109448. * Gets the total number of active particles rendered per frame
  109449. * @returns the total number of active particles rendered per frame
  109450. */
  109451. getActiveParticles(): number;
  109452. /**
  109453. * Gets the performance counter for active particles
  109454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109455. */
  109456. get activeParticlesPerfCounter(): PerfCounter;
  109457. /**
  109458. * Gets the total number of active bones rendered per frame
  109459. * @returns the total number of active bones rendered per frame
  109460. */
  109461. getActiveBones(): number;
  109462. /**
  109463. * Gets the performance counter for active bones
  109464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109465. */
  109466. get activeBonesPerfCounter(): PerfCounter;
  109467. /**
  109468. * Gets the array of active meshes
  109469. * @returns an array of AbstractMesh
  109470. */
  109471. getActiveMeshes(): SmartArray<AbstractMesh>;
  109472. /**
  109473. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109474. * @returns a number
  109475. */
  109476. getAnimationRatio(): number;
  109477. /**
  109478. * Gets an unique Id for the current render phase
  109479. * @returns a number
  109480. */
  109481. getRenderId(): number;
  109482. /**
  109483. * Gets an unique Id for the current frame
  109484. * @returns a number
  109485. */
  109486. getFrameId(): number;
  109487. /** Call this function if you want to manually increment the render Id*/
  109488. incrementRenderId(): void;
  109489. private _createUbo;
  109490. /**
  109491. * Use this method to simulate a pointer move on a mesh
  109492. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109493. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109494. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109495. * @returns the current scene
  109496. */
  109497. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109498. /**
  109499. * Use this method to simulate a pointer down on a mesh
  109500. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109501. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109502. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109503. * @returns the current scene
  109504. */
  109505. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109506. /**
  109507. * Use this method to simulate a pointer up on a mesh
  109508. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109509. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109510. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109511. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109512. * @returns the current scene
  109513. */
  109514. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109515. /**
  109516. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109517. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109518. * @returns true if the pointer was captured
  109519. */
  109520. isPointerCaptured(pointerId?: number): boolean;
  109521. /**
  109522. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109523. * @param attachUp defines if you want to attach events to pointerup
  109524. * @param attachDown defines if you want to attach events to pointerdown
  109525. * @param attachMove defines if you want to attach events to pointermove
  109526. */
  109527. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109528. /** Detaches all event handlers*/
  109529. detachControl(): void;
  109530. /**
  109531. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109532. * Delay loaded resources are not taking in account
  109533. * @return true if all required resources are ready
  109534. */
  109535. isReady(): boolean;
  109536. /** Resets all cached information relative to material (including effect and visibility) */
  109537. resetCachedMaterial(): void;
  109538. /**
  109539. * Registers a function to be called before every frame render
  109540. * @param func defines the function to register
  109541. */
  109542. registerBeforeRender(func: () => void): void;
  109543. /**
  109544. * Unregisters a function called before every frame render
  109545. * @param func defines the function to unregister
  109546. */
  109547. unregisterBeforeRender(func: () => void): void;
  109548. /**
  109549. * Registers a function to be called after every frame render
  109550. * @param func defines the function to register
  109551. */
  109552. registerAfterRender(func: () => void): void;
  109553. /**
  109554. * Unregisters a function called after every frame render
  109555. * @param func defines the function to unregister
  109556. */
  109557. unregisterAfterRender(func: () => void): void;
  109558. private _executeOnceBeforeRender;
  109559. /**
  109560. * The provided function will run before render once and will be disposed afterwards.
  109561. * A timeout delay can be provided so that the function will be executed in N ms.
  109562. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109563. * @param func The function to be executed.
  109564. * @param timeout optional delay in ms
  109565. */
  109566. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109567. /** @hidden */
  109568. _addPendingData(data: any): void;
  109569. /** @hidden */
  109570. _removePendingData(data: any): void;
  109571. /**
  109572. * Returns the number of items waiting to be loaded
  109573. * @returns the number of items waiting to be loaded
  109574. */
  109575. getWaitingItemsCount(): number;
  109576. /**
  109577. * Returns a boolean indicating if the scene is still loading data
  109578. */
  109579. get isLoading(): boolean;
  109580. /**
  109581. * Registers a function to be executed when the scene is ready
  109582. * @param {Function} func - the function to be executed
  109583. */
  109584. executeWhenReady(func: () => void): void;
  109585. /**
  109586. * Returns a promise that resolves when the scene is ready
  109587. * @returns A promise that resolves when the scene is ready
  109588. */
  109589. whenReadyAsync(): Promise<void>;
  109590. /** @hidden */
  109591. _checkIsReady(): void;
  109592. /**
  109593. * Gets all animatable attached to the scene
  109594. */
  109595. get animatables(): Animatable[];
  109596. /**
  109597. * Resets the last animation time frame.
  109598. * Useful to override when animations start running when loading a scene for the first time.
  109599. */
  109600. resetLastAnimationTimeFrame(): void;
  109601. /**
  109602. * Gets the current view matrix
  109603. * @returns a Matrix
  109604. */
  109605. getViewMatrix(): Matrix;
  109606. /**
  109607. * Gets the current projection matrix
  109608. * @returns a Matrix
  109609. */
  109610. getProjectionMatrix(): Matrix;
  109611. /**
  109612. * Gets the current transform matrix
  109613. * @returns a Matrix made of View * Projection
  109614. */
  109615. getTransformMatrix(): Matrix;
  109616. /**
  109617. * Sets the current transform matrix
  109618. * @param viewL defines the View matrix to use
  109619. * @param projectionL defines the Projection matrix to use
  109620. * @param viewR defines the right View matrix to use (if provided)
  109621. * @param projectionR defines the right Projection matrix to use (if provided)
  109622. */
  109623. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109624. /**
  109625. * Gets the uniform buffer used to store scene data
  109626. * @returns a UniformBuffer
  109627. */
  109628. getSceneUniformBuffer(): UniformBuffer;
  109629. /**
  109630. * Gets an unique (relatively to the current scene) Id
  109631. * @returns an unique number for the scene
  109632. */
  109633. getUniqueId(): number;
  109634. /**
  109635. * Add a mesh to the list of scene's meshes
  109636. * @param newMesh defines the mesh to add
  109637. * @param recursive if all child meshes should also be added to the scene
  109638. */
  109639. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109640. /**
  109641. * Remove a mesh for the list of scene's meshes
  109642. * @param toRemove defines the mesh to remove
  109643. * @param recursive if all child meshes should also be removed from the scene
  109644. * @returns the index where the mesh was in the mesh list
  109645. */
  109646. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109647. /**
  109648. * Add a transform node to the list of scene's transform nodes
  109649. * @param newTransformNode defines the transform node to add
  109650. */
  109651. addTransformNode(newTransformNode: TransformNode): void;
  109652. /**
  109653. * Remove a transform node for the list of scene's transform nodes
  109654. * @param toRemove defines the transform node to remove
  109655. * @returns the index where the transform node was in the transform node list
  109656. */
  109657. removeTransformNode(toRemove: TransformNode): number;
  109658. /**
  109659. * Remove a skeleton for the list of scene's skeletons
  109660. * @param toRemove defines the skeleton to remove
  109661. * @returns the index where the skeleton was in the skeleton list
  109662. */
  109663. removeSkeleton(toRemove: Skeleton): number;
  109664. /**
  109665. * Remove a morph target for the list of scene's morph targets
  109666. * @param toRemove defines the morph target to remove
  109667. * @returns the index where the morph target was in the morph target list
  109668. */
  109669. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109670. /**
  109671. * Remove a light for the list of scene's lights
  109672. * @param toRemove defines the light to remove
  109673. * @returns the index where the light was in the light list
  109674. */
  109675. removeLight(toRemove: Light): number;
  109676. /**
  109677. * Remove a camera for the list of scene's cameras
  109678. * @param toRemove defines the camera to remove
  109679. * @returns the index where the camera was in the camera list
  109680. */
  109681. removeCamera(toRemove: Camera): number;
  109682. /**
  109683. * Remove a particle system for the list of scene's particle systems
  109684. * @param toRemove defines the particle system to remove
  109685. * @returns the index where the particle system was in the particle system list
  109686. */
  109687. removeParticleSystem(toRemove: IParticleSystem): number;
  109688. /**
  109689. * Remove a animation for the list of scene's animations
  109690. * @param toRemove defines the animation to remove
  109691. * @returns the index where the animation was in the animation list
  109692. */
  109693. removeAnimation(toRemove: Animation): number;
  109694. /**
  109695. * Will stop the animation of the given target
  109696. * @param target - the target
  109697. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109698. * @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)
  109699. */
  109700. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109701. /**
  109702. * Removes the given animation group from this scene.
  109703. * @param toRemove The animation group to remove
  109704. * @returns The index of the removed animation group
  109705. */
  109706. removeAnimationGroup(toRemove: AnimationGroup): number;
  109707. /**
  109708. * Removes the given multi-material from this scene.
  109709. * @param toRemove The multi-material to remove
  109710. * @returns The index of the removed multi-material
  109711. */
  109712. removeMultiMaterial(toRemove: MultiMaterial): number;
  109713. /**
  109714. * Removes the given material from this scene.
  109715. * @param toRemove The material to remove
  109716. * @returns The index of the removed material
  109717. */
  109718. removeMaterial(toRemove: Material): number;
  109719. /**
  109720. * Removes the given action manager from this scene.
  109721. * @param toRemove The action manager to remove
  109722. * @returns The index of the removed action manager
  109723. */
  109724. removeActionManager(toRemove: AbstractActionManager): number;
  109725. /**
  109726. * Removes the given texture from this scene.
  109727. * @param toRemove The texture to remove
  109728. * @returns The index of the removed texture
  109729. */
  109730. removeTexture(toRemove: BaseTexture): number;
  109731. /**
  109732. * Adds the given light to this scene
  109733. * @param newLight The light to add
  109734. */
  109735. addLight(newLight: Light): void;
  109736. /**
  109737. * Sorts the list list based on light priorities
  109738. */
  109739. sortLightsByPriority(): void;
  109740. /**
  109741. * Adds the given camera to this scene
  109742. * @param newCamera The camera to add
  109743. */
  109744. addCamera(newCamera: Camera): void;
  109745. /**
  109746. * Adds the given skeleton to this scene
  109747. * @param newSkeleton The skeleton to add
  109748. */
  109749. addSkeleton(newSkeleton: Skeleton): void;
  109750. /**
  109751. * Adds the given particle system to this scene
  109752. * @param newParticleSystem The particle system to add
  109753. */
  109754. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109755. /**
  109756. * Adds the given animation to this scene
  109757. * @param newAnimation The animation to add
  109758. */
  109759. addAnimation(newAnimation: Animation): void;
  109760. /**
  109761. * Adds the given animation group to this scene.
  109762. * @param newAnimationGroup The animation group to add
  109763. */
  109764. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109765. /**
  109766. * Adds the given multi-material to this scene
  109767. * @param newMultiMaterial The multi-material to add
  109768. */
  109769. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109770. /**
  109771. * Adds the given material to this scene
  109772. * @param newMaterial The material to add
  109773. */
  109774. addMaterial(newMaterial: Material): void;
  109775. /**
  109776. * Adds the given morph target to this scene
  109777. * @param newMorphTargetManager The morph target to add
  109778. */
  109779. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109780. /**
  109781. * Adds the given geometry to this scene
  109782. * @param newGeometry The geometry to add
  109783. */
  109784. addGeometry(newGeometry: Geometry): void;
  109785. /**
  109786. * Adds the given action manager to this scene
  109787. * @param newActionManager The action manager to add
  109788. */
  109789. addActionManager(newActionManager: AbstractActionManager): void;
  109790. /**
  109791. * Adds the given texture to this scene.
  109792. * @param newTexture The texture to add
  109793. */
  109794. addTexture(newTexture: BaseTexture): void;
  109795. /**
  109796. * Switch active camera
  109797. * @param newCamera defines the new active camera
  109798. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109799. */
  109800. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109801. /**
  109802. * sets the active camera of the scene using its ID
  109803. * @param id defines the camera's ID
  109804. * @return the new active camera or null if none found.
  109805. */
  109806. setActiveCameraByID(id: string): Nullable<Camera>;
  109807. /**
  109808. * sets the active camera of the scene using its name
  109809. * @param name defines the camera's name
  109810. * @returns the new active camera or null if none found.
  109811. */
  109812. setActiveCameraByName(name: string): Nullable<Camera>;
  109813. /**
  109814. * get an animation group using its name
  109815. * @param name defines the material's name
  109816. * @return the animation group or null if none found.
  109817. */
  109818. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109819. /**
  109820. * Get a material using its unique id
  109821. * @param uniqueId defines the material's unique id
  109822. * @return the material or null if none found.
  109823. */
  109824. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109825. /**
  109826. * get a material using its id
  109827. * @param id defines the material's ID
  109828. * @return the material or null if none found.
  109829. */
  109830. getMaterialByID(id: string): Nullable<Material>;
  109831. /**
  109832. * Gets a the last added material using a given id
  109833. * @param id defines the material's ID
  109834. * @return the last material with the given id or null if none found.
  109835. */
  109836. getLastMaterialByID(id: string): Nullable<Material>;
  109837. /**
  109838. * Gets a material using its name
  109839. * @param name defines the material's name
  109840. * @return the material or null if none found.
  109841. */
  109842. getMaterialByName(name: string): Nullable<Material>;
  109843. /**
  109844. * Get a texture using its unique id
  109845. * @param uniqueId defines the texture's unique id
  109846. * @return the texture or null if none found.
  109847. */
  109848. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109849. /**
  109850. * Gets a camera using its id
  109851. * @param id defines the id to look for
  109852. * @returns the camera or null if not found
  109853. */
  109854. getCameraByID(id: string): Nullable<Camera>;
  109855. /**
  109856. * Gets a camera using its unique id
  109857. * @param uniqueId defines the unique id to look for
  109858. * @returns the camera or null if not found
  109859. */
  109860. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109861. /**
  109862. * Gets a camera using its name
  109863. * @param name defines the camera's name
  109864. * @return the camera or null if none found.
  109865. */
  109866. getCameraByName(name: string): Nullable<Camera>;
  109867. /**
  109868. * Gets a bone using its id
  109869. * @param id defines the bone's id
  109870. * @return the bone or null if not found
  109871. */
  109872. getBoneByID(id: string): Nullable<Bone>;
  109873. /**
  109874. * Gets a bone using its id
  109875. * @param name defines the bone's name
  109876. * @return the bone or null if not found
  109877. */
  109878. getBoneByName(name: string): Nullable<Bone>;
  109879. /**
  109880. * Gets a light node using its name
  109881. * @param name defines the the light's name
  109882. * @return the light or null if none found.
  109883. */
  109884. getLightByName(name: string): Nullable<Light>;
  109885. /**
  109886. * Gets a light node using its id
  109887. * @param id defines the light's id
  109888. * @return the light or null if none found.
  109889. */
  109890. getLightByID(id: string): Nullable<Light>;
  109891. /**
  109892. * Gets a light node using its scene-generated unique ID
  109893. * @param uniqueId defines the light's unique id
  109894. * @return the light or null if none found.
  109895. */
  109896. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109897. /**
  109898. * Gets a particle system by id
  109899. * @param id defines the particle system id
  109900. * @return the corresponding system or null if none found
  109901. */
  109902. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109903. /**
  109904. * Gets a geometry using its ID
  109905. * @param id defines the geometry's id
  109906. * @return the geometry or null if none found.
  109907. */
  109908. getGeometryByID(id: string): Nullable<Geometry>;
  109909. private _getGeometryByUniqueID;
  109910. /**
  109911. * Add a new geometry to this scene
  109912. * @param geometry defines the geometry to be added to the scene.
  109913. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109914. * @return a boolean defining if the geometry was added or not
  109915. */
  109916. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109917. /**
  109918. * Removes an existing geometry
  109919. * @param geometry defines the geometry to be removed from the scene
  109920. * @return a boolean defining if the geometry was removed or not
  109921. */
  109922. removeGeometry(geometry: Geometry): boolean;
  109923. /**
  109924. * Gets the list of geometries attached to the scene
  109925. * @returns an array of Geometry
  109926. */
  109927. getGeometries(): Geometry[];
  109928. /**
  109929. * Gets the first added mesh found of a given ID
  109930. * @param id defines the id to search for
  109931. * @return the mesh found or null if not found at all
  109932. */
  109933. getMeshByID(id: string): Nullable<AbstractMesh>;
  109934. /**
  109935. * Gets a list of meshes using their id
  109936. * @param id defines the id to search for
  109937. * @returns a list of meshes
  109938. */
  109939. getMeshesByID(id: string): Array<AbstractMesh>;
  109940. /**
  109941. * Gets the first added transform node found of a given ID
  109942. * @param id defines the id to search for
  109943. * @return the found transform node or null if not found at all.
  109944. */
  109945. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109946. /**
  109947. * Gets a transform node with its auto-generated unique id
  109948. * @param uniqueId efines the unique id to search for
  109949. * @return the found transform node or null if not found at all.
  109950. */
  109951. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109952. /**
  109953. * Gets a list of transform nodes using their id
  109954. * @param id defines the id to search for
  109955. * @returns a list of transform nodes
  109956. */
  109957. getTransformNodesByID(id: string): Array<TransformNode>;
  109958. /**
  109959. * Gets a mesh with its auto-generated unique id
  109960. * @param uniqueId defines the unique id to search for
  109961. * @return the found mesh or null if not found at all.
  109962. */
  109963. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109964. /**
  109965. * Gets a the last added mesh using a given id
  109966. * @param id defines the id to search for
  109967. * @return the found mesh or null if not found at all.
  109968. */
  109969. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109970. /**
  109971. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109972. * @param id defines the id to search for
  109973. * @return the found node or null if not found at all
  109974. */
  109975. getLastEntryByID(id: string): Nullable<Node>;
  109976. /**
  109977. * Gets a node (Mesh, Camera, Light) using a given id
  109978. * @param id defines the id to search for
  109979. * @return the found node or null if not found at all
  109980. */
  109981. getNodeByID(id: string): Nullable<Node>;
  109982. /**
  109983. * Gets a node (Mesh, Camera, Light) using a given name
  109984. * @param name defines the name to search for
  109985. * @return the found node or null if not found at all.
  109986. */
  109987. getNodeByName(name: string): Nullable<Node>;
  109988. /**
  109989. * Gets a mesh using a given name
  109990. * @param name defines the name to search for
  109991. * @return the found mesh or null if not found at all.
  109992. */
  109993. getMeshByName(name: string): Nullable<AbstractMesh>;
  109994. /**
  109995. * Gets a transform node using a given name
  109996. * @param name defines the name to search for
  109997. * @return the found transform node or null if not found at all.
  109998. */
  109999. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110000. /**
  110001. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110002. * @param id defines the id to search for
  110003. * @return the found skeleton or null if not found at all.
  110004. */
  110005. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  110006. /**
  110007. * Gets a skeleton using a given auto generated unique id
  110008. * @param uniqueId defines the unique id to search for
  110009. * @return the found skeleton or null if not found at all.
  110010. */
  110011. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  110012. /**
  110013. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  110014. * @param id defines the id to search for
  110015. * @return the found skeleton or null if not found at all.
  110016. */
  110017. getSkeletonById(id: string): Nullable<Skeleton>;
  110018. /**
  110019. * Gets a skeleton using a given name
  110020. * @param name defines the name to search for
  110021. * @return the found skeleton or null if not found at all.
  110022. */
  110023. getSkeletonByName(name: string): Nullable<Skeleton>;
  110024. /**
  110025. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  110026. * @param id defines the id to search for
  110027. * @return the found morph target manager or null if not found at all.
  110028. */
  110029. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  110030. /**
  110031. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  110032. * @param id defines the id to search for
  110033. * @return the found morph target or null if not found at all.
  110034. */
  110035. getMorphTargetById(id: string): Nullable<MorphTarget>;
  110036. /**
  110037. * Gets a boolean indicating if the given mesh is active
  110038. * @param mesh defines the mesh to look for
  110039. * @returns true if the mesh is in the active list
  110040. */
  110041. isActiveMesh(mesh: AbstractMesh): boolean;
  110042. /**
  110043. * Return a unique id as a string which can serve as an identifier for the scene
  110044. */
  110045. get uid(): string;
  110046. /**
  110047. * Add an externaly attached data from its key.
  110048. * This method call will fail and return false, if such key already exists.
  110049. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  110050. * @param key the unique key that identifies the data
  110051. * @param data the data object to associate to the key for this Engine instance
  110052. * @return true if no such key were already present and the data was added successfully, false otherwise
  110053. */
  110054. addExternalData<T>(key: string, data: T): boolean;
  110055. /**
  110056. * Get an externaly attached data from its key
  110057. * @param key the unique key that identifies the data
  110058. * @return the associated data, if present (can be null), or undefined if not present
  110059. */
  110060. getExternalData<T>(key: string): Nullable<T>;
  110061. /**
  110062. * Get an externaly attached data from its key, create it using a factory if it's not already present
  110063. * @param key the unique key that identifies the data
  110064. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  110065. * @return the associated data, can be null if the factory returned null.
  110066. */
  110067. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  110068. /**
  110069. * Remove an externaly attached data from the Engine instance
  110070. * @param key the unique key that identifies the data
  110071. * @return true if the data was successfully removed, false if it doesn't exist
  110072. */
  110073. removeExternalData(key: string): boolean;
  110074. private _evaluateSubMesh;
  110075. /**
  110076. * Clear the processed materials smart array preventing retention point in material dispose.
  110077. */
  110078. freeProcessedMaterials(): void;
  110079. private _preventFreeActiveMeshesAndRenderingGroups;
  110080. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  110081. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  110082. * when disposing several meshes in a row or a hierarchy of meshes.
  110083. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  110084. */
  110085. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  110086. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110087. /**
  110088. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110089. */
  110090. freeActiveMeshes(): void;
  110091. /**
  110092. * Clear the info related to rendering groups preventing retention points during dispose.
  110093. */
  110094. freeRenderingGroups(): void;
  110095. /** @hidden */
  110096. _isInIntermediateRendering(): boolean;
  110097. /**
  110098. * Lambda returning the list of potentially active meshes.
  110099. */
  110100. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110101. /**
  110102. * Lambda returning the list of potentially active sub meshes.
  110103. */
  110104. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110105. /**
  110106. * Lambda returning the list of potentially intersecting sub meshes.
  110107. */
  110108. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110109. /**
  110110. * Lambda returning the list of potentially colliding sub meshes.
  110111. */
  110112. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110113. private _activeMeshesFrozen;
  110114. private _skipEvaluateActiveMeshesCompletely;
  110115. /**
  110116. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110117. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110118. * @returns the current scene
  110119. */
  110120. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110121. /**
  110122. * Use this function to restart evaluating active meshes on every frame
  110123. * @returns the current scene
  110124. */
  110125. unfreezeActiveMeshes(): Scene;
  110126. private _evaluateActiveMeshes;
  110127. private _activeMesh;
  110128. /**
  110129. * Update the transform matrix to update from the current active camera
  110130. * @param force defines a boolean used to force the update even if cache is up to date
  110131. */
  110132. updateTransformMatrix(force?: boolean): void;
  110133. private _bindFrameBuffer;
  110134. /** @hidden */
  110135. _allowPostProcessClearColor: boolean;
  110136. /** @hidden */
  110137. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110138. private _processSubCameras;
  110139. private _checkIntersections;
  110140. /** @hidden */
  110141. _advancePhysicsEngineStep(step: number): void;
  110142. /**
  110143. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110144. */
  110145. getDeterministicFrameTime: () => number;
  110146. /** @hidden */
  110147. _animate(): void;
  110148. /** Execute all animations (for a frame) */
  110149. animate(): void;
  110150. /**
  110151. * Render the scene
  110152. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110153. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110154. */
  110155. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110156. /**
  110157. * Freeze all materials
  110158. * A frozen material will not be updatable but should be faster to render
  110159. */
  110160. freezeMaterials(): void;
  110161. /**
  110162. * Unfreeze all materials
  110163. * A frozen material will not be updatable but should be faster to render
  110164. */
  110165. unfreezeMaterials(): void;
  110166. /**
  110167. * Releases all held ressources
  110168. */
  110169. dispose(): void;
  110170. /**
  110171. * Gets if the scene is already disposed
  110172. */
  110173. get isDisposed(): boolean;
  110174. /**
  110175. * Call this function to reduce memory footprint of the scene.
  110176. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110177. */
  110178. clearCachedVertexData(): void;
  110179. /**
  110180. * This function will remove the local cached buffer data from texture.
  110181. * It will save memory but will prevent the texture from being rebuilt
  110182. */
  110183. cleanCachedTextureBuffer(): void;
  110184. /**
  110185. * Get the world extend vectors with an optional filter
  110186. *
  110187. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110188. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110189. */
  110190. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110191. min: Vector3;
  110192. max: Vector3;
  110193. };
  110194. /**
  110195. * Creates a ray that can be used to pick in the scene
  110196. * @param x defines the x coordinate of the origin (on-screen)
  110197. * @param y defines the y coordinate of the origin (on-screen)
  110198. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110199. * @param camera defines the camera to use for the picking
  110200. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110201. * @returns a Ray
  110202. */
  110203. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110204. /**
  110205. * Creates a ray that can be used to pick in the scene
  110206. * @param x defines the x coordinate of the origin (on-screen)
  110207. * @param y defines the y coordinate of the origin (on-screen)
  110208. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110209. * @param result defines the ray where to store the picking ray
  110210. * @param camera defines the camera to use for the picking
  110211. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110212. * @returns the current scene
  110213. */
  110214. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110215. /**
  110216. * Creates a ray that can be used to pick in the scene
  110217. * @param x defines the x coordinate of the origin (on-screen)
  110218. * @param y defines the y coordinate of the origin (on-screen)
  110219. * @param camera defines the camera to use for the picking
  110220. * @returns a Ray
  110221. */
  110222. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110223. /**
  110224. * Creates a ray that can be used to pick in the scene
  110225. * @param x defines the x coordinate of the origin (on-screen)
  110226. * @param y defines the y coordinate of the origin (on-screen)
  110227. * @param result defines the ray where to store the picking ray
  110228. * @param camera defines the camera to use for the picking
  110229. * @returns the current scene
  110230. */
  110231. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110232. /** Launch a ray to try to pick a mesh in the scene
  110233. * @param x position on screen
  110234. * @param y position on screen
  110235. * @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
  110236. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110237. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110238. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110239. * @returns a PickingInfo
  110240. */
  110241. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110242. /** Use the given ray to pick a mesh in the scene
  110243. * @param ray The ray to use to pick meshes
  110244. * @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
  110245. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110246. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110247. * @returns a PickingInfo
  110248. */
  110249. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110250. /**
  110251. * Launch a ray to try to pick a mesh in the scene
  110252. * @param x X position on screen
  110253. * @param y Y position on screen
  110254. * @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
  110255. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110257. * @returns an array of PickingInfo
  110258. */
  110259. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110260. /**
  110261. * Launch a ray to try to pick a mesh in the scene
  110262. * @param ray Ray to use
  110263. * @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
  110264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110265. * @returns an array of PickingInfo
  110266. */
  110267. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110268. /**
  110269. * Force the value of meshUnderPointer
  110270. * @param mesh defines the mesh to use
  110271. */
  110272. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110273. /**
  110274. * Gets the mesh under the pointer
  110275. * @returns a Mesh or null if no mesh is under the pointer
  110276. */
  110277. getPointerOverMesh(): Nullable<AbstractMesh>;
  110278. /** @hidden */
  110279. _rebuildGeometries(): void;
  110280. /** @hidden */
  110281. _rebuildTextures(): void;
  110282. private _getByTags;
  110283. /**
  110284. * Get a list of meshes by tags
  110285. * @param tagsQuery defines the tags query to use
  110286. * @param forEach defines a predicate used to filter results
  110287. * @returns an array of Mesh
  110288. */
  110289. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110290. /**
  110291. * Get a list of cameras by tags
  110292. * @param tagsQuery defines the tags query to use
  110293. * @param forEach defines a predicate used to filter results
  110294. * @returns an array of Camera
  110295. */
  110296. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110297. /**
  110298. * Get a list of lights by tags
  110299. * @param tagsQuery defines the tags query to use
  110300. * @param forEach defines a predicate used to filter results
  110301. * @returns an array of Light
  110302. */
  110303. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110304. /**
  110305. * Get a list of materials by tags
  110306. * @param tagsQuery defines the tags query to use
  110307. * @param forEach defines a predicate used to filter results
  110308. * @returns an array of Material
  110309. */
  110310. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110311. /**
  110312. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110313. * This allowed control for front to back rendering or reversly depending of the special needs.
  110314. *
  110315. * @param renderingGroupId The rendering group id corresponding to its index
  110316. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110317. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110318. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110319. */
  110320. 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;
  110321. /**
  110322. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110323. *
  110324. * @param renderingGroupId The rendering group id corresponding to its index
  110325. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110326. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110327. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110328. */
  110329. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110330. /**
  110331. * Gets the current auto clear configuration for one rendering group of the rendering
  110332. * manager.
  110333. * @param index the rendering group index to get the information for
  110334. * @returns The auto clear setup for the requested rendering group
  110335. */
  110336. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110337. private _blockMaterialDirtyMechanism;
  110338. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110339. get blockMaterialDirtyMechanism(): boolean;
  110340. set blockMaterialDirtyMechanism(value: boolean);
  110341. /**
  110342. * Will flag all materials as dirty to trigger new shader compilation
  110343. * @param flag defines the flag used to specify which material part must be marked as dirty
  110344. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110345. */
  110346. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110347. /** @hidden */
  110348. _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;
  110349. /** @hidden */
  110350. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110351. /** @hidden */
  110352. _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;
  110353. /** @hidden */
  110354. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110355. /** @hidden */
  110356. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110357. /** @hidden */
  110358. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110359. }
  110360. }
  110361. declare module BABYLON {
  110362. /**
  110363. * Set of assets to keep when moving a scene into an asset container.
  110364. */
  110365. export class KeepAssets extends AbstractScene {
  110366. }
  110367. /**
  110368. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110369. */
  110370. export class InstantiatedEntries {
  110371. /**
  110372. * List of new root nodes (eg. nodes with no parent)
  110373. */
  110374. rootNodes: TransformNode[];
  110375. /**
  110376. * List of new skeletons
  110377. */
  110378. skeletons: Skeleton[];
  110379. /**
  110380. * List of new animation groups
  110381. */
  110382. animationGroups: AnimationGroup[];
  110383. }
  110384. /**
  110385. * Container with a set of assets that can be added or removed from a scene.
  110386. */
  110387. export class AssetContainer extends AbstractScene {
  110388. private _wasAddedToScene;
  110389. /**
  110390. * The scene the AssetContainer belongs to.
  110391. */
  110392. scene: Scene;
  110393. /**
  110394. * Instantiates an AssetContainer.
  110395. * @param scene The scene the AssetContainer belongs to.
  110396. */
  110397. constructor(scene: Scene);
  110398. /**
  110399. * Instantiate or clone all meshes and add the new ones to the scene.
  110400. * Skeletons and animation groups will all be cloned
  110401. * @param nameFunction defines an optional function used to get new names for clones
  110402. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110403. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110404. */
  110405. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110406. /**
  110407. * Adds all the assets from the container to the scene.
  110408. */
  110409. addAllToScene(): void;
  110410. /**
  110411. * Removes all the assets in the container from the scene
  110412. */
  110413. removeAllFromScene(): void;
  110414. /**
  110415. * Disposes all the assets in the container
  110416. */
  110417. dispose(): void;
  110418. private _moveAssets;
  110419. /**
  110420. * Removes all the assets contained in the scene and adds them to the container.
  110421. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110422. */
  110423. moveAllFromScene(keepAssets?: KeepAssets): void;
  110424. /**
  110425. * 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.
  110426. * @returns the root mesh
  110427. */
  110428. createRootMesh(): Mesh;
  110429. /**
  110430. * Merge animations from this asset container into a scene
  110431. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110432. * @param animatables set of animatables to retarget to a node from the scene
  110433. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110434. */
  110435. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110436. }
  110437. }
  110438. declare module BABYLON {
  110439. /**
  110440. * Defines how the parser contract is defined.
  110441. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110442. */
  110443. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110444. /**
  110445. * Defines how the individual parser contract is defined.
  110446. * These parser can parse an individual asset
  110447. */
  110448. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110449. /**
  110450. * Base class of the scene acting as a container for the different elements composing a scene.
  110451. * This class is dynamically extended by the different components of the scene increasing
  110452. * flexibility and reducing coupling
  110453. */
  110454. export abstract class AbstractScene {
  110455. /**
  110456. * Stores the list of available parsers in the application.
  110457. */
  110458. private static _BabylonFileParsers;
  110459. /**
  110460. * Stores the list of available individual parsers in the application.
  110461. */
  110462. private static _IndividualBabylonFileParsers;
  110463. /**
  110464. * Adds a parser in the list of available ones
  110465. * @param name Defines the name of the parser
  110466. * @param parser Defines the parser to add
  110467. */
  110468. static AddParser(name: string, parser: BabylonFileParser): void;
  110469. /**
  110470. * Gets a general parser from the list of avaialble ones
  110471. * @param name Defines the name of the parser
  110472. * @returns the requested parser or null
  110473. */
  110474. static GetParser(name: string): Nullable<BabylonFileParser>;
  110475. /**
  110476. * Adds n individual parser in the list of available ones
  110477. * @param name Defines the name of the parser
  110478. * @param parser Defines the parser to add
  110479. */
  110480. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110481. /**
  110482. * Gets an individual parser from the list of avaialble ones
  110483. * @param name Defines the name of the parser
  110484. * @returns the requested parser or null
  110485. */
  110486. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110487. /**
  110488. * Parser json data and populate both a scene and its associated container object
  110489. * @param jsonData Defines the data to parse
  110490. * @param scene Defines the scene to parse the data for
  110491. * @param container Defines the container attached to the parsing sequence
  110492. * @param rootUrl Defines the root url of the data
  110493. */
  110494. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110495. /**
  110496. * Gets the list of root nodes (ie. nodes with no parent)
  110497. */
  110498. rootNodes: Node[];
  110499. /** All of the cameras added to this scene
  110500. * @see http://doc.babylonjs.com/babylon101/cameras
  110501. */
  110502. cameras: Camera[];
  110503. /**
  110504. * All of the lights added to this scene
  110505. * @see http://doc.babylonjs.com/babylon101/lights
  110506. */
  110507. lights: Light[];
  110508. /**
  110509. * All of the (abstract) meshes added to this scene
  110510. */
  110511. meshes: AbstractMesh[];
  110512. /**
  110513. * The list of skeletons added to the scene
  110514. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110515. */
  110516. skeletons: Skeleton[];
  110517. /**
  110518. * All of the particle systems added to this scene
  110519. * @see http://doc.babylonjs.com/babylon101/particles
  110520. */
  110521. particleSystems: IParticleSystem[];
  110522. /**
  110523. * Gets a list of Animations associated with the scene
  110524. */
  110525. animations: Animation[];
  110526. /**
  110527. * All of the animation groups added to this scene
  110528. * @see http://doc.babylonjs.com/how_to/group
  110529. */
  110530. animationGroups: AnimationGroup[];
  110531. /**
  110532. * All of the multi-materials added to this scene
  110533. * @see http://doc.babylonjs.com/how_to/multi_materials
  110534. */
  110535. multiMaterials: MultiMaterial[];
  110536. /**
  110537. * All of the materials added to this scene
  110538. * In the context of a Scene, it is not supposed to be modified manually.
  110539. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110540. * Note also that the order of the Material within the array is not significant and might change.
  110541. * @see http://doc.babylonjs.com/babylon101/materials
  110542. */
  110543. materials: Material[];
  110544. /**
  110545. * The list of morph target managers added to the scene
  110546. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110547. */
  110548. morphTargetManagers: MorphTargetManager[];
  110549. /**
  110550. * The list of geometries used in the scene.
  110551. */
  110552. geometries: Geometry[];
  110553. /**
  110554. * All of the tranform nodes added to this scene
  110555. * In the context of a Scene, it is not supposed to be modified manually.
  110556. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110557. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110558. * @see http://doc.babylonjs.com/how_to/transformnode
  110559. */
  110560. transformNodes: TransformNode[];
  110561. /**
  110562. * ActionManagers available on the scene.
  110563. */
  110564. actionManagers: AbstractActionManager[];
  110565. /**
  110566. * Textures to keep.
  110567. */
  110568. textures: BaseTexture[];
  110569. /**
  110570. * Environment texture for the scene
  110571. */
  110572. environmentTexture: Nullable<BaseTexture>;
  110573. /**
  110574. * @returns all meshes, lights, cameras, transformNodes and bones
  110575. */
  110576. getNodes(): Array<Node>;
  110577. }
  110578. }
  110579. declare module BABYLON {
  110580. /**
  110581. * Interface used to define options for Sound class
  110582. */
  110583. export interface ISoundOptions {
  110584. /**
  110585. * Does the sound autoplay once loaded.
  110586. */
  110587. autoplay?: boolean;
  110588. /**
  110589. * Does the sound loop after it finishes playing once.
  110590. */
  110591. loop?: boolean;
  110592. /**
  110593. * Sound's volume
  110594. */
  110595. volume?: number;
  110596. /**
  110597. * Is it a spatial sound?
  110598. */
  110599. spatialSound?: boolean;
  110600. /**
  110601. * Maximum distance to hear that sound
  110602. */
  110603. maxDistance?: number;
  110604. /**
  110605. * Uses user defined attenuation function
  110606. */
  110607. useCustomAttenuation?: boolean;
  110608. /**
  110609. * Define the roll off factor of spatial sounds.
  110610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110611. */
  110612. rolloffFactor?: number;
  110613. /**
  110614. * Define the reference distance the sound should be heard perfectly.
  110615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110616. */
  110617. refDistance?: number;
  110618. /**
  110619. * Define the distance attenuation model the sound will follow.
  110620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110621. */
  110622. distanceModel?: string;
  110623. /**
  110624. * Defines the playback speed (1 by default)
  110625. */
  110626. playbackRate?: number;
  110627. /**
  110628. * Defines if the sound is from a streaming source
  110629. */
  110630. streaming?: boolean;
  110631. /**
  110632. * Defines an optional length (in seconds) inside the sound file
  110633. */
  110634. length?: number;
  110635. /**
  110636. * Defines an optional offset (in seconds) inside the sound file
  110637. */
  110638. offset?: number;
  110639. /**
  110640. * If true, URLs will not be required to state the audio file codec to use.
  110641. */
  110642. skipCodecCheck?: boolean;
  110643. }
  110644. /**
  110645. * Defines a sound that can be played in the application.
  110646. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110648. */
  110649. export class Sound {
  110650. /**
  110651. * The name of the sound in the scene.
  110652. */
  110653. name: string;
  110654. /**
  110655. * Does the sound autoplay once loaded.
  110656. */
  110657. autoplay: boolean;
  110658. /**
  110659. * Does the sound loop after it finishes playing once.
  110660. */
  110661. loop: boolean;
  110662. /**
  110663. * Does the sound use a custom attenuation curve to simulate the falloff
  110664. * happening when the source gets further away from the camera.
  110665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110666. */
  110667. useCustomAttenuation: boolean;
  110668. /**
  110669. * The sound track id this sound belongs to.
  110670. */
  110671. soundTrackId: number;
  110672. /**
  110673. * Is this sound currently played.
  110674. */
  110675. isPlaying: boolean;
  110676. /**
  110677. * Is this sound currently paused.
  110678. */
  110679. isPaused: boolean;
  110680. /**
  110681. * Does this sound enables spatial sound.
  110682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110683. */
  110684. spatialSound: boolean;
  110685. /**
  110686. * Define the reference distance the sound should be heard perfectly.
  110687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110688. */
  110689. refDistance: number;
  110690. /**
  110691. * Define the roll off factor of spatial sounds.
  110692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110693. */
  110694. rolloffFactor: number;
  110695. /**
  110696. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110698. */
  110699. maxDistance: number;
  110700. /**
  110701. * Define the distance attenuation model the sound will follow.
  110702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110703. */
  110704. distanceModel: string;
  110705. /**
  110706. * @hidden
  110707. * Back Compat
  110708. **/
  110709. onended: () => any;
  110710. /**
  110711. * Observable event when the current playing sound finishes.
  110712. */
  110713. onEndedObservable: Observable<Sound>;
  110714. private _panningModel;
  110715. private _playbackRate;
  110716. private _streaming;
  110717. private _startTime;
  110718. private _startOffset;
  110719. private _position;
  110720. /** @hidden */
  110721. _positionInEmitterSpace: boolean;
  110722. private _localDirection;
  110723. private _volume;
  110724. private _isReadyToPlay;
  110725. private _isDirectional;
  110726. private _readyToPlayCallback;
  110727. private _audioBuffer;
  110728. private _soundSource;
  110729. private _streamingSource;
  110730. private _soundPanner;
  110731. private _soundGain;
  110732. private _inputAudioNode;
  110733. private _outputAudioNode;
  110734. private _coneInnerAngle;
  110735. private _coneOuterAngle;
  110736. private _coneOuterGain;
  110737. private _scene;
  110738. private _connectedTransformNode;
  110739. private _customAttenuationFunction;
  110740. private _registerFunc;
  110741. private _isOutputConnected;
  110742. private _htmlAudioElement;
  110743. private _urlType;
  110744. private _length?;
  110745. private _offset?;
  110746. /** @hidden */
  110747. static _SceneComponentInitialization: (scene: Scene) => void;
  110748. /**
  110749. * Create a sound and attach it to a scene
  110750. * @param name Name of your sound
  110751. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110752. * @param scene defines the scene the sound belongs to
  110753. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110754. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110755. */
  110756. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110757. /**
  110758. * Release the sound and its associated resources
  110759. */
  110760. dispose(): void;
  110761. /**
  110762. * Gets if the sounds is ready to be played or not.
  110763. * @returns true if ready, otherwise false
  110764. */
  110765. isReady(): boolean;
  110766. private _soundLoaded;
  110767. /**
  110768. * Sets the data of the sound from an audiobuffer
  110769. * @param audioBuffer The audioBuffer containing the data
  110770. */
  110771. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110772. /**
  110773. * Updates the current sounds options such as maxdistance, loop...
  110774. * @param options A JSON object containing values named as the object properties
  110775. */
  110776. updateOptions(options: ISoundOptions): void;
  110777. private _createSpatialParameters;
  110778. private _updateSpatialParameters;
  110779. /**
  110780. * Switch the panning model to HRTF:
  110781. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110783. */
  110784. switchPanningModelToHRTF(): void;
  110785. /**
  110786. * Switch the panning model to Equal Power:
  110787. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110789. */
  110790. switchPanningModelToEqualPower(): void;
  110791. private _switchPanningModel;
  110792. /**
  110793. * Connect this sound to a sound track audio node like gain...
  110794. * @param soundTrackAudioNode the sound track audio node to connect to
  110795. */
  110796. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110797. /**
  110798. * Transform this sound into a directional source
  110799. * @param coneInnerAngle Size of the inner cone in degree
  110800. * @param coneOuterAngle Size of the outer cone in degree
  110801. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110802. */
  110803. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110804. /**
  110805. * Gets or sets the inner angle for the directional cone.
  110806. */
  110807. get directionalConeInnerAngle(): number;
  110808. /**
  110809. * Gets or sets the inner angle for the directional cone.
  110810. */
  110811. set directionalConeInnerAngle(value: number);
  110812. /**
  110813. * Gets or sets the outer angle for the directional cone.
  110814. */
  110815. get directionalConeOuterAngle(): number;
  110816. /**
  110817. * Gets or sets the outer angle for the directional cone.
  110818. */
  110819. set directionalConeOuterAngle(value: number);
  110820. /**
  110821. * Sets the position of the emitter if spatial sound is enabled
  110822. * @param newPosition Defines the new posisiton
  110823. */
  110824. setPosition(newPosition: Vector3): void;
  110825. /**
  110826. * Sets the local direction of the emitter if spatial sound is enabled
  110827. * @param newLocalDirection Defines the new local direction
  110828. */
  110829. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110830. private _updateDirection;
  110831. /** @hidden */
  110832. updateDistanceFromListener(): void;
  110833. /**
  110834. * Sets a new custom attenuation function for the sound.
  110835. * @param callback Defines the function used for the attenuation
  110836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110837. */
  110838. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110839. /**
  110840. * Play the sound
  110841. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110842. * @param offset (optional) Start the sound at a specific time in seconds
  110843. * @param length (optional) Sound duration (in seconds)
  110844. */
  110845. play(time?: number, offset?: number, length?: number): void;
  110846. private _onended;
  110847. /**
  110848. * Stop the sound
  110849. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110850. */
  110851. stop(time?: number): void;
  110852. /**
  110853. * Put the sound in pause
  110854. */
  110855. pause(): void;
  110856. /**
  110857. * Sets a dedicated volume for this sounds
  110858. * @param newVolume Define the new volume of the sound
  110859. * @param time Define time for gradual change to new volume
  110860. */
  110861. setVolume(newVolume: number, time?: number): void;
  110862. /**
  110863. * Set the sound play back rate
  110864. * @param newPlaybackRate Define the playback rate the sound should be played at
  110865. */
  110866. setPlaybackRate(newPlaybackRate: number): void;
  110867. /**
  110868. * Gets the volume of the sound.
  110869. * @returns the volume of the sound
  110870. */
  110871. getVolume(): number;
  110872. /**
  110873. * Attach the sound to a dedicated mesh
  110874. * @param transformNode The transform node to connect the sound with
  110875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110876. */
  110877. attachToMesh(transformNode: TransformNode): void;
  110878. /**
  110879. * Detach the sound from the previously attached mesh
  110880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110881. */
  110882. detachFromMesh(): void;
  110883. private _onRegisterAfterWorldMatrixUpdate;
  110884. /**
  110885. * Clone the current sound in the scene.
  110886. * @returns the new sound clone
  110887. */
  110888. clone(): Nullable<Sound>;
  110889. /**
  110890. * Gets the current underlying audio buffer containing the data
  110891. * @returns the audio buffer
  110892. */
  110893. getAudioBuffer(): Nullable<AudioBuffer>;
  110894. /**
  110895. * Serializes the Sound in a JSON representation
  110896. * @returns the JSON representation of the sound
  110897. */
  110898. serialize(): any;
  110899. /**
  110900. * Parse a JSON representation of a sound to innstantiate in a given scene
  110901. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110902. * @param scene Define the scene the new parsed sound should be created in
  110903. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110904. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110905. * @returns the newly parsed sound
  110906. */
  110907. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110908. }
  110909. }
  110910. declare module BABYLON {
  110911. /**
  110912. * This defines an action helpful to play a defined sound on a triggered action.
  110913. */
  110914. export class PlaySoundAction extends Action {
  110915. private _sound;
  110916. /**
  110917. * Instantiate the action
  110918. * @param triggerOptions defines the trigger options
  110919. * @param sound defines the sound to play
  110920. * @param condition defines the trigger related conditions
  110921. */
  110922. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110923. /** @hidden */
  110924. _prepare(): void;
  110925. /**
  110926. * Execute the action and play the sound.
  110927. */
  110928. execute(): void;
  110929. /**
  110930. * Serializes the actions and its related information.
  110931. * @param parent defines the object to serialize in
  110932. * @returns the serialized object
  110933. */
  110934. serialize(parent: any): any;
  110935. }
  110936. /**
  110937. * This defines an action helpful to stop a defined sound on a triggered action.
  110938. */
  110939. export class StopSoundAction extends Action {
  110940. private _sound;
  110941. /**
  110942. * Instantiate the action
  110943. * @param triggerOptions defines the trigger options
  110944. * @param sound defines the sound to stop
  110945. * @param condition defines the trigger related conditions
  110946. */
  110947. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110948. /** @hidden */
  110949. _prepare(): void;
  110950. /**
  110951. * Execute the action and stop the sound.
  110952. */
  110953. execute(): void;
  110954. /**
  110955. * Serializes the actions and its related information.
  110956. * @param parent defines the object to serialize in
  110957. * @returns the serialized object
  110958. */
  110959. serialize(parent: any): any;
  110960. }
  110961. }
  110962. declare module BABYLON {
  110963. /**
  110964. * This defines an action responsible to change the value of a property
  110965. * by interpolating between its current value and the newly set one once triggered.
  110966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110967. */
  110968. export class InterpolateValueAction extends Action {
  110969. /**
  110970. * Defines the path of the property where the value should be interpolated
  110971. */
  110972. propertyPath: string;
  110973. /**
  110974. * Defines the target value at the end of the interpolation.
  110975. */
  110976. value: any;
  110977. /**
  110978. * Defines the time it will take for the property to interpolate to the value.
  110979. */
  110980. duration: number;
  110981. /**
  110982. * Defines if the other scene animations should be stopped when the action has been triggered
  110983. */
  110984. stopOtherAnimations?: boolean;
  110985. /**
  110986. * Defines a callback raised once the interpolation animation has been done.
  110987. */
  110988. onInterpolationDone?: () => void;
  110989. /**
  110990. * Observable triggered once the interpolation animation has been done.
  110991. */
  110992. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110993. private _target;
  110994. private _effectiveTarget;
  110995. private _property;
  110996. /**
  110997. * Instantiate the action
  110998. * @param triggerOptions defines the trigger options
  110999. * @param target defines the object containing the value to interpolate
  111000. * @param propertyPath defines the path to the property in the target object
  111001. * @param value defines the target value at the end of the interpolation
  111002. * @param duration deines the time it will take for the property to interpolate to the value.
  111003. * @param condition defines the trigger related conditions
  111004. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  111005. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  111006. */
  111007. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  111008. /** @hidden */
  111009. _prepare(): void;
  111010. /**
  111011. * Execute the action starts the value interpolation.
  111012. */
  111013. execute(): void;
  111014. /**
  111015. * Serializes the actions and its related information.
  111016. * @param parent defines the object to serialize in
  111017. * @returns the serialized object
  111018. */
  111019. serialize(parent: any): any;
  111020. }
  111021. }
  111022. declare module BABYLON {
  111023. /**
  111024. * Options allowed during the creation of a sound track.
  111025. */
  111026. export interface ISoundTrackOptions {
  111027. /**
  111028. * The volume the sound track should take during creation
  111029. */
  111030. volume?: number;
  111031. /**
  111032. * Define if the sound track is the main sound track of the scene
  111033. */
  111034. mainTrack?: boolean;
  111035. }
  111036. /**
  111037. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  111038. * It will be also used in a future release to apply effects on a specific track.
  111039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111040. */
  111041. export class SoundTrack {
  111042. /**
  111043. * The unique identifier of the sound track in the scene.
  111044. */
  111045. id: number;
  111046. /**
  111047. * The list of sounds included in the sound track.
  111048. */
  111049. soundCollection: Array<Sound>;
  111050. private _outputAudioNode;
  111051. private _scene;
  111052. private _connectedAnalyser;
  111053. private _options;
  111054. private _isInitialized;
  111055. /**
  111056. * Creates a new sound track.
  111057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111058. * @param scene Define the scene the sound track belongs to
  111059. * @param options
  111060. */
  111061. constructor(scene: Scene, options?: ISoundTrackOptions);
  111062. private _initializeSoundTrackAudioGraph;
  111063. /**
  111064. * Release the sound track and its associated resources
  111065. */
  111066. dispose(): void;
  111067. /**
  111068. * Adds a sound to this sound track
  111069. * @param sound define the cound to add
  111070. * @ignoreNaming
  111071. */
  111072. AddSound(sound: Sound): void;
  111073. /**
  111074. * Removes a sound to this sound track
  111075. * @param sound define the cound to remove
  111076. * @ignoreNaming
  111077. */
  111078. RemoveSound(sound: Sound): void;
  111079. /**
  111080. * Set a global volume for the full sound track.
  111081. * @param newVolume Define the new volume of the sound track
  111082. */
  111083. setVolume(newVolume: number): void;
  111084. /**
  111085. * Switch the panning model to HRTF:
  111086. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111088. */
  111089. switchPanningModelToHRTF(): void;
  111090. /**
  111091. * Switch the panning model to Equal Power:
  111092. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111094. */
  111095. switchPanningModelToEqualPower(): void;
  111096. /**
  111097. * Connect the sound track to an audio analyser allowing some amazing
  111098. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111100. * @param analyser The analyser to connect to the engine
  111101. */
  111102. connectToAnalyser(analyser: Analyser): void;
  111103. }
  111104. }
  111105. declare module BABYLON {
  111106. interface AbstractScene {
  111107. /**
  111108. * The list of sounds used in the scene.
  111109. */
  111110. sounds: Nullable<Array<Sound>>;
  111111. }
  111112. interface Scene {
  111113. /**
  111114. * @hidden
  111115. * Backing field
  111116. */
  111117. _mainSoundTrack: SoundTrack;
  111118. /**
  111119. * The main sound track played by the scene.
  111120. * It cotains your primary collection of sounds.
  111121. */
  111122. mainSoundTrack: SoundTrack;
  111123. /**
  111124. * The list of sound tracks added to the scene
  111125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111126. */
  111127. soundTracks: Nullable<Array<SoundTrack>>;
  111128. /**
  111129. * Gets a sound using a given name
  111130. * @param name defines the name to search for
  111131. * @return the found sound or null if not found at all.
  111132. */
  111133. getSoundByName(name: string): Nullable<Sound>;
  111134. /**
  111135. * Gets or sets if audio support is enabled
  111136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111137. */
  111138. audioEnabled: boolean;
  111139. /**
  111140. * Gets or sets if audio will be output to headphones
  111141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111142. */
  111143. headphone: boolean;
  111144. /**
  111145. * Gets or sets custom audio listener position provider
  111146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111147. */
  111148. audioListenerPositionProvider: Nullable<() => Vector3>;
  111149. /**
  111150. * Gets or sets a refresh rate when using 3D audio positioning
  111151. */
  111152. audioPositioningRefreshRate: number;
  111153. }
  111154. /**
  111155. * Defines the sound scene component responsible to manage any sounds
  111156. * in a given scene.
  111157. */
  111158. export class AudioSceneComponent implements ISceneSerializableComponent {
  111159. /**
  111160. * The component name helpfull to identify the component in the list of scene components.
  111161. */
  111162. readonly name: string;
  111163. /**
  111164. * The scene the component belongs to.
  111165. */
  111166. scene: Scene;
  111167. private _audioEnabled;
  111168. /**
  111169. * Gets whether audio is enabled or not.
  111170. * Please use related enable/disable method to switch state.
  111171. */
  111172. get audioEnabled(): boolean;
  111173. private _headphone;
  111174. /**
  111175. * Gets whether audio is outputing to headphone or not.
  111176. * Please use the according Switch methods to change output.
  111177. */
  111178. get headphone(): boolean;
  111179. /**
  111180. * Gets or sets a refresh rate when using 3D audio positioning
  111181. */
  111182. audioPositioningRefreshRate: number;
  111183. private _audioListenerPositionProvider;
  111184. /**
  111185. * Gets the current audio listener position provider
  111186. */
  111187. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111188. /**
  111189. * Sets a custom listener position for all sounds in the scene
  111190. * By default, this is the position of the first active camera
  111191. */
  111192. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111193. /**
  111194. * Creates a new instance of the component for the given scene
  111195. * @param scene Defines the scene to register the component in
  111196. */
  111197. constructor(scene: Scene);
  111198. /**
  111199. * Registers the component in a given scene
  111200. */
  111201. register(): void;
  111202. /**
  111203. * Rebuilds the elements related to this component in case of
  111204. * context lost for instance.
  111205. */
  111206. rebuild(): void;
  111207. /**
  111208. * Serializes the component data to the specified json object
  111209. * @param serializationObject The object to serialize to
  111210. */
  111211. serialize(serializationObject: any): void;
  111212. /**
  111213. * Adds all the elements from the container to the scene
  111214. * @param container the container holding the elements
  111215. */
  111216. addFromContainer(container: AbstractScene): void;
  111217. /**
  111218. * Removes all the elements in the container from the scene
  111219. * @param container contains the elements to remove
  111220. * @param dispose if the removed element should be disposed (default: false)
  111221. */
  111222. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111223. /**
  111224. * Disposes the component and the associated ressources.
  111225. */
  111226. dispose(): void;
  111227. /**
  111228. * Disables audio in the associated scene.
  111229. */
  111230. disableAudio(): void;
  111231. /**
  111232. * Enables audio in the associated scene.
  111233. */
  111234. enableAudio(): void;
  111235. /**
  111236. * Switch audio to headphone output.
  111237. */
  111238. switchAudioModeForHeadphones(): void;
  111239. /**
  111240. * Switch audio to normal speakers.
  111241. */
  111242. switchAudioModeForNormalSpeakers(): void;
  111243. private _cachedCameraDirection;
  111244. private _cachedCameraPosition;
  111245. private _lastCheck;
  111246. private _afterRender;
  111247. }
  111248. }
  111249. declare module BABYLON {
  111250. /**
  111251. * Wraps one or more Sound objects and selects one with random weight for playback.
  111252. */
  111253. export class WeightedSound {
  111254. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111255. loop: boolean;
  111256. private _coneInnerAngle;
  111257. private _coneOuterAngle;
  111258. private _volume;
  111259. /** A Sound is currently playing. */
  111260. isPlaying: boolean;
  111261. /** A Sound is currently paused. */
  111262. isPaused: boolean;
  111263. private _sounds;
  111264. private _weights;
  111265. private _currentIndex?;
  111266. /**
  111267. * Creates a new WeightedSound from the list of sounds given.
  111268. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111269. * @param sounds Array of Sounds that will be selected from.
  111270. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111271. */
  111272. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111273. /**
  111274. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111275. */
  111276. get directionalConeInnerAngle(): number;
  111277. /**
  111278. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111279. */
  111280. set directionalConeInnerAngle(value: number);
  111281. /**
  111282. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111283. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111284. */
  111285. get directionalConeOuterAngle(): number;
  111286. /**
  111287. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111288. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111289. */
  111290. set directionalConeOuterAngle(value: number);
  111291. /**
  111292. * Playback volume.
  111293. */
  111294. get volume(): number;
  111295. /**
  111296. * Playback volume.
  111297. */
  111298. set volume(value: number);
  111299. private _onended;
  111300. /**
  111301. * Suspend playback
  111302. */
  111303. pause(): void;
  111304. /**
  111305. * Stop playback
  111306. */
  111307. stop(): void;
  111308. /**
  111309. * Start playback.
  111310. * @param startOffset Position the clip head at a specific time in seconds.
  111311. */
  111312. play(startOffset?: number): void;
  111313. }
  111314. }
  111315. declare module BABYLON {
  111316. /**
  111317. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111319. */
  111320. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111321. /**
  111322. * Gets the name of the behavior.
  111323. */
  111324. get name(): string;
  111325. /**
  111326. * The easing function used by animations
  111327. */
  111328. static EasingFunction: BackEase;
  111329. /**
  111330. * The easing mode used by animations
  111331. */
  111332. static EasingMode: number;
  111333. /**
  111334. * The duration of the animation, in milliseconds
  111335. */
  111336. transitionDuration: number;
  111337. /**
  111338. * Length of the distance animated by the transition when lower radius is reached
  111339. */
  111340. lowerRadiusTransitionRange: number;
  111341. /**
  111342. * Length of the distance animated by the transition when upper radius is reached
  111343. */
  111344. upperRadiusTransitionRange: number;
  111345. private _autoTransitionRange;
  111346. /**
  111347. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111348. */
  111349. get autoTransitionRange(): boolean;
  111350. /**
  111351. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111352. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111353. */
  111354. set autoTransitionRange(value: boolean);
  111355. private _attachedCamera;
  111356. private _onAfterCheckInputsObserver;
  111357. private _onMeshTargetChangedObserver;
  111358. /**
  111359. * Initializes the behavior.
  111360. */
  111361. init(): void;
  111362. /**
  111363. * Attaches the behavior to its arc rotate camera.
  111364. * @param camera Defines the camera to attach the behavior to
  111365. */
  111366. attach(camera: ArcRotateCamera): void;
  111367. /**
  111368. * Detaches the behavior from its current arc rotate camera.
  111369. */
  111370. detach(): void;
  111371. private _radiusIsAnimating;
  111372. private _radiusBounceTransition;
  111373. private _animatables;
  111374. private _cachedWheelPrecision;
  111375. /**
  111376. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111377. * @param radiusLimit The limit to check against.
  111378. * @return Bool to indicate if at limit.
  111379. */
  111380. private _isRadiusAtLimit;
  111381. /**
  111382. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111383. * @param radiusDelta The delta by which to animate to. Can be negative.
  111384. */
  111385. private _applyBoundRadiusAnimation;
  111386. /**
  111387. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111388. */
  111389. protected _clearAnimationLocks(): void;
  111390. /**
  111391. * Stops and removes all animations that have been applied to the camera
  111392. */
  111393. stopAllAnimations(): void;
  111394. }
  111395. }
  111396. declare module BABYLON {
  111397. /**
  111398. * 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.
  111399. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111400. */
  111401. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111402. /**
  111403. * Gets the name of the behavior.
  111404. */
  111405. get name(): string;
  111406. private _mode;
  111407. private _radiusScale;
  111408. private _positionScale;
  111409. private _defaultElevation;
  111410. private _elevationReturnTime;
  111411. private _elevationReturnWaitTime;
  111412. private _zoomStopsAnimation;
  111413. private _framingTime;
  111414. /**
  111415. * The easing function used by animations
  111416. */
  111417. static EasingFunction: ExponentialEase;
  111418. /**
  111419. * The easing mode used by animations
  111420. */
  111421. static EasingMode: number;
  111422. /**
  111423. * Sets the current mode used by the behavior
  111424. */
  111425. set mode(mode: number);
  111426. /**
  111427. * Gets current mode used by the behavior.
  111428. */
  111429. get mode(): number;
  111430. /**
  111431. * Sets the scale applied to the radius (1 by default)
  111432. */
  111433. set radiusScale(radius: number);
  111434. /**
  111435. * Gets the scale applied to the radius
  111436. */
  111437. get radiusScale(): number;
  111438. /**
  111439. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111440. */
  111441. set positionScale(scale: number);
  111442. /**
  111443. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111444. */
  111445. get positionScale(): number;
  111446. /**
  111447. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111448. * behaviour is triggered, in radians.
  111449. */
  111450. set defaultElevation(elevation: number);
  111451. /**
  111452. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111453. * behaviour is triggered, in radians.
  111454. */
  111455. get defaultElevation(): number;
  111456. /**
  111457. * Sets the time (in milliseconds) taken to return to the default beta position.
  111458. * Negative value indicates camera should not return to default.
  111459. */
  111460. set elevationReturnTime(speed: number);
  111461. /**
  111462. * Gets the time (in milliseconds) taken to return to the default beta position.
  111463. * Negative value indicates camera should not return to default.
  111464. */
  111465. get elevationReturnTime(): number;
  111466. /**
  111467. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111468. */
  111469. set elevationReturnWaitTime(time: number);
  111470. /**
  111471. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111472. */
  111473. get elevationReturnWaitTime(): number;
  111474. /**
  111475. * Sets the flag that indicates if user zooming should stop animation.
  111476. */
  111477. set zoomStopsAnimation(flag: boolean);
  111478. /**
  111479. * Gets the flag that indicates if user zooming should stop animation.
  111480. */
  111481. get zoomStopsAnimation(): boolean;
  111482. /**
  111483. * Sets the transition time when framing the mesh, in milliseconds
  111484. */
  111485. set framingTime(time: number);
  111486. /**
  111487. * Gets the transition time when framing the mesh, in milliseconds
  111488. */
  111489. get framingTime(): number;
  111490. /**
  111491. * Define if the behavior should automatically change the configured
  111492. * camera limits and sensibilities.
  111493. */
  111494. autoCorrectCameraLimitsAndSensibility: boolean;
  111495. private _onPrePointerObservableObserver;
  111496. private _onAfterCheckInputsObserver;
  111497. private _onMeshTargetChangedObserver;
  111498. private _attachedCamera;
  111499. private _isPointerDown;
  111500. private _lastInteractionTime;
  111501. /**
  111502. * Initializes the behavior.
  111503. */
  111504. init(): void;
  111505. /**
  111506. * Attaches the behavior to its arc rotate camera.
  111507. * @param camera Defines the camera to attach the behavior to
  111508. */
  111509. attach(camera: ArcRotateCamera): void;
  111510. /**
  111511. * Detaches the behavior from its current arc rotate camera.
  111512. */
  111513. detach(): void;
  111514. private _animatables;
  111515. private _betaIsAnimating;
  111516. private _betaTransition;
  111517. private _radiusTransition;
  111518. private _vectorTransition;
  111519. /**
  111520. * Targets the given mesh and updates zoom level accordingly.
  111521. * @param mesh The mesh to target.
  111522. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111523. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111524. */
  111525. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111526. /**
  111527. * Targets the given mesh with its children and updates zoom level accordingly.
  111528. * @param mesh The mesh to target.
  111529. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111530. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111531. */
  111532. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111533. /**
  111534. * Targets the given meshes with their children and updates zoom level accordingly.
  111535. * @param meshes The mesh to target.
  111536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111538. */
  111539. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111540. /**
  111541. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111542. * @param minimumWorld Determines the smaller position of the bounding box extend
  111543. * @param maximumWorld Determines the bigger position of the bounding box extend
  111544. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111545. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111546. */
  111547. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111548. /**
  111549. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111550. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111551. * frustum width.
  111552. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111553. * to fully enclose the mesh in the viewing frustum.
  111554. */
  111555. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111556. /**
  111557. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111558. * is automatically returned to its default position (expected to be above ground plane).
  111559. */
  111560. private _maintainCameraAboveGround;
  111561. /**
  111562. * Returns the frustum slope based on the canvas ratio and camera FOV
  111563. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111564. */
  111565. private _getFrustumSlope;
  111566. /**
  111567. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111568. */
  111569. private _clearAnimationLocks;
  111570. /**
  111571. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111572. */
  111573. private _applyUserInteraction;
  111574. /**
  111575. * Stops and removes all animations that have been applied to the camera
  111576. */
  111577. stopAllAnimations(): void;
  111578. /**
  111579. * Gets a value indicating if the user is moving the camera
  111580. */
  111581. get isUserIsMoving(): boolean;
  111582. /**
  111583. * The camera can move all the way towards the mesh.
  111584. */
  111585. static IgnoreBoundsSizeMode: number;
  111586. /**
  111587. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111588. */
  111589. static FitFrustumSidesMode: number;
  111590. }
  111591. }
  111592. declare module BABYLON {
  111593. /**
  111594. * Base class for Camera Pointer Inputs.
  111595. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111596. * for example usage.
  111597. */
  111598. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111599. /**
  111600. * Defines the camera the input is attached to.
  111601. */
  111602. abstract camera: Camera;
  111603. /**
  111604. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111605. */
  111606. protected _altKey: boolean;
  111607. protected _ctrlKey: boolean;
  111608. protected _metaKey: boolean;
  111609. protected _shiftKey: boolean;
  111610. /**
  111611. * Which mouse buttons were pressed at time of last mouse event.
  111612. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111613. */
  111614. protected _buttonsPressed: number;
  111615. /**
  111616. * Defines the buttons associated with the input to handle camera move.
  111617. */
  111618. buttons: number[];
  111619. /**
  111620. * Attach the input controls to a specific dom element to get the input from.
  111621. * @param element Defines the element the controls should be listened from
  111622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111623. */
  111624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111625. /**
  111626. * Detach the current controls from the specified dom element.
  111627. * @param element Defines the element to stop listening the inputs from
  111628. */
  111629. detachControl(element: Nullable<HTMLElement>): void;
  111630. /**
  111631. * Gets the class name of the current input.
  111632. * @returns the class name
  111633. */
  111634. getClassName(): string;
  111635. /**
  111636. * Get the friendly name associated with the input class.
  111637. * @returns the input friendly name
  111638. */
  111639. getSimpleName(): string;
  111640. /**
  111641. * Called on pointer POINTERDOUBLETAP event.
  111642. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111643. */
  111644. protected onDoubleTap(type: string): void;
  111645. /**
  111646. * Called on pointer POINTERMOVE event if only a single touch is active.
  111647. * Override this method to provide functionality.
  111648. */
  111649. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111650. /**
  111651. * Called on pointer POINTERMOVE event if multiple touches are active.
  111652. * Override this method to provide functionality.
  111653. */
  111654. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111655. /**
  111656. * Called on JS contextmenu event.
  111657. * Override this method to provide functionality.
  111658. */
  111659. protected onContextMenu(evt: PointerEvent): void;
  111660. /**
  111661. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111662. * press.
  111663. * Override this method to provide functionality.
  111664. */
  111665. protected onButtonDown(evt: PointerEvent): void;
  111666. /**
  111667. * Called each time a new POINTERUP event occurs. Ie, for each button
  111668. * release.
  111669. * Override this method to provide functionality.
  111670. */
  111671. protected onButtonUp(evt: PointerEvent): void;
  111672. /**
  111673. * Called when window becomes inactive.
  111674. * Override this method to provide functionality.
  111675. */
  111676. protected onLostFocus(): void;
  111677. private _pointerInput;
  111678. private _observer;
  111679. private _onLostFocus;
  111680. private pointA;
  111681. private pointB;
  111682. }
  111683. }
  111684. declare module BABYLON {
  111685. /**
  111686. * Manage the pointers inputs to control an arc rotate camera.
  111687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111688. */
  111689. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111690. /**
  111691. * Defines the camera the input is attached to.
  111692. */
  111693. camera: ArcRotateCamera;
  111694. /**
  111695. * Gets the class name of the current input.
  111696. * @returns the class name
  111697. */
  111698. getClassName(): string;
  111699. /**
  111700. * Defines the buttons associated with the input to handle camera move.
  111701. */
  111702. buttons: number[];
  111703. /**
  111704. * Defines the pointer angular sensibility along the X axis or how fast is
  111705. * the camera rotating.
  111706. */
  111707. angularSensibilityX: number;
  111708. /**
  111709. * Defines the pointer angular sensibility along the Y axis or how fast is
  111710. * the camera rotating.
  111711. */
  111712. angularSensibilityY: number;
  111713. /**
  111714. * Defines the pointer pinch precision or how fast is the camera zooming.
  111715. */
  111716. pinchPrecision: number;
  111717. /**
  111718. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111719. * from 0.
  111720. * It defines the percentage of current camera.radius to use as delta when
  111721. * pinch zoom is used.
  111722. */
  111723. pinchDeltaPercentage: number;
  111724. /**
  111725. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111726. * that any object in the plane at the camera's target point will scale
  111727. * perfectly with finger motion.
  111728. * Overrides pinchDeltaPercentage and pinchPrecision.
  111729. */
  111730. useNaturalPinchZoom: boolean;
  111731. /**
  111732. * Defines the pointer panning sensibility or how fast is the camera moving.
  111733. */
  111734. panningSensibility: number;
  111735. /**
  111736. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111737. */
  111738. multiTouchPanning: boolean;
  111739. /**
  111740. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111741. * zoom (pinch) through multitouch.
  111742. */
  111743. multiTouchPanAndZoom: boolean;
  111744. /**
  111745. * Revers pinch action direction.
  111746. */
  111747. pinchInwards: boolean;
  111748. private _isPanClick;
  111749. private _twoFingerActivityCount;
  111750. private _isPinching;
  111751. /**
  111752. * Called on pointer POINTERMOVE event if only a single touch is active.
  111753. */
  111754. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111755. /**
  111756. * Called on pointer POINTERDOUBLETAP event.
  111757. */
  111758. protected onDoubleTap(type: string): void;
  111759. /**
  111760. * Called on pointer POINTERMOVE event if multiple touches are active.
  111761. */
  111762. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111763. /**
  111764. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111765. * press.
  111766. */
  111767. protected onButtonDown(evt: PointerEvent): void;
  111768. /**
  111769. * Called each time a new POINTERUP event occurs. Ie, for each button
  111770. * release.
  111771. */
  111772. protected onButtonUp(evt: PointerEvent): void;
  111773. /**
  111774. * Called when window becomes inactive.
  111775. */
  111776. protected onLostFocus(): void;
  111777. }
  111778. }
  111779. declare module BABYLON {
  111780. /**
  111781. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111783. */
  111784. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111785. /**
  111786. * Defines the camera the input is attached to.
  111787. */
  111788. camera: ArcRotateCamera;
  111789. /**
  111790. * Defines the list of key codes associated with the up action (increase alpha)
  111791. */
  111792. keysUp: number[];
  111793. /**
  111794. * Defines the list of key codes associated with the down action (decrease alpha)
  111795. */
  111796. keysDown: number[];
  111797. /**
  111798. * Defines the list of key codes associated with the left action (increase beta)
  111799. */
  111800. keysLeft: number[];
  111801. /**
  111802. * Defines the list of key codes associated with the right action (decrease beta)
  111803. */
  111804. keysRight: number[];
  111805. /**
  111806. * Defines the list of key codes associated with the reset action.
  111807. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111808. */
  111809. keysReset: number[];
  111810. /**
  111811. * Defines the panning sensibility of the inputs.
  111812. * (How fast is the camera panning)
  111813. */
  111814. panningSensibility: number;
  111815. /**
  111816. * Defines the zooming sensibility of the inputs.
  111817. * (How fast is the camera zooming)
  111818. */
  111819. zoomingSensibility: number;
  111820. /**
  111821. * Defines whether maintaining the alt key down switch the movement mode from
  111822. * orientation to zoom.
  111823. */
  111824. useAltToZoom: boolean;
  111825. /**
  111826. * Rotation speed of the camera
  111827. */
  111828. angularSpeed: number;
  111829. private _keys;
  111830. private _ctrlPressed;
  111831. private _altPressed;
  111832. private _onCanvasBlurObserver;
  111833. private _onKeyboardObserver;
  111834. private _engine;
  111835. private _scene;
  111836. /**
  111837. * Attach the input controls to a specific dom element to get the input from.
  111838. * @param element Defines the element the controls should be listened from
  111839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111840. */
  111841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111842. /**
  111843. * Detach the current controls from the specified dom element.
  111844. * @param element Defines the element to stop listening the inputs from
  111845. */
  111846. detachControl(element: Nullable<HTMLElement>): void;
  111847. /**
  111848. * Update the current camera state depending on the inputs that have been used this frame.
  111849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111850. */
  111851. checkInputs(): void;
  111852. /**
  111853. * Gets the class name of the current intput.
  111854. * @returns the class name
  111855. */
  111856. getClassName(): string;
  111857. /**
  111858. * Get the friendly name associated with the input class.
  111859. * @returns the input friendly name
  111860. */
  111861. getSimpleName(): string;
  111862. }
  111863. }
  111864. declare module BABYLON {
  111865. /**
  111866. * Manage the mouse wheel inputs to control an arc rotate camera.
  111867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111868. */
  111869. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111870. /**
  111871. * Defines the camera the input is attached to.
  111872. */
  111873. camera: ArcRotateCamera;
  111874. /**
  111875. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111876. */
  111877. wheelPrecision: number;
  111878. /**
  111879. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111880. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111881. */
  111882. wheelDeltaPercentage: number;
  111883. private _wheel;
  111884. private _observer;
  111885. private computeDeltaFromMouseWheelLegacyEvent;
  111886. /**
  111887. * Attach the input controls to a specific dom element to get the input from.
  111888. * @param element Defines the element the controls should be listened from
  111889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111890. */
  111891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111892. /**
  111893. * Detach the current controls from the specified dom element.
  111894. * @param element Defines the element to stop listening the inputs from
  111895. */
  111896. detachControl(element: Nullable<HTMLElement>): void;
  111897. /**
  111898. * Gets the class name of the current intput.
  111899. * @returns the class name
  111900. */
  111901. getClassName(): string;
  111902. /**
  111903. * Get the friendly name associated with the input class.
  111904. * @returns the input friendly name
  111905. */
  111906. getSimpleName(): string;
  111907. }
  111908. }
  111909. declare module BABYLON {
  111910. /**
  111911. * Default Inputs manager for the ArcRotateCamera.
  111912. * It groups all the default supported inputs for ease of use.
  111913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111914. */
  111915. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111916. /**
  111917. * Instantiates a new ArcRotateCameraInputsManager.
  111918. * @param camera Defines the camera the inputs belong to
  111919. */
  111920. constructor(camera: ArcRotateCamera);
  111921. /**
  111922. * Add mouse wheel input support to the input manager.
  111923. * @returns the current input manager
  111924. */
  111925. addMouseWheel(): ArcRotateCameraInputsManager;
  111926. /**
  111927. * Add pointers input support to the input manager.
  111928. * @returns the current input manager
  111929. */
  111930. addPointers(): ArcRotateCameraInputsManager;
  111931. /**
  111932. * Add keyboard input support to the input manager.
  111933. * @returns the current input manager
  111934. */
  111935. addKeyboard(): ArcRotateCameraInputsManager;
  111936. }
  111937. }
  111938. declare module BABYLON {
  111939. /**
  111940. * This represents an orbital type of camera.
  111941. *
  111942. * 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.
  111943. * 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.
  111944. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111945. */
  111946. export class ArcRotateCamera extends TargetCamera {
  111947. /**
  111948. * Defines the rotation angle of the camera along the longitudinal axis.
  111949. */
  111950. alpha: number;
  111951. /**
  111952. * Defines the rotation angle of the camera along the latitudinal axis.
  111953. */
  111954. beta: number;
  111955. /**
  111956. * Defines the radius of the camera from it s target point.
  111957. */
  111958. radius: number;
  111959. protected _target: Vector3;
  111960. protected _targetHost: Nullable<AbstractMesh>;
  111961. /**
  111962. * Defines the target point of the camera.
  111963. * The camera looks towards it form the radius distance.
  111964. */
  111965. get target(): Vector3;
  111966. set target(value: Vector3);
  111967. /**
  111968. * Define the current local position of the camera in the scene
  111969. */
  111970. get position(): Vector3;
  111971. set position(newPosition: Vector3);
  111972. protected _upVector: Vector3;
  111973. protected _upToYMatrix: Matrix;
  111974. protected _YToUpMatrix: Matrix;
  111975. /**
  111976. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111977. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111978. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111979. */
  111980. set upVector(vec: Vector3);
  111981. get upVector(): Vector3;
  111982. /**
  111983. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111984. */
  111985. setMatUp(): void;
  111986. /**
  111987. * Current inertia value on the longitudinal axis.
  111988. * The bigger this number the longer it will take for the camera to stop.
  111989. */
  111990. inertialAlphaOffset: number;
  111991. /**
  111992. * Current inertia value on the latitudinal axis.
  111993. * The bigger this number the longer it will take for the camera to stop.
  111994. */
  111995. inertialBetaOffset: number;
  111996. /**
  111997. * Current inertia value on the radius axis.
  111998. * The bigger this number the longer it will take for the camera to stop.
  111999. */
  112000. inertialRadiusOffset: number;
  112001. /**
  112002. * Minimum allowed angle on the longitudinal axis.
  112003. * This can help limiting how the Camera is able to move in the scene.
  112004. */
  112005. lowerAlphaLimit: Nullable<number>;
  112006. /**
  112007. * Maximum allowed angle on the longitudinal axis.
  112008. * This can help limiting how the Camera is able to move in the scene.
  112009. */
  112010. upperAlphaLimit: Nullable<number>;
  112011. /**
  112012. * Minimum allowed angle on the latitudinal axis.
  112013. * This can help limiting how the Camera is able to move in the scene.
  112014. */
  112015. lowerBetaLimit: number;
  112016. /**
  112017. * Maximum allowed angle on the latitudinal axis.
  112018. * This can help limiting how the Camera is able to move in the scene.
  112019. */
  112020. upperBetaLimit: number;
  112021. /**
  112022. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  112023. * This can help limiting how the Camera is able to move in the scene.
  112024. */
  112025. lowerRadiusLimit: Nullable<number>;
  112026. /**
  112027. * Maximum allowed distance of the camera to the target (The camera can not get further).
  112028. * This can help limiting how the Camera is able to move in the scene.
  112029. */
  112030. upperRadiusLimit: Nullable<number>;
  112031. /**
  112032. * Defines the current inertia value used during panning of the camera along the X axis.
  112033. */
  112034. inertialPanningX: number;
  112035. /**
  112036. * Defines the current inertia value used during panning of the camera along the Y axis.
  112037. */
  112038. inertialPanningY: number;
  112039. /**
  112040. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  112041. * Basically if your fingers moves away from more than this distance you will be considered
  112042. * in pinch mode.
  112043. */
  112044. pinchToPanMaxDistance: number;
  112045. /**
  112046. * Defines the maximum distance the camera can pan.
  112047. * This could help keeping the cammera always in your scene.
  112048. */
  112049. panningDistanceLimit: Nullable<number>;
  112050. /**
  112051. * Defines the target of the camera before paning.
  112052. */
  112053. panningOriginTarget: Vector3;
  112054. /**
  112055. * Defines the value of the inertia used during panning.
  112056. * 0 would mean stop inertia and one would mean no decelleration at all.
  112057. */
  112058. panningInertia: number;
  112059. /**
  112060. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  112061. */
  112062. get angularSensibilityX(): number;
  112063. set angularSensibilityX(value: number);
  112064. /**
  112065. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  112066. */
  112067. get angularSensibilityY(): number;
  112068. set angularSensibilityY(value: number);
  112069. /**
  112070. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  112071. */
  112072. get pinchPrecision(): number;
  112073. set pinchPrecision(value: number);
  112074. /**
  112075. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  112076. * It will be used instead of pinchDeltaPrecision if different from 0.
  112077. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112078. */
  112079. get pinchDeltaPercentage(): number;
  112080. set pinchDeltaPercentage(value: number);
  112081. /**
  112082. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  112083. * and pinch delta percentage.
  112084. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112085. * that any object in the plane at the camera's target point will scale
  112086. * perfectly with finger motion.
  112087. */
  112088. get useNaturalPinchZoom(): boolean;
  112089. set useNaturalPinchZoom(value: boolean);
  112090. /**
  112091. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112092. */
  112093. get panningSensibility(): number;
  112094. set panningSensibility(value: number);
  112095. /**
  112096. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112097. */
  112098. get keysUp(): number[];
  112099. set keysUp(value: number[]);
  112100. /**
  112101. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112102. */
  112103. get keysDown(): number[];
  112104. set keysDown(value: number[]);
  112105. /**
  112106. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112107. */
  112108. get keysLeft(): number[];
  112109. set keysLeft(value: number[]);
  112110. /**
  112111. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112112. */
  112113. get keysRight(): number[];
  112114. set keysRight(value: number[]);
  112115. /**
  112116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112117. */
  112118. get wheelPrecision(): number;
  112119. set wheelPrecision(value: number);
  112120. /**
  112121. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112122. * It will be used instead of pinchDeltaPrecision if different from 0.
  112123. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112124. */
  112125. get wheelDeltaPercentage(): number;
  112126. set wheelDeltaPercentage(value: number);
  112127. /**
  112128. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112129. */
  112130. zoomOnFactor: number;
  112131. /**
  112132. * Defines a screen offset for the camera position.
  112133. */
  112134. targetScreenOffset: Vector2;
  112135. /**
  112136. * Allows the camera to be completely reversed.
  112137. * If false the camera can not arrive upside down.
  112138. */
  112139. allowUpsideDown: boolean;
  112140. /**
  112141. * Define if double tap/click is used to restore the previously saved state of the camera.
  112142. */
  112143. useInputToRestoreState: boolean;
  112144. /** @hidden */
  112145. _viewMatrix: Matrix;
  112146. /** @hidden */
  112147. _useCtrlForPanning: boolean;
  112148. /** @hidden */
  112149. _panningMouseButton: number;
  112150. /**
  112151. * Defines the input associated to the camera.
  112152. */
  112153. inputs: ArcRotateCameraInputsManager;
  112154. /** @hidden */
  112155. _reset: () => void;
  112156. /**
  112157. * Defines the allowed panning axis.
  112158. */
  112159. panningAxis: Vector3;
  112160. protected _localDirection: Vector3;
  112161. protected _transformedDirection: Vector3;
  112162. private _bouncingBehavior;
  112163. /**
  112164. * Gets the bouncing behavior of the camera if it has been enabled.
  112165. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112166. */
  112167. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112168. /**
  112169. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112170. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112171. */
  112172. get useBouncingBehavior(): boolean;
  112173. set useBouncingBehavior(value: boolean);
  112174. private _framingBehavior;
  112175. /**
  112176. * Gets the framing behavior of the camera if it has been enabled.
  112177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112178. */
  112179. get framingBehavior(): Nullable<FramingBehavior>;
  112180. /**
  112181. * Defines if the framing behavior of the camera is enabled on the camera.
  112182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112183. */
  112184. get useFramingBehavior(): boolean;
  112185. set useFramingBehavior(value: boolean);
  112186. private _autoRotationBehavior;
  112187. /**
  112188. * Gets the auto rotation behavior of the camera if it has been enabled.
  112189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112190. */
  112191. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112192. /**
  112193. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112194. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112195. */
  112196. get useAutoRotationBehavior(): boolean;
  112197. set useAutoRotationBehavior(value: boolean);
  112198. /**
  112199. * Observable triggered when the mesh target has been changed on the camera.
  112200. */
  112201. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112202. /**
  112203. * Event raised when the camera is colliding with a mesh.
  112204. */
  112205. onCollide: (collidedMesh: AbstractMesh) => void;
  112206. /**
  112207. * Defines whether the camera should check collision with the objects oh the scene.
  112208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112209. */
  112210. checkCollisions: boolean;
  112211. /**
  112212. * Defines the collision radius of the camera.
  112213. * This simulates a sphere around the camera.
  112214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112215. */
  112216. collisionRadius: Vector3;
  112217. protected _collider: Collider;
  112218. protected _previousPosition: Vector3;
  112219. protected _collisionVelocity: Vector3;
  112220. protected _newPosition: Vector3;
  112221. protected _previousAlpha: number;
  112222. protected _previousBeta: number;
  112223. protected _previousRadius: number;
  112224. protected _collisionTriggered: boolean;
  112225. protected _targetBoundingCenter: Nullable<Vector3>;
  112226. private _computationVector;
  112227. /**
  112228. * Instantiates a new ArcRotateCamera in a given scene
  112229. * @param name Defines the name of the camera
  112230. * @param alpha Defines the camera rotation along the logitudinal axis
  112231. * @param beta Defines the camera rotation along the latitudinal axis
  112232. * @param radius Defines the camera distance from its target
  112233. * @param target Defines the camera target
  112234. * @param scene Defines the scene the camera belongs to
  112235. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112236. */
  112237. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112238. /** @hidden */
  112239. _initCache(): void;
  112240. /** @hidden */
  112241. _updateCache(ignoreParentClass?: boolean): void;
  112242. protected _getTargetPosition(): Vector3;
  112243. private _storedAlpha;
  112244. private _storedBeta;
  112245. private _storedRadius;
  112246. private _storedTarget;
  112247. private _storedTargetScreenOffset;
  112248. /**
  112249. * Stores the current state of the camera (alpha, beta, radius and target)
  112250. * @returns the camera itself
  112251. */
  112252. storeState(): Camera;
  112253. /**
  112254. * @hidden
  112255. * Restored camera state. You must call storeState() first
  112256. */
  112257. _restoreStateValues(): boolean;
  112258. /** @hidden */
  112259. _isSynchronizedViewMatrix(): boolean;
  112260. /**
  112261. * Attached controls to the current camera.
  112262. * @param element Defines the element the controls should be listened from
  112263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112264. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112265. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112266. */
  112267. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112268. /**
  112269. * Detach the current controls from the camera.
  112270. * The camera will stop reacting to inputs.
  112271. * @param element Defines the element to stop listening the inputs from
  112272. */
  112273. detachControl(element: HTMLElement): void;
  112274. /** @hidden */
  112275. _checkInputs(): void;
  112276. protected _checkLimits(): void;
  112277. /**
  112278. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112279. */
  112280. rebuildAnglesAndRadius(): void;
  112281. /**
  112282. * Use a position to define the current camera related information like alpha, beta and radius
  112283. * @param position Defines the position to set the camera at
  112284. */
  112285. setPosition(position: Vector3): void;
  112286. /**
  112287. * Defines the target the camera should look at.
  112288. * This will automatically adapt alpha beta and radius to fit within the new target.
  112289. * @param target Defines the new target as a Vector or a mesh
  112290. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112291. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112292. */
  112293. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112294. /** @hidden */
  112295. _getViewMatrix(): Matrix;
  112296. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112297. /**
  112298. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112299. * @param meshes Defines the mesh to zoom on
  112300. * @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)
  112301. */
  112302. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112303. /**
  112304. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112305. * The target will be changed but the radius
  112306. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112307. * @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)
  112308. */
  112309. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112310. min: Vector3;
  112311. max: Vector3;
  112312. distance: number;
  112313. }, doNotUpdateMaxZ?: boolean): void;
  112314. /**
  112315. * @override
  112316. * Override Camera.createRigCamera
  112317. */
  112318. createRigCamera(name: string, cameraIndex: number): Camera;
  112319. /**
  112320. * @hidden
  112321. * @override
  112322. * Override Camera._updateRigCameras
  112323. */
  112324. _updateRigCameras(): void;
  112325. /**
  112326. * Destroy the camera and release the current resources hold by it.
  112327. */
  112328. dispose(): void;
  112329. /**
  112330. * Gets the current object class name.
  112331. * @return the class name
  112332. */
  112333. getClassName(): string;
  112334. }
  112335. }
  112336. declare module BABYLON {
  112337. /**
  112338. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112340. */
  112341. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112342. /**
  112343. * Gets the name of the behavior.
  112344. */
  112345. get name(): string;
  112346. private _zoomStopsAnimation;
  112347. private _idleRotationSpeed;
  112348. private _idleRotationWaitTime;
  112349. private _idleRotationSpinupTime;
  112350. /**
  112351. * Sets the flag that indicates if user zooming should stop animation.
  112352. */
  112353. set zoomStopsAnimation(flag: boolean);
  112354. /**
  112355. * Gets the flag that indicates if user zooming should stop animation.
  112356. */
  112357. get zoomStopsAnimation(): boolean;
  112358. /**
  112359. * Sets the default speed at which the camera rotates around the model.
  112360. */
  112361. set idleRotationSpeed(speed: number);
  112362. /**
  112363. * Gets the default speed at which the camera rotates around the model.
  112364. */
  112365. get idleRotationSpeed(): number;
  112366. /**
  112367. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112368. */
  112369. set idleRotationWaitTime(time: number);
  112370. /**
  112371. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112372. */
  112373. get idleRotationWaitTime(): number;
  112374. /**
  112375. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112376. */
  112377. set idleRotationSpinupTime(time: number);
  112378. /**
  112379. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112380. */
  112381. get idleRotationSpinupTime(): number;
  112382. /**
  112383. * Gets a value indicating if the camera is currently rotating because of this behavior
  112384. */
  112385. get rotationInProgress(): boolean;
  112386. private _onPrePointerObservableObserver;
  112387. private _onAfterCheckInputsObserver;
  112388. private _attachedCamera;
  112389. private _isPointerDown;
  112390. private _lastFrameTime;
  112391. private _lastInteractionTime;
  112392. private _cameraRotationSpeed;
  112393. /**
  112394. * Initializes the behavior.
  112395. */
  112396. init(): void;
  112397. /**
  112398. * Attaches the behavior to its arc rotate camera.
  112399. * @param camera Defines the camera to attach the behavior to
  112400. */
  112401. attach(camera: ArcRotateCamera): void;
  112402. /**
  112403. * Detaches the behavior from its current arc rotate camera.
  112404. */
  112405. detach(): void;
  112406. /**
  112407. * Returns true if user is scrolling.
  112408. * @return true if user is scrolling.
  112409. */
  112410. private _userIsZooming;
  112411. private _lastFrameRadius;
  112412. private _shouldAnimationStopForInteraction;
  112413. /**
  112414. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112415. */
  112416. private _applyUserInteraction;
  112417. private _userIsMoving;
  112418. }
  112419. }
  112420. declare module BABYLON {
  112421. /**
  112422. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112423. */
  112424. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112425. private ui;
  112426. /**
  112427. * The name of the behavior
  112428. */
  112429. name: string;
  112430. /**
  112431. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112432. */
  112433. distanceAwayFromFace: number;
  112434. /**
  112435. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112436. */
  112437. distanceAwayFromBottomOfFace: number;
  112438. private _faceVectors;
  112439. private _target;
  112440. private _scene;
  112441. private _onRenderObserver;
  112442. private _tmpMatrix;
  112443. private _tmpVector;
  112444. /**
  112445. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112446. * @param ui The transform node that should be attched to the mesh
  112447. */
  112448. constructor(ui: TransformNode);
  112449. /**
  112450. * Initializes the behavior
  112451. */
  112452. init(): void;
  112453. private _closestFace;
  112454. private _zeroVector;
  112455. private _lookAtTmpMatrix;
  112456. private _lookAtToRef;
  112457. /**
  112458. * Attaches the AttachToBoxBehavior to the passed in mesh
  112459. * @param target The mesh that the specified node will be attached to
  112460. */
  112461. attach(target: Mesh): void;
  112462. /**
  112463. * Detaches the behavior from the mesh
  112464. */
  112465. detach(): void;
  112466. }
  112467. }
  112468. declare module BABYLON {
  112469. /**
  112470. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112471. */
  112472. export class FadeInOutBehavior implements Behavior<Mesh> {
  112473. /**
  112474. * Time in milliseconds to delay before fading in (Default: 0)
  112475. */
  112476. delay: number;
  112477. /**
  112478. * Time in milliseconds for the mesh to fade in (Default: 300)
  112479. */
  112480. fadeInTime: number;
  112481. private _millisecondsPerFrame;
  112482. private _hovered;
  112483. private _hoverValue;
  112484. private _ownerNode;
  112485. /**
  112486. * Instatiates the FadeInOutBehavior
  112487. */
  112488. constructor();
  112489. /**
  112490. * The name of the behavior
  112491. */
  112492. get name(): string;
  112493. /**
  112494. * Initializes the behavior
  112495. */
  112496. init(): void;
  112497. /**
  112498. * Attaches the fade behavior on the passed in mesh
  112499. * @param ownerNode The mesh that will be faded in/out once attached
  112500. */
  112501. attach(ownerNode: Mesh): void;
  112502. /**
  112503. * Detaches the behavior from the mesh
  112504. */
  112505. detach(): void;
  112506. /**
  112507. * Triggers the mesh to begin fading in or out
  112508. * @param value if the object should fade in or out (true to fade in)
  112509. */
  112510. fadeIn(value: boolean): void;
  112511. private _update;
  112512. private _setAllVisibility;
  112513. }
  112514. }
  112515. declare module BABYLON {
  112516. /**
  112517. * Class containing a set of static utilities functions for managing Pivots
  112518. * @hidden
  112519. */
  112520. export class PivotTools {
  112521. private static _PivotCached;
  112522. private static _OldPivotPoint;
  112523. private static _PivotTranslation;
  112524. private static _PivotTmpVector;
  112525. /** @hidden */
  112526. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112527. /** @hidden */
  112528. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112529. }
  112530. }
  112531. declare module BABYLON {
  112532. /**
  112533. * Class containing static functions to help procedurally build meshes
  112534. */
  112535. export class PlaneBuilder {
  112536. /**
  112537. * Creates a plane mesh
  112538. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112539. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112540. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112544. * @param name defines the name of the mesh
  112545. * @param options defines the options used to create the mesh
  112546. * @param scene defines the hosting scene
  112547. * @returns the plane mesh
  112548. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112549. */
  112550. static CreatePlane(name: string, options: {
  112551. size?: number;
  112552. width?: number;
  112553. height?: number;
  112554. sideOrientation?: number;
  112555. frontUVs?: Vector4;
  112556. backUVs?: Vector4;
  112557. updatable?: boolean;
  112558. sourcePlane?: Plane;
  112559. }, scene?: Nullable<Scene>): Mesh;
  112560. }
  112561. }
  112562. declare module BABYLON {
  112563. /**
  112564. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112565. */
  112566. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112567. private static _AnyMouseID;
  112568. /**
  112569. * Abstract mesh the behavior is set on
  112570. */
  112571. attachedNode: AbstractMesh;
  112572. private _dragPlane;
  112573. private _scene;
  112574. private _pointerObserver;
  112575. private _beforeRenderObserver;
  112576. private static _planeScene;
  112577. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112578. /**
  112579. * 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)
  112580. */
  112581. maxDragAngle: number;
  112582. /**
  112583. * @hidden
  112584. */
  112585. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112586. /**
  112587. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112588. */
  112589. currentDraggingPointerID: number;
  112590. /**
  112591. * The last position where the pointer hit the drag plane in world space
  112592. */
  112593. lastDragPosition: Vector3;
  112594. /**
  112595. * If the behavior is currently in a dragging state
  112596. */
  112597. dragging: boolean;
  112598. /**
  112599. * 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)
  112600. */
  112601. dragDeltaRatio: number;
  112602. /**
  112603. * If the drag plane orientation should be updated during the dragging (Default: true)
  112604. */
  112605. updateDragPlane: boolean;
  112606. private _debugMode;
  112607. private _moving;
  112608. /**
  112609. * Fires each time the attached mesh is dragged with the pointer
  112610. * * delta between last drag position and current drag position in world space
  112611. * * dragDistance along the drag axis
  112612. * * dragPlaneNormal normal of the current drag plane used during the drag
  112613. * * dragPlanePoint in world space where the drag intersects the drag plane
  112614. */
  112615. onDragObservable: Observable<{
  112616. delta: Vector3;
  112617. dragPlanePoint: Vector3;
  112618. dragPlaneNormal: Vector3;
  112619. dragDistance: number;
  112620. pointerId: number;
  112621. }>;
  112622. /**
  112623. * Fires each time a drag begins (eg. mouse down on mesh)
  112624. */
  112625. onDragStartObservable: Observable<{
  112626. dragPlanePoint: Vector3;
  112627. pointerId: number;
  112628. }>;
  112629. /**
  112630. * Fires each time a drag ends (eg. mouse release after drag)
  112631. */
  112632. onDragEndObservable: Observable<{
  112633. dragPlanePoint: Vector3;
  112634. pointerId: number;
  112635. }>;
  112636. /**
  112637. * If the attached mesh should be moved when dragged
  112638. */
  112639. moveAttached: boolean;
  112640. /**
  112641. * If the drag behavior will react to drag events (Default: true)
  112642. */
  112643. enabled: boolean;
  112644. /**
  112645. * If pointer events should start and release the drag (Default: true)
  112646. */
  112647. startAndReleaseDragOnPointerEvents: boolean;
  112648. /**
  112649. * If camera controls should be detached during the drag
  112650. */
  112651. detachCameraControls: boolean;
  112652. /**
  112653. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112654. */
  112655. useObjectOrientationForDragging: boolean;
  112656. private _options;
  112657. /**
  112658. * Gets the options used by the behavior
  112659. */
  112660. get options(): {
  112661. dragAxis?: Vector3;
  112662. dragPlaneNormal?: Vector3;
  112663. };
  112664. /**
  112665. * Sets the options used by the behavior
  112666. */
  112667. set options(options: {
  112668. dragAxis?: Vector3;
  112669. dragPlaneNormal?: Vector3;
  112670. });
  112671. /**
  112672. * Creates a pointer drag behavior that can be attached to a mesh
  112673. * @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)
  112674. */
  112675. constructor(options?: {
  112676. dragAxis?: Vector3;
  112677. dragPlaneNormal?: Vector3;
  112678. });
  112679. /**
  112680. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112681. */
  112682. validateDrag: (targetPosition: Vector3) => boolean;
  112683. /**
  112684. * The name of the behavior
  112685. */
  112686. get name(): string;
  112687. /**
  112688. * Initializes the behavior
  112689. */
  112690. init(): void;
  112691. private _tmpVector;
  112692. private _alternatePickedPoint;
  112693. private _worldDragAxis;
  112694. private _targetPosition;
  112695. private _attachedElement;
  112696. /**
  112697. * Attaches the drag behavior the passed in mesh
  112698. * @param ownerNode The mesh that will be dragged around once attached
  112699. * @param predicate Predicate to use for pick filtering
  112700. */
  112701. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112702. /**
  112703. * Force relase the drag action by code.
  112704. */
  112705. releaseDrag(): void;
  112706. private _startDragRay;
  112707. private _lastPointerRay;
  112708. /**
  112709. * Simulates the start of a pointer drag event on the behavior
  112710. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112711. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112712. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112713. */
  112714. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112715. private _startDrag;
  112716. private _dragDelta;
  112717. private _moveDrag;
  112718. private _pickWithRayOnDragPlane;
  112719. private _pointA;
  112720. private _pointB;
  112721. private _pointC;
  112722. private _lineA;
  112723. private _lineB;
  112724. private _localAxis;
  112725. private _lookAt;
  112726. private _updateDragPlanePosition;
  112727. /**
  112728. * Detaches the behavior from the mesh
  112729. */
  112730. detach(): void;
  112731. }
  112732. }
  112733. declare module BABYLON {
  112734. /**
  112735. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112736. */
  112737. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112738. private _dragBehaviorA;
  112739. private _dragBehaviorB;
  112740. private _startDistance;
  112741. private _initialScale;
  112742. private _targetScale;
  112743. private _ownerNode;
  112744. private _sceneRenderObserver;
  112745. /**
  112746. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112747. */
  112748. constructor();
  112749. /**
  112750. * The name of the behavior
  112751. */
  112752. get name(): string;
  112753. /**
  112754. * Initializes the behavior
  112755. */
  112756. init(): void;
  112757. private _getCurrentDistance;
  112758. /**
  112759. * Attaches the scale behavior the passed in mesh
  112760. * @param ownerNode The mesh that will be scaled around once attached
  112761. */
  112762. attach(ownerNode: Mesh): void;
  112763. /**
  112764. * Detaches the behavior from the mesh
  112765. */
  112766. detach(): void;
  112767. }
  112768. }
  112769. declare module BABYLON {
  112770. /**
  112771. * 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
  112772. */
  112773. export class SixDofDragBehavior implements Behavior<Mesh> {
  112774. private static _virtualScene;
  112775. private _ownerNode;
  112776. private _sceneRenderObserver;
  112777. private _scene;
  112778. private _targetPosition;
  112779. private _virtualOriginMesh;
  112780. private _virtualDragMesh;
  112781. private _pointerObserver;
  112782. private _moving;
  112783. private _startingOrientation;
  112784. /**
  112785. * 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)
  112786. */
  112787. private zDragFactor;
  112788. /**
  112789. * If the object should rotate to face the drag origin
  112790. */
  112791. rotateDraggedObject: boolean;
  112792. /**
  112793. * If the behavior is currently in a dragging state
  112794. */
  112795. dragging: boolean;
  112796. /**
  112797. * 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)
  112798. */
  112799. dragDeltaRatio: number;
  112800. /**
  112801. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112802. */
  112803. currentDraggingPointerID: number;
  112804. /**
  112805. * If camera controls should be detached during the drag
  112806. */
  112807. detachCameraControls: boolean;
  112808. /**
  112809. * Fires each time a drag starts
  112810. */
  112811. onDragStartObservable: Observable<{}>;
  112812. /**
  112813. * Fires each time a drag ends (eg. mouse release after drag)
  112814. */
  112815. onDragEndObservable: Observable<{}>;
  112816. /**
  112817. * 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
  112818. */
  112819. constructor();
  112820. /**
  112821. * The name of the behavior
  112822. */
  112823. get name(): string;
  112824. /**
  112825. * Initializes the behavior
  112826. */
  112827. init(): void;
  112828. /**
  112829. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112830. */
  112831. private get _pointerCamera();
  112832. /**
  112833. * Attaches the scale behavior the passed in mesh
  112834. * @param ownerNode The mesh that will be scaled around once attached
  112835. */
  112836. attach(ownerNode: Mesh): void;
  112837. /**
  112838. * Detaches the behavior from the mesh
  112839. */
  112840. detach(): void;
  112841. }
  112842. }
  112843. declare module BABYLON {
  112844. /**
  112845. * Class used to apply inverse kinematics to bones
  112846. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112847. */
  112848. export class BoneIKController {
  112849. private static _tmpVecs;
  112850. private static _tmpQuat;
  112851. private static _tmpMats;
  112852. /**
  112853. * Gets or sets the target mesh
  112854. */
  112855. targetMesh: AbstractMesh;
  112856. /** Gets or sets the mesh used as pole */
  112857. poleTargetMesh: AbstractMesh;
  112858. /**
  112859. * Gets or sets the bone used as pole
  112860. */
  112861. poleTargetBone: Nullable<Bone>;
  112862. /**
  112863. * Gets or sets the target position
  112864. */
  112865. targetPosition: Vector3;
  112866. /**
  112867. * Gets or sets the pole target position
  112868. */
  112869. poleTargetPosition: Vector3;
  112870. /**
  112871. * Gets or sets the pole target local offset
  112872. */
  112873. poleTargetLocalOffset: Vector3;
  112874. /**
  112875. * Gets or sets the pole angle
  112876. */
  112877. poleAngle: number;
  112878. /**
  112879. * Gets or sets the mesh associated with the controller
  112880. */
  112881. mesh: AbstractMesh;
  112882. /**
  112883. * 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)
  112884. */
  112885. slerpAmount: number;
  112886. private _bone1Quat;
  112887. private _bone1Mat;
  112888. private _bone2Ang;
  112889. private _bone1;
  112890. private _bone2;
  112891. private _bone1Length;
  112892. private _bone2Length;
  112893. private _maxAngle;
  112894. private _maxReach;
  112895. private _rightHandedSystem;
  112896. private _bendAxis;
  112897. private _slerping;
  112898. private _adjustRoll;
  112899. /**
  112900. * Gets or sets maximum allowed angle
  112901. */
  112902. get maxAngle(): number;
  112903. set maxAngle(value: number);
  112904. /**
  112905. * Creates a new BoneIKController
  112906. * @param mesh defines the mesh to control
  112907. * @param bone defines the bone to control
  112908. * @param options defines options to set up the controller
  112909. */
  112910. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112911. targetMesh?: AbstractMesh;
  112912. poleTargetMesh?: AbstractMesh;
  112913. poleTargetBone?: Bone;
  112914. poleTargetLocalOffset?: Vector3;
  112915. poleAngle?: number;
  112916. bendAxis?: Vector3;
  112917. maxAngle?: number;
  112918. slerpAmount?: number;
  112919. });
  112920. private _setMaxAngle;
  112921. /**
  112922. * Force the controller to update the bones
  112923. */
  112924. update(): void;
  112925. }
  112926. }
  112927. declare module BABYLON {
  112928. /**
  112929. * Class used to make a bone look toward a point in space
  112930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112931. */
  112932. export class BoneLookController {
  112933. private static _tmpVecs;
  112934. private static _tmpQuat;
  112935. private static _tmpMats;
  112936. /**
  112937. * The target Vector3 that the bone will look at
  112938. */
  112939. target: Vector3;
  112940. /**
  112941. * The mesh that the bone is attached to
  112942. */
  112943. mesh: AbstractMesh;
  112944. /**
  112945. * The bone that will be looking to the target
  112946. */
  112947. bone: Bone;
  112948. /**
  112949. * The up axis of the coordinate system that is used when the bone is rotated
  112950. */
  112951. upAxis: Vector3;
  112952. /**
  112953. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112954. */
  112955. upAxisSpace: Space;
  112956. /**
  112957. * Used to make an adjustment to the yaw of the bone
  112958. */
  112959. adjustYaw: number;
  112960. /**
  112961. * Used to make an adjustment to the pitch of the bone
  112962. */
  112963. adjustPitch: number;
  112964. /**
  112965. * Used to make an adjustment to the roll of the bone
  112966. */
  112967. adjustRoll: number;
  112968. /**
  112969. * 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)
  112970. */
  112971. slerpAmount: number;
  112972. private _minYaw;
  112973. private _maxYaw;
  112974. private _minPitch;
  112975. private _maxPitch;
  112976. private _minYawSin;
  112977. private _minYawCos;
  112978. private _maxYawSin;
  112979. private _maxYawCos;
  112980. private _midYawConstraint;
  112981. private _minPitchTan;
  112982. private _maxPitchTan;
  112983. private _boneQuat;
  112984. private _slerping;
  112985. private _transformYawPitch;
  112986. private _transformYawPitchInv;
  112987. private _firstFrameSkipped;
  112988. private _yawRange;
  112989. private _fowardAxis;
  112990. /**
  112991. * Gets or sets the minimum yaw angle that the bone can look to
  112992. */
  112993. get minYaw(): number;
  112994. set minYaw(value: number);
  112995. /**
  112996. * Gets or sets the maximum yaw angle that the bone can look to
  112997. */
  112998. get maxYaw(): number;
  112999. set maxYaw(value: number);
  113000. /**
  113001. * Gets or sets the minimum pitch angle that the bone can look to
  113002. */
  113003. get minPitch(): number;
  113004. set minPitch(value: number);
  113005. /**
  113006. * Gets or sets the maximum pitch angle that the bone can look to
  113007. */
  113008. get maxPitch(): number;
  113009. set maxPitch(value: number);
  113010. /**
  113011. * Create a BoneLookController
  113012. * @param mesh the mesh that the bone belongs to
  113013. * @param bone the bone that will be looking to the target
  113014. * @param target the target Vector3 to look at
  113015. * @param options optional settings:
  113016. * * maxYaw: the maximum angle the bone will yaw to
  113017. * * minYaw: the minimum angle the bone will yaw to
  113018. * * maxPitch: the maximum angle the bone will pitch to
  113019. * * minPitch: the minimum angle the bone will yaw to
  113020. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  113021. * * upAxis: the up axis of the coordinate system
  113022. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  113023. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  113024. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  113025. * * adjustYaw: used to make an adjustment to the yaw of the bone
  113026. * * adjustPitch: used to make an adjustment to the pitch of the bone
  113027. * * adjustRoll: used to make an adjustment to the roll of the bone
  113028. **/
  113029. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  113030. maxYaw?: number;
  113031. minYaw?: number;
  113032. maxPitch?: number;
  113033. minPitch?: number;
  113034. slerpAmount?: number;
  113035. upAxis?: Vector3;
  113036. upAxisSpace?: Space;
  113037. yawAxis?: Vector3;
  113038. pitchAxis?: Vector3;
  113039. adjustYaw?: number;
  113040. adjustPitch?: number;
  113041. adjustRoll?: number;
  113042. });
  113043. /**
  113044. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  113045. */
  113046. update(): void;
  113047. private _getAngleDiff;
  113048. private _getAngleBetween;
  113049. private _isAngleBetween;
  113050. }
  113051. }
  113052. declare module BABYLON {
  113053. /**
  113054. * Manage the gamepad inputs to control an arc rotate camera.
  113055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113056. */
  113057. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  113058. /**
  113059. * Defines the camera the input is attached to.
  113060. */
  113061. camera: ArcRotateCamera;
  113062. /**
  113063. * Defines the gamepad the input is gathering event from.
  113064. */
  113065. gamepad: Nullable<Gamepad>;
  113066. /**
  113067. * Defines the gamepad rotation sensiblity.
  113068. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113069. */
  113070. gamepadRotationSensibility: number;
  113071. /**
  113072. * Defines the gamepad move sensiblity.
  113073. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113074. */
  113075. gamepadMoveSensibility: number;
  113076. private _yAxisScale;
  113077. /**
  113078. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113079. */
  113080. get invertYAxis(): boolean;
  113081. set invertYAxis(value: boolean);
  113082. private _onGamepadConnectedObserver;
  113083. private _onGamepadDisconnectedObserver;
  113084. /**
  113085. * Attach the input controls to a specific dom element to get the input from.
  113086. * @param element Defines the element the controls should be listened from
  113087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113088. */
  113089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113090. /**
  113091. * Detach the current controls from the specified dom element.
  113092. * @param element Defines the element to stop listening the inputs from
  113093. */
  113094. detachControl(element: Nullable<HTMLElement>): void;
  113095. /**
  113096. * Update the current camera state depending on the inputs that have been used this frame.
  113097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113098. */
  113099. checkInputs(): void;
  113100. /**
  113101. * Gets the class name of the current intput.
  113102. * @returns the class name
  113103. */
  113104. getClassName(): string;
  113105. /**
  113106. * Get the friendly name associated with the input class.
  113107. * @returns the input friendly name
  113108. */
  113109. getSimpleName(): string;
  113110. }
  113111. }
  113112. declare module BABYLON {
  113113. interface ArcRotateCameraInputsManager {
  113114. /**
  113115. * Add orientation input support to the input manager.
  113116. * @returns the current input manager
  113117. */
  113118. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113119. }
  113120. /**
  113121. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113123. */
  113124. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113125. /**
  113126. * Defines the camera the input is attached to.
  113127. */
  113128. camera: ArcRotateCamera;
  113129. /**
  113130. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113131. */
  113132. alphaCorrection: number;
  113133. /**
  113134. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113135. */
  113136. gammaCorrection: number;
  113137. private _alpha;
  113138. private _gamma;
  113139. private _dirty;
  113140. private _deviceOrientationHandler;
  113141. /**
  113142. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113143. */
  113144. constructor();
  113145. /**
  113146. * Attach the input controls to a specific dom element to get the input from.
  113147. * @param element Defines the element the controls should be listened from
  113148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113149. */
  113150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113151. /** @hidden */
  113152. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113153. /**
  113154. * Update the current camera state depending on the inputs that have been used this frame.
  113155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113156. */
  113157. checkInputs(): void;
  113158. /**
  113159. * Detach the current controls from the specified dom element.
  113160. * @param element Defines the element to stop listening the inputs from
  113161. */
  113162. detachControl(element: Nullable<HTMLElement>): void;
  113163. /**
  113164. * Gets the class name of the current intput.
  113165. * @returns the class name
  113166. */
  113167. getClassName(): string;
  113168. /**
  113169. * Get the friendly name associated with the input class.
  113170. * @returns the input friendly name
  113171. */
  113172. getSimpleName(): string;
  113173. }
  113174. }
  113175. declare module BABYLON {
  113176. /**
  113177. * Listen to mouse events to control the camera.
  113178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113179. */
  113180. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113181. /**
  113182. * Defines the camera the input is attached to.
  113183. */
  113184. camera: FlyCamera;
  113185. /**
  113186. * Defines if touch is enabled. (Default is true.)
  113187. */
  113188. touchEnabled: boolean;
  113189. /**
  113190. * Defines the buttons associated with the input to handle camera rotation.
  113191. */
  113192. buttons: number[];
  113193. /**
  113194. * Assign buttons for Yaw control.
  113195. */
  113196. buttonsYaw: number[];
  113197. /**
  113198. * Assign buttons for Pitch control.
  113199. */
  113200. buttonsPitch: number[];
  113201. /**
  113202. * Assign buttons for Roll control.
  113203. */
  113204. buttonsRoll: number[];
  113205. /**
  113206. * Detect if any button is being pressed while mouse is moved.
  113207. * -1 = Mouse locked.
  113208. * 0 = Left button.
  113209. * 1 = Middle Button.
  113210. * 2 = Right Button.
  113211. */
  113212. activeButton: number;
  113213. /**
  113214. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113215. * Higher values reduce its sensitivity.
  113216. */
  113217. angularSensibility: number;
  113218. private _mousemoveCallback;
  113219. private _observer;
  113220. private _rollObserver;
  113221. private previousPosition;
  113222. private noPreventDefault;
  113223. private element;
  113224. /**
  113225. * Listen to mouse events to control the camera.
  113226. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113228. */
  113229. constructor(touchEnabled?: boolean);
  113230. /**
  113231. * Attach the mouse control to the HTML DOM element.
  113232. * @param element Defines the element that listens to the input events.
  113233. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113234. */
  113235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113236. /**
  113237. * Detach the current controls from the specified dom element.
  113238. * @param element Defines the element to stop listening the inputs from
  113239. */
  113240. detachControl(element: Nullable<HTMLElement>): void;
  113241. /**
  113242. * Gets the class name of the current input.
  113243. * @returns the class name.
  113244. */
  113245. getClassName(): string;
  113246. /**
  113247. * Get the friendly name associated with the input class.
  113248. * @returns the input's friendly name.
  113249. */
  113250. getSimpleName(): string;
  113251. private _pointerInput;
  113252. private _onMouseMove;
  113253. /**
  113254. * Rotate camera by mouse offset.
  113255. */
  113256. private rotateCamera;
  113257. }
  113258. }
  113259. declare module BABYLON {
  113260. /**
  113261. * Default Inputs manager for the FlyCamera.
  113262. * It groups all the default supported inputs for ease of use.
  113263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113264. */
  113265. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113266. /**
  113267. * Instantiates a new FlyCameraInputsManager.
  113268. * @param camera Defines the camera the inputs belong to.
  113269. */
  113270. constructor(camera: FlyCamera);
  113271. /**
  113272. * Add keyboard input support to the input manager.
  113273. * @returns the new FlyCameraKeyboardMoveInput().
  113274. */
  113275. addKeyboard(): FlyCameraInputsManager;
  113276. /**
  113277. * Add mouse input support to the input manager.
  113278. * @param touchEnabled Enable touch screen support.
  113279. * @returns the new FlyCameraMouseInput().
  113280. */
  113281. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113282. }
  113283. }
  113284. declare module BABYLON {
  113285. /**
  113286. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113287. * such as in a 3D Space Shooter or a Flight Simulator.
  113288. */
  113289. export class FlyCamera extends TargetCamera {
  113290. /**
  113291. * Define the collision ellipsoid of the camera.
  113292. * This is helpful for simulating a camera body, like a player's body.
  113293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113294. */
  113295. ellipsoid: Vector3;
  113296. /**
  113297. * Define an offset for the position of the ellipsoid around the camera.
  113298. * This can be helpful if the camera is attached away from the player's body center,
  113299. * such as at its head.
  113300. */
  113301. ellipsoidOffset: Vector3;
  113302. /**
  113303. * Enable or disable collisions of the camera with the rest of the scene objects.
  113304. */
  113305. checkCollisions: boolean;
  113306. /**
  113307. * Enable or disable gravity on the camera.
  113308. */
  113309. applyGravity: boolean;
  113310. /**
  113311. * Define the current direction the camera is moving to.
  113312. */
  113313. cameraDirection: Vector3;
  113314. /**
  113315. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113316. * This overrides and empties cameraRotation.
  113317. */
  113318. rotationQuaternion: Quaternion;
  113319. /**
  113320. * Track Roll to maintain the wanted Rolling when looking around.
  113321. */
  113322. _trackRoll: number;
  113323. /**
  113324. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113325. */
  113326. rollCorrect: number;
  113327. /**
  113328. * Mimic a banked turn, Rolling the camera when Yawing.
  113329. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113330. */
  113331. bankedTurn: boolean;
  113332. /**
  113333. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113334. */
  113335. bankedTurnLimit: number;
  113336. /**
  113337. * Value of 0 disables the banked Roll.
  113338. * Value of 1 is equal to the Yaw angle in radians.
  113339. */
  113340. bankedTurnMultiplier: number;
  113341. /**
  113342. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113343. */
  113344. inputs: FlyCameraInputsManager;
  113345. /**
  113346. * Gets the input sensibility for mouse input.
  113347. * Higher values reduce sensitivity.
  113348. */
  113349. get angularSensibility(): number;
  113350. /**
  113351. * Sets the input sensibility for a mouse input.
  113352. * Higher values reduce sensitivity.
  113353. */
  113354. set angularSensibility(value: number);
  113355. /**
  113356. * Get the keys for camera movement forward.
  113357. */
  113358. get keysForward(): number[];
  113359. /**
  113360. * Set the keys for camera movement forward.
  113361. */
  113362. set keysForward(value: number[]);
  113363. /**
  113364. * Get the keys for camera movement backward.
  113365. */
  113366. get keysBackward(): number[];
  113367. set keysBackward(value: number[]);
  113368. /**
  113369. * Get the keys for camera movement up.
  113370. */
  113371. get keysUp(): number[];
  113372. /**
  113373. * Set the keys for camera movement up.
  113374. */
  113375. set keysUp(value: number[]);
  113376. /**
  113377. * Get the keys for camera movement down.
  113378. */
  113379. get keysDown(): number[];
  113380. /**
  113381. * Set the keys for camera movement down.
  113382. */
  113383. set keysDown(value: number[]);
  113384. /**
  113385. * Get the keys for camera movement left.
  113386. */
  113387. get keysLeft(): number[];
  113388. /**
  113389. * Set the keys for camera movement left.
  113390. */
  113391. set keysLeft(value: number[]);
  113392. /**
  113393. * Set the keys for camera movement right.
  113394. */
  113395. get keysRight(): number[];
  113396. /**
  113397. * Set the keys for camera movement right.
  113398. */
  113399. set keysRight(value: number[]);
  113400. /**
  113401. * Event raised when the camera collides with a mesh in the scene.
  113402. */
  113403. onCollide: (collidedMesh: AbstractMesh) => void;
  113404. private _collider;
  113405. private _needMoveForGravity;
  113406. private _oldPosition;
  113407. private _diffPosition;
  113408. private _newPosition;
  113409. /** @hidden */
  113410. _localDirection: Vector3;
  113411. /** @hidden */
  113412. _transformedDirection: Vector3;
  113413. /**
  113414. * Instantiates a FlyCamera.
  113415. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113416. * such as in a 3D Space Shooter or a Flight Simulator.
  113417. * @param name Define the name of the camera in the scene.
  113418. * @param position Define the starting position of the camera in the scene.
  113419. * @param scene Define the scene the camera belongs to.
  113420. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113421. */
  113422. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113423. /**
  113424. * Attach a control to the HTML DOM element.
  113425. * @param element Defines the element that listens to the input events.
  113426. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113427. */
  113428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113429. /**
  113430. * Detach a control from the HTML DOM element.
  113431. * The camera will stop reacting to that input.
  113432. * @param element Defines the element that listens to the input events.
  113433. */
  113434. detachControl(element: HTMLElement): void;
  113435. private _collisionMask;
  113436. /**
  113437. * Get the mask that the camera ignores in collision events.
  113438. */
  113439. get collisionMask(): number;
  113440. /**
  113441. * Set the mask that the camera ignores in collision events.
  113442. */
  113443. set collisionMask(mask: number);
  113444. /** @hidden */
  113445. _collideWithWorld(displacement: Vector3): void;
  113446. /** @hidden */
  113447. private _onCollisionPositionChange;
  113448. /** @hidden */
  113449. _checkInputs(): void;
  113450. /** @hidden */
  113451. _decideIfNeedsToMove(): boolean;
  113452. /** @hidden */
  113453. _updatePosition(): void;
  113454. /**
  113455. * Restore the Roll to its target value at the rate specified.
  113456. * @param rate - Higher means slower restoring.
  113457. * @hidden
  113458. */
  113459. restoreRoll(rate: number): void;
  113460. /**
  113461. * Destroy the camera and release the current resources held by it.
  113462. */
  113463. dispose(): void;
  113464. /**
  113465. * Get the current object class name.
  113466. * @returns the class name.
  113467. */
  113468. getClassName(): string;
  113469. }
  113470. }
  113471. declare module BABYLON {
  113472. /**
  113473. * Listen to keyboard events to control the camera.
  113474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113475. */
  113476. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113477. /**
  113478. * Defines the camera the input is attached to.
  113479. */
  113480. camera: FlyCamera;
  113481. /**
  113482. * The list of keyboard keys used to control the forward move of the camera.
  113483. */
  113484. keysForward: number[];
  113485. /**
  113486. * The list of keyboard keys used to control the backward move of the camera.
  113487. */
  113488. keysBackward: number[];
  113489. /**
  113490. * The list of keyboard keys used to control the forward move of the camera.
  113491. */
  113492. keysUp: number[];
  113493. /**
  113494. * The list of keyboard keys used to control the backward move of the camera.
  113495. */
  113496. keysDown: number[];
  113497. /**
  113498. * The list of keyboard keys used to control the right strafe move of the camera.
  113499. */
  113500. keysRight: number[];
  113501. /**
  113502. * The list of keyboard keys used to control the left strafe move of the camera.
  113503. */
  113504. keysLeft: number[];
  113505. private _keys;
  113506. private _onCanvasBlurObserver;
  113507. private _onKeyboardObserver;
  113508. private _engine;
  113509. private _scene;
  113510. /**
  113511. * Attach the input controls to a specific dom element to get the input from.
  113512. * @param element Defines the element the controls should be listened from
  113513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113514. */
  113515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113516. /**
  113517. * Detach the current controls from the specified dom element.
  113518. * @param element Defines the element to stop listening the inputs from
  113519. */
  113520. detachControl(element: Nullable<HTMLElement>): void;
  113521. /**
  113522. * Gets the class name of the current intput.
  113523. * @returns the class name
  113524. */
  113525. getClassName(): string;
  113526. /** @hidden */
  113527. _onLostFocus(e: FocusEvent): void;
  113528. /**
  113529. * Get the friendly name associated with the input class.
  113530. * @returns the input friendly name
  113531. */
  113532. getSimpleName(): string;
  113533. /**
  113534. * Update the current camera state depending on the inputs that have been used this frame.
  113535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113536. */
  113537. checkInputs(): void;
  113538. }
  113539. }
  113540. declare module BABYLON {
  113541. /**
  113542. * Manage the mouse wheel inputs to control a follow camera.
  113543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113544. */
  113545. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113546. /**
  113547. * Defines the camera the input is attached to.
  113548. */
  113549. camera: FollowCamera;
  113550. /**
  113551. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113552. */
  113553. axisControlRadius: boolean;
  113554. /**
  113555. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113556. */
  113557. axisControlHeight: boolean;
  113558. /**
  113559. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113560. */
  113561. axisControlRotation: boolean;
  113562. /**
  113563. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113564. * relation to mouseWheel events.
  113565. */
  113566. wheelPrecision: number;
  113567. /**
  113568. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113569. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113570. */
  113571. wheelDeltaPercentage: number;
  113572. private _wheel;
  113573. private _observer;
  113574. /**
  113575. * Attach the input controls to a specific dom element to get the input from.
  113576. * @param element Defines the element the controls should be listened from
  113577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113578. */
  113579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113580. /**
  113581. * Detach the current controls from the specified dom element.
  113582. * @param element Defines the element to stop listening the inputs from
  113583. */
  113584. detachControl(element: Nullable<HTMLElement>): void;
  113585. /**
  113586. * Gets the class name of the current intput.
  113587. * @returns the class name
  113588. */
  113589. getClassName(): string;
  113590. /**
  113591. * Get the friendly name associated with the input class.
  113592. * @returns the input friendly name
  113593. */
  113594. getSimpleName(): string;
  113595. }
  113596. }
  113597. declare module BABYLON {
  113598. /**
  113599. * Manage the pointers inputs to control an follow camera.
  113600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113601. */
  113602. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113603. /**
  113604. * Defines the camera the input is attached to.
  113605. */
  113606. camera: FollowCamera;
  113607. /**
  113608. * Gets the class name of the current input.
  113609. * @returns the class name
  113610. */
  113611. getClassName(): string;
  113612. /**
  113613. * Defines the pointer angular sensibility along the X axis or how fast is
  113614. * the camera rotating.
  113615. * A negative number will reverse the axis direction.
  113616. */
  113617. angularSensibilityX: number;
  113618. /**
  113619. * Defines the pointer angular sensibility along the Y axis or how fast is
  113620. * the camera rotating.
  113621. * A negative number will reverse the axis direction.
  113622. */
  113623. angularSensibilityY: number;
  113624. /**
  113625. * Defines the pointer pinch precision or how fast is the camera zooming.
  113626. * A negative number will reverse the axis direction.
  113627. */
  113628. pinchPrecision: number;
  113629. /**
  113630. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113631. * from 0.
  113632. * It defines the percentage of current camera.radius to use as delta when
  113633. * pinch zoom is used.
  113634. */
  113635. pinchDeltaPercentage: number;
  113636. /**
  113637. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113638. */
  113639. axisXControlRadius: boolean;
  113640. /**
  113641. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113642. */
  113643. axisXControlHeight: boolean;
  113644. /**
  113645. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113646. */
  113647. axisXControlRotation: boolean;
  113648. /**
  113649. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113650. */
  113651. axisYControlRadius: boolean;
  113652. /**
  113653. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113654. */
  113655. axisYControlHeight: boolean;
  113656. /**
  113657. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113658. */
  113659. axisYControlRotation: boolean;
  113660. /**
  113661. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113662. */
  113663. axisPinchControlRadius: boolean;
  113664. /**
  113665. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113666. */
  113667. axisPinchControlHeight: boolean;
  113668. /**
  113669. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113670. */
  113671. axisPinchControlRotation: boolean;
  113672. /**
  113673. * Log error messages if basic misconfiguration has occurred.
  113674. */
  113675. warningEnable: boolean;
  113676. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113677. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113678. private _warningCounter;
  113679. private _warning;
  113680. }
  113681. }
  113682. declare module BABYLON {
  113683. /**
  113684. * Default Inputs manager for the FollowCamera.
  113685. * It groups all the default supported inputs for ease of use.
  113686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113687. */
  113688. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113689. /**
  113690. * Instantiates a new FollowCameraInputsManager.
  113691. * @param camera Defines the camera the inputs belong to
  113692. */
  113693. constructor(camera: FollowCamera);
  113694. /**
  113695. * Add keyboard input support to the input manager.
  113696. * @returns the current input manager
  113697. */
  113698. addKeyboard(): FollowCameraInputsManager;
  113699. /**
  113700. * Add mouse wheel input support to the input manager.
  113701. * @returns the current input manager
  113702. */
  113703. addMouseWheel(): FollowCameraInputsManager;
  113704. /**
  113705. * Add pointers input support to the input manager.
  113706. * @returns the current input manager
  113707. */
  113708. addPointers(): FollowCameraInputsManager;
  113709. /**
  113710. * Add orientation input support to the input manager.
  113711. * @returns the current input manager
  113712. */
  113713. addVRDeviceOrientation(): FollowCameraInputsManager;
  113714. }
  113715. }
  113716. declare module BABYLON {
  113717. /**
  113718. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113719. * an arc rotate version arcFollowCamera are available.
  113720. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113721. */
  113722. export class FollowCamera extends TargetCamera {
  113723. /**
  113724. * Distance the follow camera should follow an object at
  113725. */
  113726. radius: number;
  113727. /**
  113728. * Minimum allowed distance of the camera to the axis of rotation
  113729. * (The camera can not get closer).
  113730. * This can help limiting how the Camera is able to move in the scene.
  113731. */
  113732. lowerRadiusLimit: Nullable<number>;
  113733. /**
  113734. * Maximum allowed distance of the camera to the axis of rotation
  113735. * (The camera can not get further).
  113736. * This can help limiting how the Camera is able to move in the scene.
  113737. */
  113738. upperRadiusLimit: Nullable<number>;
  113739. /**
  113740. * Define a rotation offset between the camera and the object it follows
  113741. */
  113742. rotationOffset: number;
  113743. /**
  113744. * Minimum allowed angle to camera position relative to target object.
  113745. * This can help limiting how the Camera is able to move in the scene.
  113746. */
  113747. lowerRotationOffsetLimit: Nullable<number>;
  113748. /**
  113749. * Maximum allowed angle to camera position relative to target object.
  113750. * This can help limiting how the Camera is able to move in the scene.
  113751. */
  113752. upperRotationOffsetLimit: Nullable<number>;
  113753. /**
  113754. * Define a height offset between the camera and the object it follows.
  113755. * It can help following an object from the top (like a car chaing a plane)
  113756. */
  113757. heightOffset: number;
  113758. /**
  113759. * Minimum allowed height of camera position relative to target object.
  113760. * This can help limiting how the Camera is able to move in the scene.
  113761. */
  113762. lowerHeightOffsetLimit: Nullable<number>;
  113763. /**
  113764. * Maximum allowed height of camera position relative to target object.
  113765. * This can help limiting how the Camera is able to move in the scene.
  113766. */
  113767. upperHeightOffsetLimit: Nullable<number>;
  113768. /**
  113769. * Define how fast the camera can accelerate to follow it s target.
  113770. */
  113771. cameraAcceleration: number;
  113772. /**
  113773. * Define the speed limit of the camera following an object.
  113774. */
  113775. maxCameraSpeed: number;
  113776. /**
  113777. * Define the target of the camera.
  113778. */
  113779. lockedTarget: Nullable<AbstractMesh>;
  113780. /**
  113781. * Defines the input associated with the camera.
  113782. */
  113783. inputs: FollowCameraInputsManager;
  113784. /**
  113785. * Instantiates the follow camera.
  113786. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113787. * @param name Define the name of the camera in the scene
  113788. * @param position Define the position of the camera
  113789. * @param scene Define the scene the camera belong to
  113790. * @param lockedTarget Define the target of the camera
  113791. */
  113792. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113793. private _follow;
  113794. /**
  113795. * Attached controls to the current camera.
  113796. * @param element Defines the element the controls should be listened from
  113797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113798. */
  113799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113800. /**
  113801. * Detach the current controls from the camera.
  113802. * The camera will stop reacting to inputs.
  113803. * @param element Defines the element to stop listening the inputs from
  113804. */
  113805. detachControl(element: HTMLElement): void;
  113806. /** @hidden */
  113807. _checkInputs(): void;
  113808. private _checkLimits;
  113809. /**
  113810. * Gets the camera class name.
  113811. * @returns the class name
  113812. */
  113813. getClassName(): string;
  113814. }
  113815. /**
  113816. * Arc Rotate version of the follow camera.
  113817. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113818. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113819. */
  113820. export class ArcFollowCamera extends TargetCamera {
  113821. /** The longitudinal angle of the camera */
  113822. alpha: number;
  113823. /** The latitudinal angle of the camera */
  113824. beta: number;
  113825. /** The radius of the camera from its target */
  113826. radius: number;
  113827. /** Define the camera target (the messh it should follow) */
  113828. target: Nullable<AbstractMesh>;
  113829. private _cartesianCoordinates;
  113830. /**
  113831. * Instantiates a new ArcFollowCamera
  113832. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113833. * @param name Define the name of the camera
  113834. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113835. * @param beta Define the rotation angle of the camera around the elevation axis
  113836. * @param radius Define the radius of the camera from its target point
  113837. * @param target Define the target of the camera
  113838. * @param scene Define the scene the camera belongs to
  113839. */
  113840. constructor(name: string,
  113841. /** The longitudinal angle of the camera */
  113842. alpha: number,
  113843. /** The latitudinal angle of the camera */
  113844. beta: number,
  113845. /** The radius of the camera from its target */
  113846. radius: number,
  113847. /** Define the camera target (the messh it should follow) */
  113848. target: Nullable<AbstractMesh>, scene: Scene);
  113849. private _follow;
  113850. /** @hidden */
  113851. _checkInputs(): void;
  113852. /**
  113853. * Returns the class name of the object.
  113854. * It is mostly used internally for serialization purposes.
  113855. */
  113856. getClassName(): string;
  113857. }
  113858. }
  113859. declare module BABYLON {
  113860. /**
  113861. * Manage the keyboard inputs to control the movement of a follow camera.
  113862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113863. */
  113864. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113865. /**
  113866. * Defines the camera the input is attached to.
  113867. */
  113868. camera: FollowCamera;
  113869. /**
  113870. * Defines the list of key codes associated with the up action (increase heightOffset)
  113871. */
  113872. keysHeightOffsetIncr: number[];
  113873. /**
  113874. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113875. */
  113876. keysHeightOffsetDecr: number[];
  113877. /**
  113878. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113879. */
  113880. keysHeightOffsetModifierAlt: boolean;
  113881. /**
  113882. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113883. */
  113884. keysHeightOffsetModifierCtrl: boolean;
  113885. /**
  113886. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113887. */
  113888. keysHeightOffsetModifierShift: boolean;
  113889. /**
  113890. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113891. */
  113892. keysRotationOffsetIncr: number[];
  113893. /**
  113894. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113895. */
  113896. keysRotationOffsetDecr: number[];
  113897. /**
  113898. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113899. */
  113900. keysRotationOffsetModifierAlt: boolean;
  113901. /**
  113902. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113903. */
  113904. keysRotationOffsetModifierCtrl: boolean;
  113905. /**
  113906. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113907. */
  113908. keysRotationOffsetModifierShift: boolean;
  113909. /**
  113910. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113911. */
  113912. keysRadiusIncr: number[];
  113913. /**
  113914. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113915. */
  113916. keysRadiusDecr: number[];
  113917. /**
  113918. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113919. */
  113920. keysRadiusModifierAlt: boolean;
  113921. /**
  113922. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113923. */
  113924. keysRadiusModifierCtrl: boolean;
  113925. /**
  113926. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113927. */
  113928. keysRadiusModifierShift: boolean;
  113929. /**
  113930. * Defines the rate of change of heightOffset.
  113931. */
  113932. heightSensibility: number;
  113933. /**
  113934. * Defines the rate of change of rotationOffset.
  113935. */
  113936. rotationSensibility: number;
  113937. /**
  113938. * Defines the rate of change of radius.
  113939. */
  113940. radiusSensibility: number;
  113941. private _keys;
  113942. private _ctrlPressed;
  113943. private _altPressed;
  113944. private _shiftPressed;
  113945. private _onCanvasBlurObserver;
  113946. private _onKeyboardObserver;
  113947. private _engine;
  113948. private _scene;
  113949. /**
  113950. * Attach the input controls to a specific dom element to get the input from.
  113951. * @param element Defines the element the controls should be listened from
  113952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113953. */
  113954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113955. /**
  113956. * Detach the current controls from the specified dom element.
  113957. * @param element Defines the element to stop listening the inputs from
  113958. */
  113959. detachControl(element: Nullable<HTMLElement>): void;
  113960. /**
  113961. * Update the current camera state depending on the inputs that have been used this frame.
  113962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113963. */
  113964. checkInputs(): void;
  113965. /**
  113966. * Gets the class name of the current input.
  113967. * @returns the class name
  113968. */
  113969. getClassName(): string;
  113970. /**
  113971. * Get the friendly name associated with the input class.
  113972. * @returns the input friendly name
  113973. */
  113974. getSimpleName(): string;
  113975. /**
  113976. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113977. * allow modification of the heightOffset value.
  113978. */
  113979. private _modifierHeightOffset;
  113980. /**
  113981. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113982. * allow modification of the rotationOffset value.
  113983. */
  113984. private _modifierRotationOffset;
  113985. /**
  113986. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113987. * allow modification of the radius value.
  113988. */
  113989. private _modifierRadius;
  113990. }
  113991. }
  113992. declare module BABYLON {
  113993. interface FreeCameraInputsManager {
  113994. /**
  113995. * @hidden
  113996. */
  113997. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113998. /**
  113999. * Add orientation input support to the input manager.
  114000. * @returns the current input manager
  114001. */
  114002. addDeviceOrientation(): FreeCameraInputsManager;
  114003. }
  114004. /**
  114005. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  114006. * Screen rotation is taken into account.
  114007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114008. */
  114009. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  114010. private _camera;
  114011. private _screenOrientationAngle;
  114012. private _constantTranform;
  114013. private _screenQuaternion;
  114014. private _alpha;
  114015. private _beta;
  114016. private _gamma;
  114017. /**
  114018. * Can be used to detect if a device orientation sensor is available on a device
  114019. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  114020. * @returns a promise that will resolve on orientation change
  114021. */
  114022. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  114023. /**
  114024. * @hidden
  114025. */
  114026. _onDeviceOrientationChangedObservable: Observable<void>;
  114027. /**
  114028. * Instantiates a new input
  114029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114030. */
  114031. constructor();
  114032. /**
  114033. * Define the camera controlled by the input.
  114034. */
  114035. get camera(): FreeCamera;
  114036. set camera(camera: FreeCamera);
  114037. /**
  114038. * Attach the input controls to a specific dom element to get the input from.
  114039. * @param element Defines the element the controls should be listened from
  114040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114041. */
  114042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114043. private _orientationChanged;
  114044. private _deviceOrientation;
  114045. /**
  114046. * Detach the current controls from the specified dom element.
  114047. * @param element Defines the element to stop listening the inputs from
  114048. */
  114049. detachControl(element: Nullable<HTMLElement>): void;
  114050. /**
  114051. * Update the current camera state depending on the inputs that have been used this frame.
  114052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114053. */
  114054. checkInputs(): void;
  114055. /**
  114056. * Gets the class name of the current intput.
  114057. * @returns the class name
  114058. */
  114059. getClassName(): string;
  114060. /**
  114061. * Get the friendly name associated with the input class.
  114062. * @returns the input friendly name
  114063. */
  114064. getSimpleName(): string;
  114065. }
  114066. }
  114067. declare module BABYLON {
  114068. /**
  114069. * Manage the gamepad inputs to control a free camera.
  114070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114071. */
  114072. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  114073. /**
  114074. * Define the camera the input is attached to.
  114075. */
  114076. camera: FreeCamera;
  114077. /**
  114078. * Define the Gamepad controlling the input
  114079. */
  114080. gamepad: Nullable<Gamepad>;
  114081. /**
  114082. * Defines the gamepad rotation sensiblity.
  114083. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114084. */
  114085. gamepadAngularSensibility: number;
  114086. /**
  114087. * Defines the gamepad move sensiblity.
  114088. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114089. */
  114090. gamepadMoveSensibility: number;
  114091. private _yAxisScale;
  114092. /**
  114093. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114094. */
  114095. get invertYAxis(): boolean;
  114096. set invertYAxis(value: boolean);
  114097. private _onGamepadConnectedObserver;
  114098. private _onGamepadDisconnectedObserver;
  114099. private _cameraTransform;
  114100. private _deltaTransform;
  114101. private _vector3;
  114102. private _vector2;
  114103. /**
  114104. * Attach the input controls to a specific dom element to get the input from.
  114105. * @param element Defines the element the controls should be listened from
  114106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114107. */
  114108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114109. /**
  114110. * Detach the current controls from the specified dom element.
  114111. * @param element Defines the element to stop listening the inputs from
  114112. */
  114113. detachControl(element: Nullable<HTMLElement>): void;
  114114. /**
  114115. * Update the current camera state depending on the inputs that have been used this frame.
  114116. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114117. */
  114118. checkInputs(): void;
  114119. /**
  114120. * Gets the class name of the current intput.
  114121. * @returns the class name
  114122. */
  114123. getClassName(): string;
  114124. /**
  114125. * Get the friendly name associated with the input class.
  114126. * @returns the input friendly name
  114127. */
  114128. getSimpleName(): string;
  114129. }
  114130. }
  114131. declare module BABYLON {
  114132. /**
  114133. * Defines the potential axis of a Joystick
  114134. */
  114135. export enum JoystickAxis {
  114136. /** X axis */
  114137. X = 0,
  114138. /** Y axis */
  114139. Y = 1,
  114140. /** Z axis */
  114141. Z = 2
  114142. }
  114143. /**
  114144. * Class used to define virtual joystick (used in touch mode)
  114145. */
  114146. export class VirtualJoystick {
  114147. /**
  114148. * Gets or sets a boolean indicating that left and right values must be inverted
  114149. */
  114150. reverseLeftRight: boolean;
  114151. /**
  114152. * Gets or sets a boolean indicating that up and down values must be inverted
  114153. */
  114154. reverseUpDown: boolean;
  114155. /**
  114156. * Gets the offset value for the position (ie. the change of the position value)
  114157. */
  114158. deltaPosition: Vector3;
  114159. /**
  114160. * Gets a boolean indicating if the virtual joystick was pressed
  114161. */
  114162. pressed: boolean;
  114163. /**
  114164. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114165. */
  114166. static Canvas: Nullable<HTMLCanvasElement>;
  114167. private static _globalJoystickIndex;
  114168. private static vjCanvasContext;
  114169. private static vjCanvasWidth;
  114170. private static vjCanvasHeight;
  114171. private static halfWidth;
  114172. private _action;
  114173. private _axisTargetedByLeftAndRight;
  114174. private _axisTargetedByUpAndDown;
  114175. private _joystickSensibility;
  114176. private _inversedSensibility;
  114177. private _joystickPointerID;
  114178. private _joystickColor;
  114179. private _joystickPointerPos;
  114180. private _joystickPreviousPointerPos;
  114181. private _joystickPointerStartPos;
  114182. private _deltaJoystickVector;
  114183. private _leftJoystick;
  114184. private _touches;
  114185. private _onPointerDownHandlerRef;
  114186. private _onPointerMoveHandlerRef;
  114187. private _onPointerUpHandlerRef;
  114188. private _onResize;
  114189. /**
  114190. * Creates a new virtual joystick
  114191. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114192. */
  114193. constructor(leftJoystick?: boolean);
  114194. /**
  114195. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114196. * @param newJoystickSensibility defines the new sensibility
  114197. */
  114198. setJoystickSensibility(newJoystickSensibility: number): void;
  114199. private _onPointerDown;
  114200. private _onPointerMove;
  114201. private _onPointerUp;
  114202. /**
  114203. * Change the color of the virtual joystick
  114204. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114205. */
  114206. setJoystickColor(newColor: string): void;
  114207. /**
  114208. * Defines a callback to call when the joystick is touched
  114209. * @param action defines the callback
  114210. */
  114211. setActionOnTouch(action: () => any): void;
  114212. /**
  114213. * Defines which axis you'd like to control for left & right
  114214. * @param axis defines the axis to use
  114215. */
  114216. setAxisForLeftRight(axis: JoystickAxis): void;
  114217. /**
  114218. * Defines which axis you'd like to control for up & down
  114219. * @param axis defines the axis to use
  114220. */
  114221. setAxisForUpDown(axis: JoystickAxis): void;
  114222. private _drawVirtualJoystick;
  114223. /**
  114224. * Release internal HTML canvas
  114225. */
  114226. releaseCanvas(): void;
  114227. }
  114228. }
  114229. declare module BABYLON {
  114230. interface FreeCameraInputsManager {
  114231. /**
  114232. * Add virtual joystick input support to the input manager.
  114233. * @returns the current input manager
  114234. */
  114235. addVirtualJoystick(): FreeCameraInputsManager;
  114236. }
  114237. /**
  114238. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114240. */
  114241. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114242. /**
  114243. * Defines the camera the input is attached to.
  114244. */
  114245. camera: FreeCamera;
  114246. private _leftjoystick;
  114247. private _rightjoystick;
  114248. /**
  114249. * Gets the left stick of the virtual joystick.
  114250. * @returns The virtual Joystick
  114251. */
  114252. getLeftJoystick(): VirtualJoystick;
  114253. /**
  114254. * Gets the right stick of the virtual joystick.
  114255. * @returns The virtual Joystick
  114256. */
  114257. getRightJoystick(): VirtualJoystick;
  114258. /**
  114259. * Update the current camera state depending on the inputs that have been used this frame.
  114260. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114261. */
  114262. checkInputs(): void;
  114263. /**
  114264. * Attach the input controls to a specific dom element to get the input from.
  114265. * @param element Defines the element the controls should be listened from
  114266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114267. */
  114268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114269. /**
  114270. * Detach the current controls from the specified dom element.
  114271. * @param element Defines the element to stop listening the inputs from
  114272. */
  114273. detachControl(element: Nullable<HTMLElement>): void;
  114274. /**
  114275. * Gets the class name of the current intput.
  114276. * @returns the class name
  114277. */
  114278. getClassName(): string;
  114279. /**
  114280. * Get the friendly name associated with the input class.
  114281. * @returns the input friendly name
  114282. */
  114283. getSimpleName(): string;
  114284. }
  114285. }
  114286. declare module BABYLON {
  114287. /**
  114288. * This represents a FPS type of camera controlled by touch.
  114289. * This is like a universal camera minus the Gamepad controls.
  114290. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114291. */
  114292. export class TouchCamera extends FreeCamera {
  114293. /**
  114294. * Defines the touch sensibility for rotation.
  114295. * The higher the faster.
  114296. */
  114297. get touchAngularSensibility(): number;
  114298. set touchAngularSensibility(value: number);
  114299. /**
  114300. * Defines the touch sensibility for move.
  114301. * The higher the faster.
  114302. */
  114303. get touchMoveSensibility(): number;
  114304. set touchMoveSensibility(value: number);
  114305. /**
  114306. * Instantiates a new touch camera.
  114307. * This represents a FPS type of camera controlled by touch.
  114308. * This is like a universal camera minus the Gamepad controls.
  114309. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114310. * @param name Define the name of the camera in the scene
  114311. * @param position Define the start position of the camera in the scene
  114312. * @param scene Define the scene the camera belongs to
  114313. */
  114314. constructor(name: string, position: Vector3, scene: Scene);
  114315. /**
  114316. * Gets the current object class name.
  114317. * @return the class name
  114318. */
  114319. getClassName(): string;
  114320. /** @hidden */
  114321. _setupInputs(): void;
  114322. }
  114323. }
  114324. declare module BABYLON {
  114325. /**
  114326. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114327. * being tilted forward or back and left or right.
  114328. */
  114329. export class DeviceOrientationCamera extends FreeCamera {
  114330. private _initialQuaternion;
  114331. private _quaternionCache;
  114332. private _tmpDragQuaternion;
  114333. private _disablePointerInputWhenUsingDeviceOrientation;
  114334. /**
  114335. * Creates a new device orientation camera
  114336. * @param name The name of the camera
  114337. * @param position The start position camera
  114338. * @param scene The scene the camera belongs to
  114339. */
  114340. constructor(name: string, position: Vector3, scene: Scene);
  114341. /**
  114342. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114343. */
  114344. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114345. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114346. private _dragFactor;
  114347. /**
  114348. * Enabled turning on the y axis when the orientation sensor is active
  114349. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114350. */
  114351. enableHorizontalDragging(dragFactor?: number): void;
  114352. /**
  114353. * Gets the current instance class name ("DeviceOrientationCamera").
  114354. * This helps avoiding instanceof at run time.
  114355. * @returns the class name
  114356. */
  114357. getClassName(): string;
  114358. /**
  114359. * @hidden
  114360. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114361. */
  114362. _checkInputs(): void;
  114363. /**
  114364. * Reset the camera to its default orientation on the specified axis only.
  114365. * @param axis The axis to reset
  114366. */
  114367. resetToCurrentRotation(axis?: Axis): void;
  114368. }
  114369. }
  114370. declare module BABYLON {
  114371. /**
  114372. * Defines supported buttons for XBox360 compatible gamepads
  114373. */
  114374. export enum Xbox360Button {
  114375. /** A */
  114376. A = 0,
  114377. /** B */
  114378. B = 1,
  114379. /** X */
  114380. X = 2,
  114381. /** Y */
  114382. Y = 3,
  114383. /** Left button */
  114384. LB = 4,
  114385. /** Right button */
  114386. RB = 5,
  114387. /** Back */
  114388. Back = 8,
  114389. /** Start */
  114390. Start = 9,
  114391. /** Left stick */
  114392. LeftStick = 10,
  114393. /** Right stick */
  114394. RightStick = 11
  114395. }
  114396. /** Defines values for XBox360 DPad */
  114397. export enum Xbox360Dpad {
  114398. /** Up */
  114399. Up = 12,
  114400. /** Down */
  114401. Down = 13,
  114402. /** Left */
  114403. Left = 14,
  114404. /** Right */
  114405. Right = 15
  114406. }
  114407. /**
  114408. * Defines a XBox360 gamepad
  114409. */
  114410. export class Xbox360Pad extends Gamepad {
  114411. private _leftTrigger;
  114412. private _rightTrigger;
  114413. private _onlefttriggerchanged;
  114414. private _onrighttriggerchanged;
  114415. private _onbuttondown;
  114416. private _onbuttonup;
  114417. private _ondpaddown;
  114418. private _ondpadup;
  114419. /** Observable raised when a button is pressed */
  114420. onButtonDownObservable: Observable<Xbox360Button>;
  114421. /** Observable raised when a button is released */
  114422. onButtonUpObservable: Observable<Xbox360Button>;
  114423. /** Observable raised when a pad is pressed */
  114424. onPadDownObservable: Observable<Xbox360Dpad>;
  114425. /** Observable raised when a pad is released */
  114426. onPadUpObservable: Observable<Xbox360Dpad>;
  114427. private _buttonA;
  114428. private _buttonB;
  114429. private _buttonX;
  114430. private _buttonY;
  114431. private _buttonBack;
  114432. private _buttonStart;
  114433. private _buttonLB;
  114434. private _buttonRB;
  114435. private _buttonLeftStick;
  114436. private _buttonRightStick;
  114437. private _dPadUp;
  114438. private _dPadDown;
  114439. private _dPadLeft;
  114440. private _dPadRight;
  114441. private _isXboxOnePad;
  114442. /**
  114443. * Creates a new XBox360 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. * @param xboxOne defines if it is a XBox One gamepad
  114448. */
  114449. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114450. /**
  114451. * Defines the callback to call when left trigger is pressed
  114452. * @param callback defines the callback to use
  114453. */
  114454. onlefttriggerchanged(callback: (value: number) => void): void;
  114455. /**
  114456. * Defines the callback to call when right trigger is pressed
  114457. * @param callback defines the callback to use
  114458. */
  114459. onrighttriggerchanged(callback: (value: number) => void): void;
  114460. /**
  114461. * Gets the left trigger value
  114462. */
  114463. get leftTrigger(): number;
  114464. /**
  114465. * Sets the left trigger value
  114466. */
  114467. set leftTrigger(newValue: number);
  114468. /**
  114469. * Gets the right trigger value
  114470. */
  114471. get rightTrigger(): number;
  114472. /**
  114473. * Sets the right trigger value
  114474. */
  114475. set rightTrigger(newValue: number);
  114476. /**
  114477. * Defines the callback to call when a button is pressed
  114478. * @param callback defines the callback to use
  114479. */
  114480. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114481. /**
  114482. * Defines the callback to call when a button is released
  114483. * @param callback defines the callback to use
  114484. */
  114485. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114486. /**
  114487. * Defines the callback to call when a pad is pressed
  114488. * @param callback defines the callback to use
  114489. */
  114490. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114491. /**
  114492. * Defines the callback to call when a pad is released
  114493. * @param callback defines the callback to use
  114494. */
  114495. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114496. private _setButtonValue;
  114497. private _setDPadValue;
  114498. /**
  114499. * Gets the value of the `A` button
  114500. */
  114501. get buttonA(): number;
  114502. /**
  114503. * Sets the value of the `A` button
  114504. */
  114505. set buttonA(value: number);
  114506. /**
  114507. * Gets the value of the `B` button
  114508. */
  114509. get buttonB(): number;
  114510. /**
  114511. * Sets the value of the `B` button
  114512. */
  114513. set buttonB(value: number);
  114514. /**
  114515. * Gets the value of the `X` button
  114516. */
  114517. get buttonX(): number;
  114518. /**
  114519. * Sets the value of the `X` button
  114520. */
  114521. set buttonX(value: number);
  114522. /**
  114523. * Gets the value of the `Y` button
  114524. */
  114525. get buttonY(): number;
  114526. /**
  114527. * Sets the value of the `Y` button
  114528. */
  114529. set buttonY(value: number);
  114530. /**
  114531. * Gets the value of the `Start` button
  114532. */
  114533. get buttonStart(): number;
  114534. /**
  114535. * Sets the value of the `Start` button
  114536. */
  114537. set buttonStart(value: number);
  114538. /**
  114539. * Gets the value of the `Back` button
  114540. */
  114541. get buttonBack(): number;
  114542. /**
  114543. * Sets the value of the `Back` button
  114544. */
  114545. set buttonBack(value: number);
  114546. /**
  114547. * Gets the value of the `Left` button
  114548. */
  114549. get buttonLB(): number;
  114550. /**
  114551. * Sets the value of the `Left` button
  114552. */
  114553. set buttonLB(value: number);
  114554. /**
  114555. * Gets the value of the `Right` button
  114556. */
  114557. get buttonRB(): number;
  114558. /**
  114559. * Sets the value of the `Right` button
  114560. */
  114561. set buttonRB(value: number);
  114562. /**
  114563. * Gets the value of the Left joystick
  114564. */
  114565. get buttonLeftStick(): number;
  114566. /**
  114567. * Sets the value of the Left joystick
  114568. */
  114569. set buttonLeftStick(value: number);
  114570. /**
  114571. * Gets the value of the Right joystick
  114572. */
  114573. get buttonRightStick(): number;
  114574. /**
  114575. * Sets the value of the Right joystick
  114576. */
  114577. set buttonRightStick(value: number);
  114578. /**
  114579. * Gets the value of D-pad up
  114580. */
  114581. get dPadUp(): number;
  114582. /**
  114583. * Sets the value of D-pad up
  114584. */
  114585. set dPadUp(value: number);
  114586. /**
  114587. * Gets the value of D-pad down
  114588. */
  114589. get dPadDown(): number;
  114590. /**
  114591. * Sets the value of D-pad down
  114592. */
  114593. set dPadDown(value: number);
  114594. /**
  114595. * Gets the value of D-pad left
  114596. */
  114597. get dPadLeft(): number;
  114598. /**
  114599. * Sets the value of D-pad left
  114600. */
  114601. set dPadLeft(value: number);
  114602. /**
  114603. * Gets the value of D-pad right
  114604. */
  114605. get dPadRight(): number;
  114606. /**
  114607. * Sets the value of D-pad right
  114608. */
  114609. set dPadRight(value: number);
  114610. /**
  114611. * Force the gamepad to synchronize with device values
  114612. */
  114613. update(): void;
  114614. /**
  114615. * Disposes the gamepad
  114616. */
  114617. dispose(): void;
  114618. }
  114619. }
  114620. declare module BABYLON {
  114621. /**
  114622. * Defines supported buttons for DualShock compatible gamepads
  114623. */
  114624. export enum DualShockButton {
  114625. /** Cross */
  114626. Cross = 0,
  114627. /** Circle */
  114628. Circle = 1,
  114629. /** Square */
  114630. Square = 2,
  114631. /** Triangle */
  114632. Triangle = 3,
  114633. /** L1 */
  114634. L1 = 4,
  114635. /** R1 */
  114636. R1 = 5,
  114637. /** Share */
  114638. Share = 8,
  114639. /** Options */
  114640. Options = 9,
  114641. /** Left stick */
  114642. LeftStick = 10,
  114643. /** Right stick */
  114644. RightStick = 11
  114645. }
  114646. /** Defines values for DualShock DPad */
  114647. export enum DualShockDpad {
  114648. /** Up */
  114649. Up = 12,
  114650. /** Down */
  114651. Down = 13,
  114652. /** Left */
  114653. Left = 14,
  114654. /** Right */
  114655. Right = 15
  114656. }
  114657. /**
  114658. * Defines a DualShock gamepad
  114659. */
  114660. export class DualShockPad extends Gamepad {
  114661. private _leftTrigger;
  114662. private _rightTrigger;
  114663. private _onlefttriggerchanged;
  114664. private _onrighttriggerchanged;
  114665. private _onbuttondown;
  114666. private _onbuttonup;
  114667. private _ondpaddown;
  114668. private _ondpadup;
  114669. /** Observable raised when a button is pressed */
  114670. onButtonDownObservable: Observable<DualShockButton>;
  114671. /** Observable raised when a button is released */
  114672. onButtonUpObservable: Observable<DualShockButton>;
  114673. /** Observable raised when a pad is pressed */
  114674. onPadDownObservable: Observable<DualShockDpad>;
  114675. /** Observable raised when a pad is released */
  114676. onPadUpObservable: Observable<DualShockDpad>;
  114677. private _buttonCross;
  114678. private _buttonCircle;
  114679. private _buttonSquare;
  114680. private _buttonTriangle;
  114681. private _buttonShare;
  114682. private _buttonOptions;
  114683. private _buttonL1;
  114684. private _buttonR1;
  114685. private _buttonLeftStick;
  114686. private _buttonRightStick;
  114687. private _dPadUp;
  114688. private _dPadDown;
  114689. private _dPadLeft;
  114690. private _dPadRight;
  114691. /**
  114692. * Creates a new DualShock gamepad object
  114693. * @param id defines the id of this gamepad
  114694. * @param index defines its index
  114695. * @param gamepad defines the internal HTML gamepad object
  114696. */
  114697. constructor(id: string, index: number, gamepad: any);
  114698. /**
  114699. * Defines the callback to call when left trigger is pressed
  114700. * @param callback defines the callback to use
  114701. */
  114702. onlefttriggerchanged(callback: (value: number) => void): void;
  114703. /**
  114704. * Defines the callback to call when right trigger is pressed
  114705. * @param callback defines the callback to use
  114706. */
  114707. onrighttriggerchanged(callback: (value: number) => void): void;
  114708. /**
  114709. * Gets the left trigger value
  114710. */
  114711. get leftTrigger(): number;
  114712. /**
  114713. * Sets the left trigger value
  114714. */
  114715. set leftTrigger(newValue: number);
  114716. /**
  114717. * Gets the right trigger value
  114718. */
  114719. get rightTrigger(): number;
  114720. /**
  114721. * Sets the right trigger value
  114722. */
  114723. set rightTrigger(newValue: number);
  114724. /**
  114725. * Defines the callback to call when a button is pressed
  114726. * @param callback defines the callback to use
  114727. */
  114728. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114729. /**
  114730. * Defines the callback to call when a button is released
  114731. * @param callback defines the callback to use
  114732. */
  114733. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114734. /**
  114735. * Defines the callback to call when a pad is pressed
  114736. * @param callback defines the callback to use
  114737. */
  114738. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114739. /**
  114740. * Defines the callback to call when a pad is released
  114741. * @param callback defines the callback to use
  114742. */
  114743. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114744. private _setButtonValue;
  114745. private _setDPadValue;
  114746. /**
  114747. * Gets the value of the `Cross` button
  114748. */
  114749. get buttonCross(): number;
  114750. /**
  114751. * Sets the value of the `Cross` button
  114752. */
  114753. set buttonCross(value: number);
  114754. /**
  114755. * Gets the value of the `Circle` button
  114756. */
  114757. get buttonCircle(): number;
  114758. /**
  114759. * Sets the value of the `Circle` button
  114760. */
  114761. set buttonCircle(value: number);
  114762. /**
  114763. * Gets the value of the `Square` button
  114764. */
  114765. get buttonSquare(): number;
  114766. /**
  114767. * Sets the value of the `Square` button
  114768. */
  114769. set buttonSquare(value: number);
  114770. /**
  114771. * Gets the value of the `Triangle` button
  114772. */
  114773. get buttonTriangle(): number;
  114774. /**
  114775. * Sets the value of the `Triangle` button
  114776. */
  114777. set buttonTriangle(value: number);
  114778. /**
  114779. * Gets the value of the `Options` button
  114780. */
  114781. get buttonOptions(): number;
  114782. /**
  114783. * Sets the value of the `Options` button
  114784. */
  114785. set buttonOptions(value: number);
  114786. /**
  114787. * Gets the value of the `Share` button
  114788. */
  114789. get buttonShare(): number;
  114790. /**
  114791. * Sets the value of the `Share` button
  114792. */
  114793. set buttonShare(value: number);
  114794. /**
  114795. * Gets the value of the `L1` button
  114796. */
  114797. get buttonL1(): number;
  114798. /**
  114799. * Sets the value of the `L1` button
  114800. */
  114801. set buttonL1(value: number);
  114802. /**
  114803. * Gets the value of the `R1` button
  114804. */
  114805. get buttonR1(): number;
  114806. /**
  114807. * Sets the value of the `R1` button
  114808. */
  114809. set buttonR1(value: number);
  114810. /**
  114811. * Gets the value of the Left joystick
  114812. */
  114813. get buttonLeftStick(): number;
  114814. /**
  114815. * Sets the value of the Left joystick
  114816. */
  114817. set buttonLeftStick(value: number);
  114818. /**
  114819. * Gets the value of the Right joystick
  114820. */
  114821. get buttonRightStick(): number;
  114822. /**
  114823. * Sets the value of the Right joystick
  114824. */
  114825. set buttonRightStick(value: number);
  114826. /**
  114827. * Gets the value of D-pad up
  114828. */
  114829. get dPadUp(): number;
  114830. /**
  114831. * Sets the value of D-pad up
  114832. */
  114833. set dPadUp(value: number);
  114834. /**
  114835. * Gets the value of D-pad down
  114836. */
  114837. get dPadDown(): number;
  114838. /**
  114839. * Sets the value of D-pad down
  114840. */
  114841. set dPadDown(value: number);
  114842. /**
  114843. * Gets the value of D-pad left
  114844. */
  114845. get dPadLeft(): number;
  114846. /**
  114847. * Sets the value of D-pad left
  114848. */
  114849. set dPadLeft(value: number);
  114850. /**
  114851. * Gets the value of D-pad right
  114852. */
  114853. get dPadRight(): number;
  114854. /**
  114855. * Sets the value of D-pad right
  114856. */
  114857. set dPadRight(value: number);
  114858. /**
  114859. * Force the gamepad to synchronize with device values
  114860. */
  114861. update(): void;
  114862. /**
  114863. * Disposes the gamepad
  114864. */
  114865. dispose(): void;
  114866. }
  114867. }
  114868. declare module BABYLON {
  114869. /**
  114870. * Manager for handling gamepads
  114871. */
  114872. export class GamepadManager {
  114873. private _scene?;
  114874. private _babylonGamepads;
  114875. private _oneGamepadConnected;
  114876. /** @hidden */
  114877. _isMonitoring: boolean;
  114878. private _gamepadEventSupported;
  114879. private _gamepadSupport?;
  114880. /**
  114881. * observable to be triggered when the gamepad controller has been connected
  114882. */
  114883. onGamepadConnectedObservable: Observable<Gamepad>;
  114884. /**
  114885. * observable to be triggered when the gamepad controller has been disconnected
  114886. */
  114887. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114888. private _onGamepadConnectedEvent;
  114889. private _onGamepadDisconnectedEvent;
  114890. /**
  114891. * Initializes the gamepad manager
  114892. * @param _scene BabylonJS scene
  114893. */
  114894. constructor(_scene?: Scene | undefined);
  114895. /**
  114896. * The gamepads in the game pad manager
  114897. */
  114898. get gamepads(): Gamepad[];
  114899. /**
  114900. * Get the gamepad controllers based on type
  114901. * @param type The type of gamepad controller
  114902. * @returns Nullable gamepad
  114903. */
  114904. getGamepadByType(type?: number): Nullable<Gamepad>;
  114905. /**
  114906. * Disposes the gamepad manager
  114907. */
  114908. dispose(): void;
  114909. private _addNewGamepad;
  114910. private _startMonitoringGamepads;
  114911. private _stopMonitoringGamepads;
  114912. /** @hidden */
  114913. _checkGamepadsStatus(): void;
  114914. private _updateGamepadObjects;
  114915. }
  114916. }
  114917. declare module BABYLON {
  114918. interface Scene {
  114919. /** @hidden */
  114920. _gamepadManager: Nullable<GamepadManager>;
  114921. /**
  114922. * Gets the gamepad manager associated with the scene
  114923. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114924. */
  114925. gamepadManager: GamepadManager;
  114926. }
  114927. /**
  114928. * Interface representing a free camera inputs manager
  114929. */
  114930. interface FreeCameraInputsManager {
  114931. /**
  114932. * Adds gamepad input support to the FreeCameraInputsManager.
  114933. * @returns the FreeCameraInputsManager
  114934. */
  114935. addGamepad(): FreeCameraInputsManager;
  114936. }
  114937. /**
  114938. * Interface representing an arc rotate camera inputs manager
  114939. */
  114940. interface ArcRotateCameraInputsManager {
  114941. /**
  114942. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114943. * @returns the camera inputs manager
  114944. */
  114945. addGamepad(): ArcRotateCameraInputsManager;
  114946. }
  114947. /**
  114948. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114949. */
  114950. export class GamepadSystemSceneComponent implements ISceneComponent {
  114951. /**
  114952. * The component name helpfull to identify the component in the list of scene components.
  114953. */
  114954. readonly name: string;
  114955. /**
  114956. * The scene the component belongs to.
  114957. */
  114958. scene: Scene;
  114959. /**
  114960. * Creates a new instance of the component for the given scene
  114961. * @param scene Defines the scene to register the component in
  114962. */
  114963. constructor(scene: Scene);
  114964. /**
  114965. * Registers the component in a given scene
  114966. */
  114967. register(): void;
  114968. /**
  114969. * Rebuilds the elements related to this component in case of
  114970. * context lost for instance.
  114971. */
  114972. rebuild(): void;
  114973. /**
  114974. * Disposes the component and the associated ressources
  114975. */
  114976. dispose(): void;
  114977. private _beforeCameraUpdate;
  114978. }
  114979. }
  114980. declare module BABYLON {
  114981. /**
  114982. * 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,
  114983. * which still works and will still be found in many Playgrounds.
  114984. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114985. */
  114986. export class UniversalCamera extends TouchCamera {
  114987. /**
  114988. * Defines the gamepad rotation sensiblity.
  114989. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114990. */
  114991. get gamepadAngularSensibility(): number;
  114992. set gamepadAngularSensibility(value: number);
  114993. /**
  114994. * Defines the gamepad move sensiblity.
  114995. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114996. */
  114997. get gamepadMoveSensibility(): number;
  114998. set gamepadMoveSensibility(value: number);
  114999. /**
  115000. * 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,
  115001. * which still works and will still be found in many Playgrounds.
  115002. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115003. * @param name Define the name of the camera in the scene
  115004. * @param position Define the start position of the camera in the scene
  115005. * @param scene Define the scene the camera belongs to
  115006. */
  115007. constructor(name: string, position: Vector3, scene: Scene);
  115008. /**
  115009. * Gets the current object class name.
  115010. * @return the class name
  115011. */
  115012. getClassName(): string;
  115013. }
  115014. }
  115015. declare module BABYLON {
  115016. /**
  115017. * This represents a FPS type of camera. This is only here for back compat purpose.
  115018. * Please use the UniversalCamera instead as both are identical.
  115019. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115020. */
  115021. export class GamepadCamera extends UniversalCamera {
  115022. /**
  115023. * Instantiates a new Gamepad Camera
  115024. * This represents a FPS type of camera. This is only here for back compat purpose.
  115025. * Please use the UniversalCamera instead as both are identical.
  115026. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115027. * @param name Define the name of the camera in the scene
  115028. * @param position Define the start position of the camera in the scene
  115029. * @param scene Define the scene the camera belongs to
  115030. */
  115031. constructor(name: string, position: Vector3, scene: Scene);
  115032. /**
  115033. * Gets the current object class name.
  115034. * @return the class name
  115035. */
  115036. getClassName(): string;
  115037. }
  115038. }
  115039. declare module BABYLON {
  115040. /** @hidden */
  115041. export var passPixelShader: {
  115042. name: string;
  115043. shader: string;
  115044. };
  115045. }
  115046. declare module BABYLON {
  115047. /** @hidden */
  115048. export var passCubePixelShader: {
  115049. name: string;
  115050. shader: string;
  115051. };
  115052. }
  115053. declare module BABYLON {
  115054. /**
  115055. * PassPostProcess which produces an output the same as it's input
  115056. */
  115057. export class PassPostProcess extends PostProcess {
  115058. /**
  115059. * Creates the PassPostProcess
  115060. * @param name The name of the effect.
  115061. * @param options The required width/height ratio to downsize to before computing the render pass.
  115062. * @param camera The camera to apply the render pass to.
  115063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115064. * @param engine The engine which the post process will be applied. (default: current engine)
  115065. * @param reusable If the post process can be reused on the same frame. (default: false)
  115066. * @param textureType The type of texture to be used when performing the post processing.
  115067. * @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)
  115068. */
  115069. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115070. }
  115071. /**
  115072. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  115073. */
  115074. export class PassCubePostProcess extends PostProcess {
  115075. private _face;
  115076. /**
  115077. * Gets or sets the cube face to display.
  115078. * * 0 is +X
  115079. * * 1 is -X
  115080. * * 2 is +Y
  115081. * * 3 is -Y
  115082. * * 4 is +Z
  115083. * * 5 is -Z
  115084. */
  115085. get face(): number;
  115086. set face(value: number);
  115087. /**
  115088. * Creates the PassCubePostProcess
  115089. * @param name The name of the effect.
  115090. * @param options The required width/height ratio to downsize to before computing the render pass.
  115091. * @param camera The camera to apply the render pass to.
  115092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115093. * @param engine The engine which the post process will be applied. (default: current engine)
  115094. * @param reusable If the post process can be reused on the same frame. (default: false)
  115095. * @param textureType The type of texture to be used when performing the post processing.
  115096. * @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)
  115097. */
  115098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115099. }
  115100. }
  115101. declare module BABYLON {
  115102. /** @hidden */
  115103. export var anaglyphPixelShader: {
  115104. name: string;
  115105. shader: string;
  115106. };
  115107. }
  115108. declare module BABYLON {
  115109. /**
  115110. * Postprocess used to generate anaglyphic rendering
  115111. */
  115112. export class AnaglyphPostProcess extends PostProcess {
  115113. private _passedProcess;
  115114. /**
  115115. * Creates a new AnaglyphPostProcess
  115116. * @param name defines postprocess name
  115117. * @param options defines creation options or target ratio scale
  115118. * @param rigCameras defines cameras using this postprocess
  115119. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115120. * @param engine defines hosting engine
  115121. * @param reusable defines if the postprocess will be reused multiple times per frame
  115122. */
  115123. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115124. }
  115125. }
  115126. declare module BABYLON {
  115127. /**
  115128. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115129. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115130. */
  115131. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115132. /**
  115133. * Creates a new AnaglyphArcRotateCamera
  115134. * @param name defines camera name
  115135. * @param alpha defines alpha angle (in radians)
  115136. * @param beta defines beta angle (in radians)
  115137. * @param radius defines radius
  115138. * @param target defines camera target
  115139. * @param interaxialDistance defines distance between each color axis
  115140. * @param scene defines the hosting scene
  115141. */
  115142. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115143. /**
  115144. * Gets camera class name
  115145. * @returns AnaglyphArcRotateCamera
  115146. */
  115147. getClassName(): string;
  115148. }
  115149. }
  115150. declare module BABYLON {
  115151. /**
  115152. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115153. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115154. */
  115155. export class AnaglyphFreeCamera extends FreeCamera {
  115156. /**
  115157. * Creates a new AnaglyphFreeCamera
  115158. * @param name defines camera name
  115159. * @param position defines initial position
  115160. * @param interaxialDistance defines distance between each color axis
  115161. * @param scene defines the hosting scene
  115162. */
  115163. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115164. /**
  115165. * Gets camera class name
  115166. * @returns AnaglyphFreeCamera
  115167. */
  115168. getClassName(): string;
  115169. }
  115170. }
  115171. declare module BABYLON {
  115172. /**
  115173. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115174. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115175. */
  115176. export class AnaglyphGamepadCamera extends GamepadCamera {
  115177. /**
  115178. * Creates a new AnaglyphGamepadCamera
  115179. * @param name defines camera name
  115180. * @param position defines initial position
  115181. * @param interaxialDistance defines distance between each color axis
  115182. * @param scene defines the hosting scene
  115183. */
  115184. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115185. /**
  115186. * Gets camera class name
  115187. * @returns AnaglyphGamepadCamera
  115188. */
  115189. getClassName(): string;
  115190. }
  115191. }
  115192. declare module BABYLON {
  115193. /**
  115194. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115196. */
  115197. export class AnaglyphUniversalCamera extends UniversalCamera {
  115198. /**
  115199. * Creates a new AnaglyphUniversalCamera
  115200. * @param name defines camera name
  115201. * @param position defines initial position
  115202. * @param interaxialDistance defines distance between each color axis
  115203. * @param scene defines the hosting scene
  115204. */
  115205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115206. /**
  115207. * Gets camera class name
  115208. * @returns AnaglyphUniversalCamera
  115209. */
  115210. getClassName(): string;
  115211. }
  115212. }
  115213. declare module BABYLON {
  115214. /** @hidden */
  115215. export var stereoscopicInterlacePixelShader: {
  115216. name: string;
  115217. shader: string;
  115218. };
  115219. }
  115220. declare module BABYLON {
  115221. /**
  115222. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115223. */
  115224. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115225. private _stepSize;
  115226. private _passedProcess;
  115227. /**
  115228. * Initializes a StereoscopicInterlacePostProcessI
  115229. * @param name The name of the effect.
  115230. * @param rigCameras The rig cameras to be appled to the post process
  115231. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115232. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115234. * @param engine The engine which the post process will be applied. (default: current engine)
  115235. * @param reusable If the post process can be reused on the same frame. (default: false)
  115236. */
  115237. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115238. }
  115239. /**
  115240. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115241. */
  115242. export class StereoscopicInterlacePostProcess extends PostProcess {
  115243. private _stepSize;
  115244. private _passedProcess;
  115245. /**
  115246. * Initializes a StereoscopicInterlacePostProcess
  115247. * @param name The name of the effect.
  115248. * @param rigCameras The rig cameras to be appled to the post process
  115249. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115251. * @param engine The engine which the post process will be applied. (default: current engine)
  115252. * @param reusable If the post process can be reused on the same frame. (default: false)
  115253. */
  115254. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115255. }
  115256. }
  115257. declare module BABYLON {
  115258. /**
  115259. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115260. * @see http://doc.babylonjs.com/features/cameras
  115261. */
  115262. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115263. /**
  115264. * Creates a new StereoscopicArcRotateCamera
  115265. * @param name defines camera name
  115266. * @param alpha defines alpha angle (in radians)
  115267. * @param beta defines beta angle (in radians)
  115268. * @param radius defines radius
  115269. * @param target defines camera target
  115270. * @param interaxialDistance defines distance between each color axis
  115271. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115272. * @param scene defines the hosting scene
  115273. */
  115274. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115275. /**
  115276. * Gets camera class name
  115277. * @returns StereoscopicArcRotateCamera
  115278. */
  115279. getClassName(): string;
  115280. }
  115281. }
  115282. declare module BABYLON {
  115283. /**
  115284. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115285. * @see http://doc.babylonjs.com/features/cameras
  115286. */
  115287. export class StereoscopicFreeCamera extends FreeCamera {
  115288. /**
  115289. * Creates a new StereoscopicFreeCamera
  115290. * @param name defines camera name
  115291. * @param position defines initial position
  115292. * @param interaxialDistance defines distance between each color axis
  115293. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115294. * @param scene defines the hosting scene
  115295. */
  115296. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115297. /**
  115298. * Gets camera class name
  115299. * @returns StereoscopicFreeCamera
  115300. */
  115301. getClassName(): string;
  115302. }
  115303. }
  115304. declare module BABYLON {
  115305. /**
  115306. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115307. * @see http://doc.babylonjs.com/features/cameras
  115308. */
  115309. export class StereoscopicGamepadCamera extends GamepadCamera {
  115310. /**
  115311. * Creates a new StereoscopicGamepadCamera
  115312. * @param name defines camera name
  115313. * @param position defines initial position
  115314. * @param interaxialDistance defines distance between each color axis
  115315. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115316. * @param scene defines the hosting scene
  115317. */
  115318. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115319. /**
  115320. * Gets camera class name
  115321. * @returns StereoscopicGamepadCamera
  115322. */
  115323. getClassName(): string;
  115324. }
  115325. }
  115326. declare module BABYLON {
  115327. /**
  115328. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115329. * @see http://doc.babylonjs.com/features/cameras
  115330. */
  115331. export class StereoscopicUniversalCamera extends UniversalCamera {
  115332. /**
  115333. * Creates a new StereoscopicUniversalCamera
  115334. * @param name defines camera name
  115335. * @param position defines initial position
  115336. * @param interaxialDistance defines distance between each color axis
  115337. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115338. * @param scene defines the hosting scene
  115339. */
  115340. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115341. /**
  115342. * Gets camera class name
  115343. * @returns StereoscopicUniversalCamera
  115344. */
  115345. getClassName(): string;
  115346. }
  115347. }
  115348. declare module BABYLON {
  115349. /**
  115350. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115351. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115352. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115353. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115354. */
  115355. export class VirtualJoysticksCamera extends FreeCamera {
  115356. /**
  115357. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115358. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115359. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115360. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115361. * @param name Define the name of the camera in the scene
  115362. * @param position Define the start position of the camera in the scene
  115363. * @param scene Define the scene the camera belongs to
  115364. */
  115365. constructor(name: string, position: Vector3, scene: Scene);
  115366. /**
  115367. * Gets the current object class name.
  115368. * @return the class name
  115369. */
  115370. getClassName(): string;
  115371. }
  115372. }
  115373. declare module BABYLON {
  115374. /**
  115375. * This represents all the required metrics to create a VR camera.
  115376. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115377. */
  115378. export class VRCameraMetrics {
  115379. /**
  115380. * Define the horizontal resolution off the screen.
  115381. */
  115382. hResolution: number;
  115383. /**
  115384. * Define the vertical resolution off the screen.
  115385. */
  115386. vResolution: number;
  115387. /**
  115388. * Define the horizontal screen size.
  115389. */
  115390. hScreenSize: number;
  115391. /**
  115392. * Define the vertical screen size.
  115393. */
  115394. vScreenSize: number;
  115395. /**
  115396. * Define the vertical screen center position.
  115397. */
  115398. vScreenCenter: number;
  115399. /**
  115400. * Define the distance of the eyes to the screen.
  115401. */
  115402. eyeToScreenDistance: number;
  115403. /**
  115404. * Define the distance between both lenses
  115405. */
  115406. lensSeparationDistance: number;
  115407. /**
  115408. * Define the distance between both viewer's eyes.
  115409. */
  115410. interpupillaryDistance: number;
  115411. /**
  115412. * Define the distortion factor of the VR postprocess.
  115413. * Please, touch with care.
  115414. */
  115415. distortionK: number[];
  115416. /**
  115417. * Define the chromatic aberration correction factors for the VR post process.
  115418. */
  115419. chromaAbCorrection: number[];
  115420. /**
  115421. * Define the scale factor of the post process.
  115422. * The smaller the better but the slower.
  115423. */
  115424. postProcessScaleFactor: number;
  115425. /**
  115426. * Define an offset for the lens center.
  115427. */
  115428. lensCenterOffset: number;
  115429. /**
  115430. * Define if the current vr camera should compensate the distortion of the lense or not.
  115431. */
  115432. compensateDistortion: boolean;
  115433. /**
  115434. * Defines if multiview should be enabled when rendering (Default: false)
  115435. */
  115436. multiviewEnabled: boolean;
  115437. /**
  115438. * Gets the rendering aspect ratio based on the provided resolutions.
  115439. */
  115440. get aspectRatio(): number;
  115441. /**
  115442. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115443. */
  115444. get aspectRatioFov(): number;
  115445. /**
  115446. * @hidden
  115447. */
  115448. get leftHMatrix(): Matrix;
  115449. /**
  115450. * @hidden
  115451. */
  115452. get rightHMatrix(): Matrix;
  115453. /**
  115454. * @hidden
  115455. */
  115456. get leftPreViewMatrix(): Matrix;
  115457. /**
  115458. * @hidden
  115459. */
  115460. get rightPreViewMatrix(): Matrix;
  115461. /**
  115462. * Get the default VRMetrics based on the most generic setup.
  115463. * @returns the default vr metrics
  115464. */
  115465. static GetDefault(): VRCameraMetrics;
  115466. }
  115467. }
  115468. declare module BABYLON {
  115469. /** @hidden */
  115470. export var vrDistortionCorrectionPixelShader: {
  115471. name: string;
  115472. shader: string;
  115473. };
  115474. }
  115475. declare module BABYLON {
  115476. /**
  115477. * VRDistortionCorrectionPostProcess used for mobile VR
  115478. */
  115479. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115480. private _isRightEye;
  115481. private _distortionFactors;
  115482. private _postProcessScaleFactor;
  115483. private _lensCenterOffset;
  115484. private _scaleIn;
  115485. private _scaleFactor;
  115486. private _lensCenter;
  115487. /**
  115488. * Initializes the VRDistortionCorrectionPostProcess
  115489. * @param name The name of the effect.
  115490. * @param camera The camera to apply the render pass to.
  115491. * @param isRightEye If this is for the right eye distortion
  115492. * @param vrMetrics All the required metrics for the VR camera
  115493. */
  115494. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115495. }
  115496. }
  115497. declare module BABYLON {
  115498. /**
  115499. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115500. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115501. */
  115502. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115503. /**
  115504. * Creates a new VRDeviceOrientationArcRotateCamera
  115505. * @param name defines camera name
  115506. * @param alpha defines the camera rotation along the logitudinal axis
  115507. * @param beta defines the camera rotation along the latitudinal axis
  115508. * @param radius defines the camera distance from its target
  115509. * @param target defines the camera target
  115510. * @param scene defines the scene the camera belongs to
  115511. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115512. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115513. */
  115514. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115515. /**
  115516. * Gets camera class name
  115517. * @returns VRDeviceOrientationArcRotateCamera
  115518. */
  115519. getClassName(): string;
  115520. }
  115521. }
  115522. declare module BABYLON {
  115523. /**
  115524. * Camera used to simulate VR rendering (based on FreeCamera)
  115525. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115526. */
  115527. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115528. /**
  115529. * Creates a new VRDeviceOrientationFreeCamera
  115530. * @param name defines camera name
  115531. * @param position defines the start position of the camera
  115532. * @param scene defines the scene the camera belongs to
  115533. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115534. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115535. */
  115536. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115537. /**
  115538. * Gets camera class name
  115539. * @returns VRDeviceOrientationFreeCamera
  115540. */
  115541. getClassName(): string;
  115542. }
  115543. }
  115544. declare module BABYLON {
  115545. /**
  115546. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115547. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115548. */
  115549. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115550. /**
  115551. * Creates a new VRDeviceOrientationGamepadCamera
  115552. * @param name defines camera name
  115553. * @param position defines the start position of the camera
  115554. * @param scene defines the scene the camera belongs to
  115555. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115556. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115557. */
  115558. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115559. /**
  115560. * Gets camera class name
  115561. * @returns VRDeviceOrientationGamepadCamera
  115562. */
  115563. getClassName(): string;
  115564. }
  115565. }
  115566. declare module BABYLON {
  115567. /** @hidden */
  115568. export var imageProcessingPixelShader: {
  115569. name: string;
  115570. shader: string;
  115571. };
  115572. }
  115573. declare module BABYLON {
  115574. /**
  115575. * ImageProcessingPostProcess
  115576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115577. */
  115578. export class ImageProcessingPostProcess extends PostProcess {
  115579. /**
  115580. * Default configuration related to image processing available in the PBR Material.
  115581. */
  115582. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115583. /**
  115584. * Gets the image processing configuration used either in this material.
  115585. */
  115586. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115587. /**
  115588. * Sets the Default image processing configuration used either in the this material.
  115589. *
  115590. * If sets to null, the scene one is in use.
  115591. */
  115592. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115593. /**
  115594. * Keep track of the image processing observer to allow dispose and replace.
  115595. */
  115596. private _imageProcessingObserver;
  115597. /**
  115598. * Attaches a new image processing configuration to the PBR Material.
  115599. * @param configuration
  115600. */
  115601. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115602. /**
  115603. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115604. */
  115605. get colorCurves(): Nullable<ColorCurves>;
  115606. /**
  115607. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115608. */
  115609. set colorCurves(value: Nullable<ColorCurves>);
  115610. /**
  115611. * Gets wether the color curves effect is enabled.
  115612. */
  115613. get colorCurvesEnabled(): boolean;
  115614. /**
  115615. * Sets wether the color curves effect is enabled.
  115616. */
  115617. set colorCurvesEnabled(value: boolean);
  115618. /**
  115619. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115620. */
  115621. get colorGradingTexture(): Nullable<BaseTexture>;
  115622. /**
  115623. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115624. */
  115625. set colorGradingTexture(value: Nullable<BaseTexture>);
  115626. /**
  115627. * Gets wether the color grading effect is enabled.
  115628. */
  115629. get colorGradingEnabled(): boolean;
  115630. /**
  115631. * Gets wether the color grading effect is enabled.
  115632. */
  115633. set colorGradingEnabled(value: boolean);
  115634. /**
  115635. * Gets exposure used in the effect.
  115636. */
  115637. get exposure(): number;
  115638. /**
  115639. * Sets exposure used in the effect.
  115640. */
  115641. set exposure(value: number);
  115642. /**
  115643. * Gets wether tonemapping is enabled or not.
  115644. */
  115645. get toneMappingEnabled(): boolean;
  115646. /**
  115647. * Sets wether tonemapping is enabled or not
  115648. */
  115649. set toneMappingEnabled(value: boolean);
  115650. /**
  115651. * Gets the type of tone mapping effect.
  115652. */
  115653. get toneMappingType(): number;
  115654. /**
  115655. * Sets the type of tone mapping effect.
  115656. */
  115657. set toneMappingType(value: number);
  115658. /**
  115659. * Gets contrast used in the effect.
  115660. */
  115661. get contrast(): number;
  115662. /**
  115663. * Sets contrast used in the effect.
  115664. */
  115665. set contrast(value: number);
  115666. /**
  115667. * Gets Vignette stretch size.
  115668. */
  115669. get vignetteStretch(): number;
  115670. /**
  115671. * Sets Vignette stretch size.
  115672. */
  115673. set vignetteStretch(value: number);
  115674. /**
  115675. * Gets Vignette centre X Offset.
  115676. */
  115677. get vignetteCentreX(): number;
  115678. /**
  115679. * Sets Vignette centre X Offset.
  115680. */
  115681. set vignetteCentreX(value: number);
  115682. /**
  115683. * Gets Vignette centre Y Offset.
  115684. */
  115685. get vignetteCentreY(): number;
  115686. /**
  115687. * Sets Vignette centre Y Offset.
  115688. */
  115689. set vignetteCentreY(value: number);
  115690. /**
  115691. * Gets Vignette weight or intensity of the vignette effect.
  115692. */
  115693. get vignetteWeight(): number;
  115694. /**
  115695. * Sets Vignette weight or intensity of the vignette effect.
  115696. */
  115697. set vignetteWeight(value: number);
  115698. /**
  115699. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115700. * if vignetteEnabled is set to true.
  115701. */
  115702. get vignetteColor(): Color4;
  115703. /**
  115704. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115705. * if vignetteEnabled is set to true.
  115706. */
  115707. set vignetteColor(value: Color4);
  115708. /**
  115709. * Gets Camera field of view used by the Vignette effect.
  115710. */
  115711. get vignetteCameraFov(): number;
  115712. /**
  115713. * Sets Camera field of view used by the Vignette effect.
  115714. */
  115715. set vignetteCameraFov(value: number);
  115716. /**
  115717. * Gets the vignette blend mode allowing different kind of effect.
  115718. */
  115719. get vignetteBlendMode(): number;
  115720. /**
  115721. * Sets the vignette blend mode allowing different kind of effect.
  115722. */
  115723. set vignetteBlendMode(value: number);
  115724. /**
  115725. * Gets wether the vignette effect is enabled.
  115726. */
  115727. get vignetteEnabled(): boolean;
  115728. /**
  115729. * Sets wether the vignette effect is enabled.
  115730. */
  115731. set vignetteEnabled(value: boolean);
  115732. private _fromLinearSpace;
  115733. /**
  115734. * Gets wether the input of the processing is in Gamma or Linear Space.
  115735. */
  115736. get fromLinearSpace(): boolean;
  115737. /**
  115738. * Sets wether the input of the processing is in Gamma or Linear Space.
  115739. */
  115740. set fromLinearSpace(value: boolean);
  115741. /**
  115742. * Defines cache preventing GC.
  115743. */
  115744. private _defines;
  115745. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115746. /**
  115747. * "ImageProcessingPostProcess"
  115748. * @returns "ImageProcessingPostProcess"
  115749. */
  115750. getClassName(): string;
  115751. protected _updateParameters(): void;
  115752. dispose(camera?: Camera): void;
  115753. }
  115754. }
  115755. declare module BABYLON {
  115756. /**
  115757. * Class containing static functions to help procedurally build meshes
  115758. */
  115759. export class GroundBuilder {
  115760. /**
  115761. * Creates a ground mesh
  115762. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115763. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115765. * @param name defines the name of the mesh
  115766. * @param options defines the options used to create the mesh
  115767. * @param scene defines the hosting scene
  115768. * @returns the ground mesh
  115769. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115770. */
  115771. static CreateGround(name: string, options: {
  115772. width?: number;
  115773. height?: number;
  115774. subdivisions?: number;
  115775. subdivisionsX?: number;
  115776. subdivisionsY?: number;
  115777. updatable?: boolean;
  115778. }, scene: any): Mesh;
  115779. /**
  115780. * Creates a tiled ground mesh
  115781. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115782. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115783. * * 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
  115784. * * 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
  115785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115786. * @param name defines the name of the mesh
  115787. * @param options defines the options used to create the mesh
  115788. * @param scene defines the hosting scene
  115789. * @returns the tiled ground mesh
  115790. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115791. */
  115792. static CreateTiledGround(name: string, options: {
  115793. xmin: number;
  115794. zmin: number;
  115795. xmax: number;
  115796. zmax: number;
  115797. subdivisions?: {
  115798. w: number;
  115799. h: number;
  115800. };
  115801. precision?: {
  115802. w: number;
  115803. h: number;
  115804. };
  115805. updatable?: boolean;
  115806. }, scene?: Nullable<Scene>): Mesh;
  115807. /**
  115808. * Creates a ground mesh from a height map
  115809. * * The parameter `url` sets the URL of the height map image resource.
  115810. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115811. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115812. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115813. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115814. * * 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.
  115815. * * 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).
  115816. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115818. * @param name defines the name of the mesh
  115819. * @param url defines the url to the height map
  115820. * @param options defines the options used to create the mesh
  115821. * @param scene defines the hosting scene
  115822. * @returns the ground mesh
  115823. * @see https://doc.babylonjs.com/babylon101/height_map
  115824. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115825. */
  115826. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115827. width?: number;
  115828. height?: number;
  115829. subdivisions?: number;
  115830. minHeight?: number;
  115831. maxHeight?: number;
  115832. colorFilter?: Color3;
  115833. alphaFilter?: number;
  115834. updatable?: boolean;
  115835. onReady?: (mesh: GroundMesh) => void;
  115836. }, scene?: Nullable<Scene>): GroundMesh;
  115837. }
  115838. }
  115839. declare module BABYLON {
  115840. /**
  115841. * Class containing static functions to help procedurally build meshes
  115842. */
  115843. export class TorusBuilder {
  115844. /**
  115845. * Creates a torus mesh
  115846. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115847. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115848. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115852. * @param name defines the name of the mesh
  115853. * @param options defines the options used to create the mesh
  115854. * @param scene defines the hosting scene
  115855. * @returns the torus mesh
  115856. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115857. */
  115858. static CreateTorus(name: string, options: {
  115859. diameter?: number;
  115860. thickness?: number;
  115861. tessellation?: number;
  115862. updatable?: boolean;
  115863. sideOrientation?: number;
  115864. frontUVs?: Vector4;
  115865. backUVs?: Vector4;
  115866. }, scene: any): Mesh;
  115867. }
  115868. }
  115869. declare module BABYLON {
  115870. /**
  115871. * Class containing static functions to help procedurally build meshes
  115872. */
  115873. export class CylinderBuilder {
  115874. /**
  115875. * Creates a cylinder or a cone mesh
  115876. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115877. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115878. * * 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.
  115879. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115880. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115881. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115882. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115883. * * 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).
  115884. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115885. * * 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).
  115886. * * 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
  115887. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115888. * * 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
  115889. * * 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.
  115890. * * If `enclose` is false, a ring surface is one element.
  115891. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115892. * * 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
  115893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115896. * @param name defines the name of the mesh
  115897. * @param options defines the options used to create the mesh
  115898. * @param scene defines the hosting scene
  115899. * @returns the cylinder mesh
  115900. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115901. */
  115902. static CreateCylinder(name: string, options: {
  115903. height?: number;
  115904. diameterTop?: number;
  115905. diameterBottom?: number;
  115906. diameter?: number;
  115907. tessellation?: number;
  115908. subdivisions?: number;
  115909. arc?: number;
  115910. faceColors?: Color4[];
  115911. faceUV?: Vector4[];
  115912. updatable?: boolean;
  115913. hasRings?: boolean;
  115914. enclose?: boolean;
  115915. cap?: number;
  115916. sideOrientation?: number;
  115917. frontUVs?: Vector4;
  115918. backUVs?: Vector4;
  115919. }, scene: any): Mesh;
  115920. }
  115921. }
  115922. declare module BABYLON {
  115923. /**
  115924. * States of the webXR experience
  115925. */
  115926. export enum WebXRState {
  115927. /**
  115928. * Transitioning to being in XR mode
  115929. */
  115930. ENTERING_XR = 0,
  115931. /**
  115932. * Transitioning to non XR mode
  115933. */
  115934. EXITING_XR = 1,
  115935. /**
  115936. * In XR mode and presenting
  115937. */
  115938. IN_XR = 2,
  115939. /**
  115940. * Not entered XR mode
  115941. */
  115942. NOT_IN_XR = 3
  115943. }
  115944. /**
  115945. * Abstraction of the XR render target
  115946. */
  115947. export interface WebXRRenderTarget extends IDisposable {
  115948. /**
  115949. * xrpresent context of the canvas which can be used to display/mirror xr content
  115950. */
  115951. canvasContext: WebGLRenderingContext;
  115952. /**
  115953. * xr layer for the canvas
  115954. */
  115955. xrLayer: Nullable<XRWebGLLayer>;
  115956. /**
  115957. * Initializes the xr layer for the session
  115958. * @param xrSession xr session
  115959. * @returns a promise that will resolve once the XR Layer has been created
  115960. */
  115961. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115962. }
  115963. }
  115964. declare module BABYLON {
  115965. /**
  115966. * COnfiguration object for WebXR output canvas
  115967. */
  115968. export class WebXRManagedOutputCanvasOptions {
  115969. /**
  115970. * An optional canvas in case you wish to create it yourself and provide it here.
  115971. * If not provided, a new canvas will be created
  115972. */
  115973. canvasElement?: HTMLCanvasElement;
  115974. /**
  115975. * Options for this XR Layer output
  115976. */
  115977. canvasOptions?: XRWebGLLayerOptions;
  115978. /**
  115979. * CSS styling for a newly created canvas (if not provided)
  115980. */
  115981. newCanvasCssStyle?: string;
  115982. /**
  115983. * Get the default values of the configuration object
  115984. * @returns default values of this configuration object
  115985. */
  115986. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115987. }
  115988. /**
  115989. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115990. */
  115991. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115992. private _options;
  115993. private _canvas;
  115994. private _engine;
  115995. /**
  115996. * Rendering context of the canvas which can be used to display/mirror xr content
  115997. */
  115998. canvasContext: WebGLRenderingContext;
  115999. /**
  116000. * xr layer for the canvas
  116001. */
  116002. xrLayer: Nullable<XRWebGLLayer>;
  116003. /**
  116004. * Initializes the canvas to be added/removed upon entering/exiting xr
  116005. * @param _xrSessionManager The XR Session manager
  116006. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  116007. */
  116008. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  116009. /**
  116010. * Disposes of the object
  116011. */
  116012. dispose(): void;
  116013. /**
  116014. * Initializes the xr layer for the session
  116015. * @param xrSession xr session
  116016. * @returns a promise that will resolve once the XR Layer has been created
  116017. */
  116018. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116019. private _addCanvas;
  116020. private _removeCanvas;
  116021. private _setManagedOutputCanvas;
  116022. }
  116023. }
  116024. declare module BABYLON {
  116025. /**
  116026. * Manages an XRSession to work with Babylon's engine
  116027. * @see https://doc.babylonjs.com/how_to/webxr
  116028. */
  116029. export class WebXRSessionManager implements IDisposable {
  116030. /** The scene which the session should be created for */
  116031. scene: Scene;
  116032. private _referenceSpace;
  116033. private _rttProvider;
  116034. private _sessionEnded;
  116035. private _xrNavigator;
  116036. private baseLayer;
  116037. /**
  116038. * The base reference space from which the session started. good if you want to reset your
  116039. * reference space
  116040. */
  116041. baseReferenceSpace: XRReferenceSpace;
  116042. /**
  116043. * Current XR frame
  116044. */
  116045. currentFrame: Nullable<XRFrame>;
  116046. /** WebXR timestamp updated every frame */
  116047. currentTimestamp: number;
  116048. /**
  116049. * Used just in case of a failure to initialize an immersive session.
  116050. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  116051. */
  116052. defaultHeightCompensation: number;
  116053. /**
  116054. * Fires every time a new xrFrame arrives which can be used to update the camera
  116055. */
  116056. onXRFrameObservable: Observable<XRFrame>;
  116057. /**
  116058. * Fires when the reference space changed
  116059. */
  116060. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  116061. /**
  116062. * Fires when the xr session is ended either by the device or manually done
  116063. */
  116064. onXRSessionEnded: Observable<any>;
  116065. /**
  116066. * Fires when the xr session is ended either by the device or manually done
  116067. */
  116068. onXRSessionInit: Observable<XRSession>;
  116069. /**
  116070. * Underlying xr session
  116071. */
  116072. session: XRSession;
  116073. /**
  116074. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  116075. * or get the offset the player is currently at.
  116076. */
  116077. viewerReferenceSpace: XRReferenceSpace;
  116078. /**
  116079. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116080. * @param scene The scene which the session should be created for
  116081. */
  116082. constructor(
  116083. /** The scene which the session should be created for */
  116084. scene: Scene);
  116085. /**
  116086. * The current reference space used in this session. This reference space can constantly change!
  116087. * It is mainly used to offset the camera's position.
  116088. */
  116089. get referenceSpace(): XRReferenceSpace;
  116090. /**
  116091. * Set a new reference space and triggers the observable
  116092. */
  116093. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  116094. /**
  116095. * Disposes of the session manager
  116096. */
  116097. dispose(): void;
  116098. /**
  116099. * Stops the xrSession and restores the render loop
  116100. * @returns Promise which resolves after it exits XR
  116101. */
  116102. exitXRAsync(): Promise<void>;
  116103. /**
  116104. * Gets the correct render target texture to be rendered this frame for this eye
  116105. * @param eye the eye for which to get the render target
  116106. * @returns the render target for the specified eye
  116107. */
  116108. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116109. /**
  116110. * Creates a WebXRRenderTarget object for the XR session
  116111. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116112. * @param options optional options to provide when creating a new render target
  116113. * @returns a WebXR render target to which the session can render
  116114. */
  116115. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116116. /**
  116117. * Initializes the manager
  116118. * After initialization enterXR can be called to start an XR session
  116119. * @returns Promise which resolves after it is initialized
  116120. */
  116121. initializeAsync(): Promise<void>;
  116122. /**
  116123. * Initializes an xr session
  116124. * @param xrSessionMode mode to initialize
  116125. * @param xrSessionInit defines optional and required values to pass to the session builder
  116126. * @returns a promise which will resolve once the session has been initialized
  116127. */
  116128. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116129. /**
  116130. * Checks if a session would be supported for the creation options specified
  116131. * @param sessionMode session mode to check if supported eg. immersive-vr
  116132. * @returns A Promise that resolves to true if supported and false if not
  116133. */
  116134. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116135. /**
  116136. * Resets the reference space to the one started the session
  116137. */
  116138. resetReferenceSpace(): void;
  116139. /**
  116140. * Starts rendering to the xr layer
  116141. */
  116142. runXRRenderLoop(): void;
  116143. /**
  116144. * Sets the reference space on the xr session
  116145. * @param referenceSpaceType space to set
  116146. * @returns a promise that will resolve once the reference space has been set
  116147. */
  116148. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116149. /**
  116150. * Updates the render state of the session
  116151. * @param state state to set
  116152. * @returns a promise that resolves once the render state has been updated
  116153. */
  116154. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116155. /**
  116156. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116157. * @param sessionMode defines the session to test
  116158. * @returns a promise with boolean as final value
  116159. */
  116160. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116161. private _createRenderTargetTexture;
  116162. }
  116163. }
  116164. declare module BABYLON {
  116165. /**
  116166. * WebXR Camera which holds the views for the xrSession
  116167. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116168. */
  116169. export class WebXRCamera extends FreeCamera {
  116170. private _xrSessionManager;
  116171. private _firstFrame;
  116172. private _referenceQuaternion;
  116173. private _referencedPosition;
  116174. private _xrInvPositionCache;
  116175. private _xrInvQuaternionCache;
  116176. /**
  116177. * Should position compensation execute on first frame.
  116178. * This is used when copying the position from a native (non XR) camera
  116179. */
  116180. compensateOnFirstFrame: boolean;
  116181. /**
  116182. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116183. * @param name the name of the camera
  116184. * @param scene the scene to add the camera to
  116185. * @param _xrSessionManager a constructed xr session manager
  116186. */
  116187. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116188. /**
  116189. * Return the user's height, unrelated to the current ground.
  116190. * This will be the y position of this camera, when ground level is 0.
  116191. */
  116192. get realWorldHeight(): number;
  116193. /** @hidden */
  116194. _updateForDualEyeDebugging(): void;
  116195. /**
  116196. * Sets this camera's transformation based on a non-vr camera
  116197. * @param otherCamera the non-vr camera to copy the transformation from
  116198. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116199. */
  116200. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116201. /**
  116202. * Gets the current instance class name ("WebXRCamera").
  116203. * @returns the class name
  116204. */
  116205. getClassName(): string;
  116206. private _updateFromXRSession;
  116207. private _updateNumberOfRigCameras;
  116208. private _updateReferenceSpace;
  116209. private _updateReferenceSpaceOffset;
  116210. }
  116211. }
  116212. declare module BABYLON {
  116213. /**
  116214. * Defining the interface required for a (webxr) feature
  116215. */
  116216. export interface IWebXRFeature extends IDisposable {
  116217. /**
  116218. * Is this feature attached
  116219. */
  116220. attached: boolean;
  116221. /**
  116222. * Should auto-attach be disabled?
  116223. */
  116224. disableAutoAttach: boolean;
  116225. /**
  116226. * Attach the feature to the session
  116227. * Will usually be called by the features manager
  116228. *
  116229. * @param force should attachment be forced (even when already attached)
  116230. * @returns true if successful.
  116231. */
  116232. attach(force?: boolean): boolean;
  116233. /**
  116234. * Detach the feature from the session
  116235. * Will usually be called by the features manager
  116236. *
  116237. * @returns true if successful.
  116238. */
  116239. detach(): boolean;
  116240. }
  116241. /**
  116242. * A list of the currently available features without referencing them
  116243. */
  116244. export class WebXRFeatureName {
  116245. /**
  116246. * The name of the anchor system feature
  116247. */
  116248. static ANCHOR_SYSTEM: string;
  116249. /**
  116250. * The name of the background remover feature
  116251. */
  116252. static BACKGROUND_REMOVER: string;
  116253. /**
  116254. * The name of the hit test feature
  116255. */
  116256. static HIT_TEST: string;
  116257. /**
  116258. * physics impostors for xr controllers feature
  116259. */
  116260. static PHYSICS_CONTROLLERS: string;
  116261. /**
  116262. * The name of the plane detection feature
  116263. */
  116264. static PLANE_DETECTION: string;
  116265. /**
  116266. * The name of the pointer selection feature
  116267. */
  116268. static POINTER_SELECTION: string;
  116269. /**
  116270. * The name of the teleportation feature
  116271. */
  116272. static TELEPORTATION: string;
  116273. }
  116274. /**
  116275. * Defining the constructor of a feature. Used to register the modules.
  116276. */
  116277. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116278. /**
  116279. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116280. * It is mainly used in AR sessions.
  116281. *
  116282. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116283. */
  116284. export class WebXRFeaturesManager implements IDisposable {
  116285. private _xrSessionManager;
  116286. private static readonly _AvailableFeatures;
  116287. private _features;
  116288. /**
  116289. * constructs a new features manages.
  116290. *
  116291. * @param _xrSessionManager an instance of WebXRSessionManager
  116292. */
  116293. constructor(_xrSessionManager: WebXRSessionManager);
  116294. /**
  116295. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116296. * Mainly used internally.
  116297. *
  116298. * @param featureName the name of the feature to register
  116299. * @param constructorFunction the function used to construct the module
  116300. * @param version the (babylon) version of the module
  116301. * @param stable is that a stable version of this module
  116302. */
  116303. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116304. /**
  116305. * Returns a constructor of a specific feature.
  116306. *
  116307. * @param featureName the name of the feature to construct
  116308. * @param version the version of the feature to load
  116309. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116310. * @param options optional options provided to the module.
  116311. * @returns a function that, when called, will return a new instance of this feature
  116312. */
  116313. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116314. /**
  116315. * Can be used to return the list of features currently registered
  116316. *
  116317. * @returns an Array of available features
  116318. */
  116319. static GetAvailableFeatures(): string[];
  116320. /**
  116321. * Gets the versions available for a specific feature
  116322. * @param featureName the name of the feature
  116323. * @returns an array with the available versions
  116324. */
  116325. static GetAvailableVersions(featureName: string): string[];
  116326. /**
  116327. * Return the latest unstable version of this feature
  116328. * @param featureName the name of the feature to search
  116329. * @returns the version number. if not found will return -1
  116330. */
  116331. static GetLatestVersionOfFeature(featureName: string): number;
  116332. /**
  116333. * Return the latest stable version of this feature
  116334. * @param featureName the name of the feature to search
  116335. * @returns the version number. if not found will return -1
  116336. */
  116337. static GetStableVersionOfFeature(featureName: string): number;
  116338. /**
  116339. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116340. * Can be used during a session to start a feature
  116341. * @param featureName the name of feature to attach
  116342. */
  116343. attachFeature(featureName: string): void;
  116344. /**
  116345. * Can be used inside a session or when the session ends to detach a specific feature
  116346. * @param featureName the name of the feature to detach
  116347. */
  116348. detachFeature(featureName: string): void;
  116349. /**
  116350. * Used to disable an already-enabled feature
  116351. * The feature will be disposed and will be recreated once enabled.
  116352. * @param featureName the feature to disable
  116353. * @returns true if disable was successful
  116354. */
  116355. disableFeature(featureName: string | {
  116356. Name: string;
  116357. }): boolean;
  116358. /**
  116359. * dispose this features manager
  116360. */
  116361. dispose(): void;
  116362. /**
  116363. * 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.
  116364. * 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.
  116365. *
  116366. * @param featureName the name of the feature to load or the class of the feature
  116367. * @param version optional version to load. if not provided the latest version will be enabled
  116368. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116369. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116370. * @returns a new constructed feature or throws an error if feature not found.
  116371. */
  116372. enableFeature(featureName: string | {
  116373. Name: string;
  116374. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116375. /**
  116376. * get the implementation of an enabled feature.
  116377. * @param featureName the name of the feature to load
  116378. * @returns the feature class, if found
  116379. */
  116380. getEnabledFeature(featureName: string): IWebXRFeature;
  116381. /**
  116382. * Get the list of enabled features
  116383. * @returns an array of enabled features
  116384. */
  116385. getEnabledFeatures(): string[];
  116386. }
  116387. }
  116388. declare module BABYLON {
  116389. /**
  116390. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116391. * @see https://doc.babylonjs.com/how_to/webxr
  116392. */
  116393. export class WebXRExperienceHelper implements IDisposable {
  116394. private scene;
  116395. private _nonVRCamera;
  116396. private _originalSceneAutoClear;
  116397. private _supported;
  116398. /**
  116399. * Camera used to render xr content
  116400. */
  116401. camera: WebXRCamera;
  116402. /** A features manager for this xr session */
  116403. featuresManager: WebXRFeaturesManager;
  116404. /**
  116405. * Observers registered here will be triggered after the camera's initial transformation is set
  116406. * This can be used to set a different ground level or an extra rotation.
  116407. *
  116408. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116409. * to the position set after this observable is done executing.
  116410. */
  116411. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116412. /**
  116413. * Fires when the state of the experience helper has changed
  116414. */
  116415. onStateChangedObservable: Observable<WebXRState>;
  116416. /** Session manager used to keep track of xr session */
  116417. sessionManager: WebXRSessionManager;
  116418. /**
  116419. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116420. */
  116421. state: WebXRState;
  116422. /**
  116423. * Creates a WebXRExperienceHelper
  116424. * @param scene The scene the helper should be created in
  116425. */
  116426. private constructor();
  116427. /**
  116428. * Creates the experience helper
  116429. * @param scene the scene to attach the experience helper to
  116430. * @returns a promise for the experience helper
  116431. */
  116432. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116433. /**
  116434. * Disposes of the experience helper
  116435. */
  116436. dispose(): void;
  116437. /**
  116438. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116439. * @param sessionMode options for the XR session
  116440. * @param referenceSpaceType frame of reference of the XR session
  116441. * @param renderTarget the output canvas that will be used to enter XR mode
  116442. * @returns promise that resolves after xr mode has entered
  116443. */
  116444. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116445. /**
  116446. * Exits XR mode and returns the scene to its original state
  116447. * @returns promise that resolves after xr mode has exited
  116448. */
  116449. exitXRAsync(): Promise<void>;
  116450. private _nonXRToXRCamera;
  116451. private _setState;
  116452. }
  116453. }
  116454. declare module BABYLON {
  116455. /**
  116456. * X-Y values for axes in WebXR
  116457. */
  116458. export interface IWebXRMotionControllerAxesValue {
  116459. /**
  116460. * The value of the x axis
  116461. */
  116462. x: number;
  116463. /**
  116464. * The value of the y-axis
  116465. */
  116466. y: number;
  116467. }
  116468. /**
  116469. * changed / previous values for the values of this component
  116470. */
  116471. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116472. /**
  116473. * current (this frame) value
  116474. */
  116475. current: T;
  116476. /**
  116477. * previous (last change) value
  116478. */
  116479. previous: T;
  116480. }
  116481. /**
  116482. * Represents changes in the component between current frame and last values recorded
  116483. */
  116484. export interface IWebXRMotionControllerComponentChanges {
  116485. /**
  116486. * will be populated with previous and current values if axes changed
  116487. */
  116488. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116489. /**
  116490. * will be populated with previous and current values if pressed changed
  116491. */
  116492. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116493. /**
  116494. * will be populated with previous and current values if touched changed
  116495. */
  116496. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116497. /**
  116498. * will be populated with previous and current values if value changed
  116499. */
  116500. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116501. }
  116502. /**
  116503. * This class represents a single component (for example button or thumbstick) of a motion controller
  116504. */
  116505. export class WebXRControllerComponent implements IDisposable {
  116506. /**
  116507. * the id of this component
  116508. */
  116509. id: string;
  116510. /**
  116511. * the type of the component
  116512. */
  116513. type: MotionControllerComponentType;
  116514. private _buttonIndex;
  116515. private _axesIndices;
  116516. private _axes;
  116517. private _changes;
  116518. private _currentValue;
  116519. private _hasChanges;
  116520. private _pressed;
  116521. private _touched;
  116522. /**
  116523. * button component type
  116524. */
  116525. static BUTTON_TYPE: MotionControllerComponentType;
  116526. /**
  116527. * squeeze component type
  116528. */
  116529. static SQUEEZE_TYPE: MotionControllerComponentType;
  116530. /**
  116531. * Thumbstick component type
  116532. */
  116533. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116534. /**
  116535. * Touchpad component type
  116536. */
  116537. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116538. /**
  116539. * trigger component type
  116540. */
  116541. static TRIGGER_TYPE: MotionControllerComponentType;
  116542. /**
  116543. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116544. * the axes data changes
  116545. */
  116546. onAxisValueChangedObservable: Observable<{
  116547. x: number;
  116548. y: number;
  116549. }>;
  116550. /**
  116551. * Observers registered here will be triggered when the state of a button changes
  116552. * State change is either pressed / touched / value
  116553. */
  116554. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116555. /**
  116556. * Creates a new component for a motion controller.
  116557. * It is created by the motion controller itself
  116558. *
  116559. * @param id the id of this component
  116560. * @param type the type of the component
  116561. * @param _buttonIndex index in the buttons array of the gamepad
  116562. * @param _axesIndices indices of the values in the axes array of the gamepad
  116563. */
  116564. constructor(
  116565. /**
  116566. * the id of this component
  116567. */
  116568. id: string,
  116569. /**
  116570. * the type of the component
  116571. */
  116572. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116573. /**
  116574. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116575. */
  116576. get axes(): IWebXRMotionControllerAxesValue;
  116577. /**
  116578. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116579. */
  116580. get changes(): IWebXRMotionControllerComponentChanges;
  116581. /**
  116582. * Return whether or not the component changed the last frame
  116583. */
  116584. get hasChanges(): boolean;
  116585. /**
  116586. * is the button currently pressed
  116587. */
  116588. get pressed(): boolean;
  116589. /**
  116590. * is the button currently touched
  116591. */
  116592. get touched(): boolean;
  116593. /**
  116594. * Get the current value of this component
  116595. */
  116596. get value(): number;
  116597. /**
  116598. * Dispose this component
  116599. */
  116600. dispose(): void;
  116601. /**
  116602. * Are there axes correlating to this component
  116603. * @return true is axes data is available
  116604. */
  116605. isAxes(): boolean;
  116606. /**
  116607. * Is this component a button (hence - pressable)
  116608. * @returns true if can be pressed
  116609. */
  116610. isButton(): boolean;
  116611. /**
  116612. * update this component using the gamepad object it is in. Called on every frame
  116613. * @param nativeController the native gamepad controller object
  116614. */
  116615. update(nativeController: IMinimalMotionControllerObject): void;
  116616. }
  116617. }
  116618. declare module BABYLON {
  116619. /**
  116620. * Class used to represent data loading progression
  116621. */
  116622. export class SceneLoaderProgressEvent {
  116623. /** defines if data length to load can be evaluated */
  116624. readonly lengthComputable: boolean;
  116625. /** defines the loaded data length */
  116626. readonly loaded: number;
  116627. /** defines the data length to load */
  116628. readonly total: number;
  116629. /**
  116630. * Create a new progress event
  116631. * @param lengthComputable defines if data length to load can be evaluated
  116632. * @param loaded defines the loaded data length
  116633. * @param total defines the data length to load
  116634. */
  116635. constructor(
  116636. /** defines if data length to load can be evaluated */
  116637. lengthComputable: boolean,
  116638. /** defines the loaded data length */
  116639. loaded: number,
  116640. /** defines the data length to load */
  116641. total: number);
  116642. /**
  116643. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116644. * @param event defines the source event
  116645. * @returns a new SceneLoaderProgressEvent
  116646. */
  116647. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116648. }
  116649. /**
  116650. * Interface used by SceneLoader plugins to define supported file extensions
  116651. */
  116652. export interface ISceneLoaderPluginExtensions {
  116653. /**
  116654. * Defines the list of supported extensions
  116655. */
  116656. [extension: string]: {
  116657. isBinary: boolean;
  116658. };
  116659. }
  116660. /**
  116661. * Interface used by SceneLoader plugin factory
  116662. */
  116663. export interface ISceneLoaderPluginFactory {
  116664. /**
  116665. * Defines the name of the factory
  116666. */
  116667. name: string;
  116668. /**
  116669. * Function called to create a new plugin
  116670. * @return the new plugin
  116671. */
  116672. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116673. /**
  116674. * The callback that returns true if the data can be directly loaded.
  116675. * @param data string containing the file data
  116676. * @returns if the data can be loaded directly
  116677. */
  116678. canDirectLoad?(data: string): boolean;
  116679. }
  116680. /**
  116681. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116682. */
  116683. export interface ISceneLoaderPluginBase {
  116684. /**
  116685. * The friendly name of this plugin.
  116686. */
  116687. name: string;
  116688. /**
  116689. * The file extensions supported by this plugin.
  116690. */
  116691. extensions: string | ISceneLoaderPluginExtensions;
  116692. /**
  116693. * The callback called when loading from a url.
  116694. * @param scene scene loading this url
  116695. * @param url url to load
  116696. * @param onSuccess callback called when the file successfully loads
  116697. * @param onProgress callback called while file is loading (if the server supports this mode)
  116698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116699. * @param onError callback called when the file fails to load
  116700. * @returns a file request object
  116701. */
  116702. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116703. /**
  116704. * The callback called when loading from a file object.
  116705. * @param scene scene loading this file
  116706. * @param file defines the file to load
  116707. * @param onSuccess defines the callback to call when data is loaded
  116708. * @param onProgress defines the callback to call during loading process
  116709. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116710. * @param onError defines the callback to call when an error occurs
  116711. * @returns a file request object
  116712. */
  116713. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116714. /**
  116715. * The callback that returns true if the data can be directly loaded.
  116716. * @param data string containing the file data
  116717. * @returns if the data can be loaded directly
  116718. */
  116719. canDirectLoad?(data: string): boolean;
  116720. /**
  116721. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116722. * @param scene scene loading this data
  116723. * @param data string containing the data
  116724. * @returns data to pass to the plugin
  116725. */
  116726. directLoad?(scene: Scene, data: string): any;
  116727. /**
  116728. * The callback that allows custom handling of the root url based on the response url.
  116729. * @param rootUrl the original root url
  116730. * @param responseURL the response url if available
  116731. * @returns the new root url
  116732. */
  116733. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116734. }
  116735. /**
  116736. * Interface used to define a SceneLoader plugin
  116737. */
  116738. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116739. /**
  116740. * Import meshes into a scene.
  116741. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116742. * @param scene The scene to import into
  116743. * @param data The data to import
  116744. * @param rootUrl The root url for scene and resources
  116745. * @param meshes The meshes array to import into
  116746. * @param particleSystems The particle systems array to import into
  116747. * @param skeletons The skeletons array to import into
  116748. * @param onError The callback when import fails
  116749. * @returns True if successful or false otherwise
  116750. */
  116751. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116752. /**
  116753. * Load into a scene.
  116754. * @param scene The scene to load into
  116755. * @param data The data to import
  116756. * @param rootUrl The root url for scene and resources
  116757. * @param onError The callback when import fails
  116758. * @returns True if successful or false otherwise
  116759. */
  116760. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116761. /**
  116762. * Load into an asset container.
  116763. * @param scene The scene to load into
  116764. * @param data The data to import
  116765. * @param rootUrl The root url for scene and resources
  116766. * @param onError The callback when import fails
  116767. * @returns The loaded asset container
  116768. */
  116769. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116770. }
  116771. /**
  116772. * Interface used to define an async SceneLoader plugin
  116773. */
  116774. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116775. /**
  116776. * Import meshes into a scene.
  116777. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116778. * @param scene The scene to import into
  116779. * @param data The data to import
  116780. * @param rootUrl The root url for scene and resources
  116781. * @param onProgress The callback when the load progresses
  116782. * @param fileName Defines the name of the file to load
  116783. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116784. */
  116785. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116786. meshes: AbstractMesh[];
  116787. particleSystems: IParticleSystem[];
  116788. skeletons: Skeleton[];
  116789. animationGroups: AnimationGroup[];
  116790. }>;
  116791. /**
  116792. * Load into a scene.
  116793. * @param scene The scene to load into
  116794. * @param data The data to import
  116795. * @param rootUrl The root url for scene and resources
  116796. * @param onProgress The callback when the load progresses
  116797. * @param fileName Defines the name of the file to load
  116798. * @returns Nothing
  116799. */
  116800. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116801. /**
  116802. * Load into an asset container.
  116803. * @param scene The scene to load into
  116804. * @param data The data to import
  116805. * @param rootUrl The root url for scene and resources
  116806. * @param onProgress The callback when the load progresses
  116807. * @param fileName Defines the name of the file to load
  116808. * @returns The loaded asset container
  116809. */
  116810. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116811. }
  116812. /**
  116813. * Mode that determines how to handle old animation groups before loading new ones.
  116814. */
  116815. export enum SceneLoaderAnimationGroupLoadingMode {
  116816. /**
  116817. * Reset all old animations to initial state then dispose them.
  116818. */
  116819. Clean = 0,
  116820. /**
  116821. * Stop all old animations.
  116822. */
  116823. Stop = 1,
  116824. /**
  116825. * Restart old animations from first frame.
  116826. */
  116827. Sync = 2,
  116828. /**
  116829. * Old animations remains untouched.
  116830. */
  116831. NoSync = 3
  116832. }
  116833. /**
  116834. * Class used to load scene from various file formats using registered plugins
  116835. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116836. */
  116837. export class SceneLoader {
  116838. /**
  116839. * No logging while loading
  116840. */
  116841. static readonly NO_LOGGING: number;
  116842. /**
  116843. * Minimal logging while loading
  116844. */
  116845. static readonly MINIMAL_LOGGING: number;
  116846. /**
  116847. * Summary logging while loading
  116848. */
  116849. static readonly SUMMARY_LOGGING: number;
  116850. /**
  116851. * Detailled logging while loading
  116852. */
  116853. static readonly DETAILED_LOGGING: number;
  116854. /**
  116855. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116856. */
  116857. static get ForceFullSceneLoadingForIncremental(): boolean;
  116858. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116859. /**
  116860. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116861. */
  116862. static get ShowLoadingScreen(): boolean;
  116863. static set ShowLoadingScreen(value: boolean);
  116864. /**
  116865. * Defines the current logging level (while loading the scene)
  116866. * @ignorenaming
  116867. */
  116868. static get loggingLevel(): number;
  116869. static set loggingLevel(value: number);
  116870. /**
  116871. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116872. */
  116873. static get CleanBoneMatrixWeights(): boolean;
  116874. static set CleanBoneMatrixWeights(value: boolean);
  116875. /**
  116876. * Event raised when a plugin is used to load a scene
  116877. */
  116878. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116879. private static _registeredPlugins;
  116880. private static _getDefaultPlugin;
  116881. private static _getPluginForExtension;
  116882. private static _getPluginForDirectLoad;
  116883. private static _getPluginForFilename;
  116884. private static _getDirectLoad;
  116885. private static _loadData;
  116886. private static _getFileInfo;
  116887. /**
  116888. * Gets a plugin that can load the given extension
  116889. * @param extension defines the extension to load
  116890. * @returns a plugin or null if none works
  116891. */
  116892. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116893. /**
  116894. * Gets a boolean indicating that the given extension can be loaded
  116895. * @param extension defines the extension to load
  116896. * @returns true if the extension is supported
  116897. */
  116898. static IsPluginForExtensionAvailable(extension: string): boolean;
  116899. /**
  116900. * Adds a new plugin to the list of registered plugins
  116901. * @param plugin defines the plugin to add
  116902. */
  116903. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116904. /**
  116905. * Import meshes into a scene
  116906. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116907. * @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)
  116908. * @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)
  116909. * @param scene the instance of BABYLON.Scene to append to
  116910. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116911. * @param onProgress a callback with a progress event for each file being loaded
  116912. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116913. * @param pluginExtension the extension used to determine the plugin
  116914. * @returns The loaded plugin
  116915. */
  116916. 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>;
  116917. /**
  116918. * Import meshes into a scene
  116919. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116920. * @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)
  116921. * @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)
  116922. * @param scene the instance of BABYLON.Scene to append to
  116923. * @param onProgress a callback with a progress event for each file being loaded
  116924. * @param pluginExtension the extension used to determine the plugin
  116925. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116926. */
  116927. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116928. meshes: AbstractMesh[];
  116929. particleSystems: IParticleSystem[];
  116930. skeletons: Skeleton[];
  116931. animationGroups: AnimationGroup[];
  116932. }>;
  116933. /**
  116934. * Load a scene
  116935. * @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)
  116936. * @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)
  116937. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116938. * @param onSuccess a callback with the scene when import succeeds
  116939. * @param onProgress a callback with a progress event for each file being loaded
  116940. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116941. * @param pluginExtension the extension used to determine the plugin
  116942. * @returns The loaded plugin
  116943. */
  116944. 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>;
  116945. /**
  116946. * Load a scene
  116947. * @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)
  116948. * @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)
  116949. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116950. * @param onProgress a callback with a progress event for each file being loaded
  116951. * @param pluginExtension the extension used to determine the plugin
  116952. * @returns The loaded scene
  116953. */
  116954. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116955. /**
  116956. * Append a scene
  116957. * @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)
  116958. * @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)
  116959. * @param scene is the instance of BABYLON.Scene to append to
  116960. * @param onSuccess a callback with the scene when import succeeds
  116961. * @param onProgress a callback with a progress event for each file being loaded
  116962. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116963. * @param pluginExtension the extension used to determine the plugin
  116964. * @returns The loaded plugin
  116965. */
  116966. 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>;
  116967. /**
  116968. * Append a scene
  116969. * @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)
  116970. * @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)
  116971. * @param scene is the instance of BABYLON.Scene to append to
  116972. * @param onProgress a callback with a progress event for each file being loaded
  116973. * @param pluginExtension the extension used to determine the plugin
  116974. * @returns The given scene
  116975. */
  116976. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116977. /**
  116978. * Load a scene into an asset container
  116979. * @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)
  116980. * @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)
  116981. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116982. * @param onSuccess a callback with the scene when import succeeds
  116983. * @param onProgress a callback with a progress event for each file being loaded
  116984. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116985. * @param pluginExtension the extension used to determine the plugin
  116986. * @returns The loaded plugin
  116987. */
  116988. 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>;
  116989. /**
  116990. * Load a scene into an asset container
  116991. * @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)
  116992. * @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)
  116993. * @param scene is the instance of Scene to append to
  116994. * @param onProgress a callback with a progress event for each file being loaded
  116995. * @param pluginExtension the extension used to determine the plugin
  116996. * @returns The loaded asset container
  116997. */
  116998. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116999. /**
  117000. * Import animations from a file into a scene
  117001. * @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)
  117002. * @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)
  117003. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117004. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117005. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117006. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117007. * @param onSuccess a callback with the scene when import succeeds
  117008. * @param onProgress a callback with a progress event for each file being loaded
  117009. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117010. */
  117011. 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;
  117012. /**
  117013. * Import animations from a file into a scene
  117014. * @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)
  117015. * @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)
  117016. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117017. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117018. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117019. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117020. * @param onSuccess a callback with the scene when import succeeds
  117021. * @param onProgress a callback with a progress event for each file being loaded
  117022. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117023. * @returns the updated scene with imported animations
  117024. */
  117025. 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>;
  117026. }
  117027. }
  117028. declare module BABYLON {
  117029. /**
  117030. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  117031. */
  117032. export type MotionControllerHandness = "none" | "left" | "right";
  117033. /**
  117034. * The type of components available in motion controllers.
  117035. * This is not the name of the component.
  117036. */
  117037. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  117038. /**
  117039. * The state of a controller component
  117040. */
  117041. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  117042. /**
  117043. * The schema of motion controller layout.
  117044. * No object will be initialized using this interface
  117045. * This is used just to define the profile.
  117046. */
  117047. export interface IMotionControllerLayout {
  117048. /**
  117049. * Path to load the assets. Usually relative to the base path
  117050. */
  117051. assetPath: string;
  117052. /**
  117053. * Available components (unsorted)
  117054. */
  117055. components: {
  117056. /**
  117057. * A map of component Ids
  117058. */
  117059. [componentId: string]: {
  117060. /**
  117061. * The type of input the component outputs
  117062. */
  117063. type: MotionControllerComponentType;
  117064. /**
  117065. * The indices of this component in the gamepad object
  117066. */
  117067. gamepadIndices: {
  117068. /**
  117069. * Index of button
  117070. */
  117071. button?: number;
  117072. /**
  117073. * If available, index of x-axis
  117074. */
  117075. xAxis?: number;
  117076. /**
  117077. * If available, index of y-axis
  117078. */
  117079. yAxis?: number;
  117080. };
  117081. /**
  117082. * The mesh's root node name
  117083. */
  117084. rootNodeName: string;
  117085. /**
  117086. * Animation definitions for this model
  117087. */
  117088. visualResponses: {
  117089. [stateKey: string]: {
  117090. /**
  117091. * What property will be animated
  117092. */
  117093. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117094. /**
  117095. * What states influence this visual response
  117096. */
  117097. states: MotionControllerComponentStateType[];
  117098. /**
  117099. * Type of animation - movement or visibility
  117100. */
  117101. valueNodeProperty: "transform" | "visibility";
  117102. /**
  117103. * Base node name to move. Its position will be calculated according to the min and max nodes
  117104. */
  117105. valueNodeName?: string;
  117106. /**
  117107. * Minimum movement node
  117108. */
  117109. minNodeName?: string;
  117110. /**
  117111. * Max movement node
  117112. */
  117113. maxNodeName?: string;
  117114. };
  117115. };
  117116. /**
  117117. * If touch enabled, what is the name of node to display user feedback
  117118. */
  117119. touchPointNodeName?: string;
  117120. };
  117121. };
  117122. /**
  117123. * Is it xr standard mapping or not
  117124. */
  117125. gamepadMapping: "" | "xr-standard";
  117126. /**
  117127. * Base root node of this entire model
  117128. */
  117129. rootNodeName: string;
  117130. /**
  117131. * Defines the main button component id
  117132. */
  117133. selectComponentId: string;
  117134. }
  117135. /**
  117136. * A definition for the layout map in the input profile
  117137. */
  117138. export interface IMotionControllerLayoutMap {
  117139. /**
  117140. * Layouts with handness type as a key
  117141. */
  117142. [handness: string]: IMotionControllerLayout;
  117143. }
  117144. /**
  117145. * The XR Input profile schema
  117146. * Profiles can be found here:
  117147. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117148. */
  117149. export interface IMotionControllerProfile {
  117150. /**
  117151. * fallback profiles for this profileId
  117152. */
  117153. fallbackProfileIds: string[];
  117154. /**
  117155. * The layout map, with handness as key
  117156. */
  117157. layouts: IMotionControllerLayoutMap;
  117158. /**
  117159. * The id of this profile
  117160. * correlates to the profile(s) in the xrInput.profiles array
  117161. */
  117162. profileId: string;
  117163. }
  117164. /**
  117165. * A helper-interface for the 3 meshes needed for controller button animation
  117166. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117167. */
  117168. export interface IMotionControllerButtonMeshMap {
  117169. /**
  117170. * the mesh that defines the pressed value mesh position.
  117171. * This is used to find the max-position of this button
  117172. */
  117173. pressedMesh: AbstractMesh;
  117174. /**
  117175. * the mesh that defines the unpressed value mesh position.
  117176. * This is used to find the min (or initial) position of this button
  117177. */
  117178. unpressedMesh: AbstractMesh;
  117179. /**
  117180. * The mesh that will be changed when value changes
  117181. */
  117182. valueMesh: AbstractMesh;
  117183. }
  117184. /**
  117185. * A helper-interface for the 3 meshes needed for controller axis animation.
  117186. * This will be expanded when touchpad animations are fully supported
  117187. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117188. */
  117189. export interface IMotionControllerMeshMap {
  117190. /**
  117191. * the mesh that defines the maximum value mesh position.
  117192. */
  117193. maxMesh?: AbstractMesh;
  117194. /**
  117195. * the mesh that defines the minimum value mesh position.
  117196. */
  117197. minMesh?: AbstractMesh;
  117198. /**
  117199. * The mesh that will be changed when axis value changes
  117200. */
  117201. valueMesh: AbstractMesh;
  117202. }
  117203. /**
  117204. * The elements needed for change-detection of the gamepad objects in motion controllers
  117205. */
  117206. export interface IMinimalMotionControllerObject {
  117207. /**
  117208. * Available axes of this controller
  117209. */
  117210. axes: number[];
  117211. /**
  117212. * An array of available buttons
  117213. */
  117214. buttons: Array<{
  117215. /**
  117216. * Value of the button/trigger
  117217. */
  117218. value: number;
  117219. /**
  117220. * If the button/trigger is currently touched
  117221. */
  117222. touched: boolean;
  117223. /**
  117224. * If the button/trigger is currently pressed
  117225. */
  117226. pressed: boolean;
  117227. }>;
  117228. }
  117229. /**
  117230. * An Abstract Motion controller
  117231. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117232. * Each component has an observable to check for changes in value and state
  117233. */
  117234. export abstract class WebXRAbstractMotionController implements IDisposable {
  117235. protected scene: Scene;
  117236. protected layout: IMotionControllerLayout;
  117237. /**
  117238. * The gamepad object correlating to this controller
  117239. */
  117240. gamepadObject: IMinimalMotionControllerObject;
  117241. /**
  117242. * handness (left/right/none) of this controller
  117243. */
  117244. handness: MotionControllerHandness;
  117245. private _initComponent;
  117246. private _modelReady;
  117247. /**
  117248. * A map of components (WebXRControllerComponent) in this motion controller
  117249. * Components have a ComponentType and can also have both button and axis definitions
  117250. */
  117251. readonly components: {
  117252. [id: string]: WebXRControllerComponent;
  117253. };
  117254. /**
  117255. * Disable the model's animation. Can be set at any time.
  117256. */
  117257. disableAnimation: boolean;
  117258. /**
  117259. * Observers registered here will be triggered when the model of this controller is done loading
  117260. */
  117261. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117262. /**
  117263. * The profile id of this motion controller
  117264. */
  117265. abstract profileId: string;
  117266. /**
  117267. * The root mesh of the model. It is null if the model was not yet initialized
  117268. */
  117269. rootMesh: Nullable<AbstractMesh>;
  117270. /**
  117271. * constructs a new abstract motion controller
  117272. * @param scene the scene to which the model of the controller will be added
  117273. * @param layout The profile layout to load
  117274. * @param gamepadObject The gamepad object correlating to this controller
  117275. * @param handness handness (left/right/none) of this controller
  117276. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117277. */
  117278. constructor(scene: Scene, layout: IMotionControllerLayout,
  117279. /**
  117280. * The gamepad object correlating to this controller
  117281. */
  117282. gamepadObject: IMinimalMotionControllerObject,
  117283. /**
  117284. * handness (left/right/none) of this controller
  117285. */
  117286. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117287. /**
  117288. * Dispose this controller, the model mesh and all its components
  117289. */
  117290. dispose(): void;
  117291. /**
  117292. * Returns all components of specific type
  117293. * @param type the type to search for
  117294. * @return an array of components with this type
  117295. */
  117296. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117297. /**
  117298. * get a component based an its component id as defined in layout.components
  117299. * @param id the id of the component
  117300. * @returns the component correlates to the id or undefined if not found
  117301. */
  117302. getComponent(id: string): WebXRControllerComponent;
  117303. /**
  117304. * Get the list of components available in this motion controller
  117305. * @returns an array of strings correlating to available components
  117306. */
  117307. getComponentIds(): string[];
  117308. /**
  117309. * Get the first component of specific type
  117310. * @param type type of component to find
  117311. * @return a controller component or null if not found
  117312. */
  117313. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117314. /**
  117315. * Get the main (Select) component of this controller as defined in the layout
  117316. * @returns the main component of this controller
  117317. */
  117318. getMainComponent(): WebXRControllerComponent;
  117319. /**
  117320. * Loads the model correlating to this controller
  117321. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117322. * @returns A promise fulfilled with the result of the model loading
  117323. */
  117324. loadModel(): Promise<boolean>;
  117325. /**
  117326. * Update this model using the current XRFrame
  117327. * @param xrFrame the current xr frame to use and update the model
  117328. */
  117329. updateFromXRFrame(xrFrame: XRFrame): void;
  117330. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117331. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117332. /**
  117333. * Moves the axis on the controller mesh based on its current state
  117334. * @param axis the index of the axis
  117335. * @param axisValue the value of the axis which determines the meshes new position
  117336. * @hidden
  117337. */
  117338. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117339. /**
  117340. * Update the model itself with the current frame data
  117341. * @param xrFrame the frame to use for updating the model mesh
  117342. */
  117343. protected updateModel(xrFrame: XRFrame): void;
  117344. /**
  117345. * Get the filename and path for this controller's model
  117346. * @returns a map of filename and path
  117347. */
  117348. protected abstract _getFilenameAndPath(): {
  117349. filename: string;
  117350. path: string;
  117351. };
  117352. /**
  117353. * This function is called before the mesh is loaded. It checks for loading constraints.
  117354. * For example, this function can check if the GLB loader is available
  117355. * If this function returns false, the generic controller will be loaded instead
  117356. * @returns Is the client ready to load the mesh
  117357. */
  117358. protected abstract _getModelLoadingConstraints(): boolean;
  117359. /**
  117360. * This function will be called after the model was successfully loaded and can be used
  117361. * for mesh transformations before it is available for the user
  117362. * @param meshes the loaded meshes
  117363. */
  117364. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117365. /**
  117366. * Set the root mesh for this controller. Important for the WebXR controller class
  117367. * @param meshes the loaded meshes
  117368. */
  117369. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117370. /**
  117371. * A function executed each frame that updates the mesh (if needed)
  117372. * @param xrFrame the current xrFrame
  117373. */
  117374. protected abstract _updateModel(xrFrame: XRFrame): void;
  117375. private _getGenericFilenameAndPath;
  117376. private _getGenericParentMesh;
  117377. }
  117378. }
  117379. declare module BABYLON {
  117380. /**
  117381. * A generic trigger-only motion controller for WebXR
  117382. */
  117383. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117384. /**
  117385. * Static version of the profile id of this controller
  117386. */
  117387. static ProfileId: string;
  117388. profileId: string;
  117389. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117390. protected _getFilenameAndPath(): {
  117391. filename: string;
  117392. path: string;
  117393. };
  117394. protected _getModelLoadingConstraints(): boolean;
  117395. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117396. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117397. protected _updateModel(): void;
  117398. }
  117399. }
  117400. declare module BABYLON {
  117401. /**
  117402. * Class containing static functions to help procedurally build meshes
  117403. */
  117404. export class SphereBuilder {
  117405. /**
  117406. * Creates a sphere mesh
  117407. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117408. * * 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`)
  117409. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117410. * * 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
  117411. * * 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)
  117412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117415. * @param name defines the name of the mesh
  117416. * @param options defines the options used to create the mesh
  117417. * @param scene defines the hosting scene
  117418. * @returns the sphere mesh
  117419. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117420. */
  117421. static CreateSphere(name: string, options: {
  117422. segments?: number;
  117423. diameter?: number;
  117424. diameterX?: number;
  117425. diameterY?: number;
  117426. diameterZ?: number;
  117427. arc?: number;
  117428. slice?: number;
  117429. sideOrientation?: number;
  117430. frontUVs?: Vector4;
  117431. backUVs?: Vector4;
  117432. updatable?: boolean;
  117433. }, scene?: Nullable<Scene>): Mesh;
  117434. }
  117435. }
  117436. declare module BABYLON {
  117437. /**
  117438. * A profiled motion controller has its profile loaded from an online repository.
  117439. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117440. */
  117441. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117442. private _repositoryUrl;
  117443. private _buttonMeshMapping;
  117444. private _touchDots;
  117445. /**
  117446. * The profile ID of this controller. Will be populated when the controller initializes.
  117447. */
  117448. profileId: string;
  117449. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117450. dispose(): void;
  117451. protected _getFilenameAndPath(): {
  117452. filename: string;
  117453. path: string;
  117454. };
  117455. protected _getModelLoadingConstraints(): boolean;
  117456. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117457. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117458. protected _updateModel(_xrFrame: XRFrame): void;
  117459. }
  117460. }
  117461. declare module BABYLON {
  117462. /**
  117463. * A construction function type to create a new controller based on an xrInput object
  117464. */
  117465. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117466. /**
  117467. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117468. *
  117469. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117470. * it should be replaced with auto-loaded controllers.
  117471. *
  117472. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117473. */
  117474. export class WebXRMotionControllerManager {
  117475. private static _AvailableControllers;
  117476. private static _Fallbacks;
  117477. private static _ProfileLoadingPromises;
  117478. private static _ProfilesList;
  117479. /**
  117480. * The base URL of the online controller repository. Can be changed at any time.
  117481. */
  117482. static BaseRepositoryUrl: string;
  117483. /**
  117484. * Which repository gets priority - local or online
  117485. */
  117486. static PrioritizeOnlineRepository: boolean;
  117487. /**
  117488. * Use the online repository, or use only locally-defined controllers
  117489. */
  117490. static UseOnlineRepository: boolean;
  117491. /**
  117492. * Clear the cache used for profile loading and reload when requested again
  117493. */
  117494. static ClearProfilesCache(): void;
  117495. /**
  117496. * Register the default fallbacks.
  117497. * This function is called automatically when this file is imported.
  117498. */
  117499. static DefaultFallbacks(): void;
  117500. /**
  117501. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117502. * @param profileId the profile to which a fallback needs to be found
  117503. * @return an array with corresponding fallback profiles
  117504. */
  117505. static FindFallbackWithProfileId(profileId: string): string[];
  117506. /**
  117507. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117508. * The order of search:
  117509. *
  117510. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117511. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117512. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117513. * 4) return the generic trigger controller if none were found
  117514. *
  117515. * @param xrInput the xrInput to which a new controller is initialized
  117516. * @param scene the scene to which the model will be added
  117517. * @param forceProfile force a certain profile for this controller
  117518. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117519. */
  117520. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117521. /**
  117522. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117523. *
  117524. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117525. *
  117526. * @param type the profile type to register
  117527. * @param constructFunction the function to be called when loading this profile
  117528. */
  117529. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117530. /**
  117531. * Register a fallback to a specific profile.
  117532. * @param profileId the profileId that will receive the fallbacks
  117533. * @param fallbacks A list of fallback profiles
  117534. */
  117535. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117536. /**
  117537. * Will update the list of profiles available in the repository
  117538. * @return a promise that resolves to a map of profiles available online
  117539. */
  117540. static UpdateProfilesList(): Promise<{
  117541. [profile: string]: string;
  117542. }>;
  117543. private static _LoadProfileFromRepository;
  117544. private static _LoadProfilesFromAvailableControllers;
  117545. }
  117546. }
  117547. declare module BABYLON {
  117548. /**
  117549. * Configuration options for the WebXR controller creation
  117550. */
  117551. export interface IWebXRControllerOptions {
  117552. /**
  117553. * Should the controller mesh be animated when a user interacts with it
  117554. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117555. */
  117556. disableMotionControllerAnimation?: boolean;
  117557. /**
  117558. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117559. */
  117560. doNotLoadControllerMesh?: boolean;
  117561. /**
  117562. * Force a specific controller type for this controller.
  117563. * This can be used when creating your own profile or when testing different controllers
  117564. */
  117565. forceControllerProfile?: string;
  117566. }
  117567. /**
  117568. * Represents an XR controller
  117569. */
  117570. export class WebXRInputSource {
  117571. private _scene;
  117572. /** The underlying input source for the controller */
  117573. inputSource: XRInputSource;
  117574. private _options;
  117575. private _tmpQuaternion;
  117576. private _tmpVector;
  117577. private _uniqueId;
  117578. /**
  117579. * 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
  117580. */
  117581. grip?: AbstractMesh;
  117582. /**
  117583. * If available, this is the gamepad object related to this controller.
  117584. * Using this object it is possible to get click events and trackpad changes of the
  117585. * webxr controller that is currently being used.
  117586. */
  117587. motionController?: WebXRAbstractMotionController;
  117588. /**
  117589. * Event that fires when the controller is removed/disposed.
  117590. * The object provided as event data is this controller, after associated assets were disposed.
  117591. * uniqueId is still available.
  117592. */
  117593. onDisposeObservable: Observable<WebXRInputSource>;
  117594. /**
  117595. * Will be triggered when the mesh associated with the motion controller is done loading.
  117596. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117597. * A shortened version of controller -> motion controller -> on mesh loaded.
  117598. */
  117599. onMeshLoadedObservable: Observable<AbstractMesh>;
  117600. /**
  117601. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117602. */
  117603. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117604. /**
  117605. * Pointer which can be used to select objects or attach a visible laser to
  117606. */
  117607. pointer: AbstractMesh;
  117608. /**
  117609. * Creates the controller
  117610. * @see https://doc.babylonjs.com/how_to/webxr
  117611. * @param _scene the scene which the controller should be associated to
  117612. * @param inputSource the underlying input source for the controller
  117613. * @param _options options for this controller creation
  117614. */
  117615. constructor(_scene: Scene,
  117616. /** The underlying input source for the controller */
  117617. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117618. /**
  117619. * Get this controllers unique id
  117620. */
  117621. get uniqueId(): string;
  117622. /**
  117623. * Disposes of the object
  117624. */
  117625. dispose(): void;
  117626. /**
  117627. * Gets a world space ray coming from the pointer or grip
  117628. * @param result the resulting ray
  117629. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117630. */
  117631. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117632. /**
  117633. * Updates the controller pose based on the given XRFrame
  117634. * @param xrFrame xr frame to update the pose with
  117635. * @param referenceSpace reference space to use
  117636. */
  117637. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117638. }
  117639. }
  117640. declare module BABYLON {
  117641. /**
  117642. * The schema for initialization options of the XR Input class
  117643. */
  117644. export interface IWebXRInputOptions {
  117645. /**
  117646. * If set to true no model will be automatically loaded
  117647. */
  117648. doNotLoadControllerMeshes?: boolean;
  117649. /**
  117650. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117651. * If not found, the xr input profile data will be used.
  117652. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117653. */
  117654. forceInputProfile?: string;
  117655. /**
  117656. * Do not send a request to the controller repository to load the profile.
  117657. *
  117658. * Instead, use the controllers available in babylon itself.
  117659. */
  117660. disableOnlineControllerRepository?: boolean;
  117661. /**
  117662. * A custom URL for the controllers repository
  117663. */
  117664. customControllersRepositoryURL?: string;
  117665. /**
  117666. * Should the controller model's components not move according to the user input
  117667. */
  117668. disableControllerAnimation?: boolean;
  117669. }
  117670. /**
  117671. * XR input used to track XR inputs such as controllers/rays
  117672. */
  117673. export class WebXRInput implements IDisposable {
  117674. /**
  117675. * the xr session manager for this session
  117676. */
  117677. xrSessionManager: WebXRSessionManager;
  117678. /**
  117679. * the WebXR camera for this session. Mainly used for teleportation
  117680. */
  117681. xrCamera: WebXRCamera;
  117682. private readonly options;
  117683. /**
  117684. * XR controllers being tracked
  117685. */
  117686. controllers: Array<WebXRInputSource>;
  117687. private _frameObserver;
  117688. private _sessionEndedObserver;
  117689. private _sessionInitObserver;
  117690. /**
  117691. * Event when a controller has been connected/added
  117692. */
  117693. onControllerAddedObservable: Observable<WebXRInputSource>;
  117694. /**
  117695. * Event when a controller has been removed/disconnected
  117696. */
  117697. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117698. /**
  117699. * Initializes the WebXRInput
  117700. * @param xrSessionManager the xr session manager for this session
  117701. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117702. * @param options = initialization options for this xr input
  117703. */
  117704. constructor(
  117705. /**
  117706. * the xr session manager for this session
  117707. */
  117708. xrSessionManager: WebXRSessionManager,
  117709. /**
  117710. * the WebXR camera for this session. Mainly used for teleportation
  117711. */
  117712. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117713. private _onInputSourcesChange;
  117714. private _addAndRemoveControllers;
  117715. /**
  117716. * Disposes of the object
  117717. */
  117718. dispose(): void;
  117719. }
  117720. }
  117721. declare module BABYLON {
  117722. /**
  117723. * This is the base class for all WebXR features.
  117724. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117725. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117726. */
  117727. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117728. protected _xrSessionManager: WebXRSessionManager;
  117729. private _attached;
  117730. private _removeOnDetach;
  117731. /**
  117732. * Should auto-attach be disabled?
  117733. */
  117734. disableAutoAttach: boolean;
  117735. /**
  117736. * Construct a new (abstract) WebXR feature
  117737. * @param _xrSessionManager the xr session manager for this feature
  117738. */
  117739. constructor(_xrSessionManager: WebXRSessionManager);
  117740. /**
  117741. * Is this feature attached
  117742. */
  117743. get attached(): boolean;
  117744. /**
  117745. * attach this feature
  117746. *
  117747. * @param force should attachment be forced (even when already attached)
  117748. * @returns true if successful, false is failed or already attached
  117749. */
  117750. attach(force?: boolean): boolean;
  117751. /**
  117752. * detach this feature.
  117753. *
  117754. * @returns true if successful, false if failed or already detached
  117755. */
  117756. detach(): boolean;
  117757. /**
  117758. * Dispose this feature and all of the resources attached
  117759. */
  117760. dispose(): void;
  117761. /**
  117762. * This is used to register callbacks that will automatically be removed when detach is called.
  117763. * @param observable the observable to which the observer will be attached
  117764. * @param callback the callback to register
  117765. */
  117766. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117767. /**
  117768. * Code in this function will be executed on each xrFrame received from the browser.
  117769. * This function will not execute after the feature is detached.
  117770. * @param _xrFrame the current frame
  117771. */
  117772. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117773. }
  117774. }
  117775. declare module BABYLON {
  117776. /**
  117777. * Renders a layer on top of an existing scene
  117778. */
  117779. export class UtilityLayerRenderer implements IDisposable {
  117780. /** the original scene that will be rendered on top of */
  117781. originalScene: Scene;
  117782. private _pointerCaptures;
  117783. private _lastPointerEvents;
  117784. private static _DefaultUtilityLayer;
  117785. private static _DefaultKeepDepthUtilityLayer;
  117786. private _sharedGizmoLight;
  117787. private _renderCamera;
  117788. /**
  117789. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117790. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  117791. * @returns the camera that is used when rendering the utility layer
  117792. */
  117793. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  117794. /**
  117795. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117796. * @param cam the camera that should be used when rendering the utility layer
  117797. */
  117798. setRenderCamera(cam: Nullable<Camera>): void;
  117799. /**
  117800. * @hidden
  117801. * Light which used by gizmos to get light shading
  117802. */
  117803. _getSharedGizmoLight(): HemisphericLight;
  117804. /**
  117805. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117806. */
  117807. pickUtilitySceneFirst: boolean;
  117808. /**
  117809. * 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)
  117810. */
  117811. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117812. /**
  117813. * 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)
  117814. */
  117815. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117816. /**
  117817. * The scene that is rendered on top of the original scene
  117818. */
  117819. utilityLayerScene: Scene;
  117820. /**
  117821. * If the utility layer should automatically be rendered on top of existing scene
  117822. */
  117823. shouldRender: boolean;
  117824. /**
  117825. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117826. */
  117827. onlyCheckPointerDownEvents: boolean;
  117828. /**
  117829. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117830. */
  117831. processAllEvents: boolean;
  117832. /**
  117833. * Observable raised when the pointer move from the utility layer scene to the main scene
  117834. */
  117835. onPointerOutObservable: Observable<number>;
  117836. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117837. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117838. private _afterRenderObserver;
  117839. private _sceneDisposeObserver;
  117840. private _originalPointerObserver;
  117841. /**
  117842. * Instantiates a UtilityLayerRenderer
  117843. * @param originalScene the original scene that will be rendered on top of
  117844. * @param handleEvents boolean indicating if the utility layer should handle events
  117845. */
  117846. constructor(
  117847. /** the original scene that will be rendered on top of */
  117848. originalScene: Scene, handleEvents?: boolean);
  117849. private _notifyObservers;
  117850. /**
  117851. * Renders the utility layers scene on top of the original scene
  117852. */
  117853. render(): void;
  117854. /**
  117855. * Disposes of the renderer
  117856. */
  117857. dispose(): void;
  117858. private _updateCamera;
  117859. }
  117860. }
  117861. declare module BABYLON {
  117862. /**
  117863. * Options interface for the pointer selection module
  117864. */
  117865. export interface IWebXRControllerPointerSelectionOptions {
  117866. /**
  117867. * if provided, this scene will be used to render meshes.
  117868. */
  117869. customUtilityLayerScene?: Scene;
  117870. /**
  117871. * 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)
  117872. * If not disabled, the last picked point will be used to execute a pointer up event
  117873. * If disabled, pointer up event will be triggered right after the pointer down event.
  117874. * Used in screen and gaze target ray mode only
  117875. */
  117876. disablePointerUpOnTouchOut: boolean;
  117877. /**
  117878. * For gaze mode (time to select instead of press)
  117879. */
  117880. forceGazeMode: boolean;
  117881. /**
  117882. * 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
  117883. * to start a new countdown to the pointer down event.
  117884. * Defaults to 1.
  117885. */
  117886. gazeModePointerMovedFactor?: number;
  117887. /**
  117888. * Different button type to use instead of the main component
  117889. */
  117890. overrideButtonId?: string;
  117891. /**
  117892. * use this rendering group id for the meshes (optional)
  117893. */
  117894. renderingGroupId?: number;
  117895. /**
  117896. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117897. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117898. * 3000 means 3 seconds between pointing at something and selecting it
  117899. */
  117900. timeToSelect?: number;
  117901. /**
  117902. * Should meshes created here be added to a utility layer or the main scene
  117903. */
  117904. useUtilityLayer?: boolean;
  117905. /**
  117906. * the xr input to use with this pointer selection
  117907. */
  117908. xrInput: WebXRInput;
  117909. }
  117910. /**
  117911. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117912. */
  117913. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117914. private readonly _options;
  117915. private static _idCounter;
  117916. private _attachController;
  117917. private _controllers;
  117918. private _scene;
  117919. private _tmpVectorForPickCompare;
  117920. /**
  117921. * The module's name
  117922. */
  117923. static readonly Name: string;
  117924. /**
  117925. * The (Babylon) version of this module.
  117926. * This is an integer representing the implementation version.
  117927. * This number does not correspond to the WebXR specs version
  117928. */
  117929. static readonly Version: number;
  117930. /**
  117931. * Disable lighting on the laser pointer (so it will always be visible)
  117932. */
  117933. disablePointerLighting: boolean;
  117934. /**
  117935. * Disable lighting on the selection mesh (so it will always be visible)
  117936. */
  117937. disableSelectionMeshLighting: boolean;
  117938. /**
  117939. * Should the laser pointer be displayed
  117940. */
  117941. displayLaserPointer: boolean;
  117942. /**
  117943. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117944. */
  117945. displaySelectionMesh: boolean;
  117946. /**
  117947. * This color will be set to the laser pointer when selection is triggered
  117948. */
  117949. laserPointerPickedColor: Color3;
  117950. /**
  117951. * Default color of the laser pointer
  117952. */
  117953. lasterPointerDefaultColor: Color3;
  117954. /**
  117955. * default color of the selection ring
  117956. */
  117957. selectionMeshDefaultColor: Color3;
  117958. /**
  117959. * This color will be applied to the selection ring when selection is triggered
  117960. */
  117961. selectionMeshPickedColor: Color3;
  117962. /**
  117963. * constructs a new background remover module
  117964. * @param _xrSessionManager the session manager for this module
  117965. * @param _options read-only options to be used in this module
  117966. */
  117967. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117968. /**
  117969. * attach this feature
  117970. * Will usually be called by the features manager
  117971. *
  117972. * @returns true if successful.
  117973. */
  117974. attach(): boolean;
  117975. /**
  117976. * detach this feature.
  117977. * Will usually be called by the features manager
  117978. *
  117979. * @returns true if successful.
  117980. */
  117981. detach(): boolean;
  117982. /**
  117983. * Will get the mesh under a specific pointer.
  117984. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117985. * @param controllerId the controllerId to check
  117986. * @returns The mesh under pointer or null if no mesh is under the pointer
  117987. */
  117988. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117989. /**
  117990. * Get the xr controller that correlates to the pointer id in the pointer event
  117991. *
  117992. * @param id the pointer id to search for
  117993. * @returns the controller that correlates to this id or null if not found
  117994. */
  117995. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117996. protected _onXRFrame(_xrFrame: XRFrame): void;
  117997. private _attachGazeMode;
  117998. private _attachScreenRayMode;
  117999. private _attachTrackedPointerRayMode;
  118000. private _convertNormalToDirectionOfRay;
  118001. private _detachController;
  118002. private _generateNewMeshPair;
  118003. private _pickingMoved;
  118004. private _updatePointerDistance;
  118005. }
  118006. }
  118007. declare module BABYLON {
  118008. /**
  118009. * Button which can be used to enter a different mode of XR
  118010. */
  118011. export class WebXREnterExitUIButton {
  118012. /** button element */
  118013. element: HTMLElement;
  118014. /** XR initialization options for the button */
  118015. sessionMode: XRSessionMode;
  118016. /** Reference space type */
  118017. referenceSpaceType: XRReferenceSpaceType;
  118018. /**
  118019. * Creates a WebXREnterExitUIButton
  118020. * @param element button element
  118021. * @param sessionMode XR initialization session mode
  118022. * @param referenceSpaceType the type of reference space to be used
  118023. */
  118024. constructor(
  118025. /** button element */
  118026. element: HTMLElement,
  118027. /** XR initialization options for the button */
  118028. sessionMode: XRSessionMode,
  118029. /** Reference space type */
  118030. referenceSpaceType: XRReferenceSpaceType);
  118031. /**
  118032. * Extendable function which can be used to update the button's visuals when the state changes
  118033. * @param activeButton the current active button in the UI
  118034. */
  118035. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  118036. }
  118037. /**
  118038. * Options to create the webXR UI
  118039. */
  118040. export class WebXREnterExitUIOptions {
  118041. /**
  118042. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  118043. */
  118044. customButtons?: Array<WebXREnterExitUIButton>;
  118045. /**
  118046. * A reference space type to use when creating the default button.
  118047. * Default is local-floor
  118048. */
  118049. referenceSpaceType?: XRReferenceSpaceType;
  118050. /**
  118051. * Context to enter xr with
  118052. */
  118053. renderTarget?: Nullable<WebXRRenderTarget>;
  118054. /**
  118055. * A session mode to use when creating the default button.
  118056. * Default is immersive-vr
  118057. */
  118058. sessionMode?: XRSessionMode;
  118059. }
  118060. /**
  118061. * UI to allow the user to enter/exit XR mode
  118062. */
  118063. export class WebXREnterExitUI implements IDisposable {
  118064. private scene;
  118065. /** version of the options passed to this UI */
  118066. options: WebXREnterExitUIOptions;
  118067. private _activeButton;
  118068. private _buttons;
  118069. private _overlay;
  118070. /**
  118071. * Fired every time the active button is changed.
  118072. *
  118073. * When xr is entered via a button that launches xr that button will be the callback parameter
  118074. *
  118075. * When exiting xr the callback parameter will be null)
  118076. */
  118077. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  118078. /**
  118079. *
  118080. * @param scene babylon scene object to use
  118081. * @param options (read-only) version of the options passed to this UI
  118082. */
  118083. private constructor();
  118084. /**
  118085. * Creates UI to allow the user to enter/exit XR mode
  118086. * @param scene the scene to add the ui to
  118087. * @param helper the xr experience helper to enter/exit xr with
  118088. * @param options options to configure the UI
  118089. * @returns the created ui
  118090. */
  118091. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118092. /**
  118093. * Disposes of the XR UI component
  118094. */
  118095. dispose(): void;
  118096. private _updateButtons;
  118097. }
  118098. }
  118099. declare module BABYLON {
  118100. /**
  118101. * Class containing static functions to help procedurally build meshes
  118102. */
  118103. export class LinesBuilder {
  118104. /**
  118105. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118106. * * 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
  118107. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118108. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118109. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118110. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118111. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118112. * * 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
  118113. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118116. * @param name defines the name of the new line system
  118117. * @param options defines the options used to create the line system
  118118. * @param scene defines the hosting scene
  118119. * @returns a new line system mesh
  118120. */
  118121. static CreateLineSystem(name: string, options: {
  118122. lines: Vector3[][];
  118123. updatable?: boolean;
  118124. instance?: Nullable<LinesMesh>;
  118125. colors?: Nullable<Color4[][]>;
  118126. useVertexAlpha?: boolean;
  118127. }, scene: Nullable<Scene>): LinesMesh;
  118128. /**
  118129. * Creates a line mesh
  118130. * 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
  118131. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118132. * * The parameter `points` is an array successive Vector3
  118133. * * 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
  118134. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118135. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118136. * * When updating an instance, remember that only point positions can change, not the number of points
  118137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118139. * @param name defines the name of the new line system
  118140. * @param options defines the options used to create the line system
  118141. * @param scene defines the hosting scene
  118142. * @returns a new line mesh
  118143. */
  118144. static CreateLines(name: string, options: {
  118145. points: Vector3[];
  118146. updatable?: boolean;
  118147. instance?: Nullable<LinesMesh>;
  118148. colors?: Color4[];
  118149. useVertexAlpha?: boolean;
  118150. }, scene?: Nullable<Scene>): LinesMesh;
  118151. /**
  118152. * Creates a dashed line mesh
  118153. * * 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
  118154. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118155. * * The parameter `points` is an array successive Vector3
  118156. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118157. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118158. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118159. * * 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
  118160. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118161. * * When updating an instance, remember that only point positions can change, not the number of points
  118162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118163. * @param name defines the name of the mesh
  118164. * @param options defines the options used to create the mesh
  118165. * @param scene defines the hosting scene
  118166. * @returns the dashed line mesh
  118167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118168. */
  118169. static CreateDashedLines(name: string, options: {
  118170. points: Vector3[];
  118171. dashSize?: number;
  118172. gapSize?: number;
  118173. dashNb?: number;
  118174. updatable?: boolean;
  118175. instance?: LinesMesh;
  118176. useVertexAlpha?: boolean;
  118177. }, scene?: Nullable<Scene>): LinesMesh;
  118178. }
  118179. }
  118180. declare module BABYLON {
  118181. /**
  118182. * The options container for the teleportation module
  118183. */
  118184. export interface IWebXRTeleportationOptions {
  118185. /**
  118186. * if provided, this scene will be used to render meshes.
  118187. */
  118188. customUtilityLayerScene?: Scene;
  118189. /**
  118190. * Values to configure the default target mesh
  118191. */
  118192. defaultTargetMeshOptions?: {
  118193. /**
  118194. * Fill color of the teleportation area
  118195. */
  118196. teleportationFillColor?: string;
  118197. /**
  118198. * Border color for the teleportation area
  118199. */
  118200. teleportationBorderColor?: string;
  118201. /**
  118202. * Disable the mesh's animation sequence
  118203. */
  118204. disableAnimation?: boolean;
  118205. /**
  118206. * Disable lighting on the material or the ring and arrow
  118207. */
  118208. disableLighting?: boolean;
  118209. /**
  118210. * Override the default material of the torus and arrow
  118211. */
  118212. torusArrowMaterial?: Material;
  118213. };
  118214. /**
  118215. * A list of meshes to use as floor meshes.
  118216. * Meshes can be added and removed after initializing the feature using the
  118217. * addFloorMesh and removeFloorMesh functions
  118218. * If empty, rotation will still work
  118219. */
  118220. floorMeshes?: AbstractMesh[];
  118221. /**
  118222. * use this rendering group id for the meshes (optional)
  118223. */
  118224. renderingGroupId?: number;
  118225. /**
  118226. * Should teleportation move only to snap points
  118227. */
  118228. snapPointsOnly?: boolean;
  118229. /**
  118230. * An array of points to which the teleportation will snap to.
  118231. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118232. */
  118233. snapPositions?: Vector3[];
  118234. /**
  118235. * How close should the teleportation ray be in order to snap to position.
  118236. * Default to 0.8 units (meters)
  118237. */
  118238. snapToPositionRadius?: number;
  118239. /**
  118240. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118241. * If you want to support rotation, make sure your mesh has a direction indicator.
  118242. *
  118243. * When left untouched, the default mesh will be initialized.
  118244. */
  118245. teleportationTargetMesh?: AbstractMesh;
  118246. /**
  118247. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118248. */
  118249. timeToTeleport?: number;
  118250. /**
  118251. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118252. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118253. */
  118254. useMainComponentOnly?: boolean;
  118255. /**
  118256. * Should meshes created here be added to a utility layer or the main scene
  118257. */
  118258. useUtilityLayer?: boolean;
  118259. /**
  118260. * Babylon XR Input class for controller
  118261. */
  118262. xrInput: WebXRInput;
  118263. }
  118264. /**
  118265. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118266. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118267. * the input of the attached controllers.
  118268. */
  118269. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118270. private _options;
  118271. private _controllers;
  118272. private _currentTeleportationControllerId;
  118273. private _floorMeshes;
  118274. private _quadraticBezierCurve;
  118275. private _selectionFeature;
  118276. private _snapToPositions;
  118277. private _snappedToPoint;
  118278. private _teleportationRingMaterial?;
  118279. private _tmpRay;
  118280. private _tmpVector;
  118281. /**
  118282. * The module's name
  118283. */
  118284. static readonly Name: string;
  118285. /**
  118286. * The (Babylon) version of this module.
  118287. * This is an integer representing the implementation version.
  118288. * This number does not correspond to the webxr specs version
  118289. */
  118290. static readonly Version: number;
  118291. /**
  118292. * Is movement backwards enabled
  118293. */
  118294. backwardsMovementEnabled: boolean;
  118295. /**
  118296. * Distance to travel when moving backwards
  118297. */
  118298. backwardsTeleportationDistance: number;
  118299. /**
  118300. * The distance from the user to the inspection point in the direction of the controller
  118301. * A higher number will allow the user to move further
  118302. * defaults to 5 (meters, in xr units)
  118303. */
  118304. parabolicCheckRadius: number;
  118305. /**
  118306. * Should the module support parabolic ray on top of direct ray
  118307. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118308. * Very helpful when moving between floors / different heights
  118309. */
  118310. parabolicRayEnabled: boolean;
  118311. /**
  118312. * How much rotation should be applied when rotating right and left
  118313. */
  118314. rotationAngle: number;
  118315. /**
  118316. * Is rotation enabled when moving forward?
  118317. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118318. */
  118319. rotationEnabled: boolean;
  118320. /**
  118321. * constructs a new anchor system
  118322. * @param _xrSessionManager an instance of WebXRSessionManager
  118323. * @param _options configuration object for this feature
  118324. */
  118325. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118326. /**
  118327. * Get the snapPointsOnly flag
  118328. */
  118329. get snapPointsOnly(): boolean;
  118330. /**
  118331. * Sets the snapPointsOnly flag
  118332. * @param snapToPoints should teleportation be exclusively to snap points
  118333. */
  118334. set snapPointsOnly(snapToPoints: boolean);
  118335. /**
  118336. * Add a new mesh to the floor meshes array
  118337. * @param mesh the mesh to use as floor mesh
  118338. */
  118339. addFloorMesh(mesh: AbstractMesh): void;
  118340. /**
  118341. * Add a new snap-to point to fix teleportation to this position
  118342. * @param newSnapPoint The new Snap-To point
  118343. */
  118344. addSnapPoint(newSnapPoint: Vector3): void;
  118345. attach(): boolean;
  118346. detach(): boolean;
  118347. dispose(): void;
  118348. /**
  118349. * Remove a mesh from the floor meshes array
  118350. * @param mesh the mesh to remove
  118351. */
  118352. removeFloorMesh(mesh: AbstractMesh): void;
  118353. /**
  118354. * Remove a mesh from the floor meshes array using its name
  118355. * @param name the mesh name to remove
  118356. */
  118357. removeFloorMeshByName(name: string): void;
  118358. /**
  118359. * 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
  118360. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118361. * @returns was the point found and removed or not
  118362. */
  118363. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118364. /**
  118365. * This function sets a selection feature that will be disabled when
  118366. * the forward ray is shown and will be reattached when hidden.
  118367. * This is used to remove the selection rays when moving.
  118368. * @param selectionFeature the feature to disable when forward movement is enabled
  118369. */
  118370. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118371. protected _onXRFrame(_xrFrame: XRFrame): void;
  118372. private _attachController;
  118373. private _createDefaultTargetMesh;
  118374. private _detachController;
  118375. private _findClosestSnapPointWithRadius;
  118376. private _setTargetMeshPosition;
  118377. private _setTargetMeshVisibility;
  118378. private _showParabolicPath;
  118379. private _teleportForward;
  118380. }
  118381. }
  118382. declare module BABYLON {
  118383. /**
  118384. * Options for the default xr helper
  118385. */
  118386. export class WebXRDefaultExperienceOptions {
  118387. /**
  118388. * Enable or disable default UI to enter XR
  118389. */
  118390. disableDefaultUI?: boolean;
  118391. /**
  118392. * Should teleportation not initialize. defaults to false.
  118393. */
  118394. disableTeleportation?: boolean;
  118395. /**
  118396. * Floor meshes that will be used for teleport
  118397. */
  118398. floorMeshes?: Array<AbstractMesh>;
  118399. /**
  118400. * If set to true, the first frame will not be used to reset position
  118401. * The first frame is mainly used when copying transformation from the old camera
  118402. * Mainly used in AR
  118403. */
  118404. ignoreNativeCameraTransformation?: boolean;
  118405. /**
  118406. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118407. */
  118408. inputOptions?: IWebXRInputOptions;
  118409. /**
  118410. * optional configuration for the output canvas
  118411. */
  118412. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118413. /**
  118414. * optional UI options. This can be used among other to change session mode and reference space type
  118415. */
  118416. uiOptions?: WebXREnterExitUIOptions;
  118417. /**
  118418. * When loading teleportation and pointer select, use stable versions instead of latest.
  118419. */
  118420. useStablePlugins?: boolean;
  118421. }
  118422. /**
  118423. * Default experience which provides a similar setup to the previous webVRExperience
  118424. */
  118425. export class WebXRDefaultExperience {
  118426. /**
  118427. * Base experience
  118428. */
  118429. baseExperience: WebXRExperienceHelper;
  118430. /**
  118431. * Enables ui for entering/exiting xr
  118432. */
  118433. enterExitUI: WebXREnterExitUI;
  118434. /**
  118435. * Input experience extension
  118436. */
  118437. input: WebXRInput;
  118438. /**
  118439. * Enables laser pointer and selection
  118440. */
  118441. pointerSelection: WebXRControllerPointerSelection;
  118442. /**
  118443. * Default target xr should render to
  118444. */
  118445. renderTarget: WebXRRenderTarget;
  118446. /**
  118447. * Enables teleportation
  118448. */
  118449. teleportation: WebXRMotionControllerTeleportation;
  118450. private constructor();
  118451. /**
  118452. * Creates the default xr experience
  118453. * @param scene scene
  118454. * @param options options for basic configuration
  118455. * @returns resulting WebXRDefaultExperience
  118456. */
  118457. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118458. /**
  118459. * DIsposes of the experience helper
  118460. */
  118461. dispose(): void;
  118462. }
  118463. }
  118464. declare module BABYLON {
  118465. /**
  118466. * Options to modify the vr teleportation behavior.
  118467. */
  118468. export interface VRTeleportationOptions {
  118469. /**
  118470. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118471. */
  118472. floorMeshName?: string;
  118473. /**
  118474. * A list of meshes to be used as the teleportation floor. (default: empty)
  118475. */
  118476. floorMeshes?: Mesh[];
  118477. /**
  118478. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118479. */
  118480. teleportationMode?: number;
  118481. /**
  118482. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118483. */
  118484. teleportationTime?: number;
  118485. /**
  118486. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118487. */
  118488. teleportationSpeed?: number;
  118489. /**
  118490. * The easing function used in the animation or null for Linear. (default CircleEase)
  118491. */
  118492. easingFunction?: EasingFunction;
  118493. }
  118494. /**
  118495. * Options to modify the vr experience helper's behavior.
  118496. */
  118497. export interface VRExperienceHelperOptions extends WebVROptions {
  118498. /**
  118499. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118500. */
  118501. createDeviceOrientationCamera?: boolean;
  118502. /**
  118503. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118504. */
  118505. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118506. /**
  118507. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118508. */
  118509. laserToggle?: boolean;
  118510. /**
  118511. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118512. */
  118513. floorMeshes?: Mesh[];
  118514. /**
  118515. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118516. */
  118517. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118518. /**
  118519. * Defines if WebXR should be used instead of WebVR (if available)
  118520. */
  118521. useXR?: boolean;
  118522. }
  118523. /**
  118524. * Event containing information after VR has been entered
  118525. */
  118526. export class OnAfterEnteringVRObservableEvent {
  118527. /**
  118528. * If entering vr was successful
  118529. */
  118530. success: boolean;
  118531. }
  118532. /**
  118533. * Helps to quickly add VR support to an existing scene.
  118534. * See http://doc.babylonjs.com/how_to/webvr_helper
  118535. */
  118536. export class VRExperienceHelper {
  118537. /** Options to modify the vr experience helper's behavior. */
  118538. webVROptions: VRExperienceHelperOptions;
  118539. private _scene;
  118540. private _position;
  118541. private _btnVR;
  118542. private _btnVRDisplayed;
  118543. private _webVRsupported;
  118544. private _webVRready;
  118545. private _webVRrequesting;
  118546. private _webVRpresenting;
  118547. private _hasEnteredVR;
  118548. private _fullscreenVRpresenting;
  118549. private _inputElement;
  118550. private _webVRCamera;
  118551. private _vrDeviceOrientationCamera;
  118552. private _deviceOrientationCamera;
  118553. private _existingCamera;
  118554. private _onKeyDown;
  118555. private _onVrDisplayPresentChange;
  118556. private _onVRDisplayChanged;
  118557. private _onVRRequestPresentStart;
  118558. private _onVRRequestPresentComplete;
  118559. /**
  118560. * 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)
  118561. */
  118562. enableGazeEvenWhenNoPointerLock: boolean;
  118563. /**
  118564. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118565. */
  118566. exitVROnDoubleTap: boolean;
  118567. /**
  118568. * Observable raised right before entering VR.
  118569. */
  118570. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118571. /**
  118572. * Observable raised when entering VR has completed.
  118573. */
  118574. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118575. /**
  118576. * Observable raised when exiting VR.
  118577. */
  118578. onExitingVRObservable: Observable<VRExperienceHelper>;
  118579. /**
  118580. * Observable raised when controller mesh is loaded.
  118581. */
  118582. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118583. /** Return this.onEnteringVRObservable
  118584. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118585. */
  118586. get onEnteringVR(): Observable<VRExperienceHelper>;
  118587. /** Return this.onExitingVRObservable
  118588. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118589. */
  118590. get onExitingVR(): Observable<VRExperienceHelper>;
  118591. /** Return this.onControllerMeshLoadedObservable
  118592. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118593. */
  118594. get onControllerMeshLoaded(): Observable<WebVRController>;
  118595. private _rayLength;
  118596. private _useCustomVRButton;
  118597. private _teleportationRequested;
  118598. private _teleportActive;
  118599. private _floorMeshName;
  118600. private _floorMeshesCollection;
  118601. private _teleportationMode;
  118602. private _teleportationTime;
  118603. private _teleportationSpeed;
  118604. private _teleportationEasing;
  118605. private _rotationAllowed;
  118606. private _teleportBackwardsVector;
  118607. private _teleportationTarget;
  118608. private _isDefaultTeleportationTarget;
  118609. private _postProcessMove;
  118610. private _teleportationFillColor;
  118611. private _teleportationBorderColor;
  118612. private _rotationAngle;
  118613. private _haloCenter;
  118614. private _cameraGazer;
  118615. private _padSensibilityUp;
  118616. private _padSensibilityDown;
  118617. private _leftController;
  118618. private _rightController;
  118619. private _gazeColor;
  118620. private _laserColor;
  118621. private _pickedLaserColor;
  118622. private _pickedGazeColor;
  118623. /**
  118624. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118625. */
  118626. onNewMeshSelected: Observable<AbstractMesh>;
  118627. /**
  118628. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118629. * This observable will provide the mesh and the controller used to select the mesh
  118630. */
  118631. onMeshSelectedWithController: Observable<{
  118632. mesh: AbstractMesh;
  118633. controller: WebVRController;
  118634. }>;
  118635. /**
  118636. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118637. */
  118638. onNewMeshPicked: Observable<PickingInfo>;
  118639. private _circleEase;
  118640. /**
  118641. * Observable raised before camera teleportation
  118642. */
  118643. onBeforeCameraTeleport: Observable<Vector3>;
  118644. /**
  118645. * Observable raised after camera teleportation
  118646. */
  118647. onAfterCameraTeleport: Observable<Vector3>;
  118648. /**
  118649. * Observable raised when current selected mesh gets unselected
  118650. */
  118651. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118652. private _raySelectionPredicate;
  118653. /**
  118654. * To be optionaly changed by user to define custom ray selection
  118655. */
  118656. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118657. /**
  118658. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118659. */
  118660. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118661. /**
  118662. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118663. */
  118664. teleportationEnabled: boolean;
  118665. private _defaultHeight;
  118666. private _teleportationInitialized;
  118667. private _interactionsEnabled;
  118668. private _interactionsRequested;
  118669. private _displayGaze;
  118670. private _displayLaserPointer;
  118671. /**
  118672. * The mesh used to display where the user is going to teleport.
  118673. */
  118674. get teleportationTarget(): Mesh;
  118675. /**
  118676. * Sets the mesh to be used to display where the user is going to teleport.
  118677. */
  118678. set teleportationTarget(value: Mesh);
  118679. /**
  118680. * 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
  118681. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118682. * See http://doc.babylonjs.com/resources/baking_transformations
  118683. */
  118684. get gazeTrackerMesh(): Mesh;
  118685. set gazeTrackerMesh(value: Mesh);
  118686. /**
  118687. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118688. */
  118689. updateGazeTrackerScale: boolean;
  118690. /**
  118691. * If the gaze trackers color should be updated when selecting meshes
  118692. */
  118693. updateGazeTrackerColor: boolean;
  118694. /**
  118695. * If the controller laser color should be updated when selecting meshes
  118696. */
  118697. updateControllerLaserColor: boolean;
  118698. /**
  118699. * The gaze tracking mesh corresponding to the left controller
  118700. */
  118701. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118702. /**
  118703. * The gaze tracking mesh corresponding to the right controller
  118704. */
  118705. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118706. /**
  118707. * If the ray of the gaze should be displayed.
  118708. */
  118709. get displayGaze(): boolean;
  118710. /**
  118711. * Sets if the ray of the gaze should be displayed.
  118712. */
  118713. set displayGaze(value: boolean);
  118714. /**
  118715. * If the ray of the LaserPointer should be displayed.
  118716. */
  118717. get displayLaserPointer(): boolean;
  118718. /**
  118719. * Sets if the ray of the LaserPointer should be displayed.
  118720. */
  118721. set displayLaserPointer(value: boolean);
  118722. /**
  118723. * The deviceOrientationCamera used as the camera when not in VR.
  118724. */
  118725. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118726. /**
  118727. * Based on the current WebVR support, returns the current VR camera used.
  118728. */
  118729. get currentVRCamera(): Nullable<Camera>;
  118730. /**
  118731. * The webVRCamera which is used when in VR.
  118732. */
  118733. get webVRCamera(): WebVRFreeCamera;
  118734. /**
  118735. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118736. */
  118737. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118738. /**
  118739. * The html button that is used to trigger entering into VR.
  118740. */
  118741. get vrButton(): Nullable<HTMLButtonElement>;
  118742. private get _teleportationRequestInitiated();
  118743. /**
  118744. * Defines whether or not Pointer lock should be requested when switching to
  118745. * full screen.
  118746. */
  118747. requestPointerLockOnFullScreen: boolean;
  118748. /**
  118749. * If asking to force XR, this will be populated with the default xr experience
  118750. */
  118751. xr: WebXRDefaultExperience;
  118752. /**
  118753. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118754. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118755. */
  118756. xrTestDone: boolean;
  118757. /**
  118758. * Instantiates a VRExperienceHelper.
  118759. * Helps to quickly add VR support to an existing scene.
  118760. * @param scene The scene the VRExperienceHelper belongs to.
  118761. * @param webVROptions Options to modify the vr experience helper's behavior.
  118762. */
  118763. constructor(scene: Scene,
  118764. /** Options to modify the vr experience helper's behavior. */
  118765. webVROptions?: VRExperienceHelperOptions);
  118766. private completeVRInit;
  118767. private _onDefaultMeshLoaded;
  118768. private _onResize;
  118769. private _onFullscreenChange;
  118770. /**
  118771. * Gets a value indicating if we are currently in VR mode.
  118772. */
  118773. get isInVRMode(): boolean;
  118774. private onVrDisplayPresentChange;
  118775. private onVRDisplayChanged;
  118776. private moveButtonToBottomRight;
  118777. private displayVRButton;
  118778. private updateButtonVisibility;
  118779. private _cachedAngularSensibility;
  118780. /**
  118781. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118782. * Otherwise, will use the fullscreen API.
  118783. */
  118784. enterVR(): void;
  118785. /**
  118786. * Attempt to exit VR, or fullscreen.
  118787. */
  118788. exitVR(): void;
  118789. /**
  118790. * The position of the vr experience helper.
  118791. */
  118792. get position(): Vector3;
  118793. /**
  118794. * Sets the position of the vr experience helper.
  118795. */
  118796. set position(value: Vector3);
  118797. /**
  118798. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118799. */
  118800. enableInteractions(): void;
  118801. private get _noControllerIsActive();
  118802. private beforeRender;
  118803. private _isTeleportationFloor;
  118804. /**
  118805. * Adds a floor mesh to be used for teleportation.
  118806. * @param floorMesh the mesh to be used for teleportation.
  118807. */
  118808. addFloorMesh(floorMesh: Mesh): void;
  118809. /**
  118810. * Removes a floor mesh from being used for teleportation.
  118811. * @param floorMesh the mesh to be removed.
  118812. */
  118813. removeFloorMesh(floorMesh: Mesh): void;
  118814. /**
  118815. * Enables interactions and teleportation using the VR controllers and gaze.
  118816. * @param vrTeleportationOptions options to modify teleportation behavior.
  118817. */
  118818. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118819. private _onNewGamepadConnected;
  118820. private _tryEnableInteractionOnController;
  118821. private _onNewGamepadDisconnected;
  118822. private _enableInteractionOnController;
  118823. private _checkTeleportWithRay;
  118824. private _checkRotate;
  118825. private _checkTeleportBackwards;
  118826. private _enableTeleportationOnController;
  118827. private _createTeleportationCircles;
  118828. private _displayTeleportationTarget;
  118829. private _hideTeleportationTarget;
  118830. private _rotateCamera;
  118831. private _moveTeleportationSelectorTo;
  118832. private _workingVector;
  118833. private _workingQuaternion;
  118834. private _workingMatrix;
  118835. /**
  118836. * Time Constant Teleportation Mode
  118837. */
  118838. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118839. /**
  118840. * Speed Constant Teleportation Mode
  118841. */
  118842. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118843. /**
  118844. * Teleports the users feet to the desired location
  118845. * @param location The location where the user's feet should be placed
  118846. */
  118847. teleportCamera(location: Vector3): void;
  118848. private _convertNormalToDirectionOfRay;
  118849. private _castRayAndSelectObject;
  118850. private _notifySelectedMeshUnselected;
  118851. /**
  118852. * Permanently set new colors for the laser pointer
  118853. * @param color the new laser color
  118854. * @param pickedColor the new laser color when picked mesh detected
  118855. */
  118856. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118857. /**
  118858. * Set lighting enabled / disabled on the laser pointer of both controllers
  118859. * @param enabled should the lighting be enabled on the laser pointer
  118860. */
  118861. setLaserLightingState(enabled?: boolean): void;
  118862. /**
  118863. * Permanently set new colors for the gaze pointer
  118864. * @param color the new gaze color
  118865. * @param pickedColor the new gaze color when picked mesh detected
  118866. */
  118867. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118868. /**
  118869. * Sets the color of the laser ray from the vr controllers.
  118870. * @param color new color for the ray.
  118871. */
  118872. changeLaserColor(color: Color3): void;
  118873. /**
  118874. * Sets the color of the ray from the vr headsets gaze.
  118875. * @param color new color for the ray.
  118876. */
  118877. changeGazeColor(color: Color3): void;
  118878. /**
  118879. * Exits VR and disposes of the vr experience helper
  118880. */
  118881. dispose(): void;
  118882. /**
  118883. * Gets the name of the VRExperienceHelper class
  118884. * @returns "VRExperienceHelper"
  118885. */
  118886. getClassName(): string;
  118887. }
  118888. }
  118889. declare module BABYLON {
  118890. /**
  118891. * Contains an array of blocks representing the octree
  118892. */
  118893. export interface IOctreeContainer<T> {
  118894. /**
  118895. * Blocks within the octree
  118896. */
  118897. blocks: Array<OctreeBlock<T>>;
  118898. }
  118899. /**
  118900. * Class used to store a cell in an octree
  118901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118902. */
  118903. export class OctreeBlock<T> {
  118904. /**
  118905. * Gets the content of the current block
  118906. */
  118907. entries: T[];
  118908. /**
  118909. * Gets the list of block children
  118910. */
  118911. blocks: Array<OctreeBlock<T>>;
  118912. private _depth;
  118913. private _maxDepth;
  118914. private _capacity;
  118915. private _minPoint;
  118916. private _maxPoint;
  118917. private _boundingVectors;
  118918. private _creationFunc;
  118919. /**
  118920. * Creates a new block
  118921. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118922. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118923. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118924. * @param depth defines the current depth of this block in the octree
  118925. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118926. * @param creationFunc defines a callback to call when an element is added to the block
  118927. */
  118928. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118929. /**
  118930. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118931. */
  118932. get capacity(): number;
  118933. /**
  118934. * Gets the minimum vector (in world space) of the block's bounding box
  118935. */
  118936. get minPoint(): Vector3;
  118937. /**
  118938. * Gets the maximum vector (in world space) of the block's bounding box
  118939. */
  118940. get maxPoint(): Vector3;
  118941. /**
  118942. * Add a new element to this block
  118943. * @param entry defines the element to add
  118944. */
  118945. addEntry(entry: T): void;
  118946. /**
  118947. * Remove an element from this block
  118948. * @param entry defines the element to remove
  118949. */
  118950. removeEntry(entry: T): void;
  118951. /**
  118952. * Add an array of elements to this block
  118953. * @param entries defines the array of elements to add
  118954. */
  118955. addEntries(entries: T[]): void;
  118956. /**
  118957. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118958. * @param frustumPlanes defines the frustum planes to test
  118959. * @param selection defines the array to store current content if selection is positive
  118960. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118961. */
  118962. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118963. /**
  118964. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118965. * @param sphereCenter defines the bounding sphere center
  118966. * @param sphereRadius defines the bounding sphere radius
  118967. * @param selection defines the array to store current content if selection is positive
  118968. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118969. */
  118970. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118971. /**
  118972. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118973. * @param ray defines the ray to test with
  118974. * @param selection defines the array to store current content if selection is positive
  118975. */
  118976. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118977. /**
  118978. * Subdivide the content into child blocks (this block will then be empty)
  118979. */
  118980. createInnerBlocks(): void;
  118981. /**
  118982. * @hidden
  118983. */
  118984. 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;
  118985. }
  118986. }
  118987. declare module BABYLON {
  118988. /**
  118989. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118990. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118991. */
  118992. export class Octree<T> {
  118993. /** 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.) */
  118994. maxDepth: number;
  118995. /**
  118996. * Blocks within the octree containing objects
  118997. */
  118998. blocks: Array<OctreeBlock<T>>;
  118999. /**
  119000. * Content stored in the octree
  119001. */
  119002. dynamicContent: T[];
  119003. private _maxBlockCapacity;
  119004. private _selectionContent;
  119005. private _creationFunc;
  119006. /**
  119007. * Creates a octree
  119008. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119009. * @param creationFunc function to be used to instatiate the octree
  119010. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  119011. * @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.)
  119012. */
  119013. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  119014. /** 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.) */
  119015. maxDepth?: number);
  119016. /**
  119017. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  119018. * @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);
  119019. * @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);
  119020. * @param entries meshes to be added to the octree blocks
  119021. */
  119022. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  119023. /**
  119024. * Adds a mesh to the octree
  119025. * @param entry Mesh to add to the octree
  119026. */
  119027. addMesh(entry: T): void;
  119028. /**
  119029. * Remove an element from the octree
  119030. * @param entry defines the element to remove
  119031. */
  119032. removeMesh(entry: T): void;
  119033. /**
  119034. * Selects an array of meshes within the frustum
  119035. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  119036. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  119037. * @returns array of meshes within the frustum
  119038. */
  119039. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  119040. /**
  119041. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  119042. * @param sphereCenter defines the bounding sphere center
  119043. * @param sphereRadius defines the bounding sphere radius
  119044. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119045. * @returns an array of objects that intersect the sphere
  119046. */
  119047. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  119048. /**
  119049. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  119050. * @param ray defines the ray to test with
  119051. * @returns array of intersected objects
  119052. */
  119053. intersectsRay(ray: Ray): SmartArray<T>;
  119054. /**
  119055. * Adds a mesh into the octree block if it intersects the block
  119056. */
  119057. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  119058. /**
  119059. * Adds a submesh into the octree block if it intersects the block
  119060. */
  119061. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  119062. }
  119063. }
  119064. declare module BABYLON {
  119065. interface Scene {
  119066. /**
  119067. * @hidden
  119068. * Backing Filed
  119069. */
  119070. _selectionOctree: Octree<AbstractMesh>;
  119071. /**
  119072. * Gets the octree used to boost mesh selection (picking)
  119073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119074. */
  119075. selectionOctree: Octree<AbstractMesh>;
  119076. /**
  119077. * Creates or updates the octree used to boost selection (picking)
  119078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119079. * @param maxCapacity defines the maximum capacity per leaf
  119080. * @param maxDepth defines the maximum depth of the octree
  119081. * @returns an octree of AbstractMesh
  119082. */
  119083. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  119084. }
  119085. interface AbstractMesh {
  119086. /**
  119087. * @hidden
  119088. * Backing Field
  119089. */
  119090. _submeshesOctree: Octree<SubMesh>;
  119091. /**
  119092. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119093. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119094. * @param maxCapacity defines the maximum size of each block (64 by default)
  119095. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119096. * @returns the new octree
  119097. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119099. */
  119100. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119101. }
  119102. /**
  119103. * Defines the octree scene component responsible to manage any octrees
  119104. * in a given scene.
  119105. */
  119106. export class OctreeSceneComponent {
  119107. /**
  119108. * The component name help to identify the component in the list of scene components.
  119109. */
  119110. readonly name: string;
  119111. /**
  119112. * The scene the component belongs to.
  119113. */
  119114. scene: Scene;
  119115. /**
  119116. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119117. */
  119118. readonly checksIsEnabled: boolean;
  119119. /**
  119120. * Creates a new instance of the component for the given scene
  119121. * @param scene Defines the scene to register the component in
  119122. */
  119123. constructor(scene: Scene);
  119124. /**
  119125. * Registers the component in a given scene
  119126. */
  119127. register(): void;
  119128. /**
  119129. * Return the list of active meshes
  119130. * @returns the list of active meshes
  119131. */
  119132. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119133. /**
  119134. * Return the list of active sub meshes
  119135. * @param mesh The mesh to get the candidates sub meshes from
  119136. * @returns the list of active sub meshes
  119137. */
  119138. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119139. private _tempRay;
  119140. /**
  119141. * Return the list of sub meshes intersecting with a given local ray
  119142. * @param mesh defines the mesh to find the submesh for
  119143. * @param localRay defines the ray in local space
  119144. * @returns the list of intersecting sub meshes
  119145. */
  119146. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119147. /**
  119148. * Return the list of sub meshes colliding with a collider
  119149. * @param mesh defines the mesh to find the submesh for
  119150. * @param collider defines the collider to evaluate the collision against
  119151. * @returns the list of colliding sub meshes
  119152. */
  119153. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119154. /**
  119155. * Rebuilds the elements related to this component in case of
  119156. * context lost for instance.
  119157. */
  119158. rebuild(): void;
  119159. /**
  119160. * Disposes the component and the associated ressources.
  119161. */
  119162. dispose(): void;
  119163. }
  119164. }
  119165. declare module BABYLON {
  119166. /**
  119167. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119168. */
  119169. export class Gizmo implements IDisposable {
  119170. /** The utility layer the gizmo will be added to */
  119171. gizmoLayer: UtilityLayerRenderer;
  119172. /**
  119173. * The root mesh of the gizmo
  119174. */
  119175. _rootMesh: Mesh;
  119176. private _attachedMesh;
  119177. /**
  119178. * Ratio for the scale of the gizmo (Default: 1)
  119179. */
  119180. scaleRatio: number;
  119181. /**
  119182. * If a custom mesh has been set (Default: false)
  119183. */
  119184. protected _customMeshSet: boolean;
  119185. /**
  119186. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119187. * * When set, interactions will be enabled
  119188. */
  119189. get attachedMesh(): Nullable<AbstractMesh>;
  119190. set attachedMesh(value: Nullable<AbstractMesh>);
  119191. /**
  119192. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119193. * @param mesh The mesh to replace the default mesh of the gizmo
  119194. */
  119195. setCustomMesh(mesh: Mesh): void;
  119196. /**
  119197. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119198. */
  119199. updateGizmoRotationToMatchAttachedMesh: boolean;
  119200. /**
  119201. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119202. */
  119203. updateGizmoPositionToMatchAttachedMesh: boolean;
  119204. /**
  119205. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119206. */
  119207. updateScale: boolean;
  119208. protected _interactionsEnabled: boolean;
  119209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119210. private _beforeRenderObserver;
  119211. private _tempVector;
  119212. /**
  119213. * Creates a gizmo
  119214. * @param gizmoLayer The utility layer the gizmo will be added to
  119215. */
  119216. constructor(
  119217. /** The utility layer the gizmo will be added to */
  119218. gizmoLayer?: UtilityLayerRenderer);
  119219. /**
  119220. * Updates the gizmo to match the attached mesh's position/rotation
  119221. */
  119222. protected _update(): void;
  119223. /**
  119224. * Disposes of the gizmo
  119225. */
  119226. dispose(): void;
  119227. }
  119228. }
  119229. declare module BABYLON {
  119230. /**
  119231. * Single plane drag gizmo
  119232. */
  119233. export class PlaneDragGizmo extends Gizmo {
  119234. /**
  119235. * Drag behavior responsible for the gizmos dragging interactions
  119236. */
  119237. dragBehavior: PointerDragBehavior;
  119238. private _pointerObserver;
  119239. /**
  119240. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119241. */
  119242. snapDistance: number;
  119243. /**
  119244. * Event that fires each time the gizmo snaps to a new location.
  119245. * * snapDistance is the the change in distance
  119246. */
  119247. onSnapObservable: Observable<{
  119248. snapDistance: number;
  119249. }>;
  119250. private _plane;
  119251. private _coloredMaterial;
  119252. private _hoverMaterial;
  119253. private _isEnabled;
  119254. private _parent;
  119255. /** @hidden */
  119256. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119257. /** @hidden */
  119258. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119259. /**
  119260. * Creates a PlaneDragGizmo
  119261. * @param gizmoLayer The utility layer the gizmo will be added to
  119262. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119263. * @param color The color of the gizmo
  119264. */
  119265. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119266. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119267. /**
  119268. * If the gizmo is enabled
  119269. */
  119270. set isEnabled(value: boolean);
  119271. get isEnabled(): boolean;
  119272. /**
  119273. * Disposes of the gizmo
  119274. */
  119275. dispose(): void;
  119276. }
  119277. }
  119278. declare module BABYLON {
  119279. /**
  119280. * Gizmo that enables dragging a mesh along 3 axis
  119281. */
  119282. export class PositionGizmo extends Gizmo {
  119283. /**
  119284. * Internal gizmo used for interactions on the x axis
  119285. */
  119286. xGizmo: AxisDragGizmo;
  119287. /**
  119288. * Internal gizmo used for interactions on the y axis
  119289. */
  119290. yGizmo: AxisDragGizmo;
  119291. /**
  119292. * Internal gizmo used for interactions on the z axis
  119293. */
  119294. zGizmo: AxisDragGizmo;
  119295. /**
  119296. * Internal gizmo used for interactions on the yz plane
  119297. */
  119298. xPlaneGizmo: PlaneDragGizmo;
  119299. /**
  119300. * Internal gizmo used for interactions on the xz plane
  119301. */
  119302. yPlaneGizmo: PlaneDragGizmo;
  119303. /**
  119304. * Internal gizmo used for interactions on the xy plane
  119305. */
  119306. zPlaneGizmo: PlaneDragGizmo;
  119307. /**
  119308. * private variables
  119309. */
  119310. private _meshAttached;
  119311. private _updateGizmoRotationToMatchAttachedMesh;
  119312. private _snapDistance;
  119313. private _scaleRatio;
  119314. /** Fires an event when any of it's sub gizmos are dragged */
  119315. onDragStartObservable: Observable<unknown>;
  119316. /** Fires an event when any of it's sub gizmos are released from dragging */
  119317. onDragEndObservable: Observable<unknown>;
  119318. /**
  119319. * If set to true, planar drag is enabled
  119320. */
  119321. private _planarGizmoEnabled;
  119322. get attachedMesh(): Nullable<AbstractMesh>;
  119323. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119324. /**
  119325. * Creates a PositionGizmo
  119326. * @param gizmoLayer The utility layer the gizmo will be added to
  119327. */
  119328. constructor(gizmoLayer?: UtilityLayerRenderer);
  119329. /**
  119330. * If the planar drag gizmo is enabled
  119331. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119332. */
  119333. set planarGizmoEnabled(value: boolean);
  119334. get planarGizmoEnabled(): boolean;
  119335. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119336. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119337. /**
  119338. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119339. */
  119340. set snapDistance(value: number);
  119341. get snapDistance(): number;
  119342. /**
  119343. * Ratio for the scale of the gizmo (Default: 1)
  119344. */
  119345. set scaleRatio(value: number);
  119346. get scaleRatio(): number;
  119347. /**
  119348. * Disposes of the gizmo
  119349. */
  119350. dispose(): void;
  119351. /**
  119352. * CustomMeshes are not supported by this gizmo
  119353. * @param mesh The mesh to replace the default mesh of the gizmo
  119354. */
  119355. setCustomMesh(mesh: Mesh): void;
  119356. }
  119357. }
  119358. declare module BABYLON {
  119359. /**
  119360. * Single axis drag gizmo
  119361. */
  119362. export class AxisDragGizmo extends Gizmo {
  119363. /**
  119364. * Drag behavior responsible for the gizmos dragging interactions
  119365. */
  119366. dragBehavior: PointerDragBehavior;
  119367. private _pointerObserver;
  119368. /**
  119369. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119370. */
  119371. snapDistance: number;
  119372. /**
  119373. * Event that fires each time the gizmo snaps to a new location.
  119374. * * snapDistance is the the change in distance
  119375. */
  119376. onSnapObservable: Observable<{
  119377. snapDistance: number;
  119378. }>;
  119379. private _isEnabled;
  119380. private _parent;
  119381. private _arrow;
  119382. private _coloredMaterial;
  119383. private _hoverMaterial;
  119384. /** @hidden */
  119385. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119386. /** @hidden */
  119387. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119388. /**
  119389. * Creates an AxisDragGizmo
  119390. * @param gizmoLayer The utility layer the gizmo will be added to
  119391. * @param dragAxis The axis which the gizmo will be able to drag on
  119392. * @param color The color of the gizmo
  119393. */
  119394. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119395. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119396. /**
  119397. * If the gizmo is enabled
  119398. */
  119399. set isEnabled(value: boolean);
  119400. get isEnabled(): boolean;
  119401. /**
  119402. * Disposes of the gizmo
  119403. */
  119404. dispose(): void;
  119405. }
  119406. }
  119407. declare module BABYLON.Debug {
  119408. /**
  119409. * The Axes viewer will show 3 axes in a specific point in space
  119410. */
  119411. export class AxesViewer {
  119412. private _xAxis;
  119413. private _yAxis;
  119414. private _zAxis;
  119415. private _scaleLinesFactor;
  119416. private _instanced;
  119417. /**
  119418. * Gets the hosting scene
  119419. */
  119420. scene: Scene;
  119421. /**
  119422. * Gets or sets a number used to scale line length
  119423. */
  119424. scaleLines: number;
  119425. /** Gets the node hierarchy used to render x-axis */
  119426. get xAxis(): TransformNode;
  119427. /** Gets the node hierarchy used to render y-axis */
  119428. get yAxis(): TransformNode;
  119429. /** Gets the node hierarchy used to render z-axis */
  119430. get zAxis(): TransformNode;
  119431. /**
  119432. * Creates a new AxesViewer
  119433. * @param scene defines the hosting scene
  119434. * @param scaleLines defines a number used to scale line length (1 by default)
  119435. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119436. * @param xAxis defines the node hierarchy used to render the x-axis
  119437. * @param yAxis defines the node hierarchy used to render the y-axis
  119438. * @param zAxis defines the node hierarchy used to render the z-axis
  119439. */
  119440. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119441. /**
  119442. * Force the viewer to update
  119443. * @param position defines the position of the viewer
  119444. * @param xaxis defines the x axis of the viewer
  119445. * @param yaxis defines the y axis of the viewer
  119446. * @param zaxis defines the z axis of the viewer
  119447. */
  119448. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119449. /**
  119450. * Creates an instance of this axes viewer.
  119451. * @returns a new axes viewer with instanced meshes
  119452. */
  119453. createInstance(): AxesViewer;
  119454. /** Releases resources */
  119455. dispose(): void;
  119456. private static _SetRenderingGroupId;
  119457. }
  119458. }
  119459. declare module BABYLON.Debug {
  119460. /**
  119461. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119462. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119463. */
  119464. export class BoneAxesViewer extends AxesViewer {
  119465. /**
  119466. * Gets or sets the target mesh where to display the axes viewer
  119467. */
  119468. mesh: Nullable<Mesh>;
  119469. /**
  119470. * Gets or sets the target bone where to display the axes viewer
  119471. */
  119472. bone: Nullable<Bone>;
  119473. /** Gets current position */
  119474. pos: Vector3;
  119475. /** Gets direction of X axis */
  119476. xaxis: Vector3;
  119477. /** Gets direction of Y axis */
  119478. yaxis: Vector3;
  119479. /** Gets direction of Z axis */
  119480. zaxis: Vector3;
  119481. /**
  119482. * Creates a new BoneAxesViewer
  119483. * @param scene defines the hosting scene
  119484. * @param bone defines the target bone
  119485. * @param mesh defines the target mesh
  119486. * @param scaleLines defines a scaling factor for line length (1 by default)
  119487. */
  119488. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119489. /**
  119490. * Force the viewer to update
  119491. */
  119492. update(): void;
  119493. /** Releases resources */
  119494. dispose(): void;
  119495. }
  119496. }
  119497. declare module BABYLON {
  119498. /**
  119499. * Interface used to define scene explorer extensibility option
  119500. */
  119501. export interface IExplorerExtensibilityOption {
  119502. /**
  119503. * Define the option label
  119504. */
  119505. label: string;
  119506. /**
  119507. * Defines the action to execute on click
  119508. */
  119509. action: (entity: any) => void;
  119510. }
  119511. /**
  119512. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119513. */
  119514. export interface IExplorerExtensibilityGroup {
  119515. /**
  119516. * Defines a predicate to test if a given type mut be extended
  119517. */
  119518. predicate: (entity: any) => boolean;
  119519. /**
  119520. * Gets the list of options added to a type
  119521. */
  119522. entries: IExplorerExtensibilityOption[];
  119523. }
  119524. /**
  119525. * Interface used to define the options to use to create the Inspector
  119526. */
  119527. export interface IInspectorOptions {
  119528. /**
  119529. * Display in overlay mode (default: false)
  119530. */
  119531. overlay?: boolean;
  119532. /**
  119533. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119534. */
  119535. globalRoot?: HTMLElement;
  119536. /**
  119537. * Display the Scene explorer
  119538. */
  119539. showExplorer?: boolean;
  119540. /**
  119541. * Display the property inspector
  119542. */
  119543. showInspector?: boolean;
  119544. /**
  119545. * Display in embed mode (both panes on the right)
  119546. */
  119547. embedMode?: boolean;
  119548. /**
  119549. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119550. */
  119551. handleResize?: boolean;
  119552. /**
  119553. * Allow the panes to popup (default: true)
  119554. */
  119555. enablePopup?: boolean;
  119556. /**
  119557. * Allow the panes to be closed by users (default: true)
  119558. */
  119559. enableClose?: boolean;
  119560. /**
  119561. * Optional list of extensibility entries
  119562. */
  119563. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119564. /**
  119565. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119566. */
  119567. inspectorURL?: string;
  119568. /**
  119569. * Optional initial tab (default to DebugLayerTab.Properties)
  119570. */
  119571. initialTab?: DebugLayerTab;
  119572. }
  119573. interface Scene {
  119574. /**
  119575. * @hidden
  119576. * Backing field
  119577. */
  119578. _debugLayer: DebugLayer;
  119579. /**
  119580. * Gets the debug layer (aka Inspector) associated with the scene
  119581. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119582. */
  119583. debugLayer: DebugLayer;
  119584. }
  119585. /**
  119586. * Enum of inspector action tab
  119587. */
  119588. export enum DebugLayerTab {
  119589. /**
  119590. * Properties tag (default)
  119591. */
  119592. Properties = 0,
  119593. /**
  119594. * Debug tab
  119595. */
  119596. Debug = 1,
  119597. /**
  119598. * Statistics tab
  119599. */
  119600. Statistics = 2,
  119601. /**
  119602. * Tools tab
  119603. */
  119604. Tools = 3,
  119605. /**
  119606. * Settings tab
  119607. */
  119608. Settings = 4
  119609. }
  119610. /**
  119611. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119612. * what is happening in your scene
  119613. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119614. */
  119615. export class DebugLayer {
  119616. /**
  119617. * Define the url to get the inspector script from.
  119618. * By default it uses the babylonjs CDN.
  119619. * @ignoreNaming
  119620. */
  119621. static InspectorURL: string;
  119622. private _scene;
  119623. private BJSINSPECTOR;
  119624. private _onPropertyChangedObservable?;
  119625. /**
  119626. * Observable triggered when a property is changed through the inspector.
  119627. */
  119628. get onPropertyChangedObservable(): any;
  119629. /**
  119630. * Instantiates a new debug layer.
  119631. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119632. * what is happening in your scene
  119633. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119634. * @param scene Defines the scene to inspect
  119635. */
  119636. constructor(scene: Scene);
  119637. /** Creates the inspector window. */
  119638. private _createInspector;
  119639. /**
  119640. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119641. * @param entity defines the entity to select
  119642. * @param lineContainerTitle defines the specific block to highlight
  119643. */
  119644. select(entity: any, lineContainerTitle?: string): void;
  119645. /** Get the inspector from bundle or global */
  119646. private _getGlobalInspector;
  119647. /**
  119648. * Get if the inspector is visible or not.
  119649. * @returns true if visible otherwise, false
  119650. */
  119651. isVisible(): boolean;
  119652. /**
  119653. * Hide the inspector and close its window.
  119654. */
  119655. hide(): void;
  119656. /**
  119657. * Launch the debugLayer.
  119658. * @param config Define the configuration of the inspector
  119659. * @return a promise fulfilled when the debug layer is visible
  119660. */
  119661. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119662. }
  119663. }
  119664. declare module BABYLON {
  119665. /**
  119666. * Class containing static functions to help procedurally build meshes
  119667. */
  119668. export class BoxBuilder {
  119669. /**
  119670. * Creates a box mesh
  119671. * * The parameter `size` sets the size (float) of each box side (default 1)
  119672. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119673. * * 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)
  119674. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119678. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119679. * @param name defines the name of the mesh
  119680. * @param options defines the options used to create the mesh
  119681. * @param scene defines the hosting scene
  119682. * @returns the box mesh
  119683. */
  119684. static CreateBox(name: string, options: {
  119685. size?: number;
  119686. width?: number;
  119687. height?: number;
  119688. depth?: number;
  119689. faceUV?: Vector4[];
  119690. faceColors?: Color4[];
  119691. sideOrientation?: number;
  119692. frontUVs?: Vector4;
  119693. backUVs?: Vector4;
  119694. wrap?: boolean;
  119695. topBaseAt?: number;
  119696. bottomBaseAt?: number;
  119697. updatable?: boolean;
  119698. }, scene?: Nullable<Scene>): Mesh;
  119699. }
  119700. }
  119701. declare module BABYLON.Debug {
  119702. /**
  119703. * Used to show the physics impostor around the specific mesh
  119704. */
  119705. export class PhysicsViewer {
  119706. /** @hidden */
  119707. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119708. /** @hidden */
  119709. protected _meshes: Array<Nullable<AbstractMesh>>;
  119710. /** @hidden */
  119711. protected _scene: Nullable<Scene>;
  119712. /** @hidden */
  119713. protected _numMeshes: number;
  119714. /** @hidden */
  119715. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119716. private _renderFunction;
  119717. private _utilityLayer;
  119718. private _debugBoxMesh;
  119719. private _debugSphereMesh;
  119720. private _debugCylinderMesh;
  119721. private _debugMaterial;
  119722. private _debugMeshMeshes;
  119723. /**
  119724. * Creates a new PhysicsViewer
  119725. * @param scene defines the hosting scene
  119726. */
  119727. constructor(scene: Scene);
  119728. /** @hidden */
  119729. protected _updateDebugMeshes(): void;
  119730. /**
  119731. * Renders a specified physic impostor
  119732. * @param impostor defines the impostor to render
  119733. * @param targetMesh defines the mesh represented by the impostor
  119734. * @returns the new debug mesh used to render the impostor
  119735. */
  119736. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119737. /**
  119738. * Hides a specified physic impostor
  119739. * @param impostor defines the impostor to hide
  119740. */
  119741. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119742. private _getDebugMaterial;
  119743. private _getDebugBoxMesh;
  119744. private _getDebugSphereMesh;
  119745. private _getDebugCylinderMesh;
  119746. private _getDebugMeshMesh;
  119747. private _getDebugMesh;
  119748. /** Releases all resources */
  119749. dispose(): void;
  119750. }
  119751. }
  119752. declare module BABYLON {
  119753. /**
  119754. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119755. * in order to better appreciate the issue one might have.
  119756. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119757. */
  119758. export class RayHelper {
  119759. /**
  119760. * Defines the ray we are currently tryin to visualize.
  119761. */
  119762. ray: Nullable<Ray>;
  119763. private _renderPoints;
  119764. private _renderLine;
  119765. private _renderFunction;
  119766. private _scene;
  119767. private _updateToMeshFunction;
  119768. private _attachedToMesh;
  119769. private _meshSpaceDirection;
  119770. private _meshSpaceOrigin;
  119771. /**
  119772. * Helper function to create a colored helper in a scene in one line.
  119773. * @param ray Defines the ray we are currently tryin to visualize
  119774. * @param scene Defines the scene the ray is used in
  119775. * @param color Defines the color we want to see the ray in
  119776. * @returns The newly created ray helper.
  119777. */
  119778. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119779. /**
  119780. * Instantiate a new ray helper.
  119781. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119782. * in order to better appreciate the issue one might have.
  119783. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119784. * @param ray Defines the ray we are currently tryin to visualize
  119785. */
  119786. constructor(ray: Ray);
  119787. /**
  119788. * Shows the ray we are willing to debug.
  119789. * @param scene Defines the scene the ray needs to be rendered in
  119790. * @param color Defines the color the ray needs to be rendered in
  119791. */
  119792. show(scene: Scene, color?: Color3): void;
  119793. /**
  119794. * Hides the ray we are debugging.
  119795. */
  119796. hide(): void;
  119797. private _render;
  119798. /**
  119799. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119800. * @param mesh Defines the mesh we want the helper attached to
  119801. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119802. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119803. * @param length Defines the length of the ray
  119804. */
  119805. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119806. /**
  119807. * Detach the ray helper from the mesh it has previously been attached to.
  119808. */
  119809. detachFromMesh(): void;
  119810. private _updateToMesh;
  119811. /**
  119812. * Dispose the helper and release its associated resources.
  119813. */
  119814. dispose(): void;
  119815. }
  119816. }
  119817. declare module BABYLON.Debug {
  119818. /**
  119819. * Class used to render a debug view of a given skeleton
  119820. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119821. */
  119822. export class SkeletonViewer {
  119823. /** defines the skeleton to render */
  119824. skeleton: Skeleton;
  119825. /** defines the mesh attached to the skeleton */
  119826. mesh: AbstractMesh;
  119827. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119828. autoUpdateBonesMatrices: boolean;
  119829. /** defines the rendering group id to use with the viewer */
  119830. renderingGroupId: number;
  119831. /** Gets or sets the color used to render the skeleton */
  119832. color: Color3;
  119833. private _scene;
  119834. private _debugLines;
  119835. private _debugMesh;
  119836. private _isEnabled;
  119837. private _renderFunction;
  119838. private _utilityLayer;
  119839. /**
  119840. * Returns the mesh used to render the bones
  119841. */
  119842. get debugMesh(): Nullable<LinesMesh>;
  119843. /**
  119844. * Creates a new SkeletonViewer
  119845. * @param skeleton defines the skeleton to render
  119846. * @param mesh defines the mesh attached to the skeleton
  119847. * @param scene defines the hosting scene
  119848. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119849. * @param renderingGroupId defines the rendering group id to use with the viewer
  119850. */
  119851. constructor(
  119852. /** defines the skeleton to render */
  119853. skeleton: Skeleton,
  119854. /** defines the mesh attached to the skeleton */
  119855. mesh: AbstractMesh, scene: Scene,
  119856. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119857. autoUpdateBonesMatrices?: boolean,
  119858. /** defines the rendering group id to use with the viewer */
  119859. renderingGroupId?: number);
  119860. /** Gets or sets a boolean indicating if the viewer is enabled */
  119861. set isEnabled(value: boolean);
  119862. get isEnabled(): boolean;
  119863. private _getBonePosition;
  119864. private _getLinesForBonesWithLength;
  119865. private _getLinesForBonesNoLength;
  119866. /** Update the viewer to sync with current skeleton state */
  119867. update(): void;
  119868. /** Release associated resources */
  119869. dispose(): void;
  119870. }
  119871. }
  119872. declare module BABYLON {
  119873. /**
  119874. * Options to create the null engine
  119875. */
  119876. export class NullEngineOptions {
  119877. /**
  119878. * Render width (Default: 512)
  119879. */
  119880. renderWidth: number;
  119881. /**
  119882. * Render height (Default: 256)
  119883. */
  119884. renderHeight: number;
  119885. /**
  119886. * Texture size (Default: 512)
  119887. */
  119888. textureSize: number;
  119889. /**
  119890. * If delta time between frames should be constant
  119891. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119892. */
  119893. deterministicLockstep: boolean;
  119894. /**
  119895. * Maximum about of steps between frames (Default: 4)
  119896. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119897. */
  119898. lockstepMaxSteps: number;
  119899. }
  119900. /**
  119901. * The null engine class provides support for headless version of babylon.js.
  119902. * This can be used in server side scenario or for testing purposes
  119903. */
  119904. export class NullEngine extends Engine {
  119905. private _options;
  119906. /**
  119907. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119909. * @returns true if engine is in deterministic lock step mode
  119910. */
  119911. isDeterministicLockStep(): boolean;
  119912. /**
  119913. * Gets the max steps when engine is running in deterministic lock step
  119914. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119915. * @returns the max steps
  119916. */
  119917. getLockstepMaxSteps(): number;
  119918. /**
  119919. * Gets the current hardware scaling level.
  119920. * By default the hardware scaling level is computed from the window device ratio.
  119921. * 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.
  119922. * @returns a number indicating the current hardware scaling level
  119923. */
  119924. getHardwareScalingLevel(): number;
  119925. constructor(options?: NullEngineOptions);
  119926. /**
  119927. * Creates a vertex buffer
  119928. * @param vertices the data for the vertex buffer
  119929. * @returns the new WebGL static buffer
  119930. */
  119931. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119932. /**
  119933. * Creates a new index buffer
  119934. * @param indices defines the content of the index buffer
  119935. * @param updatable defines if the index buffer must be updatable
  119936. * @returns a new webGL buffer
  119937. */
  119938. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119939. /**
  119940. * Clear the current render buffer or the current render target (if any is set up)
  119941. * @param color defines the color to use
  119942. * @param backBuffer defines if the back buffer must be cleared
  119943. * @param depth defines if the depth buffer must be cleared
  119944. * @param stencil defines if the stencil buffer must be cleared
  119945. */
  119946. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119947. /**
  119948. * Gets the current render width
  119949. * @param useScreen defines if screen size must be used (or the current render target if any)
  119950. * @returns a number defining the current render width
  119951. */
  119952. getRenderWidth(useScreen?: boolean): number;
  119953. /**
  119954. * Gets the current render height
  119955. * @param useScreen defines if screen size must be used (or the current render target if any)
  119956. * @returns a number defining the current render height
  119957. */
  119958. getRenderHeight(useScreen?: boolean): number;
  119959. /**
  119960. * Set the WebGL's viewport
  119961. * @param viewport defines the viewport element to be used
  119962. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119963. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119964. */
  119965. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119966. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119967. /**
  119968. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119969. * @param pipelineContext defines the pipeline context to use
  119970. * @param uniformsNames defines the list of uniform names
  119971. * @returns an array of webGL uniform locations
  119972. */
  119973. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119974. /**
  119975. * Gets the lsit of active attributes for a given webGL program
  119976. * @param pipelineContext defines the pipeline context to use
  119977. * @param attributesNames defines the list of attribute names to get
  119978. * @returns an array of indices indicating the offset of each attribute
  119979. */
  119980. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119981. /**
  119982. * Binds an effect to the webGL context
  119983. * @param effect defines the effect to bind
  119984. */
  119985. bindSamplers(effect: Effect): void;
  119986. /**
  119987. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119988. * @param effect defines the effect to activate
  119989. */
  119990. enableEffect(effect: Effect): void;
  119991. /**
  119992. * Set various states to the webGL context
  119993. * @param culling defines backface culling state
  119994. * @param zOffset defines the value to apply to zOffset (0 by default)
  119995. * @param force defines if states must be applied even if cache is up to date
  119996. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119997. */
  119998. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119999. /**
  120000. * Set the value of an uniform to an array of int32
  120001. * @param uniform defines the webGL uniform location where to store the value
  120002. * @param array defines the array of int32 to store
  120003. */
  120004. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120005. /**
  120006. * Set the value of an uniform to an array of int32 (stored as vec2)
  120007. * @param uniform defines the webGL uniform location where to store the value
  120008. * @param array defines the array of int32 to store
  120009. */
  120010. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120011. /**
  120012. * Set the value of an uniform to an array of int32 (stored as vec3)
  120013. * @param uniform defines the webGL uniform location where to store the value
  120014. * @param array defines the array of int32 to store
  120015. */
  120016. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120017. /**
  120018. * Set the value of an uniform to an array of int32 (stored as vec4)
  120019. * @param uniform defines the webGL uniform location where to store the value
  120020. * @param array defines the array of int32 to store
  120021. */
  120022. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120023. /**
  120024. * Set the value of an uniform to an array of float32
  120025. * @param uniform defines the webGL uniform location where to store the value
  120026. * @param array defines the array of float32 to store
  120027. */
  120028. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120029. /**
  120030. * Set the value of an uniform to an array of float32 (stored as vec2)
  120031. * @param uniform defines the webGL uniform location where to store the value
  120032. * @param array defines the array of float32 to store
  120033. */
  120034. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120035. /**
  120036. * Set the value of an uniform to an array of float32 (stored as vec3)
  120037. * @param uniform defines the webGL uniform location where to store the value
  120038. * @param array defines the array of float32 to store
  120039. */
  120040. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120041. /**
  120042. * Set the value of an uniform to an array of float32 (stored as vec4)
  120043. * @param uniform defines the webGL uniform location where to store the value
  120044. * @param array defines the array of float32 to store
  120045. */
  120046. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120047. /**
  120048. * Set the value of an uniform to an array of number
  120049. * @param uniform defines the webGL uniform location where to store the value
  120050. * @param array defines the array of number to store
  120051. */
  120052. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120053. /**
  120054. * Set the value of an uniform to an array of number (stored as vec2)
  120055. * @param uniform defines the webGL uniform location where to store the value
  120056. * @param array defines the array of number to store
  120057. */
  120058. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120059. /**
  120060. * Set the value of an uniform to an array of number (stored as vec3)
  120061. * @param uniform defines the webGL uniform location where to store the value
  120062. * @param array defines the array of number to store
  120063. */
  120064. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120065. /**
  120066. * Set the value of an uniform to an array of number (stored as vec4)
  120067. * @param uniform defines the webGL uniform location where to store the value
  120068. * @param array defines the array of number to store
  120069. */
  120070. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120071. /**
  120072. * Set the value of an uniform to an array of float32 (stored as matrices)
  120073. * @param uniform defines the webGL uniform location where to store the value
  120074. * @param matrices defines the array of float32 to store
  120075. */
  120076. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120077. /**
  120078. * Set the value of an uniform to a matrix (3x3)
  120079. * @param uniform defines the webGL uniform location where to store the value
  120080. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120081. */
  120082. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120083. /**
  120084. * Set the value of an uniform to a matrix (2x2)
  120085. * @param uniform defines the webGL uniform location where to store the value
  120086. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120087. */
  120088. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120089. /**
  120090. * Set the value of an uniform to a number (float)
  120091. * @param uniform defines the webGL uniform location where to store the value
  120092. * @param value defines the float number to store
  120093. */
  120094. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120095. /**
  120096. * Set the value of an uniform to a vec2
  120097. * @param uniform defines the webGL uniform location where to store the value
  120098. * @param x defines the 1st component of the value
  120099. * @param y defines the 2nd component of the value
  120100. */
  120101. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120102. /**
  120103. * Set the value of an uniform to a vec3
  120104. * @param uniform defines the webGL uniform location where to store the value
  120105. * @param x defines the 1st component of the value
  120106. * @param y defines the 2nd component of the value
  120107. * @param z defines the 3rd component of the value
  120108. */
  120109. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120110. /**
  120111. * Set the value of an uniform to a boolean
  120112. * @param uniform defines the webGL uniform location where to store the value
  120113. * @param bool defines the boolean to store
  120114. */
  120115. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120116. /**
  120117. * Set the value of an uniform to a vec4
  120118. * @param uniform defines the webGL uniform location where to store the value
  120119. * @param x defines the 1st component of the value
  120120. * @param y defines the 2nd component of the value
  120121. * @param z defines the 3rd component of the value
  120122. * @param w defines the 4th component of the value
  120123. */
  120124. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120125. /**
  120126. * Sets the current alpha mode
  120127. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120128. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120129. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120130. */
  120131. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120132. /**
  120133. * Bind webGl buffers directly to the webGL context
  120134. * @param vertexBuffers defines the vertex buffer to bind
  120135. * @param indexBuffer defines the index buffer to bind
  120136. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120137. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120138. * @param effect defines the effect associated with the vertex buffer
  120139. */
  120140. bindBuffers(vertexBuffers: {
  120141. [key: string]: VertexBuffer;
  120142. }, indexBuffer: DataBuffer, effect: Effect): void;
  120143. /**
  120144. * Force the entire cache to be cleared
  120145. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120146. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120147. */
  120148. wipeCaches(bruteForce?: boolean): void;
  120149. /**
  120150. * Send a draw order
  120151. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120152. * @param indexStart defines the starting index
  120153. * @param indexCount defines the number of index to draw
  120154. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120155. */
  120156. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120157. /**
  120158. * Draw a list of indexed primitives
  120159. * @param fillMode defines the primitive to use
  120160. * @param indexStart defines the starting index
  120161. * @param indexCount defines the number of index to draw
  120162. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120163. */
  120164. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120165. /**
  120166. * Draw a list of unindexed primitives
  120167. * @param fillMode defines the primitive to use
  120168. * @param verticesStart defines the index of first vertex to draw
  120169. * @param verticesCount defines the count of vertices to draw
  120170. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120171. */
  120172. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120173. /** @hidden */
  120174. _createTexture(): WebGLTexture;
  120175. /** @hidden */
  120176. _releaseTexture(texture: InternalTexture): void;
  120177. /**
  120178. * Usually called from Texture.ts.
  120179. * Passed information to create a WebGLTexture
  120180. * @param urlArg defines a value which contains one of the following:
  120181. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120182. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120183. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120184. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120185. * @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)
  120186. * @param scene needed for loading to the correct scene
  120187. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120188. * @param onLoad optional callback to be called upon successful completion
  120189. * @param onError optional callback to be called upon failure
  120190. * @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
  120191. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120192. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120193. * @param forcedExtension defines the extension to use to pick the right loader
  120194. * @param mimeType defines an optional mime type
  120195. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120196. */
  120197. 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;
  120198. /**
  120199. * Creates a new render target texture
  120200. * @param size defines the size of the texture
  120201. * @param options defines the options used to create the texture
  120202. * @returns a new render target texture stored in an InternalTexture
  120203. */
  120204. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120205. /**
  120206. * Update the sampling mode of a given texture
  120207. * @param samplingMode defines the required sampling mode
  120208. * @param texture defines the texture to update
  120209. */
  120210. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120211. /**
  120212. * Binds the frame buffer to the specified texture.
  120213. * @param texture The texture to render to or null for the default canvas
  120214. * @param faceIndex The face of the texture to render to in case of cube texture
  120215. * @param requiredWidth The width of the target to render to
  120216. * @param requiredHeight The height of the target to render to
  120217. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120218. * @param lodLevel defines le lod level to bind to the frame buffer
  120219. */
  120220. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120221. /**
  120222. * Unbind the current render target texture from the webGL context
  120223. * @param texture defines the render target texture to unbind
  120224. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120225. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120226. */
  120227. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120228. /**
  120229. * Creates a dynamic vertex buffer
  120230. * @param vertices the data for the dynamic vertex buffer
  120231. * @returns the new WebGL dynamic buffer
  120232. */
  120233. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120234. /**
  120235. * Update the content of a dynamic texture
  120236. * @param texture defines the texture to update
  120237. * @param canvas defines the canvas containing the source
  120238. * @param invertY defines if data must be stored with Y axis inverted
  120239. * @param premulAlpha defines if alpha is stored as premultiplied
  120240. * @param format defines the format of the data
  120241. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120242. */
  120243. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120244. /**
  120245. * Gets a boolean indicating if all created effects are ready
  120246. * @returns true if all effects are ready
  120247. */
  120248. areAllEffectsReady(): boolean;
  120249. /**
  120250. * @hidden
  120251. * Get the current error code of the webGL context
  120252. * @returns the error code
  120253. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120254. */
  120255. getError(): number;
  120256. /** @hidden */
  120257. _getUnpackAlignement(): number;
  120258. /** @hidden */
  120259. _unpackFlipY(value: boolean): void;
  120260. /**
  120261. * Update a dynamic index buffer
  120262. * @param indexBuffer defines the target index buffer
  120263. * @param indices defines the data to update
  120264. * @param offset defines the offset in the target index buffer where update should start
  120265. */
  120266. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120267. /**
  120268. * Updates a dynamic vertex buffer.
  120269. * @param vertexBuffer the vertex buffer to update
  120270. * @param vertices the data used to update the vertex buffer
  120271. * @param byteOffset the byte offset of the data (optional)
  120272. * @param byteLength the byte length of the data (optional)
  120273. */
  120274. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120275. /** @hidden */
  120276. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120277. /** @hidden */
  120278. _bindTexture(channel: number, texture: InternalTexture): void;
  120279. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120280. /**
  120281. * 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
  120282. */
  120283. releaseEffects(): void;
  120284. displayLoadingUI(): void;
  120285. hideLoadingUI(): void;
  120286. /** @hidden */
  120287. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120288. /** @hidden */
  120289. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120290. /** @hidden */
  120291. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120292. /** @hidden */
  120293. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120294. }
  120295. }
  120296. declare module BABYLON {
  120297. /**
  120298. * @hidden
  120299. **/
  120300. export class _TimeToken {
  120301. _startTimeQuery: Nullable<WebGLQuery>;
  120302. _endTimeQuery: Nullable<WebGLQuery>;
  120303. _timeElapsedQuery: Nullable<WebGLQuery>;
  120304. _timeElapsedQueryEnded: boolean;
  120305. }
  120306. }
  120307. declare module BABYLON {
  120308. /** @hidden */
  120309. export class _OcclusionDataStorage {
  120310. /** @hidden */
  120311. occlusionInternalRetryCounter: number;
  120312. /** @hidden */
  120313. isOcclusionQueryInProgress: boolean;
  120314. /** @hidden */
  120315. isOccluded: boolean;
  120316. /** @hidden */
  120317. occlusionRetryCount: number;
  120318. /** @hidden */
  120319. occlusionType: number;
  120320. /** @hidden */
  120321. occlusionQueryAlgorithmType: number;
  120322. }
  120323. interface Engine {
  120324. /**
  120325. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120326. * @return the new query
  120327. */
  120328. createQuery(): WebGLQuery;
  120329. /**
  120330. * Delete and release a webGL query
  120331. * @param query defines the query to delete
  120332. * @return the current engine
  120333. */
  120334. deleteQuery(query: WebGLQuery): Engine;
  120335. /**
  120336. * Check if a given query has resolved and got its value
  120337. * @param query defines the query to check
  120338. * @returns true if the query got its value
  120339. */
  120340. isQueryResultAvailable(query: WebGLQuery): boolean;
  120341. /**
  120342. * Gets the value of a given query
  120343. * @param query defines the query to check
  120344. * @returns the value of the query
  120345. */
  120346. getQueryResult(query: WebGLQuery): number;
  120347. /**
  120348. * Initiates an occlusion query
  120349. * @param algorithmType defines the algorithm to use
  120350. * @param query defines the query to use
  120351. * @returns the current engine
  120352. * @see http://doc.babylonjs.com/features/occlusionquery
  120353. */
  120354. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120355. /**
  120356. * Ends an occlusion query
  120357. * @see http://doc.babylonjs.com/features/occlusionquery
  120358. * @param algorithmType defines the algorithm to use
  120359. * @returns the current engine
  120360. */
  120361. endOcclusionQuery(algorithmType: number): Engine;
  120362. /**
  120363. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120364. * Please note that only one query can be issued at a time
  120365. * @returns a time token used to track the time span
  120366. */
  120367. startTimeQuery(): Nullable<_TimeToken>;
  120368. /**
  120369. * Ends a time query
  120370. * @param token defines the token used to measure the time span
  120371. * @returns the time spent (in ns)
  120372. */
  120373. endTimeQuery(token: _TimeToken): int;
  120374. /** @hidden */
  120375. _currentNonTimestampToken: Nullable<_TimeToken>;
  120376. /** @hidden */
  120377. _createTimeQuery(): WebGLQuery;
  120378. /** @hidden */
  120379. _deleteTimeQuery(query: WebGLQuery): void;
  120380. /** @hidden */
  120381. _getGlAlgorithmType(algorithmType: number): number;
  120382. /** @hidden */
  120383. _getTimeQueryResult(query: WebGLQuery): any;
  120384. /** @hidden */
  120385. _getTimeQueryAvailability(query: WebGLQuery): any;
  120386. }
  120387. interface AbstractMesh {
  120388. /**
  120389. * Backing filed
  120390. * @hidden
  120391. */
  120392. __occlusionDataStorage: _OcclusionDataStorage;
  120393. /**
  120394. * Access property
  120395. * @hidden
  120396. */
  120397. _occlusionDataStorage: _OcclusionDataStorage;
  120398. /**
  120399. * 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.
  120400. * The default value is -1 which means don't break the query and wait till the result
  120401. * @see http://doc.babylonjs.com/features/occlusionquery
  120402. */
  120403. occlusionRetryCount: number;
  120404. /**
  120405. * 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:
  120406. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120407. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120408. * * 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.
  120409. * @see http://doc.babylonjs.com/features/occlusionquery
  120410. */
  120411. occlusionType: number;
  120412. /**
  120413. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120414. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120415. * * 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.
  120416. * @see http://doc.babylonjs.com/features/occlusionquery
  120417. */
  120418. occlusionQueryAlgorithmType: number;
  120419. /**
  120420. * 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
  120421. * @see http://doc.babylonjs.com/features/occlusionquery
  120422. */
  120423. isOccluded: boolean;
  120424. /**
  120425. * Flag to check the progress status of the query
  120426. * @see http://doc.babylonjs.com/features/occlusionquery
  120427. */
  120428. isOcclusionQueryInProgress: boolean;
  120429. }
  120430. }
  120431. declare module BABYLON {
  120432. /** @hidden */
  120433. export var _forceTransformFeedbackToBundle: boolean;
  120434. interface Engine {
  120435. /**
  120436. * Creates a webGL transform feedback object
  120437. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120438. * @returns the webGL transform feedback object
  120439. */
  120440. createTransformFeedback(): WebGLTransformFeedback;
  120441. /**
  120442. * Delete a webGL transform feedback object
  120443. * @param value defines the webGL transform feedback object to delete
  120444. */
  120445. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120446. /**
  120447. * Bind a webGL transform feedback object to the webgl context
  120448. * @param value defines the webGL transform feedback object to bind
  120449. */
  120450. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120451. /**
  120452. * Begins a transform feedback operation
  120453. * @param usePoints defines if points or triangles must be used
  120454. */
  120455. beginTransformFeedback(usePoints: boolean): void;
  120456. /**
  120457. * Ends a transform feedback operation
  120458. */
  120459. endTransformFeedback(): void;
  120460. /**
  120461. * Specify the varyings to use with transform feedback
  120462. * @param program defines the associated webGL program
  120463. * @param value defines the list of strings representing the varying names
  120464. */
  120465. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120466. /**
  120467. * Bind a webGL buffer for a transform feedback operation
  120468. * @param value defines the webGL buffer to bind
  120469. */
  120470. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120471. }
  120472. }
  120473. declare module BABYLON {
  120474. /**
  120475. * Creation options of the multi render target texture.
  120476. */
  120477. export interface IMultiRenderTargetOptions {
  120478. /**
  120479. * Define if the texture needs to create mip maps after render.
  120480. */
  120481. generateMipMaps?: boolean;
  120482. /**
  120483. * Define the types of all the draw buffers we want to create
  120484. */
  120485. types?: number[];
  120486. /**
  120487. * Define the sampling modes of all the draw buffers we want to create
  120488. */
  120489. samplingModes?: number[];
  120490. /**
  120491. * Define if a depth buffer is required
  120492. */
  120493. generateDepthBuffer?: boolean;
  120494. /**
  120495. * Define if a stencil buffer is required
  120496. */
  120497. generateStencilBuffer?: boolean;
  120498. /**
  120499. * Define if a depth texture is required instead of a depth buffer
  120500. */
  120501. generateDepthTexture?: boolean;
  120502. /**
  120503. * Define the number of desired draw buffers
  120504. */
  120505. textureCount?: number;
  120506. /**
  120507. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120508. */
  120509. doNotChangeAspectRatio?: boolean;
  120510. /**
  120511. * Define the default type of the buffers we are creating
  120512. */
  120513. defaultType?: number;
  120514. }
  120515. /**
  120516. * A multi render target, like a render target provides the ability to render to a texture.
  120517. * Unlike the render target, it can render to several draw buffers in one draw.
  120518. * This is specially interesting in deferred rendering or for any effects requiring more than
  120519. * just one color from a single pass.
  120520. */
  120521. export class MultiRenderTarget extends RenderTargetTexture {
  120522. private _internalTextures;
  120523. private _textures;
  120524. private _multiRenderTargetOptions;
  120525. /**
  120526. * Get if draw buffers are currently supported by the used hardware and browser.
  120527. */
  120528. get isSupported(): boolean;
  120529. /**
  120530. * Get the list of textures generated by the multi render target.
  120531. */
  120532. get textures(): Texture[];
  120533. /**
  120534. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120535. */
  120536. get depthTexture(): Texture;
  120537. /**
  120538. * Set the wrapping mode on U of all the textures we are rendering to.
  120539. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120540. */
  120541. set wrapU(wrap: number);
  120542. /**
  120543. * Set the wrapping mode on V of all the textures we are rendering to.
  120544. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120545. */
  120546. set wrapV(wrap: number);
  120547. /**
  120548. * Instantiate a new multi render target texture.
  120549. * A multi render target, like a render target provides the ability to render to a texture.
  120550. * Unlike the render target, it can render to several draw buffers in one draw.
  120551. * This is specially interesting in deferred rendering or for any effects requiring more than
  120552. * just one color from a single pass.
  120553. * @param name Define the name of the texture
  120554. * @param size Define the size of the buffers to render to
  120555. * @param count Define the number of target we are rendering into
  120556. * @param scene Define the scene the texture belongs to
  120557. * @param options Define the options used to create the multi render target
  120558. */
  120559. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120560. /** @hidden */
  120561. _rebuild(): void;
  120562. private _createInternalTextures;
  120563. private _createTextures;
  120564. /**
  120565. * Define the number of samples used if MSAA is enabled.
  120566. */
  120567. get samples(): number;
  120568. set samples(value: number);
  120569. /**
  120570. * Resize all the textures in the multi render target.
  120571. * Be carrefull as it will recreate all the data in the new texture.
  120572. * @param size Define the new size
  120573. */
  120574. resize(size: any): void;
  120575. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120576. /**
  120577. * Dispose the render targets and their associated resources
  120578. */
  120579. dispose(): void;
  120580. /**
  120581. * Release all the underlying texture used as draw buffers.
  120582. */
  120583. releaseInternalTextures(): void;
  120584. }
  120585. }
  120586. declare module BABYLON {
  120587. interface ThinEngine {
  120588. /**
  120589. * Unbind a list of render target textures from the webGL context
  120590. * This is used only when drawBuffer extension or webGL2 are active
  120591. * @param textures defines the render target textures to unbind
  120592. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120593. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120594. */
  120595. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120596. /**
  120597. * Create a multi render target texture
  120598. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120599. * @param size defines the size of the texture
  120600. * @param options defines the creation options
  120601. * @returns the cube texture as an InternalTexture
  120602. */
  120603. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120604. /**
  120605. * Update the sample count for a given multiple render target texture
  120606. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120607. * @param textures defines the textures to update
  120608. * @param samples defines the sample count to set
  120609. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120610. */
  120611. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120612. }
  120613. }
  120614. declare module BABYLON {
  120615. /**
  120616. * Class used to define an additional view for the engine
  120617. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120618. */
  120619. export class EngineView {
  120620. /** Defines the canvas where to render the view */
  120621. target: HTMLCanvasElement;
  120622. /** Defines an optional camera used to render the view (will use active camera else) */
  120623. camera?: Camera;
  120624. }
  120625. interface Engine {
  120626. /**
  120627. * Gets or sets the HTML element to use for attaching events
  120628. */
  120629. inputElement: Nullable<HTMLElement>;
  120630. /**
  120631. * Gets the current engine view
  120632. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120633. */
  120634. activeView: Nullable<EngineView>;
  120635. /** Gets or sets the list of views */
  120636. views: EngineView[];
  120637. /**
  120638. * Register a new child canvas
  120639. * @param canvas defines the canvas to register
  120640. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120641. * @returns the associated view
  120642. */
  120643. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120644. /**
  120645. * Remove a registered child canvas
  120646. * @param canvas defines the canvas to remove
  120647. * @returns the current engine
  120648. */
  120649. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120650. }
  120651. }
  120652. declare module BABYLON {
  120653. /**
  120654. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120655. */
  120656. export interface CubeMapInfo {
  120657. /**
  120658. * The pixel array for the front face.
  120659. * This is stored in format, left to right, up to down format.
  120660. */
  120661. front: Nullable<ArrayBufferView>;
  120662. /**
  120663. * The pixel array for the back face.
  120664. * This is stored in format, left to right, up to down format.
  120665. */
  120666. back: Nullable<ArrayBufferView>;
  120667. /**
  120668. * The pixel array for the left face.
  120669. * This is stored in format, left to right, up to down format.
  120670. */
  120671. left: Nullable<ArrayBufferView>;
  120672. /**
  120673. * The pixel array for the right face.
  120674. * This is stored in format, left to right, up to down format.
  120675. */
  120676. right: Nullable<ArrayBufferView>;
  120677. /**
  120678. * The pixel array for the up face.
  120679. * This is stored in format, left to right, up to down format.
  120680. */
  120681. up: Nullable<ArrayBufferView>;
  120682. /**
  120683. * The pixel array for the down face.
  120684. * This is stored in format, left to right, up to down format.
  120685. */
  120686. down: Nullable<ArrayBufferView>;
  120687. /**
  120688. * The size of the cubemap stored.
  120689. *
  120690. * Each faces will be size * size pixels.
  120691. */
  120692. size: number;
  120693. /**
  120694. * The format of the texture.
  120695. *
  120696. * RGBA, RGB.
  120697. */
  120698. format: number;
  120699. /**
  120700. * The type of the texture data.
  120701. *
  120702. * UNSIGNED_INT, FLOAT.
  120703. */
  120704. type: number;
  120705. /**
  120706. * Specifies whether the texture is in gamma space.
  120707. */
  120708. gammaSpace: boolean;
  120709. }
  120710. /**
  120711. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120712. */
  120713. export class PanoramaToCubeMapTools {
  120714. private static FACE_FRONT;
  120715. private static FACE_BACK;
  120716. private static FACE_RIGHT;
  120717. private static FACE_LEFT;
  120718. private static FACE_DOWN;
  120719. private static FACE_UP;
  120720. /**
  120721. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120722. *
  120723. * @param float32Array The source data.
  120724. * @param inputWidth The width of the input panorama.
  120725. * @param inputHeight The height of the input panorama.
  120726. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120727. * @return The cubemap data
  120728. */
  120729. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120730. private static CreateCubemapTexture;
  120731. private static CalcProjectionSpherical;
  120732. }
  120733. }
  120734. declare module BABYLON {
  120735. /**
  120736. * Helper class dealing with the extraction of spherical polynomial dataArray
  120737. * from a cube map.
  120738. */
  120739. export class CubeMapToSphericalPolynomialTools {
  120740. private static FileFaces;
  120741. /**
  120742. * Converts a texture to the according Spherical Polynomial data.
  120743. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120744. *
  120745. * @param texture The texture to extract the information from.
  120746. * @return The Spherical Polynomial data.
  120747. */
  120748. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120749. /**
  120750. * Converts a cubemap to the according Spherical Polynomial data.
  120751. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120752. *
  120753. * @param cubeInfo The Cube map to extract the information from.
  120754. * @return The Spherical Polynomial data.
  120755. */
  120756. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120757. }
  120758. }
  120759. declare module BABYLON {
  120760. interface BaseTexture {
  120761. /**
  120762. * Get the polynomial representation of the texture data.
  120763. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120764. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120765. */
  120766. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120767. }
  120768. }
  120769. declare module BABYLON {
  120770. /** @hidden */
  120771. export var rgbdEncodePixelShader: {
  120772. name: string;
  120773. shader: string;
  120774. };
  120775. }
  120776. declare module BABYLON {
  120777. /** @hidden */
  120778. export var rgbdDecodePixelShader: {
  120779. name: string;
  120780. shader: string;
  120781. };
  120782. }
  120783. declare module BABYLON {
  120784. /**
  120785. * Raw texture data and descriptor sufficient for WebGL texture upload
  120786. */
  120787. export interface EnvironmentTextureInfo {
  120788. /**
  120789. * Version of the environment map
  120790. */
  120791. version: number;
  120792. /**
  120793. * Width of image
  120794. */
  120795. width: number;
  120796. /**
  120797. * Irradiance information stored in the file.
  120798. */
  120799. irradiance: any;
  120800. /**
  120801. * Specular information stored in the file.
  120802. */
  120803. specular: any;
  120804. }
  120805. /**
  120806. * Defines One Image in the file. It requires only the position in the file
  120807. * as well as the length.
  120808. */
  120809. interface BufferImageData {
  120810. /**
  120811. * Length of the image data.
  120812. */
  120813. length: number;
  120814. /**
  120815. * Position of the data from the null terminator delimiting the end of the JSON.
  120816. */
  120817. position: number;
  120818. }
  120819. /**
  120820. * Defines the specular data enclosed in the file.
  120821. * This corresponds to the version 1 of the data.
  120822. */
  120823. export interface EnvironmentTextureSpecularInfoV1 {
  120824. /**
  120825. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120826. */
  120827. specularDataPosition?: number;
  120828. /**
  120829. * This contains all the images data needed to reconstruct the cubemap.
  120830. */
  120831. mipmaps: Array<BufferImageData>;
  120832. /**
  120833. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120834. */
  120835. lodGenerationScale: number;
  120836. }
  120837. /**
  120838. * Sets of helpers addressing the serialization and deserialization of environment texture
  120839. * stored in a BabylonJS env file.
  120840. * Those files are usually stored as .env files.
  120841. */
  120842. export class EnvironmentTextureTools {
  120843. /**
  120844. * Magic number identifying the env file.
  120845. */
  120846. private static _MagicBytes;
  120847. /**
  120848. * Gets the environment info from an env file.
  120849. * @param data The array buffer containing the .env bytes.
  120850. * @returns the environment file info (the json header) if successfully parsed.
  120851. */
  120852. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120853. /**
  120854. * Creates an environment texture from a loaded cube texture.
  120855. * @param texture defines the cube texture to convert in env file
  120856. * @return a promise containing the environment data if succesfull.
  120857. */
  120858. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120859. /**
  120860. * Creates a JSON representation of the spherical data.
  120861. * @param texture defines the texture containing the polynomials
  120862. * @return the JSON representation of the spherical info
  120863. */
  120864. private static _CreateEnvTextureIrradiance;
  120865. /**
  120866. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120867. * @param data the image data
  120868. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120869. * @return the views described by info providing access to the underlying buffer
  120870. */
  120871. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120872. /**
  120873. * Uploads the texture info contained in the env file to the GPU.
  120874. * @param texture defines the internal texture to upload to
  120875. * @param data defines the data to load
  120876. * @param info defines the texture info retrieved through the GetEnvInfo method
  120877. * @returns a promise
  120878. */
  120879. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120880. private static _OnImageReadyAsync;
  120881. /**
  120882. * Uploads the levels of image data to the GPU.
  120883. * @param texture defines the internal texture to upload to
  120884. * @param imageData defines the array buffer views of image data [mipmap][face]
  120885. * @returns a promise
  120886. */
  120887. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120888. /**
  120889. * Uploads spherical polynomials information to the texture.
  120890. * @param texture defines the texture we are trying to upload the information to
  120891. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120892. */
  120893. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120894. /** @hidden */
  120895. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120896. }
  120897. }
  120898. declare module BABYLON {
  120899. /**
  120900. * Contains position and normal vectors for a vertex
  120901. */
  120902. export class PositionNormalVertex {
  120903. /** the position of the vertex (defaut: 0,0,0) */
  120904. position: Vector3;
  120905. /** the normal of the vertex (defaut: 0,1,0) */
  120906. normal: Vector3;
  120907. /**
  120908. * Creates a PositionNormalVertex
  120909. * @param position the position of the vertex (defaut: 0,0,0)
  120910. * @param normal the normal of the vertex (defaut: 0,1,0)
  120911. */
  120912. constructor(
  120913. /** the position of the vertex (defaut: 0,0,0) */
  120914. position?: Vector3,
  120915. /** the normal of the vertex (defaut: 0,1,0) */
  120916. normal?: Vector3);
  120917. /**
  120918. * Clones the PositionNormalVertex
  120919. * @returns the cloned PositionNormalVertex
  120920. */
  120921. clone(): PositionNormalVertex;
  120922. }
  120923. /**
  120924. * Contains position, normal and uv vectors for a vertex
  120925. */
  120926. export class PositionNormalTextureVertex {
  120927. /** the position of the vertex (defaut: 0,0,0) */
  120928. position: Vector3;
  120929. /** the normal of the vertex (defaut: 0,1,0) */
  120930. normal: Vector3;
  120931. /** the uv of the vertex (default: 0,0) */
  120932. uv: Vector2;
  120933. /**
  120934. * Creates a PositionNormalTextureVertex
  120935. * @param position the position of the vertex (defaut: 0,0,0)
  120936. * @param normal the normal of the vertex (defaut: 0,1,0)
  120937. * @param uv the uv of the vertex (default: 0,0)
  120938. */
  120939. constructor(
  120940. /** the position of the vertex (defaut: 0,0,0) */
  120941. position?: Vector3,
  120942. /** the normal of the vertex (defaut: 0,1,0) */
  120943. normal?: Vector3,
  120944. /** the uv of the vertex (default: 0,0) */
  120945. uv?: Vector2);
  120946. /**
  120947. * Clones the PositionNormalTextureVertex
  120948. * @returns the cloned PositionNormalTextureVertex
  120949. */
  120950. clone(): PositionNormalTextureVertex;
  120951. }
  120952. }
  120953. declare module BABYLON {
  120954. /** @hidden */
  120955. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120956. private _genericAttributeLocation;
  120957. private _varyingLocationCount;
  120958. private _varyingLocationMap;
  120959. private _replacements;
  120960. private _textureCount;
  120961. private _uniforms;
  120962. lineProcessor(line: string): string;
  120963. attributeProcessor(attribute: string): string;
  120964. varyingProcessor(varying: string, isFragment: boolean): string;
  120965. uniformProcessor(uniform: string): string;
  120966. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120967. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120968. }
  120969. }
  120970. declare module BABYLON {
  120971. /**
  120972. * Container for accessors for natively-stored mesh data buffers.
  120973. */
  120974. class NativeDataBuffer extends DataBuffer {
  120975. /**
  120976. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120977. */
  120978. nativeIndexBuffer?: any;
  120979. /**
  120980. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120981. */
  120982. nativeVertexBuffer?: any;
  120983. }
  120984. /** @hidden */
  120985. class NativeTexture extends InternalTexture {
  120986. getInternalTexture(): InternalTexture;
  120987. getViewCount(): number;
  120988. }
  120989. /** @hidden */
  120990. export class NativeEngine extends Engine {
  120991. private readonly _native;
  120992. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120993. private readonly INVALID_HANDLE;
  120994. getHardwareScalingLevel(): number;
  120995. constructor();
  120996. /**
  120997. * Can be used to override the current requestAnimationFrame requester.
  120998. * @hidden
  120999. */
  121000. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121001. /**
  121002. * Override default engine behavior.
  121003. * @param color
  121004. * @param backBuffer
  121005. * @param depth
  121006. * @param stencil
  121007. */
  121008. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121009. /**
  121010. * Gets host document
  121011. * @returns the host document object
  121012. */
  121013. getHostDocument(): Nullable<Document>;
  121014. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121015. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  121016. createVertexBuffer(data: DataArray): NativeDataBuffer;
  121017. recordVertexArrayObject(vertexBuffers: {
  121018. [key: string]: VertexBuffer;
  121019. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121020. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121021. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121022. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121023. /**
  121024. * Draw a list of indexed primitives
  121025. * @param fillMode defines the primitive to use
  121026. * @param indexStart defines the starting index
  121027. * @param indexCount defines the number of index to draw
  121028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121029. */
  121030. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121031. /**
  121032. * Draw a list of unindexed primitives
  121033. * @param fillMode defines the primitive to use
  121034. * @param verticesStart defines the index of first vertex to draw
  121035. * @param verticesCount defines the count of vertices to draw
  121036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121037. */
  121038. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121039. createPipelineContext(): IPipelineContext;
  121040. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121041. /** @hidden */
  121042. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121043. /** @hidden */
  121044. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121045. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121046. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121047. protected _setProgram(program: WebGLProgram): void;
  121048. _releaseEffect(effect: Effect): void;
  121049. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121050. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  121051. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  121052. bindSamplers(effect: Effect): void;
  121053. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  121054. getRenderWidth(useScreen?: boolean): number;
  121055. getRenderHeight(useScreen?: boolean): number;
  121056. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  121057. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121058. /**
  121059. * Set the z offset to apply to current rendering
  121060. * @param value defines the offset to apply
  121061. */
  121062. setZOffset(value: number): void;
  121063. /**
  121064. * Gets the current value of the zOffset
  121065. * @returns the current zOffset state
  121066. */
  121067. getZOffset(): number;
  121068. /**
  121069. * Enable or disable depth buffering
  121070. * @param enable defines the state to set
  121071. */
  121072. setDepthBuffer(enable: boolean): void;
  121073. /**
  121074. * Gets a boolean indicating if depth writing is enabled
  121075. * @returns the current depth writing state
  121076. */
  121077. getDepthWrite(): boolean;
  121078. /**
  121079. * Enable or disable depth writing
  121080. * @param enable defines the state to set
  121081. */
  121082. setDepthWrite(enable: boolean): void;
  121083. /**
  121084. * Enable or disable color writing
  121085. * @param enable defines the state to set
  121086. */
  121087. setColorWrite(enable: boolean): void;
  121088. /**
  121089. * Gets a boolean indicating if color writing is enabled
  121090. * @returns the current color writing state
  121091. */
  121092. getColorWrite(): boolean;
  121093. /**
  121094. * Sets alpha constants used by some alpha blending modes
  121095. * @param r defines the red component
  121096. * @param g defines the green component
  121097. * @param b defines the blue component
  121098. * @param a defines the alpha component
  121099. */
  121100. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121101. /**
  121102. * Sets the current alpha mode
  121103. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121104. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121105. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121106. */
  121107. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121108. /**
  121109. * Gets the current alpha mode
  121110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121111. * @returns the current alpha mode
  121112. */
  121113. getAlphaMode(): number;
  121114. setInt(uniform: WebGLUniformLocation, int: number): void;
  121115. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121116. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121117. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121118. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121119. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121120. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121121. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121122. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121123. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121124. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121125. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121126. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121127. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121128. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121129. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121130. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121131. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121132. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121133. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121134. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121135. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121136. wipeCaches(bruteForce?: boolean): void;
  121137. _createTexture(): WebGLTexture;
  121138. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121139. /**
  121140. * Usually called from Texture.ts.
  121141. * Passed information to create a WebGLTexture
  121142. * @param urlArg defines a value which contains one of the following:
  121143. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121144. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121145. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121146. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121147. * @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)
  121148. * @param scene needed for loading to the correct scene
  121149. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121150. * @param onLoad optional callback to be called upon successful completion
  121151. * @param onError optional callback to be called upon failure
  121152. * @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
  121153. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121154. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121155. * @param forcedExtension defines the extension to use to pick the right loader
  121156. * @param mimeType defines an optional mime type
  121157. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121158. */
  121159. 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;
  121160. /**
  121161. * Creates a cube texture
  121162. * @param rootUrl defines the url where the files to load is located
  121163. * @param scene defines the current scene
  121164. * @param files defines the list of files to load (1 per face)
  121165. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121166. * @param onLoad defines an optional callback raised when the texture is loaded
  121167. * @param onError defines an optional callback raised if there is an issue to load the texture
  121168. * @param format defines the format of the data
  121169. * @param forcedExtension defines the extension to use to pick the right loader
  121170. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121171. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121172. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121173. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121174. * @returns the cube texture as an InternalTexture
  121175. */
  121176. 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;
  121177. private _getSamplingFilter;
  121178. private static _GetNativeTextureFormat;
  121179. createRenderTargetTexture(size: number | {
  121180. width: number;
  121181. height: number;
  121182. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121183. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121184. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121185. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121186. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121187. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121188. /**
  121189. * Updates a dynamic vertex buffer.
  121190. * @param vertexBuffer the vertex buffer to update
  121191. * @param data the data used to update the vertex buffer
  121192. * @param byteOffset the byte offset of the data (optional)
  121193. * @param byteLength the byte length of the data (optional)
  121194. */
  121195. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121196. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121197. private _updateAnisotropicLevel;
  121198. private _getAddressMode;
  121199. /** @hidden */
  121200. _bindTexture(channel: number, texture: InternalTexture): void;
  121201. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121202. releaseEffects(): void;
  121203. /** @hidden */
  121204. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121205. /** @hidden */
  121206. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121207. /** @hidden */
  121208. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121209. /** @hidden */
  121210. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121211. }
  121212. }
  121213. declare module BABYLON {
  121214. /**
  121215. * Gather the list of clipboard event types as constants.
  121216. */
  121217. export class ClipboardEventTypes {
  121218. /**
  121219. * The clipboard event is fired when a copy command is active (pressed).
  121220. */
  121221. static readonly COPY: number;
  121222. /**
  121223. * The clipboard event is fired when a cut command is active (pressed).
  121224. */
  121225. static readonly CUT: number;
  121226. /**
  121227. * The clipboard event is fired when a paste command is active (pressed).
  121228. */
  121229. static readonly PASTE: number;
  121230. }
  121231. /**
  121232. * This class is used to store clipboard related info for the onClipboardObservable event.
  121233. */
  121234. export class ClipboardInfo {
  121235. /**
  121236. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121237. */
  121238. type: number;
  121239. /**
  121240. * Defines the related dom event
  121241. */
  121242. event: ClipboardEvent;
  121243. /**
  121244. *Creates an instance of ClipboardInfo.
  121245. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121246. * @param event Defines the related dom event
  121247. */
  121248. constructor(
  121249. /**
  121250. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121251. */
  121252. type: number,
  121253. /**
  121254. * Defines the related dom event
  121255. */
  121256. event: ClipboardEvent);
  121257. /**
  121258. * Get the clipboard event's type from the keycode.
  121259. * @param keyCode Defines the keyCode for the current keyboard event.
  121260. * @return {number}
  121261. */
  121262. static GetTypeFromCharacter(keyCode: number): number;
  121263. }
  121264. }
  121265. declare module BABYLON {
  121266. /**
  121267. * Google Daydream controller
  121268. */
  121269. export class DaydreamController extends WebVRController {
  121270. /**
  121271. * Base Url for the controller model.
  121272. */
  121273. static MODEL_BASE_URL: string;
  121274. /**
  121275. * File name for the controller model.
  121276. */
  121277. static MODEL_FILENAME: string;
  121278. /**
  121279. * Gamepad Id prefix used to identify Daydream Controller.
  121280. */
  121281. static readonly GAMEPAD_ID_PREFIX: string;
  121282. /**
  121283. * Creates a new DaydreamController from a gamepad
  121284. * @param vrGamepad the gamepad that the controller should be created from
  121285. */
  121286. constructor(vrGamepad: any);
  121287. /**
  121288. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121289. * @param scene scene in which to add meshes
  121290. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121291. */
  121292. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121293. /**
  121294. * Called once for each button that changed state since the last frame
  121295. * @param buttonIdx Which button index changed
  121296. * @param state New state of the button
  121297. * @param changes Which properties on the state changed since last frame
  121298. */
  121299. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121300. }
  121301. }
  121302. declare module BABYLON {
  121303. /**
  121304. * Gear VR Controller
  121305. */
  121306. export class GearVRController extends WebVRController {
  121307. /**
  121308. * Base Url for the controller model.
  121309. */
  121310. static MODEL_BASE_URL: string;
  121311. /**
  121312. * File name for the controller model.
  121313. */
  121314. static MODEL_FILENAME: string;
  121315. /**
  121316. * Gamepad Id prefix used to identify this controller.
  121317. */
  121318. static readonly GAMEPAD_ID_PREFIX: string;
  121319. private readonly _buttonIndexToObservableNameMap;
  121320. /**
  121321. * Creates a new GearVRController from a gamepad
  121322. * @param vrGamepad the gamepad that the controller should be created from
  121323. */
  121324. constructor(vrGamepad: any);
  121325. /**
  121326. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121327. * @param scene scene in which to add meshes
  121328. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121329. */
  121330. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121331. /**
  121332. * Called once for each button that changed state since the last frame
  121333. * @param buttonIdx Which button index changed
  121334. * @param state New state of the button
  121335. * @param changes Which properties on the state changed since last frame
  121336. */
  121337. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121338. }
  121339. }
  121340. declare module BABYLON {
  121341. /**
  121342. * Generic Controller
  121343. */
  121344. export class GenericController extends WebVRController {
  121345. /**
  121346. * Base Url for the controller model.
  121347. */
  121348. static readonly MODEL_BASE_URL: string;
  121349. /**
  121350. * File name for the controller model.
  121351. */
  121352. static readonly MODEL_FILENAME: string;
  121353. /**
  121354. * Creates a new GenericController from a gamepad
  121355. * @param vrGamepad the gamepad that the controller should be created from
  121356. */
  121357. constructor(vrGamepad: any);
  121358. /**
  121359. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121360. * @param scene scene in which to add meshes
  121361. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121362. */
  121363. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121364. /**
  121365. * Called once for each button that changed state since the last frame
  121366. * @param buttonIdx Which button index changed
  121367. * @param state New state of the button
  121368. * @param changes Which properties on the state changed since last frame
  121369. */
  121370. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121371. }
  121372. }
  121373. declare module BABYLON {
  121374. /**
  121375. * Oculus Touch Controller
  121376. */
  121377. export class OculusTouchController extends WebVRController {
  121378. /**
  121379. * Base Url for the controller model.
  121380. */
  121381. static MODEL_BASE_URL: string;
  121382. /**
  121383. * File name for the left controller model.
  121384. */
  121385. static MODEL_LEFT_FILENAME: string;
  121386. /**
  121387. * File name for the right controller model.
  121388. */
  121389. static MODEL_RIGHT_FILENAME: string;
  121390. /**
  121391. * Base Url for the Quest controller model.
  121392. */
  121393. static QUEST_MODEL_BASE_URL: string;
  121394. /**
  121395. * @hidden
  121396. * If the controllers are running on a device that needs the updated Quest controller models
  121397. */
  121398. static _IsQuest: boolean;
  121399. /**
  121400. * Fired when the secondary trigger on this controller is modified
  121401. */
  121402. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121403. /**
  121404. * Fired when the thumb rest on this controller is modified
  121405. */
  121406. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121407. /**
  121408. * Creates a new OculusTouchController from a gamepad
  121409. * @param vrGamepad the gamepad that the controller should be created from
  121410. */
  121411. constructor(vrGamepad: any);
  121412. /**
  121413. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121414. * @param scene scene in which to add meshes
  121415. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121416. */
  121417. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121418. /**
  121419. * Fired when the A button on this controller is modified
  121420. */
  121421. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121422. /**
  121423. * Fired when the B button on this controller is modified
  121424. */
  121425. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121426. /**
  121427. * Fired when the X button on this controller is modified
  121428. */
  121429. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121430. /**
  121431. * Fired when the Y button on this controller is modified
  121432. */
  121433. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121434. /**
  121435. * Called once for each button that changed state since the last frame
  121436. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121437. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121438. * 2) secondary trigger (same)
  121439. * 3) A (right) X (left), touch, pressed = value
  121440. * 4) B / Y
  121441. * 5) thumb rest
  121442. * @param buttonIdx Which button index changed
  121443. * @param state New state of the button
  121444. * @param changes Which properties on the state changed since last frame
  121445. */
  121446. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121447. }
  121448. }
  121449. declare module BABYLON {
  121450. /**
  121451. * Vive Controller
  121452. */
  121453. export class ViveController extends WebVRController {
  121454. /**
  121455. * Base Url for the controller model.
  121456. */
  121457. static MODEL_BASE_URL: string;
  121458. /**
  121459. * File name for the controller model.
  121460. */
  121461. static MODEL_FILENAME: string;
  121462. /**
  121463. * Creates a new ViveController from a gamepad
  121464. * @param vrGamepad the gamepad that the controller should be created from
  121465. */
  121466. constructor(vrGamepad: any);
  121467. /**
  121468. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121469. * @param scene scene in which to add meshes
  121470. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121471. */
  121472. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121473. /**
  121474. * Fired when the left button on this controller is modified
  121475. */
  121476. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121477. /**
  121478. * Fired when the right button on this controller is modified
  121479. */
  121480. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121481. /**
  121482. * Fired when the menu button on this controller is modified
  121483. */
  121484. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121485. /**
  121486. * Called once for each button that changed state since the last frame
  121487. * Vive mapping:
  121488. * 0: touchpad
  121489. * 1: trigger
  121490. * 2: left AND right buttons
  121491. * 3: menu button
  121492. * @param buttonIdx Which button index changed
  121493. * @param state New state of the button
  121494. * @param changes Which properties on the state changed since last frame
  121495. */
  121496. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121497. }
  121498. }
  121499. declare module BABYLON {
  121500. /**
  121501. * Defines the WindowsMotionController object that the state of the windows motion controller
  121502. */
  121503. export class WindowsMotionController extends WebVRController {
  121504. /**
  121505. * The base url used to load the left and right controller models
  121506. */
  121507. static MODEL_BASE_URL: string;
  121508. /**
  121509. * The name of the left controller model file
  121510. */
  121511. static MODEL_LEFT_FILENAME: string;
  121512. /**
  121513. * The name of the right controller model file
  121514. */
  121515. static MODEL_RIGHT_FILENAME: string;
  121516. /**
  121517. * The controller name prefix for this controller type
  121518. */
  121519. static readonly GAMEPAD_ID_PREFIX: string;
  121520. /**
  121521. * The controller id pattern for this controller type
  121522. */
  121523. private static readonly GAMEPAD_ID_PATTERN;
  121524. private _loadedMeshInfo;
  121525. protected readonly _mapping: {
  121526. buttons: string[];
  121527. buttonMeshNames: {
  121528. 'trigger': string;
  121529. 'menu': string;
  121530. 'grip': string;
  121531. 'thumbstick': string;
  121532. 'trackpad': string;
  121533. };
  121534. buttonObservableNames: {
  121535. 'trigger': string;
  121536. 'menu': string;
  121537. 'grip': string;
  121538. 'thumbstick': string;
  121539. 'trackpad': string;
  121540. };
  121541. axisMeshNames: string[];
  121542. pointingPoseMeshName: string;
  121543. };
  121544. /**
  121545. * Fired when the trackpad on this controller is clicked
  121546. */
  121547. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121548. /**
  121549. * Fired when the trackpad on this controller is modified
  121550. */
  121551. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121552. /**
  121553. * The current x and y values of this controller's trackpad
  121554. */
  121555. trackpad: StickValues;
  121556. /**
  121557. * Creates a new WindowsMotionController from a gamepad
  121558. * @param vrGamepad the gamepad that the controller should be created from
  121559. */
  121560. constructor(vrGamepad: any);
  121561. /**
  121562. * Fired when the trigger on this controller is modified
  121563. */
  121564. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121565. /**
  121566. * Fired when the menu button on this controller is modified
  121567. */
  121568. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121569. /**
  121570. * Fired when the grip button on this controller is modified
  121571. */
  121572. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121573. /**
  121574. * Fired when the thumbstick button on this controller is modified
  121575. */
  121576. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121577. /**
  121578. * Fired when the touchpad button on this controller is modified
  121579. */
  121580. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121581. /**
  121582. * Fired when the touchpad values on this controller are modified
  121583. */
  121584. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121585. protected _updateTrackpad(): void;
  121586. /**
  121587. * Called once per frame by the engine.
  121588. */
  121589. update(): void;
  121590. /**
  121591. * Called once for each button that changed state since the last frame
  121592. * @param buttonIdx Which button index changed
  121593. * @param state New state of the button
  121594. * @param changes Which properties on the state changed since last frame
  121595. */
  121596. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121597. /**
  121598. * Moves the buttons on the controller mesh based on their current state
  121599. * @param buttonName the name of the button to move
  121600. * @param buttonValue the value of the button which determines the buttons new position
  121601. */
  121602. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121603. /**
  121604. * Moves the axis on the controller mesh based on its current state
  121605. * @param axis the index of the axis
  121606. * @param axisValue the value of the axis which determines the meshes new position
  121607. * @hidden
  121608. */
  121609. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121610. /**
  121611. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121612. * @param scene scene in which to add meshes
  121613. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121614. */
  121615. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121616. /**
  121617. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121618. * can be transformed by button presses and axes values, based on this._mapping.
  121619. *
  121620. * @param scene scene in which the meshes exist
  121621. * @param meshes list of meshes that make up the controller model to process
  121622. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121623. */
  121624. private processModel;
  121625. private createMeshInfo;
  121626. /**
  121627. * Gets the ray of the controller in the direction the controller is pointing
  121628. * @param length the length the resulting ray should be
  121629. * @returns a ray in the direction the controller is pointing
  121630. */
  121631. getForwardRay(length?: number): Ray;
  121632. /**
  121633. * Disposes of the controller
  121634. */
  121635. dispose(): void;
  121636. }
  121637. /**
  121638. * This class represents a new windows motion controller in XR.
  121639. */
  121640. export class XRWindowsMotionController extends WindowsMotionController {
  121641. /**
  121642. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121643. */
  121644. protected readonly _mapping: {
  121645. buttons: string[];
  121646. buttonMeshNames: {
  121647. 'trigger': string;
  121648. 'menu': string;
  121649. 'grip': string;
  121650. 'thumbstick': string;
  121651. 'trackpad': string;
  121652. };
  121653. buttonObservableNames: {
  121654. 'trigger': string;
  121655. 'menu': string;
  121656. 'grip': string;
  121657. 'thumbstick': string;
  121658. 'trackpad': string;
  121659. };
  121660. axisMeshNames: string[];
  121661. pointingPoseMeshName: string;
  121662. };
  121663. /**
  121664. * Construct a new XR-Based windows motion controller
  121665. *
  121666. * @param gamepadInfo the gamepad object from the browser
  121667. */
  121668. constructor(gamepadInfo: any);
  121669. /**
  121670. * holds the thumbstick values (X,Y)
  121671. */
  121672. thumbstickValues: StickValues;
  121673. /**
  121674. * Fired when the thumbstick on this controller is clicked
  121675. */
  121676. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121677. /**
  121678. * Fired when the thumbstick on this controller is modified
  121679. */
  121680. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121681. /**
  121682. * Fired when the touchpad button on this controller is modified
  121683. */
  121684. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121685. /**
  121686. * Fired when the touchpad values on this controller are modified
  121687. */
  121688. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121689. /**
  121690. * Fired when the thumbstick button on this controller is modified
  121691. * here to prevent breaking changes
  121692. */
  121693. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121694. /**
  121695. * updating the thumbstick(!) and not the trackpad.
  121696. * This is named this way due to the difference between WebVR and XR and to avoid
  121697. * changing the parent class.
  121698. */
  121699. protected _updateTrackpad(): void;
  121700. /**
  121701. * Disposes the class with joy
  121702. */
  121703. dispose(): void;
  121704. }
  121705. }
  121706. declare module BABYLON {
  121707. /**
  121708. * Class containing static functions to help procedurally build meshes
  121709. */
  121710. export class PolyhedronBuilder {
  121711. /**
  121712. * Creates a polyhedron mesh
  121713. * * 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
  121714. * * The parameter `size` (positive float, default 1) sets the polygon size
  121715. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121716. * * 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`
  121717. * * 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
  121718. * * 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)`)
  121719. * * 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
  121720. * * 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
  121721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121724. * @param name defines the name of the mesh
  121725. * @param options defines the options used to create the mesh
  121726. * @param scene defines the hosting scene
  121727. * @returns the polyhedron mesh
  121728. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121729. */
  121730. static CreatePolyhedron(name: string, options: {
  121731. type?: number;
  121732. size?: number;
  121733. sizeX?: number;
  121734. sizeY?: number;
  121735. sizeZ?: number;
  121736. custom?: any;
  121737. faceUV?: Vector4[];
  121738. faceColors?: Color4[];
  121739. flat?: boolean;
  121740. updatable?: boolean;
  121741. sideOrientation?: number;
  121742. frontUVs?: Vector4;
  121743. backUVs?: Vector4;
  121744. }, scene?: Nullable<Scene>): Mesh;
  121745. }
  121746. }
  121747. declare module BABYLON {
  121748. /**
  121749. * Gizmo that enables scaling a mesh along 3 axis
  121750. */
  121751. export class ScaleGizmo extends Gizmo {
  121752. /**
  121753. * Internal gizmo used for interactions on the x axis
  121754. */
  121755. xGizmo: AxisScaleGizmo;
  121756. /**
  121757. * Internal gizmo used for interactions on the y axis
  121758. */
  121759. yGizmo: AxisScaleGizmo;
  121760. /**
  121761. * Internal gizmo used for interactions on the z axis
  121762. */
  121763. zGizmo: AxisScaleGizmo;
  121764. /**
  121765. * Internal gizmo used to scale all axis equally
  121766. */
  121767. uniformScaleGizmo: AxisScaleGizmo;
  121768. private _meshAttached;
  121769. private _updateGizmoRotationToMatchAttachedMesh;
  121770. private _snapDistance;
  121771. private _scaleRatio;
  121772. private _uniformScalingMesh;
  121773. private _octahedron;
  121774. private _sensitivity;
  121775. /** Fires an event when any of it's sub gizmos are dragged */
  121776. onDragStartObservable: Observable<unknown>;
  121777. /** Fires an event when any of it's sub gizmos are released from dragging */
  121778. onDragEndObservable: Observable<unknown>;
  121779. get attachedMesh(): Nullable<AbstractMesh>;
  121780. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121781. /**
  121782. * Creates a ScaleGizmo
  121783. * @param gizmoLayer The utility layer the gizmo will be added to
  121784. */
  121785. constructor(gizmoLayer?: UtilityLayerRenderer);
  121786. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121787. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121788. /**
  121789. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121790. */
  121791. set snapDistance(value: number);
  121792. get snapDistance(): number;
  121793. /**
  121794. * Ratio for the scale of the gizmo (Default: 1)
  121795. */
  121796. set scaleRatio(value: number);
  121797. get scaleRatio(): number;
  121798. /**
  121799. * Sensitivity factor for dragging (Default: 1)
  121800. */
  121801. set sensitivity(value: number);
  121802. get sensitivity(): number;
  121803. /**
  121804. * Disposes of the gizmo
  121805. */
  121806. dispose(): void;
  121807. }
  121808. }
  121809. declare module BABYLON {
  121810. /**
  121811. * Single axis scale gizmo
  121812. */
  121813. export class AxisScaleGizmo extends Gizmo {
  121814. /**
  121815. * Drag behavior responsible for the gizmos dragging interactions
  121816. */
  121817. dragBehavior: PointerDragBehavior;
  121818. private _pointerObserver;
  121819. /**
  121820. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121821. */
  121822. snapDistance: number;
  121823. /**
  121824. * Event that fires each time the gizmo snaps to a new location.
  121825. * * snapDistance is the the change in distance
  121826. */
  121827. onSnapObservable: Observable<{
  121828. snapDistance: number;
  121829. }>;
  121830. /**
  121831. * If the scaling operation should be done on all axis (default: false)
  121832. */
  121833. uniformScaling: boolean;
  121834. /**
  121835. * Custom sensitivity value for the drag strength
  121836. */
  121837. sensitivity: number;
  121838. private _isEnabled;
  121839. private _parent;
  121840. private _arrow;
  121841. private _coloredMaterial;
  121842. private _hoverMaterial;
  121843. /**
  121844. * Creates an AxisScaleGizmo
  121845. * @param gizmoLayer The utility layer the gizmo will be added to
  121846. * @param dragAxis The axis which the gizmo will be able to scale on
  121847. * @param color The color of the gizmo
  121848. */
  121849. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121850. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121851. /**
  121852. * If the gizmo is enabled
  121853. */
  121854. set isEnabled(value: boolean);
  121855. get isEnabled(): boolean;
  121856. /**
  121857. * Disposes of the gizmo
  121858. */
  121859. dispose(): void;
  121860. /**
  121861. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121862. * @param mesh The mesh to replace the default mesh of the gizmo
  121863. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121864. */
  121865. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121866. }
  121867. }
  121868. declare module BABYLON {
  121869. /**
  121870. * Bounding box gizmo
  121871. */
  121872. export class BoundingBoxGizmo extends Gizmo {
  121873. private _lineBoundingBox;
  121874. private _rotateSpheresParent;
  121875. private _scaleBoxesParent;
  121876. private _boundingDimensions;
  121877. private _renderObserver;
  121878. private _pointerObserver;
  121879. private _scaleDragSpeed;
  121880. private _tmpQuaternion;
  121881. private _tmpVector;
  121882. private _tmpRotationMatrix;
  121883. /**
  121884. * 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)
  121885. */
  121886. ignoreChildren: boolean;
  121887. /**
  121888. * 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)
  121889. */
  121890. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121891. /**
  121892. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121893. */
  121894. rotationSphereSize: number;
  121895. /**
  121896. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121897. */
  121898. scaleBoxSize: number;
  121899. /**
  121900. * 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)
  121901. */
  121902. fixedDragMeshScreenSize: boolean;
  121903. /**
  121904. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121905. */
  121906. fixedDragMeshScreenSizeDistanceFactor: number;
  121907. /**
  121908. * Fired when a rotation sphere or scale box is dragged
  121909. */
  121910. onDragStartObservable: Observable<{}>;
  121911. /**
  121912. * Fired when a scale box is dragged
  121913. */
  121914. onScaleBoxDragObservable: Observable<{}>;
  121915. /**
  121916. * Fired when a scale box drag is ended
  121917. */
  121918. onScaleBoxDragEndObservable: Observable<{}>;
  121919. /**
  121920. * Fired when a rotation sphere is dragged
  121921. */
  121922. onRotationSphereDragObservable: Observable<{}>;
  121923. /**
  121924. * Fired when a rotation sphere drag is ended
  121925. */
  121926. onRotationSphereDragEndObservable: Observable<{}>;
  121927. /**
  121928. * 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)
  121929. */
  121930. scalePivot: Nullable<Vector3>;
  121931. /**
  121932. * Mesh used as a pivot to rotate the attached mesh
  121933. */
  121934. private _anchorMesh;
  121935. private _existingMeshScale;
  121936. private _dragMesh;
  121937. private pointerDragBehavior;
  121938. private coloredMaterial;
  121939. private hoverColoredMaterial;
  121940. /**
  121941. * Sets the color of the bounding box gizmo
  121942. * @param color the color to set
  121943. */
  121944. setColor(color: Color3): void;
  121945. /**
  121946. * Creates an BoundingBoxGizmo
  121947. * @param gizmoLayer The utility layer the gizmo will be added to
  121948. * @param color The color of the gizmo
  121949. */
  121950. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121951. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121952. private _selectNode;
  121953. /**
  121954. * Updates the bounding box information for the Gizmo
  121955. */
  121956. updateBoundingBox(): void;
  121957. private _updateRotationSpheres;
  121958. private _updateScaleBoxes;
  121959. /**
  121960. * Enables rotation on the specified axis and disables rotation on the others
  121961. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121962. */
  121963. setEnabledRotationAxis(axis: string): void;
  121964. /**
  121965. * Enables/disables scaling
  121966. * @param enable if scaling should be enabled
  121967. */
  121968. setEnabledScaling(enable: boolean): void;
  121969. private _updateDummy;
  121970. /**
  121971. * Enables a pointer drag behavior on the bounding box of the gizmo
  121972. */
  121973. enableDragBehavior(): void;
  121974. /**
  121975. * Disposes of the gizmo
  121976. */
  121977. dispose(): void;
  121978. /**
  121979. * 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)
  121980. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121981. * @returns the bounding box mesh with the passed in mesh as a child
  121982. */
  121983. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121984. /**
  121985. * CustomMeshes are not supported by this gizmo
  121986. * @param mesh The mesh to replace the default mesh of the gizmo
  121987. */
  121988. setCustomMesh(mesh: Mesh): void;
  121989. }
  121990. }
  121991. declare module BABYLON {
  121992. /**
  121993. * Single plane rotation gizmo
  121994. */
  121995. export class PlaneRotationGizmo extends Gizmo {
  121996. /**
  121997. * Drag behavior responsible for the gizmos dragging interactions
  121998. */
  121999. dragBehavior: PointerDragBehavior;
  122000. private _pointerObserver;
  122001. /**
  122002. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  122003. */
  122004. snapDistance: number;
  122005. /**
  122006. * Event that fires each time the gizmo snaps to a new location.
  122007. * * snapDistance is the the change in distance
  122008. */
  122009. onSnapObservable: Observable<{
  122010. snapDistance: number;
  122011. }>;
  122012. private _isEnabled;
  122013. private _parent;
  122014. /**
  122015. * Creates a PlaneRotationGizmo
  122016. * @param gizmoLayer The utility layer the gizmo will be added to
  122017. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  122018. * @param color The color of the gizmo
  122019. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122020. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122021. */
  122022. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  122023. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122024. /**
  122025. * If the gizmo is enabled
  122026. */
  122027. set isEnabled(value: boolean);
  122028. get isEnabled(): boolean;
  122029. /**
  122030. * Disposes of the gizmo
  122031. */
  122032. dispose(): void;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. /**
  122037. * Gizmo that enables rotating a mesh along 3 axis
  122038. */
  122039. export class RotationGizmo extends Gizmo {
  122040. /**
  122041. * Internal gizmo used for interactions on the x axis
  122042. */
  122043. xGizmo: PlaneRotationGizmo;
  122044. /**
  122045. * Internal gizmo used for interactions on the y axis
  122046. */
  122047. yGizmo: PlaneRotationGizmo;
  122048. /**
  122049. * Internal gizmo used for interactions on the z axis
  122050. */
  122051. zGizmo: PlaneRotationGizmo;
  122052. /** Fires an event when any of it's sub gizmos are dragged */
  122053. onDragStartObservable: Observable<unknown>;
  122054. /** Fires an event when any of it's sub gizmos are released from dragging */
  122055. onDragEndObservable: Observable<unknown>;
  122056. private _meshAttached;
  122057. get attachedMesh(): Nullable<AbstractMesh>;
  122058. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122059. /**
  122060. * Creates a RotationGizmo
  122061. * @param gizmoLayer The utility layer the gizmo will be added to
  122062. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122063. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122064. */
  122065. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  122066. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122067. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122068. /**
  122069. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122070. */
  122071. set snapDistance(value: number);
  122072. get snapDistance(): number;
  122073. /**
  122074. * Ratio for the scale of the gizmo (Default: 1)
  122075. */
  122076. set scaleRatio(value: number);
  122077. get scaleRatio(): number;
  122078. /**
  122079. * Disposes of the gizmo
  122080. */
  122081. dispose(): void;
  122082. /**
  122083. * CustomMeshes are not supported by this gizmo
  122084. * @param mesh The mesh to replace the default mesh of the gizmo
  122085. */
  122086. setCustomMesh(mesh: Mesh): void;
  122087. }
  122088. }
  122089. declare module BABYLON {
  122090. /**
  122091. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122092. */
  122093. export class GizmoManager implements IDisposable {
  122094. private scene;
  122095. /**
  122096. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122097. */
  122098. gizmos: {
  122099. positionGizmo: Nullable<PositionGizmo>;
  122100. rotationGizmo: Nullable<RotationGizmo>;
  122101. scaleGizmo: Nullable<ScaleGizmo>;
  122102. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122103. };
  122104. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122105. clearGizmoOnEmptyPointerEvent: boolean;
  122106. /** Fires an event when the manager is attached to a mesh */
  122107. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122108. private _gizmosEnabled;
  122109. private _pointerObserver;
  122110. private _attachedMesh;
  122111. private _boundingBoxColor;
  122112. private _defaultUtilityLayer;
  122113. private _defaultKeepDepthUtilityLayer;
  122114. /**
  122115. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122116. */
  122117. boundingBoxDragBehavior: SixDofDragBehavior;
  122118. /**
  122119. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122120. */
  122121. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122122. /**
  122123. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122124. */
  122125. usePointerToAttachGizmos: boolean;
  122126. /**
  122127. * Utility layer that the bounding box gizmo belongs to
  122128. */
  122129. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122130. /**
  122131. * Utility layer that all gizmos besides bounding box belong to
  122132. */
  122133. get utilityLayer(): UtilityLayerRenderer;
  122134. /**
  122135. * Instatiates a gizmo manager
  122136. * @param scene the scene to overlay the gizmos on top of
  122137. */
  122138. constructor(scene: Scene);
  122139. /**
  122140. * Attaches a set of gizmos to the specified mesh
  122141. * @param mesh The mesh the gizmo's should be attached to
  122142. */
  122143. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122144. /**
  122145. * If the position gizmo is enabled
  122146. */
  122147. set positionGizmoEnabled(value: boolean);
  122148. get positionGizmoEnabled(): boolean;
  122149. /**
  122150. * If the rotation gizmo is enabled
  122151. */
  122152. set rotationGizmoEnabled(value: boolean);
  122153. get rotationGizmoEnabled(): boolean;
  122154. /**
  122155. * If the scale gizmo is enabled
  122156. */
  122157. set scaleGizmoEnabled(value: boolean);
  122158. get scaleGizmoEnabled(): boolean;
  122159. /**
  122160. * If the boundingBox gizmo is enabled
  122161. */
  122162. set boundingBoxGizmoEnabled(value: boolean);
  122163. get boundingBoxGizmoEnabled(): boolean;
  122164. /**
  122165. * Disposes of the gizmo manager
  122166. */
  122167. dispose(): void;
  122168. }
  122169. }
  122170. declare module BABYLON {
  122171. /**
  122172. * A directional light is defined by a direction (what a surprise!).
  122173. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122174. * 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.
  122175. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122176. */
  122177. export class DirectionalLight extends ShadowLight {
  122178. private _shadowFrustumSize;
  122179. /**
  122180. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122181. */
  122182. get shadowFrustumSize(): number;
  122183. /**
  122184. * Specifies a fix frustum size for the shadow generation.
  122185. */
  122186. set shadowFrustumSize(value: number);
  122187. private _shadowOrthoScale;
  122188. /**
  122189. * Gets the shadow projection scale against the optimal computed one.
  122190. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122191. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122192. */
  122193. get shadowOrthoScale(): number;
  122194. /**
  122195. * Sets the shadow projection scale against the optimal computed one.
  122196. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122197. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122198. */
  122199. set shadowOrthoScale(value: number);
  122200. /**
  122201. * Automatically compute the projection matrix to best fit (including all the casters)
  122202. * on each frame.
  122203. */
  122204. autoUpdateExtends: boolean;
  122205. /**
  122206. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122207. * on each frame. autoUpdateExtends must be set to true for this to work
  122208. */
  122209. autoCalcShadowZBounds: boolean;
  122210. private _orthoLeft;
  122211. private _orthoRight;
  122212. private _orthoTop;
  122213. private _orthoBottom;
  122214. /**
  122215. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122216. * The directional light is emitted from everywhere in the given direction.
  122217. * It can cast shadows.
  122218. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122219. * @param name The friendly name of the light
  122220. * @param direction The direction of the light
  122221. * @param scene The scene the light belongs to
  122222. */
  122223. constructor(name: string, direction: Vector3, scene: Scene);
  122224. /**
  122225. * Returns the string "DirectionalLight".
  122226. * @return The class name
  122227. */
  122228. getClassName(): string;
  122229. /**
  122230. * Returns the integer 1.
  122231. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122232. */
  122233. getTypeID(): number;
  122234. /**
  122235. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122236. * Returns the DirectionalLight Shadow projection matrix.
  122237. */
  122238. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122239. /**
  122240. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122241. * Returns the DirectionalLight Shadow projection matrix.
  122242. */
  122243. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122244. /**
  122245. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122246. * Returns the DirectionalLight Shadow projection matrix.
  122247. */
  122248. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122249. protected _buildUniformLayout(): void;
  122250. /**
  122251. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122252. * @param effect The effect to update
  122253. * @param lightIndex The index of the light in the effect to update
  122254. * @returns The directional light
  122255. */
  122256. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122257. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122258. /**
  122259. * Gets the minZ used for shadow according to both the scene and the light.
  122260. *
  122261. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122262. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122263. * @param activeCamera The camera we are returning the min for
  122264. * @returns the depth min z
  122265. */
  122266. getDepthMinZ(activeCamera: Camera): number;
  122267. /**
  122268. * Gets the maxZ used for shadow according to both the scene and the light.
  122269. *
  122270. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122271. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122272. * @param activeCamera The camera we are returning the max for
  122273. * @returns the depth max z
  122274. */
  122275. getDepthMaxZ(activeCamera: Camera): number;
  122276. /**
  122277. * Prepares the list of defines specific to the light type.
  122278. * @param defines the list of defines
  122279. * @param lightIndex defines the index of the light for the effect
  122280. */
  122281. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122282. }
  122283. }
  122284. declare module BABYLON {
  122285. /**
  122286. * Class containing static functions to help procedurally build meshes
  122287. */
  122288. export class HemisphereBuilder {
  122289. /**
  122290. * Creates a hemisphere mesh
  122291. * @param name defines the name of the mesh
  122292. * @param options defines the options used to create the mesh
  122293. * @param scene defines the hosting scene
  122294. * @returns the hemisphere mesh
  122295. */
  122296. static CreateHemisphere(name: string, options: {
  122297. segments?: number;
  122298. diameter?: number;
  122299. sideOrientation?: number;
  122300. }, scene: any): Mesh;
  122301. }
  122302. }
  122303. declare module BABYLON {
  122304. /**
  122305. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122306. * These values define a cone of light starting from the position, emitting toward the direction.
  122307. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122308. * and the exponent defines the speed of the decay of the light with distance (reach).
  122309. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122310. */
  122311. export class SpotLight extends ShadowLight {
  122312. private _angle;
  122313. private _innerAngle;
  122314. private _cosHalfAngle;
  122315. private _lightAngleScale;
  122316. private _lightAngleOffset;
  122317. /**
  122318. * Gets the cone angle of the spot light in Radians.
  122319. */
  122320. get angle(): number;
  122321. /**
  122322. * Sets the cone angle of the spot light in Radians.
  122323. */
  122324. set angle(value: number);
  122325. /**
  122326. * Only used in gltf falloff mode, this defines the angle where
  122327. * the directional falloff will start before cutting at angle which could be seen
  122328. * as outer angle.
  122329. */
  122330. get innerAngle(): number;
  122331. /**
  122332. * Only used in gltf falloff mode, this defines the angle where
  122333. * the directional falloff will start before cutting at angle which could be seen
  122334. * as outer angle.
  122335. */
  122336. set innerAngle(value: number);
  122337. private _shadowAngleScale;
  122338. /**
  122339. * Allows scaling the angle of the light for shadow generation only.
  122340. */
  122341. get shadowAngleScale(): number;
  122342. /**
  122343. * Allows scaling the angle of the light for shadow generation only.
  122344. */
  122345. set shadowAngleScale(value: number);
  122346. /**
  122347. * The light decay speed with the distance from the emission spot.
  122348. */
  122349. exponent: number;
  122350. private _projectionTextureMatrix;
  122351. /**
  122352. * Allows reading the projecton texture
  122353. */
  122354. get projectionTextureMatrix(): Matrix;
  122355. protected _projectionTextureLightNear: number;
  122356. /**
  122357. * Gets the near clip of the Spotlight for texture projection.
  122358. */
  122359. get projectionTextureLightNear(): number;
  122360. /**
  122361. * Sets the near clip of the Spotlight for texture projection.
  122362. */
  122363. set projectionTextureLightNear(value: number);
  122364. protected _projectionTextureLightFar: number;
  122365. /**
  122366. * Gets the far clip of the Spotlight for texture projection.
  122367. */
  122368. get projectionTextureLightFar(): number;
  122369. /**
  122370. * Sets the far clip of the Spotlight for texture projection.
  122371. */
  122372. set projectionTextureLightFar(value: number);
  122373. protected _projectionTextureUpDirection: Vector3;
  122374. /**
  122375. * Gets the Up vector of the Spotlight for texture projection.
  122376. */
  122377. get projectionTextureUpDirection(): Vector3;
  122378. /**
  122379. * Sets the Up vector of the Spotlight for texture projection.
  122380. */
  122381. set projectionTextureUpDirection(value: Vector3);
  122382. private _projectionTexture;
  122383. /**
  122384. * Gets the projection texture of the light.
  122385. */
  122386. get projectionTexture(): Nullable<BaseTexture>;
  122387. /**
  122388. * Sets the projection texture of the light.
  122389. */
  122390. set projectionTexture(value: Nullable<BaseTexture>);
  122391. private _projectionTextureViewLightDirty;
  122392. private _projectionTextureProjectionLightDirty;
  122393. private _projectionTextureDirty;
  122394. private _projectionTextureViewTargetVector;
  122395. private _projectionTextureViewLightMatrix;
  122396. private _projectionTextureProjectionLightMatrix;
  122397. private _projectionTextureScalingMatrix;
  122398. /**
  122399. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122400. * It can cast shadows.
  122401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122402. * @param name The light friendly name
  122403. * @param position The position of the spot light in the scene
  122404. * @param direction The direction of the light in the scene
  122405. * @param angle The cone angle of the light in Radians
  122406. * @param exponent The light decay speed with the distance from the emission spot
  122407. * @param scene The scene the lights belongs to
  122408. */
  122409. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122410. /**
  122411. * Returns the string "SpotLight".
  122412. * @returns the class name
  122413. */
  122414. getClassName(): string;
  122415. /**
  122416. * Returns the integer 2.
  122417. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122418. */
  122419. getTypeID(): number;
  122420. /**
  122421. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122422. */
  122423. protected _setDirection(value: Vector3): void;
  122424. /**
  122425. * Overrides the position setter to recompute the projection texture view light Matrix.
  122426. */
  122427. protected _setPosition(value: Vector3): void;
  122428. /**
  122429. * 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.
  122430. * Returns the SpotLight.
  122431. */
  122432. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122433. protected _computeProjectionTextureViewLightMatrix(): void;
  122434. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122435. /**
  122436. * Main function for light texture projection matrix computing.
  122437. */
  122438. protected _computeProjectionTextureMatrix(): void;
  122439. protected _buildUniformLayout(): void;
  122440. private _computeAngleValues;
  122441. /**
  122442. * Sets the passed Effect "effect" with the Light textures.
  122443. * @param effect The effect to update
  122444. * @param lightIndex The index of the light in the effect to update
  122445. * @returns The light
  122446. */
  122447. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122448. /**
  122449. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122450. * @param effect The effect to update
  122451. * @param lightIndex The index of the light in the effect to update
  122452. * @returns The spot light
  122453. */
  122454. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122455. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122456. /**
  122457. * Disposes the light and the associated resources.
  122458. */
  122459. dispose(): void;
  122460. /**
  122461. * Prepares the list of defines specific to the light type.
  122462. * @param defines the list of defines
  122463. * @param lightIndex defines the index of the light for the effect
  122464. */
  122465. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122466. }
  122467. }
  122468. declare module BABYLON {
  122469. /**
  122470. * Gizmo that enables viewing a light
  122471. */
  122472. export class LightGizmo extends Gizmo {
  122473. private _lightMesh;
  122474. private _material;
  122475. private _cachedPosition;
  122476. private _cachedForward;
  122477. private _attachedMeshParent;
  122478. /**
  122479. * Creates a LightGizmo
  122480. * @param gizmoLayer The utility layer the gizmo will be added to
  122481. */
  122482. constructor(gizmoLayer?: UtilityLayerRenderer);
  122483. private _light;
  122484. /**
  122485. * The light that the gizmo is attached to
  122486. */
  122487. set light(light: Nullable<Light>);
  122488. get light(): Nullable<Light>;
  122489. /**
  122490. * Gets the material used to render the light gizmo
  122491. */
  122492. get material(): StandardMaterial;
  122493. /**
  122494. * @hidden
  122495. * Updates the gizmo to match the attached mesh's position/rotation
  122496. */
  122497. protected _update(): void;
  122498. private static _Scale;
  122499. /**
  122500. * Creates the lines for a light mesh
  122501. */
  122502. private static _CreateLightLines;
  122503. /**
  122504. * Disposes of the light gizmo
  122505. */
  122506. dispose(): void;
  122507. private static _CreateHemisphericLightMesh;
  122508. private static _CreatePointLightMesh;
  122509. private static _CreateSpotLightMesh;
  122510. private static _CreateDirectionalLightMesh;
  122511. }
  122512. }
  122513. declare module BABYLON {
  122514. /** @hidden */
  122515. export var backgroundFragmentDeclaration: {
  122516. name: string;
  122517. shader: string;
  122518. };
  122519. }
  122520. declare module BABYLON {
  122521. /** @hidden */
  122522. export var backgroundUboDeclaration: {
  122523. name: string;
  122524. shader: string;
  122525. };
  122526. }
  122527. declare module BABYLON {
  122528. /** @hidden */
  122529. export var backgroundPixelShader: {
  122530. name: string;
  122531. shader: string;
  122532. };
  122533. }
  122534. declare module BABYLON {
  122535. /** @hidden */
  122536. export var backgroundVertexDeclaration: {
  122537. name: string;
  122538. shader: string;
  122539. };
  122540. }
  122541. declare module BABYLON {
  122542. /** @hidden */
  122543. export var backgroundVertexShader: {
  122544. name: string;
  122545. shader: string;
  122546. };
  122547. }
  122548. declare module BABYLON {
  122549. /**
  122550. * Background material used to create an efficient environement around your scene.
  122551. */
  122552. export class BackgroundMaterial extends PushMaterial {
  122553. /**
  122554. * Standard reflectance value at parallel view angle.
  122555. */
  122556. static StandardReflectance0: number;
  122557. /**
  122558. * Standard reflectance value at grazing angle.
  122559. */
  122560. static StandardReflectance90: number;
  122561. protected _primaryColor: Color3;
  122562. /**
  122563. * Key light Color (multiply against the environement texture)
  122564. */
  122565. primaryColor: Color3;
  122566. protected __perceptualColor: Nullable<Color3>;
  122567. /**
  122568. * Experimental Internal Use Only.
  122569. *
  122570. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122571. * This acts as a helper to set the primary color to a more "human friendly" value.
  122572. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122573. * output color as close as possible from the chosen value.
  122574. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122575. * part of lighting setup.)
  122576. */
  122577. get _perceptualColor(): Nullable<Color3>;
  122578. set _perceptualColor(value: Nullable<Color3>);
  122579. protected _primaryColorShadowLevel: float;
  122580. /**
  122581. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122582. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122583. */
  122584. get primaryColorShadowLevel(): float;
  122585. set primaryColorShadowLevel(value: float);
  122586. protected _primaryColorHighlightLevel: float;
  122587. /**
  122588. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122589. * The primary color is used at the level chosen to define what the white area would look.
  122590. */
  122591. get primaryColorHighlightLevel(): float;
  122592. set primaryColorHighlightLevel(value: float);
  122593. protected _reflectionTexture: Nullable<BaseTexture>;
  122594. /**
  122595. * Reflection Texture used in the material.
  122596. * Should be author in a specific way for the best result (refer to the documentation).
  122597. */
  122598. reflectionTexture: Nullable<BaseTexture>;
  122599. protected _reflectionBlur: float;
  122600. /**
  122601. * Reflection Texture level of blur.
  122602. *
  122603. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122604. * texture twice.
  122605. */
  122606. reflectionBlur: float;
  122607. protected _diffuseTexture: Nullable<BaseTexture>;
  122608. /**
  122609. * Diffuse Texture used in the material.
  122610. * Should be author in a specific way for the best result (refer to the documentation).
  122611. */
  122612. diffuseTexture: Nullable<BaseTexture>;
  122613. protected _shadowLights: Nullable<IShadowLight[]>;
  122614. /**
  122615. * Specify the list of lights casting shadow on the material.
  122616. * All scene shadow lights will be included if null.
  122617. */
  122618. shadowLights: Nullable<IShadowLight[]>;
  122619. protected _shadowLevel: float;
  122620. /**
  122621. * Helps adjusting the shadow to a softer level if required.
  122622. * 0 means black shadows and 1 means no shadows.
  122623. */
  122624. shadowLevel: float;
  122625. protected _sceneCenter: Vector3;
  122626. /**
  122627. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122628. * It is usually zero but might be interesting to modify according to your setup.
  122629. */
  122630. sceneCenter: Vector3;
  122631. protected _opacityFresnel: boolean;
  122632. /**
  122633. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122634. * This helps ensuring a nice transition when the camera goes under the ground.
  122635. */
  122636. opacityFresnel: boolean;
  122637. protected _reflectionFresnel: boolean;
  122638. /**
  122639. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122640. * This helps adding a mirror texture on the ground.
  122641. */
  122642. reflectionFresnel: boolean;
  122643. protected _reflectionFalloffDistance: number;
  122644. /**
  122645. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122646. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122647. */
  122648. reflectionFalloffDistance: number;
  122649. protected _reflectionAmount: number;
  122650. /**
  122651. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122652. */
  122653. reflectionAmount: number;
  122654. protected _reflectionReflectance0: number;
  122655. /**
  122656. * This specifies the weight of the reflection at grazing angle.
  122657. */
  122658. reflectionReflectance0: number;
  122659. protected _reflectionReflectance90: number;
  122660. /**
  122661. * This specifies the weight of the reflection at a perpendicular point of view.
  122662. */
  122663. reflectionReflectance90: number;
  122664. /**
  122665. * Sets the reflection reflectance fresnel values according to the default standard
  122666. * empirically know to work well :-)
  122667. */
  122668. set reflectionStandardFresnelWeight(value: number);
  122669. protected _useRGBColor: boolean;
  122670. /**
  122671. * Helps to directly use the maps channels instead of their level.
  122672. */
  122673. useRGBColor: boolean;
  122674. protected _enableNoise: boolean;
  122675. /**
  122676. * This helps reducing the banding effect that could occur on the background.
  122677. */
  122678. enableNoise: boolean;
  122679. /**
  122680. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122681. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122682. * Recommended to be keep at 1.0 except for special cases.
  122683. */
  122684. get fovMultiplier(): number;
  122685. set fovMultiplier(value: number);
  122686. private _fovMultiplier;
  122687. /**
  122688. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122689. */
  122690. useEquirectangularFOV: boolean;
  122691. private _maxSimultaneousLights;
  122692. /**
  122693. * Number of Simultaneous lights allowed on the material.
  122694. */
  122695. maxSimultaneousLights: int;
  122696. /**
  122697. * Default configuration related to image processing available in the Background Material.
  122698. */
  122699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122700. /**
  122701. * Keep track of the image processing observer to allow dispose and replace.
  122702. */
  122703. private _imageProcessingObserver;
  122704. /**
  122705. * Attaches a new image processing configuration to the PBR Material.
  122706. * @param configuration (if null the scene configuration will be use)
  122707. */
  122708. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122709. /**
  122710. * Gets the image processing configuration used either in this material.
  122711. */
  122712. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122713. /**
  122714. * Sets the Default image processing configuration used either in the this material.
  122715. *
  122716. * If sets to null, the scene one is in use.
  122717. */
  122718. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122719. /**
  122720. * Gets wether the color curves effect is enabled.
  122721. */
  122722. get cameraColorCurvesEnabled(): boolean;
  122723. /**
  122724. * Sets wether the color curves effect is enabled.
  122725. */
  122726. set cameraColorCurvesEnabled(value: boolean);
  122727. /**
  122728. * Gets wether the color grading effect is enabled.
  122729. */
  122730. get cameraColorGradingEnabled(): boolean;
  122731. /**
  122732. * Gets wether the color grading effect is enabled.
  122733. */
  122734. set cameraColorGradingEnabled(value: boolean);
  122735. /**
  122736. * Gets wether tonemapping is enabled or not.
  122737. */
  122738. get cameraToneMappingEnabled(): boolean;
  122739. /**
  122740. * Sets wether tonemapping is enabled or not
  122741. */
  122742. set cameraToneMappingEnabled(value: boolean);
  122743. /**
  122744. * The camera exposure used on this material.
  122745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122746. * This corresponds to a photographic exposure.
  122747. */
  122748. get cameraExposure(): float;
  122749. /**
  122750. * The camera exposure used on this material.
  122751. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122752. * This corresponds to a photographic exposure.
  122753. */
  122754. set cameraExposure(value: float);
  122755. /**
  122756. * Gets The camera contrast used on this material.
  122757. */
  122758. get cameraContrast(): float;
  122759. /**
  122760. * Sets The camera contrast used on this material.
  122761. */
  122762. set cameraContrast(value: float);
  122763. /**
  122764. * Gets the Color Grading 2D Lookup Texture.
  122765. */
  122766. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122767. /**
  122768. * Sets the Color Grading 2D Lookup Texture.
  122769. */
  122770. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122771. /**
  122772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122774. * 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;
  122775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122776. */
  122777. get cameraColorCurves(): Nullable<ColorCurves>;
  122778. /**
  122779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122781. * 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;
  122782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122783. */
  122784. set cameraColorCurves(value: Nullable<ColorCurves>);
  122785. /**
  122786. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122787. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122788. */
  122789. switchToBGR: boolean;
  122790. private _renderTargets;
  122791. private _reflectionControls;
  122792. private _white;
  122793. private _primaryShadowColor;
  122794. private _primaryHighlightColor;
  122795. /**
  122796. * Instantiates a Background Material in the given scene
  122797. * @param name The friendly name of the material
  122798. * @param scene The scene to add the material to
  122799. */
  122800. constructor(name: string, scene: Scene);
  122801. /**
  122802. * Gets a boolean indicating that current material needs to register RTT
  122803. */
  122804. get hasRenderTargetTextures(): boolean;
  122805. /**
  122806. * The entire material has been created in order to prevent overdraw.
  122807. * @returns false
  122808. */
  122809. needAlphaTesting(): boolean;
  122810. /**
  122811. * The entire material has been created in order to prevent overdraw.
  122812. * @returns true if blending is enable
  122813. */
  122814. needAlphaBlending(): boolean;
  122815. /**
  122816. * Checks wether the material is ready to be rendered for a given mesh.
  122817. * @param mesh The mesh to render
  122818. * @param subMesh The submesh to check against
  122819. * @param useInstances Specify wether or not the material is used with instances
  122820. * @returns true if all the dependencies are ready (Textures, Effects...)
  122821. */
  122822. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122823. /**
  122824. * Compute the primary color according to the chosen perceptual color.
  122825. */
  122826. private _computePrimaryColorFromPerceptualColor;
  122827. /**
  122828. * Compute the highlights and shadow colors according to their chosen levels.
  122829. */
  122830. private _computePrimaryColors;
  122831. /**
  122832. * Build the uniform buffer used in the material.
  122833. */
  122834. buildUniformLayout(): void;
  122835. /**
  122836. * Unbind the material.
  122837. */
  122838. unbind(): void;
  122839. /**
  122840. * Bind only the world matrix to the material.
  122841. * @param world The world matrix to bind.
  122842. */
  122843. bindOnlyWorldMatrix(world: Matrix): void;
  122844. /**
  122845. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122846. * @param world The world matrix to bind.
  122847. * @param subMesh The submesh to bind for.
  122848. */
  122849. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122850. /**
  122851. * Checks to see if a texture is used in the material.
  122852. * @param texture - Base texture to use.
  122853. * @returns - Boolean specifying if a texture is used in the material.
  122854. */
  122855. hasTexture(texture: BaseTexture): boolean;
  122856. /**
  122857. * Dispose the material.
  122858. * @param forceDisposeEffect Force disposal of the associated effect.
  122859. * @param forceDisposeTextures Force disposal of the associated textures.
  122860. */
  122861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122862. /**
  122863. * Clones the material.
  122864. * @param name The cloned name.
  122865. * @returns The cloned material.
  122866. */
  122867. clone(name: string): BackgroundMaterial;
  122868. /**
  122869. * Serializes the current material to its JSON representation.
  122870. * @returns The JSON representation.
  122871. */
  122872. serialize(): any;
  122873. /**
  122874. * Gets the class name of the material
  122875. * @returns "BackgroundMaterial"
  122876. */
  122877. getClassName(): string;
  122878. /**
  122879. * Parse a JSON input to create back a background material.
  122880. * @param source The JSON data to parse
  122881. * @param scene The scene to create the parsed material in
  122882. * @param rootUrl The root url of the assets the material depends upon
  122883. * @returns the instantiated BackgroundMaterial.
  122884. */
  122885. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122886. }
  122887. }
  122888. declare module BABYLON {
  122889. /**
  122890. * Represents the different options available during the creation of
  122891. * a Environment helper.
  122892. *
  122893. * This can control the default ground, skybox and image processing setup of your scene.
  122894. */
  122895. export interface IEnvironmentHelperOptions {
  122896. /**
  122897. * Specifies whether or not to create a ground.
  122898. * True by default.
  122899. */
  122900. createGround: boolean;
  122901. /**
  122902. * Specifies the ground size.
  122903. * 15 by default.
  122904. */
  122905. groundSize: number;
  122906. /**
  122907. * The texture used on the ground for the main color.
  122908. * Comes from the BabylonJS CDN by default.
  122909. *
  122910. * Remarks: Can be either a texture or a url.
  122911. */
  122912. groundTexture: string | BaseTexture;
  122913. /**
  122914. * The color mixed in the ground texture by default.
  122915. * BabylonJS clearColor by default.
  122916. */
  122917. groundColor: Color3;
  122918. /**
  122919. * Specifies the ground opacity.
  122920. * 1 by default.
  122921. */
  122922. groundOpacity: number;
  122923. /**
  122924. * Enables the ground to receive shadows.
  122925. * True by default.
  122926. */
  122927. enableGroundShadow: boolean;
  122928. /**
  122929. * Helps preventing the shadow to be fully black on the ground.
  122930. * 0.5 by default.
  122931. */
  122932. groundShadowLevel: number;
  122933. /**
  122934. * Creates a mirror texture attach to the ground.
  122935. * false by default.
  122936. */
  122937. enableGroundMirror: boolean;
  122938. /**
  122939. * Specifies the ground mirror size ratio.
  122940. * 0.3 by default as the default kernel is 64.
  122941. */
  122942. groundMirrorSizeRatio: number;
  122943. /**
  122944. * Specifies the ground mirror blur kernel size.
  122945. * 64 by default.
  122946. */
  122947. groundMirrorBlurKernel: number;
  122948. /**
  122949. * Specifies the ground mirror visibility amount.
  122950. * 1 by default
  122951. */
  122952. groundMirrorAmount: number;
  122953. /**
  122954. * Specifies the ground mirror reflectance weight.
  122955. * This uses the standard weight of the background material to setup the fresnel effect
  122956. * of the mirror.
  122957. * 1 by default.
  122958. */
  122959. groundMirrorFresnelWeight: number;
  122960. /**
  122961. * Specifies the ground mirror Falloff distance.
  122962. * This can helps reducing the size of the reflection.
  122963. * 0 by Default.
  122964. */
  122965. groundMirrorFallOffDistance: number;
  122966. /**
  122967. * Specifies the ground mirror texture type.
  122968. * Unsigned Int by Default.
  122969. */
  122970. groundMirrorTextureType: number;
  122971. /**
  122972. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122973. * the shown objects.
  122974. */
  122975. groundYBias: number;
  122976. /**
  122977. * Specifies whether or not to create a skybox.
  122978. * True by default.
  122979. */
  122980. createSkybox: boolean;
  122981. /**
  122982. * Specifies the skybox size.
  122983. * 20 by default.
  122984. */
  122985. skyboxSize: number;
  122986. /**
  122987. * The texture used on the skybox for the main color.
  122988. * Comes from the BabylonJS CDN by default.
  122989. *
  122990. * Remarks: Can be either a texture or a url.
  122991. */
  122992. skyboxTexture: string | BaseTexture;
  122993. /**
  122994. * The color mixed in the skybox texture by default.
  122995. * BabylonJS clearColor by default.
  122996. */
  122997. skyboxColor: Color3;
  122998. /**
  122999. * The background rotation around the Y axis of the scene.
  123000. * This helps aligning the key lights of your scene with the background.
  123001. * 0 by default.
  123002. */
  123003. backgroundYRotation: number;
  123004. /**
  123005. * Compute automatically the size of the elements to best fit with the scene.
  123006. */
  123007. sizeAuto: boolean;
  123008. /**
  123009. * Default position of the rootMesh if autoSize is not true.
  123010. */
  123011. rootPosition: Vector3;
  123012. /**
  123013. * Sets up the image processing in the scene.
  123014. * true by default.
  123015. */
  123016. setupImageProcessing: boolean;
  123017. /**
  123018. * The texture used as your environment texture in the scene.
  123019. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  123020. *
  123021. * Remarks: Can be either a texture or a url.
  123022. */
  123023. environmentTexture: string | BaseTexture;
  123024. /**
  123025. * The value of the exposure to apply to the scene.
  123026. * 0.6 by default if setupImageProcessing is true.
  123027. */
  123028. cameraExposure: number;
  123029. /**
  123030. * The value of the contrast to apply to the scene.
  123031. * 1.6 by default if setupImageProcessing is true.
  123032. */
  123033. cameraContrast: number;
  123034. /**
  123035. * Specifies whether or not tonemapping should be enabled in the scene.
  123036. * true by default if setupImageProcessing is true.
  123037. */
  123038. toneMappingEnabled: boolean;
  123039. }
  123040. /**
  123041. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  123042. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  123043. * It also helps with the default setup of your imageProcessing configuration.
  123044. */
  123045. export class EnvironmentHelper {
  123046. /**
  123047. * Default ground texture URL.
  123048. */
  123049. private static _groundTextureCDNUrl;
  123050. /**
  123051. * Default skybox texture URL.
  123052. */
  123053. private static _skyboxTextureCDNUrl;
  123054. /**
  123055. * Default environment texture URL.
  123056. */
  123057. private static _environmentTextureCDNUrl;
  123058. /**
  123059. * Creates the default options for the helper.
  123060. */
  123061. private static _getDefaultOptions;
  123062. private _rootMesh;
  123063. /**
  123064. * Gets the root mesh created by the helper.
  123065. */
  123066. get rootMesh(): Mesh;
  123067. private _skybox;
  123068. /**
  123069. * Gets the skybox created by the helper.
  123070. */
  123071. get skybox(): Nullable<Mesh>;
  123072. private _skyboxTexture;
  123073. /**
  123074. * Gets the skybox texture created by the helper.
  123075. */
  123076. get skyboxTexture(): Nullable<BaseTexture>;
  123077. private _skyboxMaterial;
  123078. /**
  123079. * Gets the skybox material created by the helper.
  123080. */
  123081. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  123082. private _ground;
  123083. /**
  123084. * Gets the ground mesh created by the helper.
  123085. */
  123086. get ground(): Nullable<Mesh>;
  123087. private _groundTexture;
  123088. /**
  123089. * Gets the ground texture created by the helper.
  123090. */
  123091. get groundTexture(): Nullable<BaseTexture>;
  123092. private _groundMirror;
  123093. /**
  123094. * Gets the ground mirror created by the helper.
  123095. */
  123096. get groundMirror(): Nullable<MirrorTexture>;
  123097. /**
  123098. * Gets the ground mirror render list to helps pushing the meshes
  123099. * you wish in the ground reflection.
  123100. */
  123101. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123102. private _groundMaterial;
  123103. /**
  123104. * Gets the ground material created by the helper.
  123105. */
  123106. get groundMaterial(): Nullable<BackgroundMaterial>;
  123107. /**
  123108. * Stores the creation options.
  123109. */
  123110. private readonly _scene;
  123111. private _options;
  123112. /**
  123113. * This observable will be notified with any error during the creation of the environment,
  123114. * mainly texture creation errors.
  123115. */
  123116. onErrorObservable: Observable<{
  123117. message?: string;
  123118. exception?: any;
  123119. }>;
  123120. /**
  123121. * constructor
  123122. * @param options Defines the options we want to customize the helper
  123123. * @param scene The scene to add the material to
  123124. */
  123125. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123126. /**
  123127. * Updates the background according to the new options
  123128. * @param options
  123129. */
  123130. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123131. /**
  123132. * Sets the primary color of all the available elements.
  123133. * @param color the main color to affect to the ground and the background
  123134. */
  123135. setMainColor(color: Color3): void;
  123136. /**
  123137. * Setup the image processing according to the specified options.
  123138. */
  123139. private _setupImageProcessing;
  123140. /**
  123141. * Setup the environment texture according to the specified options.
  123142. */
  123143. private _setupEnvironmentTexture;
  123144. /**
  123145. * Setup the background according to the specified options.
  123146. */
  123147. private _setupBackground;
  123148. /**
  123149. * Get the scene sizes according to the setup.
  123150. */
  123151. private _getSceneSize;
  123152. /**
  123153. * Setup the ground according to the specified options.
  123154. */
  123155. private _setupGround;
  123156. /**
  123157. * Setup the ground material according to the specified options.
  123158. */
  123159. private _setupGroundMaterial;
  123160. /**
  123161. * Setup the ground diffuse texture according to the specified options.
  123162. */
  123163. private _setupGroundDiffuseTexture;
  123164. /**
  123165. * Setup the ground mirror texture according to the specified options.
  123166. */
  123167. private _setupGroundMirrorTexture;
  123168. /**
  123169. * Setup the ground to receive the mirror texture.
  123170. */
  123171. private _setupMirrorInGroundMaterial;
  123172. /**
  123173. * Setup the skybox according to the specified options.
  123174. */
  123175. private _setupSkybox;
  123176. /**
  123177. * Setup the skybox material according to the specified options.
  123178. */
  123179. private _setupSkyboxMaterial;
  123180. /**
  123181. * Setup the skybox reflection texture according to the specified options.
  123182. */
  123183. private _setupSkyboxReflectionTexture;
  123184. private _errorHandler;
  123185. /**
  123186. * Dispose all the elements created by the Helper.
  123187. */
  123188. dispose(): void;
  123189. }
  123190. }
  123191. declare module BABYLON {
  123192. /**
  123193. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123194. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123195. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123196. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123197. */
  123198. export class PhotoDome extends TransformNode {
  123199. /**
  123200. * Define the image as a Monoscopic panoramic 360 image.
  123201. */
  123202. static readonly MODE_MONOSCOPIC: number;
  123203. /**
  123204. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123205. */
  123206. static readonly MODE_TOPBOTTOM: number;
  123207. /**
  123208. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123209. */
  123210. static readonly MODE_SIDEBYSIDE: number;
  123211. private _useDirectMapping;
  123212. /**
  123213. * The texture being displayed on the sphere
  123214. */
  123215. protected _photoTexture: Texture;
  123216. /**
  123217. * Gets or sets the texture being displayed on the sphere
  123218. */
  123219. get photoTexture(): Texture;
  123220. set photoTexture(value: Texture);
  123221. /**
  123222. * Observable raised when an error occured while loading the 360 image
  123223. */
  123224. onLoadErrorObservable: Observable<string>;
  123225. /**
  123226. * The skybox material
  123227. */
  123228. protected _material: BackgroundMaterial;
  123229. /**
  123230. * The surface used for the skybox
  123231. */
  123232. protected _mesh: Mesh;
  123233. /**
  123234. * Gets the mesh used for the skybox.
  123235. */
  123236. get mesh(): Mesh;
  123237. /**
  123238. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123239. * Also see the options.resolution property.
  123240. */
  123241. get fovMultiplier(): number;
  123242. set fovMultiplier(value: number);
  123243. private _imageMode;
  123244. /**
  123245. * Gets or set the current video mode for the video. It can be:
  123246. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123247. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123248. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123249. */
  123250. get imageMode(): number;
  123251. set imageMode(value: number);
  123252. /**
  123253. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123254. * @param name Element's name, child elements will append suffixes for their own names.
  123255. * @param urlsOfPhoto defines the url of the photo to display
  123256. * @param options defines an object containing optional or exposed sub element properties
  123257. * @param onError defines a callback called when an error occured while loading the texture
  123258. */
  123259. constructor(name: string, urlOfPhoto: string, options: {
  123260. resolution?: number;
  123261. size?: number;
  123262. useDirectMapping?: boolean;
  123263. faceForward?: boolean;
  123264. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123265. private _onBeforeCameraRenderObserver;
  123266. private _changeImageMode;
  123267. /**
  123268. * Releases resources associated with this node.
  123269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123271. */
  123272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123273. }
  123274. }
  123275. declare module BABYLON {
  123276. /**
  123277. * Class used to host RGBD texture specific utilities
  123278. */
  123279. export class RGBDTextureTools {
  123280. /**
  123281. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123282. * @param texture the texture to expand.
  123283. */
  123284. static ExpandRGBDTexture(texture: Texture): void;
  123285. }
  123286. }
  123287. declare module BABYLON {
  123288. /**
  123289. * Class used to host texture specific utilities
  123290. */
  123291. export class BRDFTextureTools {
  123292. /**
  123293. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123294. * @param scene defines the hosting scene
  123295. * @returns the environment BRDF texture
  123296. */
  123297. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123298. private static _environmentBRDFBase64Texture;
  123299. }
  123300. }
  123301. declare module BABYLON {
  123302. /**
  123303. * @hidden
  123304. */
  123305. export interface IMaterialClearCoatDefines {
  123306. CLEARCOAT: boolean;
  123307. CLEARCOAT_DEFAULTIOR: boolean;
  123308. CLEARCOAT_TEXTURE: boolean;
  123309. CLEARCOAT_TEXTUREDIRECTUV: number;
  123310. CLEARCOAT_BUMP: boolean;
  123311. CLEARCOAT_BUMPDIRECTUV: number;
  123312. CLEARCOAT_TINT: boolean;
  123313. CLEARCOAT_TINT_TEXTURE: boolean;
  123314. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123315. /** @hidden */
  123316. _areTexturesDirty: boolean;
  123317. }
  123318. /**
  123319. * Define the code related to the clear coat parameters of the pbr material.
  123320. */
  123321. export class PBRClearCoatConfiguration {
  123322. /**
  123323. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123324. * The default fits with a polyurethane material.
  123325. */
  123326. private static readonly _DefaultIndexOfRefraction;
  123327. private _isEnabled;
  123328. /**
  123329. * Defines if the clear coat is enabled in the material.
  123330. */
  123331. isEnabled: boolean;
  123332. /**
  123333. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123334. */
  123335. intensity: number;
  123336. /**
  123337. * Defines the clear coat layer roughness.
  123338. */
  123339. roughness: number;
  123340. private _indexOfRefraction;
  123341. /**
  123342. * Defines the index of refraction of the clear coat.
  123343. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123344. * The default fits with a polyurethane material.
  123345. * Changing the default value is more performance intensive.
  123346. */
  123347. indexOfRefraction: number;
  123348. private _texture;
  123349. /**
  123350. * Stores the clear coat values in a texture.
  123351. */
  123352. texture: Nullable<BaseTexture>;
  123353. private _bumpTexture;
  123354. /**
  123355. * Define the clear coat specific bump texture.
  123356. */
  123357. bumpTexture: Nullable<BaseTexture>;
  123358. private _isTintEnabled;
  123359. /**
  123360. * Defines if the clear coat tint is enabled in the material.
  123361. */
  123362. isTintEnabled: boolean;
  123363. /**
  123364. * Defines the clear coat tint of the material.
  123365. * This is only use if tint is enabled
  123366. */
  123367. tintColor: Color3;
  123368. /**
  123369. * Defines the distance at which the tint color should be found in the
  123370. * clear coat media.
  123371. * This is only use if tint is enabled
  123372. */
  123373. tintColorAtDistance: number;
  123374. /**
  123375. * Defines the clear coat layer thickness.
  123376. * This is only use if tint is enabled
  123377. */
  123378. tintThickness: number;
  123379. private _tintTexture;
  123380. /**
  123381. * Stores the clear tint values in a texture.
  123382. * rgb is tint
  123383. * a is a thickness factor
  123384. */
  123385. tintTexture: Nullable<BaseTexture>;
  123386. /** @hidden */
  123387. private _internalMarkAllSubMeshesAsTexturesDirty;
  123388. /** @hidden */
  123389. _markAllSubMeshesAsTexturesDirty(): void;
  123390. /**
  123391. * Instantiate a new istance of clear coat configuration.
  123392. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123393. */
  123394. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123395. /**
  123396. * Gets wehter the submesh is ready to be used or not.
  123397. * @param defines the list of "defines" to update.
  123398. * @param scene defines the scene the material belongs to.
  123399. * @param engine defines the engine the material belongs to.
  123400. * @param disableBumpMap defines wether the material disables bump or not.
  123401. * @returns - boolean indicating that the submesh is ready or not.
  123402. */
  123403. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123404. /**
  123405. * Checks to see if a texture is used in the material.
  123406. * @param defines the list of "defines" to update.
  123407. * @param scene defines the scene to the material belongs to.
  123408. */
  123409. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123410. /**
  123411. * Binds the material data.
  123412. * @param uniformBuffer defines the Uniform buffer to fill in.
  123413. * @param scene defines the scene the material belongs to.
  123414. * @param engine defines the engine the material belongs to.
  123415. * @param disableBumpMap defines wether the material disables bump or not.
  123416. * @param isFrozen defines wether the material is frozen or not.
  123417. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123418. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123419. */
  123420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123421. /**
  123422. * Checks to see if a texture is used in the material.
  123423. * @param texture - Base texture to use.
  123424. * @returns - Boolean specifying if a texture is used in the material.
  123425. */
  123426. hasTexture(texture: BaseTexture): boolean;
  123427. /**
  123428. * Returns an array of the actively used textures.
  123429. * @param activeTextures Array of BaseTextures
  123430. */
  123431. getActiveTextures(activeTextures: BaseTexture[]): void;
  123432. /**
  123433. * Returns the animatable textures.
  123434. * @param animatables Array of animatable textures.
  123435. */
  123436. getAnimatables(animatables: IAnimatable[]): void;
  123437. /**
  123438. * Disposes the resources of the material.
  123439. * @param forceDisposeTextures - Forces the disposal of all textures.
  123440. */
  123441. dispose(forceDisposeTextures?: boolean): void;
  123442. /**
  123443. * Get the current class name of the texture useful for serialization or dynamic coding.
  123444. * @returns "PBRClearCoatConfiguration"
  123445. */
  123446. getClassName(): string;
  123447. /**
  123448. * Add fallbacks to the effect fallbacks list.
  123449. * @param defines defines the Base texture to use.
  123450. * @param fallbacks defines the current fallback list.
  123451. * @param currentRank defines the current fallback rank.
  123452. * @returns the new fallback rank.
  123453. */
  123454. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123455. /**
  123456. * Add the required uniforms to the current list.
  123457. * @param uniforms defines the current uniform list.
  123458. */
  123459. static AddUniforms(uniforms: string[]): void;
  123460. /**
  123461. * Add the required samplers to the current list.
  123462. * @param samplers defines the current sampler list.
  123463. */
  123464. static AddSamplers(samplers: string[]): void;
  123465. /**
  123466. * Add the required uniforms to the current buffer.
  123467. * @param uniformBuffer defines the current uniform buffer.
  123468. */
  123469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123470. /**
  123471. * Makes a duplicate of the current configuration into another one.
  123472. * @param clearCoatConfiguration define the config where to copy the info
  123473. */
  123474. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123475. /**
  123476. * Serializes this clear coat configuration.
  123477. * @returns - An object with the serialized config.
  123478. */
  123479. serialize(): any;
  123480. /**
  123481. * Parses a anisotropy Configuration from a serialized object.
  123482. * @param source - Serialized object.
  123483. * @param scene Defines the scene we are parsing for
  123484. * @param rootUrl Defines the rootUrl to load from
  123485. */
  123486. parse(source: any, scene: Scene, rootUrl: string): void;
  123487. }
  123488. }
  123489. declare module BABYLON {
  123490. /**
  123491. * @hidden
  123492. */
  123493. export interface IMaterialAnisotropicDefines {
  123494. ANISOTROPIC: boolean;
  123495. ANISOTROPIC_TEXTURE: boolean;
  123496. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123497. MAINUV1: boolean;
  123498. _areTexturesDirty: boolean;
  123499. _needUVs: boolean;
  123500. }
  123501. /**
  123502. * Define the code related to the anisotropic parameters of the pbr material.
  123503. */
  123504. export class PBRAnisotropicConfiguration {
  123505. private _isEnabled;
  123506. /**
  123507. * Defines if the anisotropy is enabled in the material.
  123508. */
  123509. isEnabled: boolean;
  123510. /**
  123511. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123512. */
  123513. intensity: number;
  123514. /**
  123515. * Defines if the effect is along the tangents, bitangents or in between.
  123516. * By default, the effect is "strectching" the highlights along the tangents.
  123517. */
  123518. direction: Vector2;
  123519. private _texture;
  123520. /**
  123521. * Stores the anisotropy values in a texture.
  123522. * rg is direction (like normal from -1 to 1)
  123523. * b is a intensity
  123524. */
  123525. texture: Nullable<BaseTexture>;
  123526. /** @hidden */
  123527. private _internalMarkAllSubMeshesAsTexturesDirty;
  123528. /** @hidden */
  123529. _markAllSubMeshesAsTexturesDirty(): void;
  123530. /**
  123531. * Instantiate a new istance of anisotropy configuration.
  123532. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123533. */
  123534. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123535. /**
  123536. * Specifies that the submesh is ready to be used.
  123537. * @param defines the list of "defines" to update.
  123538. * @param scene defines the scene the material belongs to.
  123539. * @returns - boolean indicating that the submesh is ready or not.
  123540. */
  123541. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123542. /**
  123543. * Checks to see if a texture is used in the material.
  123544. * @param defines the list of "defines" to update.
  123545. * @param mesh the mesh we are preparing the defines for.
  123546. * @param scene defines the scene the material belongs to.
  123547. */
  123548. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123549. /**
  123550. * Binds the material data.
  123551. * @param uniformBuffer defines the Uniform buffer to fill in.
  123552. * @param scene defines the scene the material belongs to.
  123553. * @param isFrozen defines wether the material is frozen or not.
  123554. */
  123555. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123556. /**
  123557. * Checks to see if a texture is used in the material.
  123558. * @param texture - Base texture to use.
  123559. * @returns - Boolean specifying if a texture is used in the material.
  123560. */
  123561. hasTexture(texture: BaseTexture): boolean;
  123562. /**
  123563. * Returns an array of the actively used textures.
  123564. * @param activeTextures Array of BaseTextures
  123565. */
  123566. getActiveTextures(activeTextures: BaseTexture[]): void;
  123567. /**
  123568. * Returns the animatable textures.
  123569. * @param animatables Array of animatable textures.
  123570. */
  123571. getAnimatables(animatables: IAnimatable[]): void;
  123572. /**
  123573. * Disposes the resources of the material.
  123574. * @param forceDisposeTextures - Forces the disposal of all textures.
  123575. */
  123576. dispose(forceDisposeTextures?: boolean): void;
  123577. /**
  123578. * Get the current class name of the texture useful for serialization or dynamic coding.
  123579. * @returns "PBRAnisotropicConfiguration"
  123580. */
  123581. getClassName(): string;
  123582. /**
  123583. * Add fallbacks to the effect fallbacks list.
  123584. * @param defines defines the Base texture to use.
  123585. * @param fallbacks defines the current fallback list.
  123586. * @param currentRank defines the current fallback rank.
  123587. * @returns the new fallback rank.
  123588. */
  123589. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123590. /**
  123591. * Add the required uniforms to the current list.
  123592. * @param uniforms defines the current uniform list.
  123593. */
  123594. static AddUniforms(uniforms: string[]): void;
  123595. /**
  123596. * Add the required uniforms to the current buffer.
  123597. * @param uniformBuffer defines the current uniform buffer.
  123598. */
  123599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123600. /**
  123601. * Add the required samplers to the current list.
  123602. * @param samplers defines the current sampler list.
  123603. */
  123604. static AddSamplers(samplers: string[]): void;
  123605. /**
  123606. * Makes a duplicate of the current configuration into another one.
  123607. * @param anisotropicConfiguration define the config where to copy the info
  123608. */
  123609. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123610. /**
  123611. * Serializes this anisotropy configuration.
  123612. * @returns - An object with the serialized config.
  123613. */
  123614. serialize(): any;
  123615. /**
  123616. * Parses a anisotropy Configuration from a serialized object.
  123617. * @param source - Serialized object.
  123618. * @param scene Defines the scene we are parsing for
  123619. * @param rootUrl Defines the rootUrl to load from
  123620. */
  123621. parse(source: any, scene: Scene, rootUrl: string): void;
  123622. }
  123623. }
  123624. declare module BABYLON {
  123625. /**
  123626. * @hidden
  123627. */
  123628. export interface IMaterialBRDFDefines {
  123629. BRDF_V_HEIGHT_CORRELATED: boolean;
  123630. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123631. SPHERICAL_HARMONICS: boolean;
  123632. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123633. /** @hidden */
  123634. _areMiscDirty: boolean;
  123635. }
  123636. /**
  123637. * Define the code related to the BRDF parameters of the pbr material.
  123638. */
  123639. export class PBRBRDFConfiguration {
  123640. /**
  123641. * Default value used for the energy conservation.
  123642. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123643. */
  123644. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123645. /**
  123646. * Default value used for the Smith Visibility Height Correlated mode.
  123647. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123648. */
  123649. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123650. /**
  123651. * Default value used for the IBL diffuse part.
  123652. * This can help switching back to the polynomials mode globally which is a tiny bit
  123653. * less GPU intensive at the drawback of a lower quality.
  123654. */
  123655. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123656. /**
  123657. * Default value used for activating energy conservation for the specular workflow.
  123658. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123659. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123660. */
  123661. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123662. private _useEnergyConservation;
  123663. /**
  123664. * Defines if the material uses energy conservation.
  123665. */
  123666. useEnergyConservation: boolean;
  123667. private _useSmithVisibilityHeightCorrelated;
  123668. /**
  123669. * LEGACY Mode set to false
  123670. * Defines if the material uses height smith correlated visibility term.
  123671. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123672. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123673. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123674. * Not relying on height correlated will also disable energy conservation.
  123675. */
  123676. useSmithVisibilityHeightCorrelated: boolean;
  123677. private _useSphericalHarmonics;
  123678. /**
  123679. * LEGACY Mode set to false
  123680. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123681. * diffuse part of the IBL.
  123682. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123683. * to the ground truth.
  123684. */
  123685. useSphericalHarmonics: boolean;
  123686. private _useSpecularGlossinessInputEnergyConservation;
  123687. /**
  123688. * Defines if the material uses energy conservation, when the specular workflow is active.
  123689. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123690. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123691. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123692. */
  123693. useSpecularGlossinessInputEnergyConservation: boolean;
  123694. /** @hidden */
  123695. private _internalMarkAllSubMeshesAsMiscDirty;
  123696. /** @hidden */
  123697. _markAllSubMeshesAsMiscDirty(): void;
  123698. /**
  123699. * Instantiate a new istance of clear coat configuration.
  123700. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123701. */
  123702. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123703. /**
  123704. * Checks to see if a texture is used in the material.
  123705. * @param defines the list of "defines" to update.
  123706. */
  123707. prepareDefines(defines: IMaterialBRDFDefines): void;
  123708. /**
  123709. * Get the current class name of the texture useful for serialization or dynamic coding.
  123710. * @returns "PBRClearCoatConfiguration"
  123711. */
  123712. getClassName(): string;
  123713. /**
  123714. * Makes a duplicate of the current configuration into another one.
  123715. * @param brdfConfiguration define the config where to copy the info
  123716. */
  123717. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123718. /**
  123719. * Serializes this BRDF configuration.
  123720. * @returns - An object with the serialized config.
  123721. */
  123722. serialize(): any;
  123723. /**
  123724. * Parses a anisotropy Configuration from a serialized object.
  123725. * @param source - Serialized object.
  123726. * @param scene Defines the scene we are parsing for
  123727. * @param rootUrl Defines the rootUrl to load from
  123728. */
  123729. parse(source: any, scene: Scene, rootUrl: string): void;
  123730. }
  123731. }
  123732. declare module BABYLON {
  123733. /**
  123734. * @hidden
  123735. */
  123736. export interface IMaterialSheenDefines {
  123737. SHEEN: boolean;
  123738. SHEEN_TEXTURE: boolean;
  123739. SHEEN_TEXTUREDIRECTUV: number;
  123740. SHEEN_LINKWITHALBEDO: boolean;
  123741. /** @hidden */
  123742. _areTexturesDirty: boolean;
  123743. }
  123744. /**
  123745. * Define the code related to the Sheen parameters of the pbr material.
  123746. */
  123747. export class PBRSheenConfiguration {
  123748. private _isEnabled;
  123749. /**
  123750. * Defines if the material uses sheen.
  123751. */
  123752. isEnabled: boolean;
  123753. private _linkSheenWithAlbedo;
  123754. /**
  123755. * Defines if the sheen is linked to the sheen color.
  123756. */
  123757. linkSheenWithAlbedo: boolean;
  123758. /**
  123759. * Defines the sheen intensity.
  123760. */
  123761. intensity: number;
  123762. /**
  123763. * Defines the sheen color.
  123764. */
  123765. color: Color3;
  123766. private _texture;
  123767. /**
  123768. * Stores the sheen tint values in a texture.
  123769. * rgb is tint
  123770. * a is a intensity
  123771. */
  123772. texture: Nullable<BaseTexture>;
  123773. /** @hidden */
  123774. private _internalMarkAllSubMeshesAsTexturesDirty;
  123775. /** @hidden */
  123776. _markAllSubMeshesAsTexturesDirty(): void;
  123777. /**
  123778. * Instantiate a new istance of clear coat configuration.
  123779. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123780. */
  123781. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123782. /**
  123783. * Specifies that the submesh is ready to be used.
  123784. * @param defines the list of "defines" to update.
  123785. * @param scene defines the scene the material belongs to.
  123786. * @returns - boolean indicating that the submesh is ready or not.
  123787. */
  123788. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123789. /**
  123790. * Checks to see if a texture is used in the material.
  123791. * @param defines the list of "defines" to update.
  123792. * @param scene defines the scene the material belongs to.
  123793. */
  123794. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123795. /**
  123796. * Binds the material data.
  123797. * @param uniformBuffer defines the Uniform buffer to fill in.
  123798. * @param scene defines the scene the material belongs to.
  123799. * @param isFrozen defines wether the material is frozen or not.
  123800. */
  123801. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123802. /**
  123803. * Checks to see if a texture is used in the material.
  123804. * @param texture - Base texture to use.
  123805. * @returns - Boolean specifying if a texture is used in the material.
  123806. */
  123807. hasTexture(texture: BaseTexture): boolean;
  123808. /**
  123809. * Returns an array of the actively used textures.
  123810. * @param activeTextures Array of BaseTextures
  123811. */
  123812. getActiveTextures(activeTextures: BaseTexture[]): void;
  123813. /**
  123814. * Returns the animatable textures.
  123815. * @param animatables Array of animatable textures.
  123816. */
  123817. getAnimatables(animatables: IAnimatable[]): void;
  123818. /**
  123819. * Disposes the resources of the material.
  123820. * @param forceDisposeTextures - Forces the disposal of all textures.
  123821. */
  123822. dispose(forceDisposeTextures?: boolean): void;
  123823. /**
  123824. * Get the current class name of the texture useful for serialization or dynamic coding.
  123825. * @returns "PBRSheenConfiguration"
  123826. */
  123827. getClassName(): string;
  123828. /**
  123829. * Add fallbacks to the effect fallbacks list.
  123830. * @param defines defines the Base texture to use.
  123831. * @param fallbacks defines the current fallback list.
  123832. * @param currentRank defines the current fallback rank.
  123833. * @returns the new fallback rank.
  123834. */
  123835. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123836. /**
  123837. * Add the required uniforms to the current list.
  123838. * @param uniforms defines the current uniform list.
  123839. */
  123840. static AddUniforms(uniforms: string[]): void;
  123841. /**
  123842. * Add the required uniforms to the current buffer.
  123843. * @param uniformBuffer defines the current uniform buffer.
  123844. */
  123845. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123846. /**
  123847. * Add the required samplers to the current list.
  123848. * @param samplers defines the current sampler list.
  123849. */
  123850. static AddSamplers(samplers: string[]): void;
  123851. /**
  123852. * Makes a duplicate of the current configuration into another one.
  123853. * @param sheenConfiguration define the config where to copy the info
  123854. */
  123855. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123856. /**
  123857. * Serializes this BRDF configuration.
  123858. * @returns - An object with the serialized config.
  123859. */
  123860. serialize(): any;
  123861. /**
  123862. * Parses a anisotropy Configuration from a serialized object.
  123863. * @param source - Serialized object.
  123864. * @param scene Defines the scene we are parsing for
  123865. * @param rootUrl Defines the rootUrl to load from
  123866. */
  123867. parse(source: any, scene: Scene, rootUrl: string): void;
  123868. }
  123869. }
  123870. declare module BABYLON {
  123871. /**
  123872. * @hidden
  123873. */
  123874. export interface IMaterialSubSurfaceDefines {
  123875. SUBSURFACE: boolean;
  123876. SS_REFRACTION: boolean;
  123877. SS_TRANSLUCENCY: boolean;
  123878. SS_SCATERRING: boolean;
  123879. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123880. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123881. SS_REFRACTIONMAP_3D: boolean;
  123882. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123883. SS_LODINREFRACTIONALPHA: boolean;
  123884. SS_GAMMAREFRACTION: boolean;
  123885. SS_RGBDREFRACTION: boolean;
  123886. SS_LINEARSPECULARREFRACTION: boolean;
  123887. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123888. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123889. /** @hidden */
  123890. _areTexturesDirty: boolean;
  123891. }
  123892. /**
  123893. * Define the code related to the sub surface parameters of the pbr material.
  123894. */
  123895. export class PBRSubSurfaceConfiguration {
  123896. private _isRefractionEnabled;
  123897. /**
  123898. * Defines if the refraction is enabled in the material.
  123899. */
  123900. isRefractionEnabled: boolean;
  123901. private _isTranslucencyEnabled;
  123902. /**
  123903. * Defines if the translucency is enabled in the material.
  123904. */
  123905. isTranslucencyEnabled: boolean;
  123906. private _isScatteringEnabled;
  123907. /**
  123908. * Defines the refraction intensity of the material.
  123909. * The refraction when enabled replaces the Diffuse part of the material.
  123910. * The intensity helps transitionning between diffuse and refraction.
  123911. */
  123912. refractionIntensity: number;
  123913. /**
  123914. * Defines the translucency intensity of the material.
  123915. * When translucency has been enabled, this defines how much of the "translucency"
  123916. * is addded to the diffuse part of the material.
  123917. */
  123918. translucencyIntensity: number;
  123919. /**
  123920. * Defines the scattering intensity of the material.
  123921. * When scattering has been enabled, this defines how much of the "scattered light"
  123922. * is addded to the diffuse part of the material.
  123923. */
  123924. scatteringIntensity: number;
  123925. private _thicknessTexture;
  123926. /**
  123927. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123928. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123929. * 0 would mean minimumThickness
  123930. * 1 would mean maximumThickness
  123931. * The other channels might be use as a mask to vary the different effects intensity.
  123932. */
  123933. thicknessTexture: Nullable<BaseTexture>;
  123934. private _refractionTexture;
  123935. /**
  123936. * Defines the texture to use for refraction.
  123937. */
  123938. refractionTexture: Nullable<BaseTexture>;
  123939. private _indexOfRefraction;
  123940. /**
  123941. * Defines the index of refraction used in the material.
  123942. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123943. */
  123944. indexOfRefraction: number;
  123945. private _invertRefractionY;
  123946. /**
  123947. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123948. */
  123949. invertRefractionY: boolean;
  123950. private _linkRefractionWithTransparency;
  123951. /**
  123952. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123953. * Materials half opaque for instance using refraction could benefit from this control.
  123954. */
  123955. linkRefractionWithTransparency: boolean;
  123956. /**
  123957. * Defines the minimum thickness stored in the thickness map.
  123958. * If no thickness map is defined, this value will be used to simulate thickness.
  123959. */
  123960. minimumThickness: number;
  123961. /**
  123962. * Defines the maximum thickness stored in the thickness map.
  123963. */
  123964. maximumThickness: number;
  123965. /**
  123966. * Defines the volume tint of the material.
  123967. * This is used for both translucency and scattering.
  123968. */
  123969. tintColor: Color3;
  123970. /**
  123971. * Defines the distance at which the tint color should be found in the media.
  123972. * This is used for refraction only.
  123973. */
  123974. tintColorAtDistance: number;
  123975. /**
  123976. * Defines how far each channel transmit through the media.
  123977. * It is defined as a color to simplify it selection.
  123978. */
  123979. diffusionDistance: Color3;
  123980. private _useMaskFromThicknessTexture;
  123981. /**
  123982. * Stores the intensity of the different subsurface effects in the thickness texture.
  123983. * * the green channel is the translucency intensity.
  123984. * * the blue channel is the scattering intensity.
  123985. * * the alpha channel is the refraction intensity.
  123986. */
  123987. useMaskFromThicknessTexture: boolean;
  123988. /** @hidden */
  123989. private _internalMarkAllSubMeshesAsTexturesDirty;
  123990. /** @hidden */
  123991. _markAllSubMeshesAsTexturesDirty(): void;
  123992. /**
  123993. * Instantiate a new istance of sub surface configuration.
  123994. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123995. */
  123996. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123997. /**
  123998. * Gets wehter the submesh is ready to be used or not.
  123999. * @param defines the list of "defines" to update.
  124000. * @param scene defines the scene the material belongs to.
  124001. * @returns - boolean indicating that the submesh is ready or not.
  124002. */
  124003. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  124004. /**
  124005. * Checks to see if a texture is used in the material.
  124006. * @param defines the list of "defines" to update.
  124007. * @param scene defines the scene to the material belongs to.
  124008. */
  124009. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  124010. /**
  124011. * Binds the material data.
  124012. * @param uniformBuffer defines the Uniform buffer to fill in.
  124013. * @param scene defines the scene the material belongs to.
  124014. * @param engine defines the engine the material belongs to.
  124015. * @param isFrozen defines wether the material is frozen or not.
  124016. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  124017. */
  124018. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  124019. /**
  124020. * Unbinds the material from the mesh.
  124021. * @param activeEffect defines the effect that should be unbound from.
  124022. * @returns true if unbound, otherwise false
  124023. */
  124024. unbind(activeEffect: Effect): boolean;
  124025. /**
  124026. * Returns the texture used for refraction or null if none is used.
  124027. * @param scene defines the scene the material belongs to.
  124028. * @returns - Refraction texture if present. If no refraction texture and refraction
  124029. * is linked with transparency, returns environment texture. Otherwise, returns null.
  124030. */
  124031. private _getRefractionTexture;
  124032. /**
  124033. * Returns true if alpha blending should be disabled.
  124034. */
  124035. get disableAlphaBlending(): boolean;
  124036. /**
  124037. * Fills the list of render target textures.
  124038. * @param renderTargets the list of render targets to update
  124039. */
  124040. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  124041. /**
  124042. * Checks to see if a texture is used in the material.
  124043. * @param texture - Base texture to use.
  124044. * @returns - Boolean specifying if a texture is used in the material.
  124045. */
  124046. hasTexture(texture: BaseTexture): boolean;
  124047. /**
  124048. * Gets a boolean indicating that current material needs to register RTT
  124049. * @returns true if this uses a render target otherwise false.
  124050. */
  124051. hasRenderTargetTextures(): boolean;
  124052. /**
  124053. * Returns an array of the actively used textures.
  124054. * @param activeTextures Array of BaseTextures
  124055. */
  124056. getActiveTextures(activeTextures: BaseTexture[]): void;
  124057. /**
  124058. * Returns the animatable textures.
  124059. * @param animatables Array of animatable textures.
  124060. */
  124061. getAnimatables(animatables: IAnimatable[]): void;
  124062. /**
  124063. * Disposes the resources of the material.
  124064. * @param forceDisposeTextures - Forces the disposal of all textures.
  124065. */
  124066. dispose(forceDisposeTextures?: boolean): void;
  124067. /**
  124068. * Get the current class name of the texture useful for serialization or dynamic coding.
  124069. * @returns "PBRSubSurfaceConfiguration"
  124070. */
  124071. getClassName(): string;
  124072. /**
  124073. * Add fallbacks to the effect fallbacks list.
  124074. * @param defines defines the Base texture to use.
  124075. * @param fallbacks defines the current fallback list.
  124076. * @param currentRank defines the current fallback rank.
  124077. * @returns the new fallback rank.
  124078. */
  124079. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124080. /**
  124081. * Add the required uniforms to the current list.
  124082. * @param uniforms defines the current uniform list.
  124083. */
  124084. static AddUniforms(uniforms: string[]): void;
  124085. /**
  124086. * Add the required samplers to the current list.
  124087. * @param samplers defines the current sampler list.
  124088. */
  124089. static AddSamplers(samplers: string[]): void;
  124090. /**
  124091. * Add the required uniforms to the current buffer.
  124092. * @param uniformBuffer defines the current uniform buffer.
  124093. */
  124094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124095. /**
  124096. * Makes a duplicate of the current configuration into another one.
  124097. * @param configuration define the config where to copy the info
  124098. */
  124099. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124100. /**
  124101. * Serializes this Sub Surface configuration.
  124102. * @returns - An object with the serialized config.
  124103. */
  124104. serialize(): any;
  124105. /**
  124106. * Parses a anisotropy Configuration from a serialized object.
  124107. * @param source - Serialized object.
  124108. * @param scene Defines the scene we are parsing for
  124109. * @param rootUrl Defines the rootUrl to load from
  124110. */
  124111. parse(source: any, scene: Scene, rootUrl: string): void;
  124112. }
  124113. }
  124114. declare module BABYLON {
  124115. /** @hidden */
  124116. export var pbrFragmentDeclaration: {
  124117. name: string;
  124118. shader: string;
  124119. };
  124120. }
  124121. declare module BABYLON {
  124122. /** @hidden */
  124123. export var pbrUboDeclaration: {
  124124. name: string;
  124125. shader: string;
  124126. };
  124127. }
  124128. declare module BABYLON {
  124129. /** @hidden */
  124130. export var pbrFragmentExtraDeclaration: {
  124131. name: string;
  124132. shader: string;
  124133. };
  124134. }
  124135. declare module BABYLON {
  124136. /** @hidden */
  124137. export var pbrFragmentSamplersDeclaration: {
  124138. name: string;
  124139. shader: string;
  124140. };
  124141. }
  124142. declare module BABYLON {
  124143. /** @hidden */
  124144. export var pbrHelperFunctions: {
  124145. name: string;
  124146. shader: string;
  124147. };
  124148. }
  124149. declare module BABYLON {
  124150. /** @hidden */
  124151. export var harmonicsFunctions: {
  124152. name: string;
  124153. shader: string;
  124154. };
  124155. }
  124156. declare module BABYLON {
  124157. /** @hidden */
  124158. export var pbrDirectLightingSetupFunctions: {
  124159. name: string;
  124160. shader: string;
  124161. };
  124162. }
  124163. declare module BABYLON {
  124164. /** @hidden */
  124165. export var pbrDirectLightingFalloffFunctions: {
  124166. name: string;
  124167. shader: string;
  124168. };
  124169. }
  124170. declare module BABYLON {
  124171. /** @hidden */
  124172. export var pbrBRDFFunctions: {
  124173. name: string;
  124174. shader: string;
  124175. };
  124176. }
  124177. declare module BABYLON {
  124178. /** @hidden */
  124179. export var pbrDirectLightingFunctions: {
  124180. name: string;
  124181. shader: string;
  124182. };
  124183. }
  124184. declare module BABYLON {
  124185. /** @hidden */
  124186. export var pbrIBLFunctions: {
  124187. name: string;
  124188. shader: string;
  124189. };
  124190. }
  124191. declare module BABYLON {
  124192. /** @hidden */
  124193. export var pbrDebug: {
  124194. name: string;
  124195. shader: string;
  124196. };
  124197. }
  124198. declare module BABYLON {
  124199. /** @hidden */
  124200. export var pbrPixelShader: {
  124201. name: string;
  124202. shader: string;
  124203. };
  124204. }
  124205. declare module BABYLON {
  124206. /** @hidden */
  124207. export var pbrVertexDeclaration: {
  124208. name: string;
  124209. shader: string;
  124210. };
  124211. }
  124212. declare module BABYLON {
  124213. /** @hidden */
  124214. export var pbrVertexShader: {
  124215. name: string;
  124216. shader: string;
  124217. };
  124218. }
  124219. declare module BABYLON {
  124220. /**
  124221. * Manages the defines for the PBR Material.
  124222. * @hidden
  124223. */
  124224. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124225. PBR: boolean;
  124226. MAINUV1: boolean;
  124227. MAINUV2: boolean;
  124228. UV1: boolean;
  124229. UV2: boolean;
  124230. ALBEDO: boolean;
  124231. GAMMAALBEDO: boolean;
  124232. ALBEDODIRECTUV: number;
  124233. VERTEXCOLOR: boolean;
  124234. AMBIENT: boolean;
  124235. AMBIENTDIRECTUV: number;
  124236. AMBIENTINGRAYSCALE: boolean;
  124237. OPACITY: boolean;
  124238. VERTEXALPHA: boolean;
  124239. OPACITYDIRECTUV: number;
  124240. OPACITYRGB: boolean;
  124241. ALPHATEST: boolean;
  124242. DEPTHPREPASS: boolean;
  124243. ALPHABLEND: boolean;
  124244. ALPHAFROMALBEDO: boolean;
  124245. ALPHATESTVALUE: string;
  124246. SPECULAROVERALPHA: boolean;
  124247. RADIANCEOVERALPHA: boolean;
  124248. ALPHAFRESNEL: boolean;
  124249. LINEARALPHAFRESNEL: boolean;
  124250. PREMULTIPLYALPHA: boolean;
  124251. EMISSIVE: boolean;
  124252. EMISSIVEDIRECTUV: number;
  124253. REFLECTIVITY: boolean;
  124254. REFLECTIVITYDIRECTUV: number;
  124255. SPECULARTERM: boolean;
  124256. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124257. MICROSURFACEAUTOMATIC: boolean;
  124258. LODBASEDMICROSFURACE: boolean;
  124259. MICROSURFACEMAP: boolean;
  124260. MICROSURFACEMAPDIRECTUV: number;
  124261. METALLICWORKFLOW: boolean;
  124262. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124263. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124264. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124265. AOSTOREINMETALMAPRED: boolean;
  124266. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124267. ENVIRONMENTBRDF: boolean;
  124268. ENVIRONMENTBRDF_RGBD: boolean;
  124269. NORMAL: boolean;
  124270. TANGENT: boolean;
  124271. BUMP: boolean;
  124272. BUMPDIRECTUV: number;
  124273. OBJECTSPACE_NORMALMAP: boolean;
  124274. PARALLAX: boolean;
  124275. PARALLAXOCCLUSION: boolean;
  124276. NORMALXYSCALE: boolean;
  124277. LIGHTMAP: boolean;
  124278. LIGHTMAPDIRECTUV: number;
  124279. USELIGHTMAPASSHADOWMAP: boolean;
  124280. GAMMALIGHTMAP: boolean;
  124281. RGBDLIGHTMAP: boolean;
  124282. REFLECTION: boolean;
  124283. REFLECTIONMAP_3D: boolean;
  124284. REFLECTIONMAP_SPHERICAL: boolean;
  124285. REFLECTIONMAP_PLANAR: boolean;
  124286. REFLECTIONMAP_CUBIC: boolean;
  124287. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124288. REFLECTIONMAP_PROJECTION: boolean;
  124289. REFLECTIONMAP_SKYBOX: boolean;
  124290. REFLECTIONMAP_EXPLICIT: boolean;
  124291. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124292. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124293. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124294. INVERTCUBICMAP: boolean;
  124295. USESPHERICALFROMREFLECTIONMAP: boolean;
  124296. USEIRRADIANCEMAP: boolean;
  124297. SPHERICAL_HARMONICS: boolean;
  124298. USESPHERICALINVERTEX: boolean;
  124299. REFLECTIONMAP_OPPOSITEZ: boolean;
  124300. LODINREFLECTIONALPHA: boolean;
  124301. GAMMAREFLECTION: boolean;
  124302. RGBDREFLECTION: boolean;
  124303. LINEARSPECULARREFLECTION: boolean;
  124304. RADIANCEOCCLUSION: boolean;
  124305. HORIZONOCCLUSION: boolean;
  124306. INSTANCES: boolean;
  124307. NUM_BONE_INFLUENCERS: number;
  124308. BonesPerMesh: number;
  124309. BONETEXTURE: boolean;
  124310. NONUNIFORMSCALING: boolean;
  124311. MORPHTARGETS: boolean;
  124312. MORPHTARGETS_NORMAL: boolean;
  124313. MORPHTARGETS_TANGENT: boolean;
  124314. MORPHTARGETS_UV: boolean;
  124315. NUM_MORPH_INFLUENCERS: number;
  124316. IMAGEPROCESSING: boolean;
  124317. VIGNETTE: boolean;
  124318. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124319. VIGNETTEBLENDMODEOPAQUE: boolean;
  124320. TONEMAPPING: boolean;
  124321. TONEMAPPING_ACES: boolean;
  124322. CONTRAST: boolean;
  124323. COLORCURVES: boolean;
  124324. COLORGRADING: boolean;
  124325. COLORGRADING3D: boolean;
  124326. SAMPLER3DGREENDEPTH: boolean;
  124327. SAMPLER3DBGRMAP: boolean;
  124328. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124329. EXPOSURE: boolean;
  124330. MULTIVIEW: boolean;
  124331. USEPHYSICALLIGHTFALLOFF: boolean;
  124332. USEGLTFLIGHTFALLOFF: boolean;
  124333. TWOSIDEDLIGHTING: boolean;
  124334. SHADOWFLOAT: boolean;
  124335. CLIPPLANE: boolean;
  124336. CLIPPLANE2: boolean;
  124337. CLIPPLANE3: boolean;
  124338. CLIPPLANE4: boolean;
  124339. CLIPPLANE5: boolean;
  124340. CLIPPLANE6: boolean;
  124341. POINTSIZE: boolean;
  124342. FOG: boolean;
  124343. LOGARITHMICDEPTH: boolean;
  124344. FORCENORMALFORWARD: boolean;
  124345. SPECULARAA: boolean;
  124346. CLEARCOAT: boolean;
  124347. CLEARCOAT_DEFAULTIOR: boolean;
  124348. CLEARCOAT_TEXTURE: boolean;
  124349. CLEARCOAT_TEXTUREDIRECTUV: number;
  124350. CLEARCOAT_BUMP: boolean;
  124351. CLEARCOAT_BUMPDIRECTUV: number;
  124352. CLEARCOAT_TINT: boolean;
  124353. CLEARCOAT_TINT_TEXTURE: boolean;
  124354. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124355. ANISOTROPIC: boolean;
  124356. ANISOTROPIC_TEXTURE: boolean;
  124357. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124358. BRDF_V_HEIGHT_CORRELATED: boolean;
  124359. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124360. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124361. SHEEN: boolean;
  124362. SHEEN_TEXTURE: boolean;
  124363. SHEEN_TEXTUREDIRECTUV: number;
  124364. SHEEN_LINKWITHALBEDO: boolean;
  124365. SUBSURFACE: boolean;
  124366. SS_REFRACTION: boolean;
  124367. SS_TRANSLUCENCY: boolean;
  124368. SS_SCATERRING: boolean;
  124369. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124370. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124371. SS_REFRACTIONMAP_3D: boolean;
  124372. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124373. SS_LODINREFRACTIONALPHA: boolean;
  124374. SS_GAMMAREFRACTION: boolean;
  124375. SS_RGBDREFRACTION: boolean;
  124376. SS_LINEARSPECULARREFRACTION: boolean;
  124377. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124378. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124379. UNLIT: boolean;
  124380. DEBUGMODE: number;
  124381. /**
  124382. * Initializes the PBR Material defines.
  124383. */
  124384. constructor();
  124385. /**
  124386. * Resets the PBR Material defines.
  124387. */
  124388. reset(): void;
  124389. }
  124390. /**
  124391. * The Physically based material base class of BJS.
  124392. *
  124393. * This offers the main features of a standard PBR material.
  124394. * For more information, please refer to the documentation :
  124395. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124396. */
  124397. export abstract class PBRBaseMaterial extends PushMaterial {
  124398. /**
  124399. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124400. */
  124401. static readonly PBRMATERIAL_OPAQUE: number;
  124402. /**
  124403. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124404. */
  124405. static readonly PBRMATERIAL_ALPHATEST: number;
  124406. /**
  124407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124408. */
  124409. static readonly PBRMATERIAL_ALPHABLEND: number;
  124410. /**
  124411. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124412. * They are also discarded below the alpha cutoff threshold to improve performances.
  124413. */
  124414. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124415. /**
  124416. * Defines the default value of how much AO map is occluding the analytical lights
  124417. * (point spot...).
  124418. */
  124419. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124420. /**
  124421. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124422. */
  124423. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124424. /**
  124425. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124426. * to enhance interoperability with other engines.
  124427. */
  124428. static readonly LIGHTFALLOFF_GLTF: number;
  124429. /**
  124430. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124431. * to enhance interoperability with other materials.
  124432. */
  124433. static readonly LIGHTFALLOFF_STANDARD: number;
  124434. /**
  124435. * Intensity of the direct lights e.g. the four lights available in your scene.
  124436. * This impacts both the direct diffuse and specular highlights.
  124437. */
  124438. protected _directIntensity: number;
  124439. /**
  124440. * Intensity of the emissive part of the material.
  124441. * This helps controlling the emissive effect without modifying the emissive color.
  124442. */
  124443. protected _emissiveIntensity: number;
  124444. /**
  124445. * Intensity of the environment e.g. how much the environment will light the object
  124446. * either through harmonics for rough material or through the refelction for shiny ones.
  124447. */
  124448. protected _environmentIntensity: number;
  124449. /**
  124450. * This is a special control allowing the reduction of the specular highlights coming from the
  124451. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124452. */
  124453. protected _specularIntensity: number;
  124454. /**
  124455. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124456. */
  124457. private _lightingInfos;
  124458. /**
  124459. * Debug Control allowing disabling the bump map on this material.
  124460. */
  124461. protected _disableBumpMap: boolean;
  124462. /**
  124463. * AKA Diffuse Texture in standard nomenclature.
  124464. */
  124465. protected _albedoTexture: Nullable<BaseTexture>;
  124466. /**
  124467. * AKA Occlusion Texture in other nomenclature.
  124468. */
  124469. protected _ambientTexture: Nullable<BaseTexture>;
  124470. /**
  124471. * AKA Occlusion Texture Intensity in other nomenclature.
  124472. */
  124473. protected _ambientTextureStrength: number;
  124474. /**
  124475. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124476. * 1 means it completely occludes it
  124477. * 0 mean it has no impact
  124478. */
  124479. protected _ambientTextureImpactOnAnalyticalLights: number;
  124480. /**
  124481. * Stores the alpha values in a texture.
  124482. */
  124483. protected _opacityTexture: Nullable<BaseTexture>;
  124484. /**
  124485. * Stores the reflection values in a texture.
  124486. */
  124487. protected _reflectionTexture: Nullable<BaseTexture>;
  124488. /**
  124489. * Stores the emissive values in a texture.
  124490. */
  124491. protected _emissiveTexture: Nullable<BaseTexture>;
  124492. /**
  124493. * AKA Specular texture in other nomenclature.
  124494. */
  124495. protected _reflectivityTexture: Nullable<BaseTexture>;
  124496. /**
  124497. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124498. */
  124499. protected _metallicTexture: Nullable<BaseTexture>;
  124500. /**
  124501. * Specifies the metallic scalar of the metallic/roughness workflow.
  124502. * Can also be used to scale the metalness values of the metallic texture.
  124503. */
  124504. protected _metallic: Nullable<number>;
  124505. /**
  124506. * Specifies the roughness scalar of the metallic/roughness workflow.
  124507. * Can also be used to scale the roughness values of the metallic texture.
  124508. */
  124509. protected _roughness: Nullable<number>;
  124510. /**
  124511. * Specifies the an F0 factor to help configuring the material F0.
  124512. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124513. * to 0.5 the previously hard coded value stays the same.
  124514. * Can also be used to scale the F0 values of the metallic texture.
  124515. */
  124516. protected _metallicF0Factor: number;
  124517. /**
  124518. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124519. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124520. * your expectation as it multiplies with the texture data.
  124521. */
  124522. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124523. /**
  124524. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124525. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124526. */
  124527. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124528. /**
  124529. * Stores surface normal data used to displace a mesh in a texture.
  124530. */
  124531. protected _bumpTexture: Nullable<BaseTexture>;
  124532. /**
  124533. * Stores the pre-calculated light information of a mesh in a texture.
  124534. */
  124535. protected _lightmapTexture: Nullable<BaseTexture>;
  124536. /**
  124537. * The color of a material in ambient lighting.
  124538. */
  124539. protected _ambientColor: Color3;
  124540. /**
  124541. * AKA Diffuse Color in other nomenclature.
  124542. */
  124543. protected _albedoColor: Color3;
  124544. /**
  124545. * AKA Specular Color in other nomenclature.
  124546. */
  124547. protected _reflectivityColor: Color3;
  124548. /**
  124549. * The color applied when light is reflected from a material.
  124550. */
  124551. protected _reflectionColor: Color3;
  124552. /**
  124553. * The color applied when light is emitted from a material.
  124554. */
  124555. protected _emissiveColor: Color3;
  124556. /**
  124557. * AKA Glossiness in other nomenclature.
  124558. */
  124559. protected _microSurface: number;
  124560. /**
  124561. * Specifies that the material will use the light map as a show map.
  124562. */
  124563. protected _useLightmapAsShadowmap: boolean;
  124564. /**
  124565. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124566. * makes the reflect vector face the model (under horizon).
  124567. */
  124568. protected _useHorizonOcclusion: boolean;
  124569. /**
  124570. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124571. * too much the area relying on ambient texture to define their ambient occlusion.
  124572. */
  124573. protected _useRadianceOcclusion: boolean;
  124574. /**
  124575. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124576. */
  124577. protected _useAlphaFromAlbedoTexture: boolean;
  124578. /**
  124579. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124580. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124581. */
  124582. protected _useSpecularOverAlpha: boolean;
  124583. /**
  124584. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124585. */
  124586. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124587. /**
  124588. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124589. */
  124590. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124591. /**
  124592. * Specifies if the metallic texture contains the roughness information in its green channel.
  124593. */
  124594. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124595. /**
  124596. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124597. */
  124598. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124599. /**
  124600. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124601. */
  124602. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124603. /**
  124604. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124605. */
  124606. protected _useAmbientInGrayScale: boolean;
  124607. /**
  124608. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124609. * The material will try to infer what glossiness each pixel should be.
  124610. */
  124611. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124612. /**
  124613. * Defines the falloff type used in this material.
  124614. * It by default is Physical.
  124615. */
  124616. protected _lightFalloff: number;
  124617. /**
  124618. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124619. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124620. */
  124621. protected _useRadianceOverAlpha: boolean;
  124622. /**
  124623. * Allows using an object space normal map (instead of tangent space).
  124624. */
  124625. protected _useObjectSpaceNormalMap: boolean;
  124626. /**
  124627. * Allows using the bump map in parallax mode.
  124628. */
  124629. protected _useParallax: boolean;
  124630. /**
  124631. * Allows using the bump map in parallax occlusion mode.
  124632. */
  124633. protected _useParallaxOcclusion: boolean;
  124634. /**
  124635. * Controls the scale bias of the parallax mode.
  124636. */
  124637. protected _parallaxScaleBias: number;
  124638. /**
  124639. * If sets to true, disables all the lights affecting the material.
  124640. */
  124641. protected _disableLighting: boolean;
  124642. /**
  124643. * Number of Simultaneous lights allowed on the material.
  124644. */
  124645. protected _maxSimultaneousLights: number;
  124646. /**
  124647. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124648. */
  124649. protected _invertNormalMapX: boolean;
  124650. /**
  124651. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124652. */
  124653. protected _invertNormalMapY: boolean;
  124654. /**
  124655. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124656. */
  124657. protected _twoSidedLighting: boolean;
  124658. /**
  124659. * Defines the alpha limits in alpha test mode.
  124660. */
  124661. protected _alphaCutOff: number;
  124662. /**
  124663. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124664. */
  124665. protected _forceAlphaTest: boolean;
  124666. /**
  124667. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124668. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124669. */
  124670. protected _useAlphaFresnel: boolean;
  124671. /**
  124672. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124673. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124674. */
  124675. protected _useLinearAlphaFresnel: boolean;
  124676. /**
  124677. * The transparency mode of the material.
  124678. */
  124679. protected _transparencyMode: Nullable<number>;
  124680. /**
  124681. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124682. * from cos thetav and roughness:
  124683. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124684. */
  124685. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124686. /**
  124687. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124688. */
  124689. protected _forceIrradianceInFragment: boolean;
  124690. /**
  124691. * Force normal to face away from face.
  124692. */
  124693. protected _forceNormalForward: boolean;
  124694. /**
  124695. * Enables specular anti aliasing in the PBR shader.
  124696. * It will both interacts on the Geometry for analytical and IBL lighting.
  124697. * It also prefilter the roughness map based on the bump values.
  124698. */
  124699. protected _enableSpecularAntiAliasing: boolean;
  124700. /**
  124701. * Default configuration related to image processing available in the PBR Material.
  124702. */
  124703. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124704. /**
  124705. * Keep track of the image processing observer to allow dispose and replace.
  124706. */
  124707. private _imageProcessingObserver;
  124708. /**
  124709. * Attaches a new image processing configuration to the PBR Material.
  124710. * @param configuration
  124711. */
  124712. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124713. /**
  124714. * Stores the available render targets.
  124715. */
  124716. private _renderTargets;
  124717. /**
  124718. * Sets the global ambient color for the material used in lighting calculations.
  124719. */
  124720. private _globalAmbientColor;
  124721. /**
  124722. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124723. */
  124724. private _useLogarithmicDepth;
  124725. /**
  124726. * If set to true, no lighting calculations will be applied.
  124727. */
  124728. private _unlit;
  124729. private _debugMode;
  124730. /**
  124731. * @hidden
  124732. * This is reserved for the inspector.
  124733. * Defines the material debug mode.
  124734. * It helps seeing only some components of the material while troubleshooting.
  124735. */
  124736. debugMode: number;
  124737. /**
  124738. * @hidden
  124739. * This is reserved for the inspector.
  124740. * Specify from where on screen the debug mode should start.
  124741. * The value goes from -1 (full screen) to 1 (not visible)
  124742. * It helps with side by side comparison against the final render
  124743. * This defaults to -1
  124744. */
  124745. private debugLimit;
  124746. /**
  124747. * @hidden
  124748. * This is reserved for the inspector.
  124749. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124750. * You can use the factor to better multiply the final value.
  124751. */
  124752. private debugFactor;
  124753. /**
  124754. * Defines the clear coat layer parameters for the material.
  124755. */
  124756. readonly clearCoat: PBRClearCoatConfiguration;
  124757. /**
  124758. * Defines the anisotropic parameters for the material.
  124759. */
  124760. readonly anisotropy: PBRAnisotropicConfiguration;
  124761. /**
  124762. * Defines the BRDF parameters for the material.
  124763. */
  124764. readonly brdf: PBRBRDFConfiguration;
  124765. /**
  124766. * Defines the Sheen parameters for the material.
  124767. */
  124768. readonly sheen: PBRSheenConfiguration;
  124769. /**
  124770. * Defines the SubSurface parameters for the material.
  124771. */
  124772. readonly subSurface: PBRSubSurfaceConfiguration;
  124773. /**
  124774. * Custom callback helping to override the default shader used in the material.
  124775. */
  124776. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124777. protected _rebuildInParallel: boolean;
  124778. /**
  124779. * Instantiates a new PBRMaterial instance.
  124780. *
  124781. * @param name The material name
  124782. * @param scene The scene the material will be use in.
  124783. */
  124784. constructor(name: string, scene: Scene);
  124785. /**
  124786. * Gets a boolean indicating that current material needs to register RTT
  124787. */
  124788. get hasRenderTargetTextures(): boolean;
  124789. /**
  124790. * Gets the name of the material class.
  124791. */
  124792. getClassName(): string;
  124793. /**
  124794. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124795. */
  124796. get useLogarithmicDepth(): boolean;
  124797. /**
  124798. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124799. */
  124800. set useLogarithmicDepth(value: boolean);
  124801. /**
  124802. * Gets the current transparency mode.
  124803. */
  124804. get transparencyMode(): Nullable<number>;
  124805. /**
  124806. * Sets the transparency mode of the material.
  124807. *
  124808. * | Value | Type | Description |
  124809. * | ----- | ----------------------------------- | ----------- |
  124810. * | 0 | OPAQUE | |
  124811. * | 1 | ALPHATEST | |
  124812. * | 2 | ALPHABLEND | |
  124813. * | 3 | ALPHATESTANDBLEND | |
  124814. *
  124815. */
  124816. set transparencyMode(value: Nullable<number>);
  124817. /**
  124818. * Returns true if alpha blending should be disabled.
  124819. */
  124820. private get _disableAlphaBlending();
  124821. /**
  124822. * Specifies whether or not this material should be rendered in alpha blend mode.
  124823. */
  124824. needAlphaBlending(): boolean;
  124825. /**
  124826. * Specifies if the mesh will require alpha blending.
  124827. * @param mesh - BJS mesh.
  124828. */
  124829. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124830. /**
  124831. * Specifies whether or not this material should be rendered in alpha test mode.
  124832. */
  124833. needAlphaTesting(): boolean;
  124834. /**
  124835. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124836. */
  124837. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124838. /**
  124839. * Gets the texture used for the alpha test.
  124840. */
  124841. getAlphaTestTexture(): Nullable<BaseTexture>;
  124842. /**
  124843. * Specifies that the submesh is ready to be used.
  124844. * @param mesh - BJS mesh.
  124845. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124846. * @param useInstances - Specifies that instances should be used.
  124847. * @returns - boolean indicating that the submesh is ready or not.
  124848. */
  124849. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124850. /**
  124851. * Specifies if the material uses metallic roughness workflow.
  124852. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124853. */
  124854. isMetallicWorkflow(): boolean;
  124855. private _prepareEffect;
  124856. private _prepareDefines;
  124857. /**
  124858. * Force shader compilation
  124859. */
  124860. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124861. /**
  124862. * Initializes the uniform buffer layout for the shader.
  124863. */
  124864. buildUniformLayout(): void;
  124865. /**
  124866. * Unbinds the material from the mesh
  124867. */
  124868. unbind(): void;
  124869. /**
  124870. * Binds the submesh data.
  124871. * @param world - The world matrix.
  124872. * @param mesh - The BJS mesh.
  124873. * @param subMesh - A submesh of the BJS mesh.
  124874. */
  124875. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124876. /**
  124877. * Returns the animatable textures.
  124878. * @returns - Array of animatable textures.
  124879. */
  124880. getAnimatables(): IAnimatable[];
  124881. /**
  124882. * Returns the texture used for reflections.
  124883. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124884. */
  124885. private _getReflectionTexture;
  124886. /**
  124887. * Returns an array of the actively used textures.
  124888. * @returns - Array of BaseTextures
  124889. */
  124890. getActiveTextures(): BaseTexture[];
  124891. /**
  124892. * Checks to see if a texture is used in the material.
  124893. * @param texture - Base texture to use.
  124894. * @returns - Boolean specifying if a texture is used in the material.
  124895. */
  124896. hasTexture(texture: BaseTexture): boolean;
  124897. /**
  124898. * Disposes the resources of the material.
  124899. * @param forceDisposeEffect - Forces the disposal of effects.
  124900. * @param forceDisposeTextures - Forces the disposal of all textures.
  124901. */
  124902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124903. }
  124904. }
  124905. declare module BABYLON {
  124906. /**
  124907. * The Physically based material of BJS.
  124908. *
  124909. * This offers the main features of a standard PBR material.
  124910. * For more information, please refer to the documentation :
  124911. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124912. */
  124913. export class PBRMaterial extends PBRBaseMaterial {
  124914. /**
  124915. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124916. */
  124917. static readonly PBRMATERIAL_OPAQUE: number;
  124918. /**
  124919. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124920. */
  124921. static readonly PBRMATERIAL_ALPHATEST: number;
  124922. /**
  124923. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124924. */
  124925. static readonly PBRMATERIAL_ALPHABLEND: number;
  124926. /**
  124927. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124928. * They are also discarded below the alpha cutoff threshold to improve performances.
  124929. */
  124930. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124931. /**
  124932. * Defines the default value of how much AO map is occluding the analytical lights
  124933. * (point spot...).
  124934. */
  124935. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124936. /**
  124937. * Intensity of the direct lights e.g. the four lights available in your scene.
  124938. * This impacts both the direct diffuse and specular highlights.
  124939. */
  124940. directIntensity: number;
  124941. /**
  124942. * Intensity of the emissive part of the material.
  124943. * This helps controlling the emissive effect without modifying the emissive color.
  124944. */
  124945. emissiveIntensity: number;
  124946. /**
  124947. * Intensity of the environment e.g. how much the environment will light the object
  124948. * either through harmonics for rough material or through the refelction for shiny ones.
  124949. */
  124950. environmentIntensity: number;
  124951. /**
  124952. * This is a special control allowing the reduction of the specular highlights coming from the
  124953. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124954. */
  124955. specularIntensity: number;
  124956. /**
  124957. * Debug Control allowing disabling the bump map on this material.
  124958. */
  124959. disableBumpMap: boolean;
  124960. /**
  124961. * AKA Diffuse Texture in standard nomenclature.
  124962. */
  124963. albedoTexture: BaseTexture;
  124964. /**
  124965. * AKA Occlusion Texture in other nomenclature.
  124966. */
  124967. ambientTexture: BaseTexture;
  124968. /**
  124969. * AKA Occlusion Texture Intensity in other nomenclature.
  124970. */
  124971. ambientTextureStrength: number;
  124972. /**
  124973. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124974. * 1 means it completely occludes it
  124975. * 0 mean it has no impact
  124976. */
  124977. ambientTextureImpactOnAnalyticalLights: number;
  124978. /**
  124979. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124980. */
  124981. opacityTexture: BaseTexture;
  124982. /**
  124983. * Stores the reflection values in a texture.
  124984. */
  124985. reflectionTexture: Nullable<BaseTexture>;
  124986. /**
  124987. * Stores the emissive values in a texture.
  124988. */
  124989. emissiveTexture: BaseTexture;
  124990. /**
  124991. * AKA Specular texture in other nomenclature.
  124992. */
  124993. reflectivityTexture: BaseTexture;
  124994. /**
  124995. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124996. */
  124997. metallicTexture: BaseTexture;
  124998. /**
  124999. * Specifies the metallic scalar of the metallic/roughness workflow.
  125000. * Can also be used to scale the metalness values of the metallic texture.
  125001. */
  125002. metallic: Nullable<number>;
  125003. /**
  125004. * Specifies the roughness scalar of the metallic/roughness workflow.
  125005. * Can also be used to scale the roughness values of the metallic texture.
  125006. */
  125007. roughness: Nullable<number>;
  125008. /**
  125009. * Specifies the an F0 factor to help configuring the material F0.
  125010. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125011. * to 0.5 the previously hard coded value stays the same.
  125012. * Can also be used to scale the F0 values of the metallic texture.
  125013. */
  125014. metallicF0Factor: number;
  125015. /**
  125016. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125017. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125018. * your expectation as it multiplies with the texture data.
  125019. */
  125020. useMetallicF0FactorFromMetallicTexture: boolean;
  125021. /**
  125022. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125023. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125024. */
  125025. microSurfaceTexture: BaseTexture;
  125026. /**
  125027. * Stores surface normal data used to displace a mesh in a texture.
  125028. */
  125029. bumpTexture: BaseTexture;
  125030. /**
  125031. * Stores the pre-calculated light information of a mesh in a texture.
  125032. */
  125033. lightmapTexture: BaseTexture;
  125034. /**
  125035. * Stores the refracted light information in a texture.
  125036. */
  125037. get refractionTexture(): Nullable<BaseTexture>;
  125038. set refractionTexture(value: Nullable<BaseTexture>);
  125039. /**
  125040. * The color of a material in ambient lighting.
  125041. */
  125042. ambientColor: Color3;
  125043. /**
  125044. * AKA Diffuse Color in other nomenclature.
  125045. */
  125046. albedoColor: Color3;
  125047. /**
  125048. * AKA Specular Color in other nomenclature.
  125049. */
  125050. reflectivityColor: Color3;
  125051. /**
  125052. * The color reflected from the material.
  125053. */
  125054. reflectionColor: Color3;
  125055. /**
  125056. * The color emitted from the material.
  125057. */
  125058. emissiveColor: Color3;
  125059. /**
  125060. * AKA Glossiness in other nomenclature.
  125061. */
  125062. microSurface: number;
  125063. /**
  125064. * source material index of refraction (IOR)' / 'destination material IOR.
  125065. */
  125066. get indexOfRefraction(): number;
  125067. set indexOfRefraction(value: number);
  125068. /**
  125069. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125070. */
  125071. get invertRefractionY(): boolean;
  125072. set invertRefractionY(value: boolean);
  125073. /**
  125074. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125075. * Materials half opaque for instance using refraction could benefit from this control.
  125076. */
  125077. get linkRefractionWithTransparency(): boolean;
  125078. set linkRefractionWithTransparency(value: boolean);
  125079. /**
  125080. * If true, the light map contains occlusion information instead of lighting info.
  125081. */
  125082. useLightmapAsShadowmap: boolean;
  125083. /**
  125084. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125085. */
  125086. useAlphaFromAlbedoTexture: boolean;
  125087. /**
  125088. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125089. */
  125090. forceAlphaTest: boolean;
  125091. /**
  125092. * Defines the alpha limits in alpha test mode.
  125093. */
  125094. alphaCutOff: number;
  125095. /**
  125096. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125097. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125098. */
  125099. useSpecularOverAlpha: boolean;
  125100. /**
  125101. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125102. */
  125103. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125104. /**
  125105. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125106. */
  125107. useRoughnessFromMetallicTextureAlpha: boolean;
  125108. /**
  125109. * Specifies if the metallic texture contains the roughness information in its green channel.
  125110. */
  125111. useRoughnessFromMetallicTextureGreen: boolean;
  125112. /**
  125113. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125114. */
  125115. useMetallnessFromMetallicTextureBlue: boolean;
  125116. /**
  125117. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125118. */
  125119. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125120. /**
  125121. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125122. */
  125123. useAmbientInGrayScale: boolean;
  125124. /**
  125125. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125126. * The material will try to infer what glossiness each pixel should be.
  125127. */
  125128. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125129. /**
  125130. * BJS is using an harcoded light falloff based on a manually sets up range.
  125131. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125132. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125133. */
  125134. get usePhysicalLightFalloff(): boolean;
  125135. /**
  125136. * BJS is using an harcoded light falloff based on a manually sets up range.
  125137. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125138. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125139. */
  125140. set usePhysicalLightFalloff(value: boolean);
  125141. /**
  125142. * In order to support the falloff compatibility with gltf, a special mode has been added
  125143. * to reproduce the gltf light falloff.
  125144. */
  125145. get useGLTFLightFalloff(): boolean;
  125146. /**
  125147. * In order to support the falloff compatibility with gltf, a special mode has been added
  125148. * to reproduce the gltf light falloff.
  125149. */
  125150. set useGLTFLightFalloff(value: boolean);
  125151. /**
  125152. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125153. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125154. */
  125155. useRadianceOverAlpha: boolean;
  125156. /**
  125157. * Allows using an object space normal map (instead of tangent space).
  125158. */
  125159. useObjectSpaceNormalMap: boolean;
  125160. /**
  125161. * Allows using the bump map in parallax mode.
  125162. */
  125163. useParallax: boolean;
  125164. /**
  125165. * Allows using the bump map in parallax occlusion mode.
  125166. */
  125167. useParallaxOcclusion: boolean;
  125168. /**
  125169. * Controls the scale bias of the parallax mode.
  125170. */
  125171. parallaxScaleBias: number;
  125172. /**
  125173. * If sets to true, disables all the lights affecting the material.
  125174. */
  125175. disableLighting: boolean;
  125176. /**
  125177. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125178. */
  125179. forceIrradianceInFragment: boolean;
  125180. /**
  125181. * Number of Simultaneous lights allowed on the material.
  125182. */
  125183. maxSimultaneousLights: number;
  125184. /**
  125185. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125186. */
  125187. invertNormalMapX: boolean;
  125188. /**
  125189. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125190. */
  125191. invertNormalMapY: boolean;
  125192. /**
  125193. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125194. */
  125195. twoSidedLighting: boolean;
  125196. /**
  125197. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125198. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125199. */
  125200. useAlphaFresnel: boolean;
  125201. /**
  125202. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125203. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125204. */
  125205. useLinearAlphaFresnel: boolean;
  125206. /**
  125207. * Let user defines the brdf lookup texture used for IBL.
  125208. * A default 8bit version is embedded but you could point at :
  125209. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125210. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125211. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125212. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125213. */
  125214. environmentBRDFTexture: Nullable<BaseTexture>;
  125215. /**
  125216. * Force normal to face away from face.
  125217. */
  125218. forceNormalForward: boolean;
  125219. /**
  125220. * Enables specular anti aliasing in the PBR shader.
  125221. * It will both interacts on the Geometry for analytical and IBL lighting.
  125222. * It also prefilter the roughness map based on the bump values.
  125223. */
  125224. enableSpecularAntiAliasing: boolean;
  125225. /**
  125226. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125227. * makes the reflect vector face the model (under horizon).
  125228. */
  125229. useHorizonOcclusion: boolean;
  125230. /**
  125231. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125232. * too much the area relying on ambient texture to define their ambient occlusion.
  125233. */
  125234. useRadianceOcclusion: boolean;
  125235. /**
  125236. * If set to true, no lighting calculations will be applied.
  125237. */
  125238. unlit: boolean;
  125239. /**
  125240. * Gets the image processing configuration used either in this material.
  125241. */
  125242. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125243. /**
  125244. * Sets the Default image processing configuration used either in the this material.
  125245. *
  125246. * If sets to null, the scene one is in use.
  125247. */
  125248. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125249. /**
  125250. * Gets wether the color curves effect is enabled.
  125251. */
  125252. get cameraColorCurvesEnabled(): boolean;
  125253. /**
  125254. * Sets wether the color curves effect is enabled.
  125255. */
  125256. set cameraColorCurvesEnabled(value: boolean);
  125257. /**
  125258. * Gets wether the color grading effect is enabled.
  125259. */
  125260. get cameraColorGradingEnabled(): boolean;
  125261. /**
  125262. * Gets wether the color grading effect is enabled.
  125263. */
  125264. set cameraColorGradingEnabled(value: boolean);
  125265. /**
  125266. * Gets wether tonemapping is enabled or not.
  125267. */
  125268. get cameraToneMappingEnabled(): boolean;
  125269. /**
  125270. * Sets wether tonemapping is enabled or not
  125271. */
  125272. set cameraToneMappingEnabled(value: boolean);
  125273. /**
  125274. * The camera exposure used on this material.
  125275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125276. * This corresponds to a photographic exposure.
  125277. */
  125278. get cameraExposure(): number;
  125279. /**
  125280. * The camera exposure used on this material.
  125281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125282. * This corresponds to a photographic exposure.
  125283. */
  125284. set cameraExposure(value: number);
  125285. /**
  125286. * Gets The camera contrast used on this material.
  125287. */
  125288. get cameraContrast(): number;
  125289. /**
  125290. * Sets The camera contrast used on this material.
  125291. */
  125292. set cameraContrast(value: number);
  125293. /**
  125294. * Gets the Color Grading 2D Lookup Texture.
  125295. */
  125296. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125297. /**
  125298. * Sets the Color Grading 2D Lookup Texture.
  125299. */
  125300. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125301. /**
  125302. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125303. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125304. * 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;
  125305. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125306. */
  125307. get cameraColorCurves(): Nullable<ColorCurves>;
  125308. /**
  125309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125311. * 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;
  125312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125313. */
  125314. set cameraColorCurves(value: Nullable<ColorCurves>);
  125315. /**
  125316. * Instantiates a new PBRMaterial instance.
  125317. *
  125318. * @param name The material name
  125319. * @param scene The scene the material will be use in.
  125320. */
  125321. constructor(name: string, scene: Scene);
  125322. /**
  125323. * Returns the name of this material class.
  125324. */
  125325. getClassName(): string;
  125326. /**
  125327. * Makes a duplicate of the current material.
  125328. * @param name - name to use for the new material.
  125329. */
  125330. clone(name: string): PBRMaterial;
  125331. /**
  125332. * Serializes this PBR Material.
  125333. * @returns - An object with the serialized material.
  125334. */
  125335. serialize(): any;
  125336. /**
  125337. * Parses a PBR Material from a serialized object.
  125338. * @param source - Serialized object.
  125339. * @param scene - BJS scene instance.
  125340. * @param rootUrl - url for the scene object
  125341. * @returns - PBRMaterial
  125342. */
  125343. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125344. }
  125345. }
  125346. declare module BABYLON {
  125347. /**
  125348. * Direct draw surface info
  125349. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125350. */
  125351. export interface DDSInfo {
  125352. /**
  125353. * Width of the texture
  125354. */
  125355. width: number;
  125356. /**
  125357. * Width of the texture
  125358. */
  125359. height: number;
  125360. /**
  125361. * Number of Mipmaps for the texture
  125362. * @see https://en.wikipedia.org/wiki/Mipmap
  125363. */
  125364. mipmapCount: number;
  125365. /**
  125366. * If the textures format is a known fourCC format
  125367. * @see https://www.fourcc.org/
  125368. */
  125369. isFourCC: boolean;
  125370. /**
  125371. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125372. */
  125373. isRGB: boolean;
  125374. /**
  125375. * If the texture is a lumincance format
  125376. */
  125377. isLuminance: boolean;
  125378. /**
  125379. * If this is a cube texture
  125380. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125381. */
  125382. isCube: boolean;
  125383. /**
  125384. * If the texture is a compressed format eg. FOURCC_DXT1
  125385. */
  125386. isCompressed: boolean;
  125387. /**
  125388. * The dxgiFormat of the texture
  125389. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125390. */
  125391. dxgiFormat: number;
  125392. /**
  125393. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125394. */
  125395. textureType: number;
  125396. /**
  125397. * Sphericle polynomial created for the dds texture
  125398. */
  125399. sphericalPolynomial?: SphericalPolynomial;
  125400. }
  125401. /**
  125402. * Class used to provide DDS decompression tools
  125403. */
  125404. export class DDSTools {
  125405. /**
  125406. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125407. */
  125408. static StoreLODInAlphaChannel: boolean;
  125409. /**
  125410. * Gets DDS information from an array buffer
  125411. * @param data defines the array buffer view to read data from
  125412. * @returns the DDS information
  125413. */
  125414. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125415. private static _FloatView;
  125416. private static _Int32View;
  125417. private static _ToHalfFloat;
  125418. private static _FromHalfFloat;
  125419. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125420. private static _GetHalfFloatRGBAArrayBuffer;
  125421. private static _GetFloatRGBAArrayBuffer;
  125422. private static _GetFloatAsUIntRGBAArrayBuffer;
  125423. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125424. private static _GetRGBAArrayBuffer;
  125425. private static _ExtractLongWordOrder;
  125426. private static _GetRGBArrayBuffer;
  125427. private static _GetLuminanceArrayBuffer;
  125428. /**
  125429. * Uploads DDS Levels to a Babylon Texture
  125430. * @hidden
  125431. */
  125432. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125433. }
  125434. interface ThinEngine {
  125435. /**
  125436. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125437. * @param rootUrl defines the url where the file to load is located
  125438. * @param scene defines the current scene
  125439. * @param lodScale defines scale to apply to the mip map selection
  125440. * @param lodOffset defines offset to apply to the mip map selection
  125441. * @param onLoad defines an optional callback raised when the texture is loaded
  125442. * @param onError defines an optional callback raised if there is an issue to load the texture
  125443. * @param format defines the format of the data
  125444. * @param forcedExtension defines the extension to use to pick the right loader
  125445. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125446. * @returns the cube texture as an InternalTexture
  125447. */
  125448. 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;
  125449. }
  125450. }
  125451. declare module BABYLON {
  125452. /**
  125453. * Implementation of the DDS Texture Loader.
  125454. * @hidden
  125455. */
  125456. export class _DDSTextureLoader implements IInternalTextureLoader {
  125457. /**
  125458. * Defines wether the loader supports cascade loading the different faces.
  125459. */
  125460. readonly supportCascades: boolean;
  125461. /**
  125462. * This returns if the loader support the current file information.
  125463. * @param extension defines the file extension of the file being loaded
  125464. * @returns true if the loader can load the specified file
  125465. */
  125466. canLoad(extension: string): boolean;
  125467. /**
  125468. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125469. * @param data contains the texture data
  125470. * @param texture defines the BabylonJS internal texture
  125471. * @param createPolynomials will be true if polynomials have been requested
  125472. * @param onLoad defines the callback to trigger once the texture is ready
  125473. * @param onError defines the callback to trigger in case of error
  125474. */
  125475. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125476. /**
  125477. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125478. * @param data contains the texture data
  125479. * @param texture defines the BabylonJS internal texture
  125480. * @param callback defines the method to call once ready to upload
  125481. */
  125482. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125483. }
  125484. }
  125485. declare module BABYLON {
  125486. /**
  125487. * Implementation of the ENV Texture Loader.
  125488. * @hidden
  125489. */
  125490. export class _ENVTextureLoader implements IInternalTextureLoader {
  125491. /**
  125492. * Defines wether the loader supports cascade loading the different faces.
  125493. */
  125494. readonly supportCascades: boolean;
  125495. /**
  125496. * This returns if the loader support the current file information.
  125497. * @param extension defines the file extension of the file being loaded
  125498. * @returns true if the loader can load the specified file
  125499. */
  125500. canLoad(extension: string): boolean;
  125501. /**
  125502. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125503. * @param data contains the texture data
  125504. * @param texture defines the BabylonJS internal texture
  125505. * @param createPolynomials will be true if polynomials have been requested
  125506. * @param onLoad defines the callback to trigger once the texture is ready
  125507. * @param onError defines the callback to trigger in case of error
  125508. */
  125509. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125510. /**
  125511. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125512. * @param data contains the texture data
  125513. * @param texture defines the BabylonJS internal texture
  125514. * @param callback defines the method to call once ready to upload
  125515. */
  125516. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125517. }
  125518. }
  125519. declare module BABYLON {
  125520. /**
  125521. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125522. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125523. */
  125524. export class KhronosTextureContainer {
  125525. /** contents of the KTX container file */
  125526. data: ArrayBufferView;
  125527. private static HEADER_LEN;
  125528. private static COMPRESSED_2D;
  125529. private static COMPRESSED_3D;
  125530. private static TEX_2D;
  125531. private static TEX_3D;
  125532. /**
  125533. * Gets the openGL type
  125534. */
  125535. glType: number;
  125536. /**
  125537. * Gets the openGL type size
  125538. */
  125539. glTypeSize: number;
  125540. /**
  125541. * Gets the openGL format
  125542. */
  125543. glFormat: number;
  125544. /**
  125545. * Gets the openGL internal format
  125546. */
  125547. glInternalFormat: number;
  125548. /**
  125549. * Gets the base internal format
  125550. */
  125551. glBaseInternalFormat: number;
  125552. /**
  125553. * Gets image width in pixel
  125554. */
  125555. pixelWidth: number;
  125556. /**
  125557. * Gets image height in pixel
  125558. */
  125559. pixelHeight: number;
  125560. /**
  125561. * Gets image depth in pixels
  125562. */
  125563. pixelDepth: number;
  125564. /**
  125565. * Gets the number of array elements
  125566. */
  125567. numberOfArrayElements: number;
  125568. /**
  125569. * Gets the number of faces
  125570. */
  125571. numberOfFaces: number;
  125572. /**
  125573. * Gets the number of mipmap levels
  125574. */
  125575. numberOfMipmapLevels: number;
  125576. /**
  125577. * Gets the bytes of key value data
  125578. */
  125579. bytesOfKeyValueData: number;
  125580. /**
  125581. * Gets the load type
  125582. */
  125583. loadType: number;
  125584. /**
  125585. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125586. */
  125587. isInvalid: boolean;
  125588. /**
  125589. * Creates a new KhronosTextureContainer
  125590. * @param data contents of the KTX container file
  125591. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125592. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125593. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125594. */
  125595. constructor(
  125596. /** contents of the KTX container file */
  125597. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125598. /**
  125599. * Uploads KTX content to a Babylon Texture.
  125600. * It is assumed that the texture has already been created & is currently bound
  125601. * @hidden
  125602. */
  125603. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125604. private _upload2DCompressedLevels;
  125605. /**
  125606. * Checks if the given data starts with a KTX file identifier.
  125607. * @param data the data to check
  125608. * @returns true if the data is a KTX file or false otherwise
  125609. */
  125610. static IsValid(data: ArrayBufferView): boolean;
  125611. }
  125612. }
  125613. declare module BABYLON {
  125614. /**
  125615. * Class for loading KTX2 files
  125616. * !!! Experimental Extension Subject to Changes !!!
  125617. * @hidden
  125618. */
  125619. export class KhronosTextureContainer2 {
  125620. private static _ModulePromise;
  125621. private static _TranscodeFormat;
  125622. constructor(engine: ThinEngine);
  125623. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125624. private _determineTranscodeFormat;
  125625. /**
  125626. * Checks if the given data starts with a KTX2 file identifier.
  125627. * @param data the data to check
  125628. * @returns true if the data is a KTX2 file or false otherwise
  125629. */
  125630. static IsValid(data: ArrayBufferView): boolean;
  125631. }
  125632. }
  125633. declare module BABYLON {
  125634. /**
  125635. * Implementation of the KTX Texture Loader.
  125636. * @hidden
  125637. */
  125638. export class _KTXTextureLoader implements IInternalTextureLoader {
  125639. /**
  125640. * Defines wether the loader supports cascade loading the different faces.
  125641. */
  125642. readonly supportCascades: boolean;
  125643. /**
  125644. * This returns if the loader support the current file information.
  125645. * @param extension defines the file extension of the file being loaded
  125646. * @returns true if the loader can load the specified file
  125647. */
  125648. canLoad(extension: string): boolean;
  125649. /**
  125650. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125651. * @param data contains the texture data
  125652. * @param texture defines the BabylonJS internal texture
  125653. * @param createPolynomials will be true if polynomials have been requested
  125654. * @param onLoad defines the callback to trigger once the texture is ready
  125655. * @param onError defines the callback to trigger in case of error
  125656. */
  125657. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125658. /**
  125659. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125660. * @param data contains the texture data
  125661. * @param texture defines the BabylonJS internal texture
  125662. * @param callback defines the method to call once ready to upload
  125663. */
  125664. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125665. }
  125666. }
  125667. declare module BABYLON {
  125668. /** @hidden */
  125669. export var _forceSceneHelpersToBundle: boolean;
  125670. interface Scene {
  125671. /**
  125672. * Creates a default light for the scene.
  125673. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125674. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125675. */
  125676. createDefaultLight(replace?: boolean): void;
  125677. /**
  125678. * Creates a default camera for the scene.
  125679. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125680. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125681. * @param replace has default false, when true replaces the active camera in the scene
  125682. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125683. */
  125684. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125685. /**
  125686. * Creates a default camera and a default light.
  125687. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125688. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125689. * @param replace has the default false, when true replaces the active camera/light in the scene
  125690. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125691. */
  125692. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125693. /**
  125694. * Creates a new sky box
  125695. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125696. * @param environmentTexture defines the texture to use as environment texture
  125697. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125698. * @param scale defines the overall scale of the skybox
  125699. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125700. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125701. * @returns a new mesh holding the sky box
  125702. */
  125703. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125704. /**
  125705. * Creates a new environment
  125706. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125707. * @param options defines the options you can use to configure the environment
  125708. * @returns the new EnvironmentHelper
  125709. */
  125710. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125711. /**
  125712. * Creates a new VREXperienceHelper
  125713. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125714. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125715. * @returns a new VREXperienceHelper
  125716. */
  125717. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125718. /**
  125719. * Creates a new WebXRDefaultExperience
  125720. * @see http://doc.babylonjs.com/how_to/webxr
  125721. * @param options experience options
  125722. * @returns a promise for a new WebXRDefaultExperience
  125723. */
  125724. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125725. }
  125726. }
  125727. declare module BABYLON {
  125728. /**
  125729. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125730. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125731. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125732. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125733. */
  125734. export class VideoDome extends TransformNode {
  125735. /**
  125736. * Define the video source as a Monoscopic panoramic 360 video.
  125737. */
  125738. static readonly MODE_MONOSCOPIC: number;
  125739. /**
  125740. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125741. */
  125742. static readonly MODE_TOPBOTTOM: number;
  125743. /**
  125744. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125745. */
  125746. static readonly MODE_SIDEBYSIDE: number;
  125747. private _halfDome;
  125748. private _useDirectMapping;
  125749. /**
  125750. * The video texture being displayed on the sphere
  125751. */
  125752. protected _videoTexture: VideoTexture;
  125753. /**
  125754. * Gets the video texture being displayed on the sphere
  125755. */
  125756. get videoTexture(): VideoTexture;
  125757. /**
  125758. * The skybox material
  125759. */
  125760. protected _material: BackgroundMaterial;
  125761. /**
  125762. * The surface used for the skybox
  125763. */
  125764. protected _mesh: Mesh;
  125765. /**
  125766. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125767. */
  125768. private _halfDomeMask;
  125769. /**
  125770. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125771. * Also see the options.resolution property.
  125772. */
  125773. get fovMultiplier(): number;
  125774. set fovMultiplier(value: number);
  125775. private _videoMode;
  125776. /**
  125777. * Gets or set the current video mode for the video. It can be:
  125778. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125779. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125780. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125781. */
  125782. get videoMode(): number;
  125783. set videoMode(value: number);
  125784. /**
  125785. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125786. *
  125787. */
  125788. get halfDome(): boolean;
  125789. /**
  125790. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125791. */
  125792. set halfDome(enabled: boolean);
  125793. /**
  125794. * Oberserver used in Stereoscopic VR Mode.
  125795. */
  125796. private _onBeforeCameraRenderObserver;
  125797. /**
  125798. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125799. * @param name Element's name, child elements will append suffixes for their own names.
  125800. * @param urlsOrVideo defines the url(s) or the video element to use
  125801. * @param options An object containing optional or exposed sub element properties
  125802. */
  125803. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125804. resolution?: number;
  125805. clickToPlay?: boolean;
  125806. autoPlay?: boolean;
  125807. loop?: boolean;
  125808. size?: number;
  125809. poster?: string;
  125810. faceForward?: boolean;
  125811. useDirectMapping?: boolean;
  125812. halfDomeMode?: boolean;
  125813. }, scene: Scene);
  125814. private _changeVideoMode;
  125815. /**
  125816. * Releases resources associated with this node.
  125817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125819. */
  125820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125821. }
  125822. }
  125823. declare module BABYLON {
  125824. /**
  125825. * This class can be used to get instrumentation data from a Babylon engine
  125826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125827. */
  125828. export class EngineInstrumentation implements IDisposable {
  125829. /**
  125830. * Define the instrumented engine.
  125831. */
  125832. engine: Engine;
  125833. private _captureGPUFrameTime;
  125834. private _gpuFrameTimeToken;
  125835. private _gpuFrameTime;
  125836. private _captureShaderCompilationTime;
  125837. private _shaderCompilationTime;
  125838. private _onBeginFrameObserver;
  125839. private _onEndFrameObserver;
  125840. private _onBeforeShaderCompilationObserver;
  125841. private _onAfterShaderCompilationObserver;
  125842. /**
  125843. * Gets the perf counter used for GPU frame time
  125844. */
  125845. get gpuFrameTimeCounter(): PerfCounter;
  125846. /**
  125847. * Gets the GPU frame time capture status
  125848. */
  125849. get captureGPUFrameTime(): boolean;
  125850. /**
  125851. * Enable or disable the GPU frame time capture
  125852. */
  125853. set captureGPUFrameTime(value: boolean);
  125854. /**
  125855. * Gets the perf counter used for shader compilation time
  125856. */
  125857. get shaderCompilationTimeCounter(): PerfCounter;
  125858. /**
  125859. * Gets the shader compilation time capture status
  125860. */
  125861. get captureShaderCompilationTime(): boolean;
  125862. /**
  125863. * Enable or disable the shader compilation time capture
  125864. */
  125865. set captureShaderCompilationTime(value: boolean);
  125866. /**
  125867. * Instantiates a new engine instrumentation.
  125868. * This class can be used to get instrumentation data from a Babylon engine
  125869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125870. * @param engine Defines the engine to instrument
  125871. */
  125872. constructor(
  125873. /**
  125874. * Define the instrumented engine.
  125875. */
  125876. engine: Engine);
  125877. /**
  125878. * Dispose and release associated resources.
  125879. */
  125880. dispose(): void;
  125881. }
  125882. }
  125883. declare module BABYLON {
  125884. /**
  125885. * This class can be used to get instrumentation data from a Babylon engine
  125886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125887. */
  125888. export class SceneInstrumentation implements IDisposable {
  125889. /**
  125890. * Defines the scene to instrument
  125891. */
  125892. scene: Scene;
  125893. private _captureActiveMeshesEvaluationTime;
  125894. private _activeMeshesEvaluationTime;
  125895. private _captureRenderTargetsRenderTime;
  125896. private _renderTargetsRenderTime;
  125897. private _captureFrameTime;
  125898. private _frameTime;
  125899. private _captureRenderTime;
  125900. private _renderTime;
  125901. private _captureInterFrameTime;
  125902. private _interFrameTime;
  125903. private _captureParticlesRenderTime;
  125904. private _particlesRenderTime;
  125905. private _captureSpritesRenderTime;
  125906. private _spritesRenderTime;
  125907. private _capturePhysicsTime;
  125908. private _physicsTime;
  125909. private _captureAnimationsTime;
  125910. private _animationsTime;
  125911. private _captureCameraRenderTime;
  125912. private _cameraRenderTime;
  125913. private _onBeforeActiveMeshesEvaluationObserver;
  125914. private _onAfterActiveMeshesEvaluationObserver;
  125915. private _onBeforeRenderTargetsRenderObserver;
  125916. private _onAfterRenderTargetsRenderObserver;
  125917. private _onAfterRenderObserver;
  125918. private _onBeforeDrawPhaseObserver;
  125919. private _onAfterDrawPhaseObserver;
  125920. private _onBeforeAnimationsObserver;
  125921. private _onBeforeParticlesRenderingObserver;
  125922. private _onAfterParticlesRenderingObserver;
  125923. private _onBeforeSpritesRenderingObserver;
  125924. private _onAfterSpritesRenderingObserver;
  125925. private _onBeforePhysicsObserver;
  125926. private _onAfterPhysicsObserver;
  125927. private _onAfterAnimationsObserver;
  125928. private _onBeforeCameraRenderObserver;
  125929. private _onAfterCameraRenderObserver;
  125930. /**
  125931. * Gets the perf counter used for active meshes evaluation time
  125932. */
  125933. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125934. /**
  125935. * Gets the active meshes evaluation time capture status
  125936. */
  125937. get captureActiveMeshesEvaluationTime(): boolean;
  125938. /**
  125939. * Enable or disable the active meshes evaluation time capture
  125940. */
  125941. set captureActiveMeshesEvaluationTime(value: boolean);
  125942. /**
  125943. * Gets the perf counter used for render targets render time
  125944. */
  125945. get renderTargetsRenderTimeCounter(): PerfCounter;
  125946. /**
  125947. * Gets the render targets render time capture status
  125948. */
  125949. get captureRenderTargetsRenderTime(): boolean;
  125950. /**
  125951. * Enable or disable the render targets render time capture
  125952. */
  125953. set captureRenderTargetsRenderTime(value: boolean);
  125954. /**
  125955. * Gets the perf counter used for particles render time
  125956. */
  125957. get particlesRenderTimeCounter(): PerfCounter;
  125958. /**
  125959. * Gets the particles render time capture status
  125960. */
  125961. get captureParticlesRenderTime(): boolean;
  125962. /**
  125963. * Enable or disable the particles render time capture
  125964. */
  125965. set captureParticlesRenderTime(value: boolean);
  125966. /**
  125967. * Gets the perf counter used for sprites render time
  125968. */
  125969. get spritesRenderTimeCounter(): PerfCounter;
  125970. /**
  125971. * Gets the sprites render time capture status
  125972. */
  125973. get captureSpritesRenderTime(): boolean;
  125974. /**
  125975. * Enable or disable the sprites render time capture
  125976. */
  125977. set captureSpritesRenderTime(value: boolean);
  125978. /**
  125979. * Gets the perf counter used for physics time
  125980. */
  125981. get physicsTimeCounter(): PerfCounter;
  125982. /**
  125983. * Gets the physics time capture status
  125984. */
  125985. get capturePhysicsTime(): boolean;
  125986. /**
  125987. * Enable or disable the physics time capture
  125988. */
  125989. set capturePhysicsTime(value: boolean);
  125990. /**
  125991. * Gets the perf counter used for animations time
  125992. */
  125993. get animationsTimeCounter(): PerfCounter;
  125994. /**
  125995. * Gets the animations time capture status
  125996. */
  125997. get captureAnimationsTime(): boolean;
  125998. /**
  125999. * Enable or disable the animations time capture
  126000. */
  126001. set captureAnimationsTime(value: boolean);
  126002. /**
  126003. * Gets the perf counter used for frame time capture
  126004. */
  126005. get frameTimeCounter(): PerfCounter;
  126006. /**
  126007. * Gets the frame time capture status
  126008. */
  126009. get captureFrameTime(): boolean;
  126010. /**
  126011. * Enable or disable the frame time capture
  126012. */
  126013. set captureFrameTime(value: boolean);
  126014. /**
  126015. * Gets the perf counter used for inter-frames time capture
  126016. */
  126017. get interFrameTimeCounter(): PerfCounter;
  126018. /**
  126019. * Gets the inter-frames time capture status
  126020. */
  126021. get captureInterFrameTime(): boolean;
  126022. /**
  126023. * Enable or disable the inter-frames time capture
  126024. */
  126025. set captureInterFrameTime(value: boolean);
  126026. /**
  126027. * Gets the perf counter used for render time capture
  126028. */
  126029. get renderTimeCounter(): PerfCounter;
  126030. /**
  126031. * Gets the render time capture status
  126032. */
  126033. get captureRenderTime(): boolean;
  126034. /**
  126035. * Enable or disable the render time capture
  126036. */
  126037. set captureRenderTime(value: boolean);
  126038. /**
  126039. * Gets the perf counter used for camera render time capture
  126040. */
  126041. get cameraRenderTimeCounter(): PerfCounter;
  126042. /**
  126043. * Gets the camera render time capture status
  126044. */
  126045. get captureCameraRenderTime(): boolean;
  126046. /**
  126047. * Enable or disable the camera render time capture
  126048. */
  126049. set captureCameraRenderTime(value: boolean);
  126050. /**
  126051. * Gets the perf counter used for draw calls
  126052. */
  126053. get drawCallsCounter(): PerfCounter;
  126054. /**
  126055. * Instantiates a new scene instrumentation.
  126056. * This class can be used to get instrumentation data from a Babylon engine
  126057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126058. * @param scene Defines the scene to instrument
  126059. */
  126060. constructor(
  126061. /**
  126062. * Defines the scene to instrument
  126063. */
  126064. scene: Scene);
  126065. /**
  126066. * Dispose and release associated resources.
  126067. */
  126068. dispose(): void;
  126069. }
  126070. }
  126071. declare module BABYLON {
  126072. /** @hidden */
  126073. export var glowMapGenerationPixelShader: {
  126074. name: string;
  126075. shader: string;
  126076. };
  126077. }
  126078. declare module BABYLON {
  126079. /** @hidden */
  126080. export var glowMapGenerationVertexShader: {
  126081. name: string;
  126082. shader: string;
  126083. };
  126084. }
  126085. declare module BABYLON {
  126086. /**
  126087. * Effect layer options. This helps customizing the behaviour
  126088. * of the effect layer.
  126089. */
  126090. export interface IEffectLayerOptions {
  126091. /**
  126092. * Multiplication factor apply to the canvas size to compute the render target size
  126093. * used to generated the objects (the smaller the faster).
  126094. */
  126095. mainTextureRatio: number;
  126096. /**
  126097. * Enforces a fixed size texture to ensure effect stability across devices.
  126098. */
  126099. mainTextureFixedSize?: number;
  126100. /**
  126101. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126102. */
  126103. alphaBlendingMode: number;
  126104. /**
  126105. * The camera attached to the layer.
  126106. */
  126107. camera: Nullable<Camera>;
  126108. /**
  126109. * The rendering group to draw the layer in.
  126110. */
  126111. renderingGroupId: number;
  126112. }
  126113. /**
  126114. * The effect layer Helps adding post process effect blended with the main pass.
  126115. *
  126116. * This can be for instance use to generate glow or higlight effects on the scene.
  126117. *
  126118. * The effect layer class can not be used directly and is intented to inherited from to be
  126119. * customized per effects.
  126120. */
  126121. export abstract class EffectLayer {
  126122. private _vertexBuffers;
  126123. private _indexBuffer;
  126124. private _cachedDefines;
  126125. private _effectLayerMapGenerationEffect;
  126126. private _effectLayerOptions;
  126127. private _mergeEffect;
  126128. protected _scene: Scene;
  126129. protected _engine: Engine;
  126130. protected _maxSize: number;
  126131. protected _mainTextureDesiredSize: ISize;
  126132. protected _mainTexture: RenderTargetTexture;
  126133. protected _shouldRender: boolean;
  126134. protected _postProcesses: PostProcess[];
  126135. protected _textures: BaseTexture[];
  126136. protected _emissiveTextureAndColor: {
  126137. texture: Nullable<BaseTexture>;
  126138. color: Color4;
  126139. };
  126140. /**
  126141. * The name of the layer
  126142. */
  126143. name: string;
  126144. /**
  126145. * The clear color of the texture used to generate the glow map.
  126146. */
  126147. neutralColor: Color4;
  126148. /**
  126149. * Specifies whether the highlight layer is enabled or not.
  126150. */
  126151. isEnabled: boolean;
  126152. /**
  126153. * Gets the camera attached to the layer.
  126154. */
  126155. get camera(): Nullable<Camera>;
  126156. /**
  126157. * Gets the rendering group id the layer should render in.
  126158. */
  126159. get renderingGroupId(): number;
  126160. set renderingGroupId(renderingGroupId: number);
  126161. /**
  126162. * An event triggered when the effect layer has been disposed.
  126163. */
  126164. onDisposeObservable: Observable<EffectLayer>;
  126165. /**
  126166. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126167. */
  126168. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126169. /**
  126170. * An event triggered when the generated texture is being merged in the scene.
  126171. */
  126172. onBeforeComposeObservable: Observable<EffectLayer>;
  126173. /**
  126174. * An event triggered when the mesh is rendered into the effect render target.
  126175. */
  126176. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126177. /**
  126178. * An event triggered after the mesh has been rendered into the effect render target.
  126179. */
  126180. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126181. /**
  126182. * An event triggered when the generated texture has been merged in the scene.
  126183. */
  126184. onAfterComposeObservable: Observable<EffectLayer>;
  126185. /**
  126186. * An event triggered when the efffect layer changes its size.
  126187. */
  126188. onSizeChangedObservable: Observable<EffectLayer>;
  126189. /** @hidden */
  126190. static _SceneComponentInitialization: (scene: Scene) => void;
  126191. /**
  126192. * Instantiates a new effect Layer and references it in the scene.
  126193. * @param name The name of the layer
  126194. * @param scene The scene to use the layer in
  126195. */
  126196. constructor(
  126197. /** The Friendly of the effect in the scene */
  126198. name: string, scene: Scene);
  126199. /**
  126200. * Get the effect name of the layer.
  126201. * @return The effect name
  126202. */
  126203. abstract getEffectName(): string;
  126204. /**
  126205. * Checks for the readiness of the element composing the layer.
  126206. * @param subMesh the mesh to check for
  126207. * @param useInstances specify whether or not to use instances to render the mesh
  126208. * @return true if ready otherwise, false
  126209. */
  126210. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126211. /**
  126212. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126213. * @returns true if the effect requires stencil during the main canvas render pass.
  126214. */
  126215. abstract needStencil(): boolean;
  126216. /**
  126217. * Create the merge effect. This is the shader use to blit the information back
  126218. * to the main canvas at the end of the scene rendering.
  126219. * @returns The effect containing the shader used to merge the effect on the main canvas
  126220. */
  126221. protected abstract _createMergeEffect(): Effect;
  126222. /**
  126223. * Creates the render target textures and post processes used in the effect layer.
  126224. */
  126225. protected abstract _createTextureAndPostProcesses(): void;
  126226. /**
  126227. * Implementation specific of rendering the generating effect on the main canvas.
  126228. * @param effect The effect used to render through
  126229. */
  126230. protected abstract _internalRender(effect: Effect): void;
  126231. /**
  126232. * Sets the required values for both the emissive texture and and the main color.
  126233. */
  126234. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126235. /**
  126236. * Free any resources and references associated to a mesh.
  126237. * Internal use
  126238. * @param mesh The mesh to free.
  126239. */
  126240. abstract _disposeMesh(mesh: Mesh): void;
  126241. /**
  126242. * Serializes this layer (Glow or Highlight for example)
  126243. * @returns a serialized layer object
  126244. */
  126245. abstract serialize?(): any;
  126246. /**
  126247. * Initializes the effect layer with the required options.
  126248. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126249. */
  126250. protected _init(options: Partial<IEffectLayerOptions>): void;
  126251. /**
  126252. * Generates the index buffer of the full screen quad blending to the main canvas.
  126253. */
  126254. private _generateIndexBuffer;
  126255. /**
  126256. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126257. */
  126258. private _generateVertexBuffer;
  126259. /**
  126260. * Sets the main texture desired size which is the closest power of two
  126261. * of the engine canvas size.
  126262. */
  126263. private _setMainTextureSize;
  126264. /**
  126265. * Creates the main texture for the effect layer.
  126266. */
  126267. protected _createMainTexture(): void;
  126268. /**
  126269. * Adds specific effects defines.
  126270. * @param defines The defines to add specifics to.
  126271. */
  126272. protected _addCustomEffectDefines(defines: string[]): void;
  126273. /**
  126274. * Checks for the readiness of the element composing the layer.
  126275. * @param subMesh the mesh to check for
  126276. * @param useInstances specify whether or not to use instances to render the mesh
  126277. * @param emissiveTexture the associated emissive texture used to generate the glow
  126278. * @return true if ready otherwise, false
  126279. */
  126280. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126281. /**
  126282. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126283. */
  126284. render(): void;
  126285. /**
  126286. * Determine if a given mesh will be used in the current effect.
  126287. * @param mesh mesh to test
  126288. * @returns true if the mesh will be used
  126289. */
  126290. hasMesh(mesh: AbstractMesh): boolean;
  126291. /**
  126292. * Returns true if the layer contains information to display, otherwise false.
  126293. * @returns true if the glow layer should be rendered
  126294. */
  126295. shouldRender(): boolean;
  126296. /**
  126297. * Returns true if the mesh should render, otherwise false.
  126298. * @param mesh The mesh to render
  126299. * @returns true if it should render otherwise false
  126300. */
  126301. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126302. /**
  126303. * Returns true if the mesh can be rendered, otherwise false.
  126304. * @param mesh The mesh to render
  126305. * @param material The material used on the mesh
  126306. * @returns true if it can be rendered otherwise false
  126307. */
  126308. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126309. /**
  126310. * Returns true if the mesh should render, otherwise false.
  126311. * @param mesh The mesh to render
  126312. * @returns true if it should render otherwise false
  126313. */
  126314. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126315. /**
  126316. * Renders the submesh passed in parameter to the generation map.
  126317. */
  126318. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126319. /**
  126320. * Defines whether the current material of the mesh should be use to render the effect.
  126321. * @param mesh defines the current mesh to render
  126322. */
  126323. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126324. /**
  126325. * Rebuild the required buffers.
  126326. * @hidden Internal use only.
  126327. */
  126328. _rebuild(): void;
  126329. /**
  126330. * Dispose only the render target textures and post process.
  126331. */
  126332. private _disposeTextureAndPostProcesses;
  126333. /**
  126334. * Dispose the highlight layer and free resources.
  126335. */
  126336. dispose(): void;
  126337. /**
  126338. * Gets the class name of the effect layer
  126339. * @returns the string with the class name of the effect layer
  126340. */
  126341. getClassName(): string;
  126342. /**
  126343. * Creates an effect layer from parsed effect layer data
  126344. * @param parsedEffectLayer defines effect layer data
  126345. * @param scene defines the current scene
  126346. * @param rootUrl defines the root URL containing the effect layer information
  126347. * @returns a parsed effect Layer
  126348. */
  126349. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126350. }
  126351. }
  126352. declare module BABYLON {
  126353. interface AbstractScene {
  126354. /**
  126355. * The list of effect layers (highlights/glow) added to the scene
  126356. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126357. * @see http://doc.babylonjs.com/how_to/glow_layer
  126358. */
  126359. effectLayers: Array<EffectLayer>;
  126360. /**
  126361. * Removes the given effect layer from this scene.
  126362. * @param toRemove defines the effect layer to remove
  126363. * @returns the index of the removed effect layer
  126364. */
  126365. removeEffectLayer(toRemove: EffectLayer): number;
  126366. /**
  126367. * Adds the given effect layer to this scene
  126368. * @param newEffectLayer defines the effect layer to add
  126369. */
  126370. addEffectLayer(newEffectLayer: EffectLayer): void;
  126371. }
  126372. /**
  126373. * Defines the layer scene component responsible to manage any effect layers
  126374. * in a given scene.
  126375. */
  126376. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126377. /**
  126378. * The component name helpfull to identify the component in the list of scene components.
  126379. */
  126380. readonly name: string;
  126381. /**
  126382. * The scene the component belongs to.
  126383. */
  126384. scene: Scene;
  126385. private _engine;
  126386. private _renderEffects;
  126387. private _needStencil;
  126388. private _previousStencilState;
  126389. /**
  126390. * Creates a new instance of the component for the given scene
  126391. * @param scene Defines the scene to register the component in
  126392. */
  126393. constructor(scene: Scene);
  126394. /**
  126395. * Registers the component in a given scene
  126396. */
  126397. register(): void;
  126398. /**
  126399. * Rebuilds the elements related to this component in case of
  126400. * context lost for instance.
  126401. */
  126402. rebuild(): void;
  126403. /**
  126404. * Serializes the component data to the specified json object
  126405. * @param serializationObject The object to serialize to
  126406. */
  126407. serialize(serializationObject: any): void;
  126408. /**
  126409. * Adds all the elements from the container to the scene
  126410. * @param container the container holding the elements
  126411. */
  126412. addFromContainer(container: AbstractScene): void;
  126413. /**
  126414. * Removes all the elements in the container from the scene
  126415. * @param container contains the elements to remove
  126416. * @param dispose if the removed element should be disposed (default: false)
  126417. */
  126418. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126419. /**
  126420. * Disposes the component and the associated ressources.
  126421. */
  126422. dispose(): void;
  126423. private _isReadyForMesh;
  126424. private _renderMainTexture;
  126425. private _setStencil;
  126426. private _setStencilBack;
  126427. private _draw;
  126428. private _drawCamera;
  126429. private _drawRenderingGroup;
  126430. }
  126431. }
  126432. declare module BABYLON {
  126433. /** @hidden */
  126434. export var glowMapMergePixelShader: {
  126435. name: string;
  126436. shader: string;
  126437. };
  126438. }
  126439. declare module BABYLON {
  126440. /** @hidden */
  126441. export var glowMapMergeVertexShader: {
  126442. name: string;
  126443. shader: string;
  126444. };
  126445. }
  126446. declare module BABYLON {
  126447. interface AbstractScene {
  126448. /**
  126449. * Return a the first highlight layer of the scene with a given name.
  126450. * @param name The name of the highlight layer to look for.
  126451. * @return The highlight layer if found otherwise null.
  126452. */
  126453. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126454. }
  126455. /**
  126456. * Glow layer options. This helps customizing the behaviour
  126457. * of the glow layer.
  126458. */
  126459. export interface IGlowLayerOptions {
  126460. /**
  126461. * Multiplication factor apply to the canvas size to compute the render target size
  126462. * used to generated the glowing objects (the smaller the faster).
  126463. */
  126464. mainTextureRatio: number;
  126465. /**
  126466. * Enforces a fixed size texture to ensure resize independant blur.
  126467. */
  126468. mainTextureFixedSize?: number;
  126469. /**
  126470. * How big is the kernel of the blur texture.
  126471. */
  126472. blurKernelSize: number;
  126473. /**
  126474. * The camera attached to the layer.
  126475. */
  126476. camera: Nullable<Camera>;
  126477. /**
  126478. * Enable MSAA by chosing the number of samples.
  126479. */
  126480. mainTextureSamples?: number;
  126481. /**
  126482. * The rendering group to draw the layer in.
  126483. */
  126484. renderingGroupId: number;
  126485. }
  126486. /**
  126487. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126488. *
  126489. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126490. *
  126491. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126492. */
  126493. export class GlowLayer extends EffectLayer {
  126494. /**
  126495. * Effect Name of the layer.
  126496. */
  126497. static readonly EffectName: string;
  126498. /**
  126499. * The default blur kernel size used for the glow.
  126500. */
  126501. static DefaultBlurKernelSize: number;
  126502. /**
  126503. * The default texture size ratio used for the glow.
  126504. */
  126505. static DefaultTextureRatio: number;
  126506. /**
  126507. * Sets the kernel size of the blur.
  126508. */
  126509. set blurKernelSize(value: number);
  126510. /**
  126511. * Gets the kernel size of the blur.
  126512. */
  126513. get blurKernelSize(): number;
  126514. /**
  126515. * Sets the glow intensity.
  126516. */
  126517. set intensity(value: number);
  126518. /**
  126519. * Gets the glow intensity.
  126520. */
  126521. get intensity(): number;
  126522. private _options;
  126523. private _intensity;
  126524. private _horizontalBlurPostprocess1;
  126525. private _verticalBlurPostprocess1;
  126526. private _horizontalBlurPostprocess2;
  126527. private _verticalBlurPostprocess2;
  126528. private _blurTexture1;
  126529. private _blurTexture2;
  126530. private _postProcesses1;
  126531. private _postProcesses2;
  126532. private _includedOnlyMeshes;
  126533. private _excludedMeshes;
  126534. private _meshesUsingTheirOwnMaterials;
  126535. /**
  126536. * Callback used to let the user override the color selection on a per mesh basis
  126537. */
  126538. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126539. /**
  126540. * Callback used to let the user override the texture selection on a per mesh basis
  126541. */
  126542. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126543. /**
  126544. * Instantiates a new glow Layer and references it to the scene.
  126545. * @param name The name of the layer
  126546. * @param scene The scene to use the layer in
  126547. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126548. */
  126549. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126550. /**
  126551. * Get the effect name of the layer.
  126552. * @return The effect name
  126553. */
  126554. getEffectName(): string;
  126555. /**
  126556. * Create the merge effect. This is the shader use to blit the information back
  126557. * to the main canvas at the end of the scene rendering.
  126558. */
  126559. protected _createMergeEffect(): Effect;
  126560. /**
  126561. * Creates the render target textures and post processes used in the glow layer.
  126562. */
  126563. protected _createTextureAndPostProcesses(): void;
  126564. /**
  126565. * Checks for the readiness of the element composing the layer.
  126566. * @param subMesh the mesh to check for
  126567. * @param useInstances specify wether or not to use instances to render the mesh
  126568. * @param emissiveTexture the associated emissive texture used to generate the glow
  126569. * @return true if ready otherwise, false
  126570. */
  126571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126572. /**
  126573. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126574. */
  126575. needStencil(): boolean;
  126576. /**
  126577. * Returns true if the mesh can be rendered, otherwise false.
  126578. * @param mesh The mesh to render
  126579. * @param material The material used on the mesh
  126580. * @returns true if it can be rendered otherwise false
  126581. */
  126582. protected _canRenderMesh(mesh: AbstractMesh, material: Material): 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. * Sets the required values for both the emissive texture and and the main color.
  126590. */
  126591. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  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. * Adds specific effects defines.
  126600. * @param defines The defines to add specifics to.
  126601. */
  126602. protected _addCustomEffectDefines(defines: string[]): void;
  126603. /**
  126604. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126605. * @param mesh The mesh to exclude from the glow layer
  126606. */
  126607. addExcludedMesh(mesh: Mesh): void;
  126608. /**
  126609. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126610. * @param mesh The mesh to remove
  126611. */
  126612. removeExcludedMesh(mesh: Mesh): void;
  126613. /**
  126614. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126615. * @param mesh The mesh to include in the glow layer
  126616. */
  126617. addIncludedOnlyMesh(mesh: Mesh): void;
  126618. /**
  126619. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126620. * @param mesh The mesh to remove
  126621. */
  126622. removeIncludedOnlyMesh(mesh: Mesh): void;
  126623. /**
  126624. * Determine if a given mesh will be used in the glow layer
  126625. * @param mesh The mesh to test
  126626. * @returns true if the mesh will be highlighted by the current glow layer
  126627. */
  126628. hasMesh(mesh: AbstractMesh): boolean;
  126629. /**
  126630. * Defines whether the current material of the mesh should be use to render the effect.
  126631. * @param mesh defines the current mesh to render
  126632. */
  126633. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126634. /**
  126635. * Add a mesh to be rendered through its own material and not with emissive only.
  126636. * @param mesh The mesh for which we need to use its material
  126637. */
  126638. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126639. /**
  126640. * Remove a mesh from being rendered through its own material and not with emissive only.
  126641. * @param mesh The mesh for which we need to not use its material
  126642. */
  126643. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126644. /**
  126645. * Free any resources and references associated to a mesh.
  126646. * Internal use
  126647. * @param mesh The mesh to free.
  126648. * @hidden
  126649. */
  126650. _disposeMesh(mesh: Mesh): void;
  126651. /**
  126652. * Gets the class name of the effect layer
  126653. * @returns the string with the class name of the effect layer
  126654. */
  126655. getClassName(): string;
  126656. /**
  126657. * Serializes this glow layer
  126658. * @returns a serialized glow layer object
  126659. */
  126660. serialize(): any;
  126661. /**
  126662. * Creates a Glow Layer from parsed glow layer data
  126663. * @param parsedGlowLayer defines glow layer data
  126664. * @param scene defines the current scene
  126665. * @param rootUrl defines the root URL containing the glow layer information
  126666. * @returns a parsed Glow Layer
  126667. */
  126668. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126669. }
  126670. }
  126671. declare module BABYLON {
  126672. /** @hidden */
  126673. export var glowBlurPostProcessPixelShader: {
  126674. name: string;
  126675. shader: string;
  126676. };
  126677. }
  126678. declare module BABYLON {
  126679. interface AbstractScene {
  126680. /**
  126681. * Return a the first highlight layer of the scene with a given name.
  126682. * @param name The name of the highlight layer to look for.
  126683. * @return The highlight layer if found otherwise null.
  126684. */
  126685. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126686. }
  126687. /**
  126688. * Highlight layer options. This helps customizing the behaviour
  126689. * of the highlight layer.
  126690. */
  126691. export interface IHighlightLayerOptions {
  126692. /**
  126693. * Multiplication factor apply to the canvas size to compute the render target size
  126694. * used to generated the glowing objects (the smaller the faster).
  126695. */
  126696. mainTextureRatio: number;
  126697. /**
  126698. * Enforces a fixed size texture to ensure resize independant blur.
  126699. */
  126700. mainTextureFixedSize?: number;
  126701. /**
  126702. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126703. * of the picture to blur (the smaller the faster).
  126704. */
  126705. blurTextureSizeRatio: number;
  126706. /**
  126707. * How big in texel of the blur texture is the vertical blur.
  126708. */
  126709. blurVerticalSize: number;
  126710. /**
  126711. * How big in texel of the blur texture is the horizontal blur.
  126712. */
  126713. blurHorizontalSize: number;
  126714. /**
  126715. * Alpha blending mode used to apply the blur. Default is combine.
  126716. */
  126717. alphaBlendingMode: number;
  126718. /**
  126719. * The camera attached to the layer.
  126720. */
  126721. camera: Nullable<Camera>;
  126722. /**
  126723. * Should we display highlight as a solid stroke?
  126724. */
  126725. isStroke?: boolean;
  126726. /**
  126727. * The rendering group to draw the layer in.
  126728. */
  126729. renderingGroupId: number;
  126730. }
  126731. /**
  126732. * The highlight layer Helps adding a glow effect around a mesh.
  126733. *
  126734. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126735. * glowy meshes to your scene.
  126736. *
  126737. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126738. */
  126739. export class HighlightLayer extends EffectLayer {
  126740. name: string;
  126741. /**
  126742. * Effect Name of the highlight layer.
  126743. */
  126744. static readonly EffectName: string;
  126745. /**
  126746. * The neutral color used during the preparation of the glow effect.
  126747. * This is black by default as the blend operation is a blend operation.
  126748. */
  126749. static NeutralColor: Color4;
  126750. /**
  126751. * Stencil value used for glowing meshes.
  126752. */
  126753. static GlowingMeshStencilReference: number;
  126754. /**
  126755. * Stencil value used for the other meshes in the scene.
  126756. */
  126757. static NormalMeshStencilReference: number;
  126758. /**
  126759. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126760. */
  126761. innerGlow: boolean;
  126762. /**
  126763. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126764. */
  126765. outerGlow: boolean;
  126766. /**
  126767. * Specifies the horizontal size of the blur.
  126768. */
  126769. set blurHorizontalSize(value: number);
  126770. /**
  126771. * Specifies the vertical size of the blur.
  126772. */
  126773. set blurVerticalSize(value: number);
  126774. /**
  126775. * Gets the horizontal size of the blur.
  126776. */
  126777. get blurHorizontalSize(): number;
  126778. /**
  126779. * Gets the vertical size of the blur.
  126780. */
  126781. get blurVerticalSize(): number;
  126782. /**
  126783. * An event triggered when the highlight layer is being blurred.
  126784. */
  126785. onBeforeBlurObservable: Observable<HighlightLayer>;
  126786. /**
  126787. * An event triggered when the highlight layer has been blurred.
  126788. */
  126789. onAfterBlurObservable: Observable<HighlightLayer>;
  126790. private _instanceGlowingMeshStencilReference;
  126791. private _options;
  126792. private _downSamplePostprocess;
  126793. private _horizontalBlurPostprocess;
  126794. private _verticalBlurPostprocess;
  126795. private _blurTexture;
  126796. private _meshes;
  126797. private _excludedMeshes;
  126798. /**
  126799. * Instantiates a new highlight Layer and references it to the scene..
  126800. * @param name The name of the layer
  126801. * @param scene The scene to use the layer in
  126802. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126803. */
  126804. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126805. /**
  126806. * Get the effect name of the layer.
  126807. * @return The effect name
  126808. */
  126809. getEffectName(): string;
  126810. /**
  126811. * Create the merge effect. This is the shader use to blit the information back
  126812. * to the main canvas at the end of the scene rendering.
  126813. */
  126814. protected _createMergeEffect(): Effect;
  126815. /**
  126816. * Creates the render target textures and post processes used in the highlight layer.
  126817. */
  126818. protected _createTextureAndPostProcesses(): void;
  126819. /**
  126820. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126821. */
  126822. needStencil(): boolean;
  126823. /**
  126824. * Checks for the readiness of the element composing the layer.
  126825. * @param subMesh the mesh to check for
  126826. * @param useInstances specify wether or not to use instances to render the mesh
  126827. * @param emissiveTexture the associated emissive texture used to generate the glow
  126828. * @return true if ready otherwise, false
  126829. */
  126830. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126831. /**
  126832. * Implementation specific of rendering the generating effect on the main canvas.
  126833. * @param effect The effect used to render through
  126834. */
  126835. protected _internalRender(effect: Effect): void;
  126836. /**
  126837. * Returns true if the layer contains information to display, otherwise false.
  126838. */
  126839. shouldRender(): boolean;
  126840. /**
  126841. * Returns true if the mesh should render, otherwise false.
  126842. * @param mesh The mesh to render
  126843. * @returns true if it should render otherwise false
  126844. */
  126845. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126846. /**
  126847. * Sets the required values for both the emissive texture and and the main color.
  126848. */
  126849. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126850. /**
  126851. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126852. * @param mesh The mesh to exclude from the highlight layer
  126853. */
  126854. addExcludedMesh(mesh: Mesh): void;
  126855. /**
  126856. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126857. * @param mesh The mesh to highlight
  126858. */
  126859. removeExcludedMesh(mesh: Mesh): void;
  126860. /**
  126861. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126862. * @param mesh mesh to test
  126863. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126864. */
  126865. hasMesh(mesh: AbstractMesh): boolean;
  126866. /**
  126867. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126868. * @param mesh The mesh to highlight
  126869. * @param color The color of the highlight
  126870. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126871. */
  126872. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126873. /**
  126874. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126875. * @param mesh The mesh to highlight
  126876. */
  126877. removeMesh(mesh: Mesh): void;
  126878. /**
  126879. * Remove all the meshes currently referenced in the highlight layer
  126880. */
  126881. removeAllMeshes(): void;
  126882. /**
  126883. * Force the stencil to the normal expected value for none glowing parts
  126884. */
  126885. private _defaultStencilReference;
  126886. /**
  126887. * Free any resources and references associated to a mesh.
  126888. * Internal use
  126889. * @param mesh The mesh to free.
  126890. * @hidden
  126891. */
  126892. _disposeMesh(mesh: Mesh): void;
  126893. /**
  126894. * Dispose the highlight layer and free resources.
  126895. */
  126896. dispose(): void;
  126897. /**
  126898. * Gets the class name of the effect layer
  126899. * @returns the string with the class name of the effect layer
  126900. */
  126901. getClassName(): string;
  126902. /**
  126903. * Serializes this Highlight layer
  126904. * @returns a serialized Highlight layer object
  126905. */
  126906. serialize(): any;
  126907. /**
  126908. * Creates a Highlight layer from parsed Highlight layer data
  126909. * @param parsedHightlightLayer defines the Highlight layer data
  126910. * @param scene defines the current scene
  126911. * @param rootUrl defines the root URL containing the Highlight layer information
  126912. * @returns a parsed Highlight layer
  126913. */
  126914. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126915. }
  126916. }
  126917. declare module BABYLON {
  126918. interface AbstractScene {
  126919. /**
  126920. * The list of layers (background and foreground) of the scene
  126921. */
  126922. layers: Array<Layer>;
  126923. }
  126924. /**
  126925. * Defines the layer scene component responsible to manage any layers
  126926. * in a given scene.
  126927. */
  126928. export class LayerSceneComponent implements ISceneComponent {
  126929. /**
  126930. * The component name helpfull to identify the component in the list of scene components.
  126931. */
  126932. readonly name: string;
  126933. /**
  126934. * The scene the component belongs to.
  126935. */
  126936. scene: Scene;
  126937. private _engine;
  126938. /**
  126939. * Creates a new instance of the component for the given scene
  126940. * @param scene Defines the scene to register the component in
  126941. */
  126942. constructor(scene: Scene);
  126943. /**
  126944. * Registers the component in a given scene
  126945. */
  126946. register(): void;
  126947. /**
  126948. * Rebuilds the elements related to this component in case of
  126949. * context lost for instance.
  126950. */
  126951. rebuild(): void;
  126952. /**
  126953. * Disposes the component and the associated ressources.
  126954. */
  126955. dispose(): void;
  126956. private _draw;
  126957. private _drawCameraPredicate;
  126958. private _drawCameraBackground;
  126959. private _drawCameraForeground;
  126960. private _drawRenderTargetPredicate;
  126961. private _drawRenderTargetBackground;
  126962. private _drawRenderTargetForeground;
  126963. /**
  126964. * Adds all the elements from the container to the scene
  126965. * @param container the container holding the elements
  126966. */
  126967. addFromContainer(container: AbstractScene): void;
  126968. /**
  126969. * Removes all the elements in the container from the scene
  126970. * @param container contains the elements to remove
  126971. * @param dispose if the removed element should be disposed (default: false)
  126972. */
  126973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126974. }
  126975. }
  126976. declare module BABYLON {
  126977. /** @hidden */
  126978. export var layerPixelShader: {
  126979. name: string;
  126980. shader: string;
  126981. };
  126982. }
  126983. declare module BABYLON {
  126984. /** @hidden */
  126985. export var layerVertexShader: {
  126986. name: string;
  126987. shader: string;
  126988. };
  126989. }
  126990. declare module BABYLON {
  126991. /**
  126992. * This represents a full screen 2d layer.
  126993. * This can be useful to display a picture in the background of your scene for instance.
  126994. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126995. */
  126996. export class Layer {
  126997. /**
  126998. * Define the name of the layer.
  126999. */
  127000. name: string;
  127001. /**
  127002. * Define the texture the layer should display.
  127003. */
  127004. texture: Nullable<Texture>;
  127005. /**
  127006. * Is the layer in background or foreground.
  127007. */
  127008. isBackground: boolean;
  127009. /**
  127010. * Define the color of the layer (instead of texture).
  127011. */
  127012. color: Color4;
  127013. /**
  127014. * Define the scale of the layer in order to zoom in out of the texture.
  127015. */
  127016. scale: Vector2;
  127017. /**
  127018. * Define an offset for the layer in order to shift the texture.
  127019. */
  127020. offset: Vector2;
  127021. /**
  127022. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  127023. */
  127024. alphaBlendingMode: number;
  127025. /**
  127026. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  127027. * Alpha test will not mix with the background color in case of transparency.
  127028. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  127029. */
  127030. alphaTest: boolean;
  127031. /**
  127032. * Define a mask to restrict the layer to only some of the scene cameras.
  127033. */
  127034. layerMask: number;
  127035. /**
  127036. * Define the list of render target the layer is visible into.
  127037. */
  127038. renderTargetTextures: RenderTargetTexture[];
  127039. /**
  127040. * Define if the layer is only used in renderTarget or if it also
  127041. * renders in the main frame buffer of the canvas.
  127042. */
  127043. renderOnlyInRenderTargetTextures: boolean;
  127044. private _scene;
  127045. private _vertexBuffers;
  127046. private _indexBuffer;
  127047. private _effect;
  127048. private _previousDefines;
  127049. /**
  127050. * An event triggered when the layer is disposed.
  127051. */
  127052. onDisposeObservable: Observable<Layer>;
  127053. private _onDisposeObserver;
  127054. /**
  127055. * Back compatibility with callback before the onDisposeObservable existed.
  127056. * The set callback will be triggered when the layer has been disposed.
  127057. */
  127058. set onDispose(callback: () => void);
  127059. /**
  127060. * An event triggered before rendering the scene
  127061. */
  127062. onBeforeRenderObservable: Observable<Layer>;
  127063. private _onBeforeRenderObserver;
  127064. /**
  127065. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127066. * The set callback will be triggered just before rendering the layer.
  127067. */
  127068. set onBeforeRender(callback: () => void);
  127069. /**
  127070. * An event triggered after rendering the scene
  127071. */
  127072. onAfterRenderObservable: Observable<Layer>;
  127073. private _onAfterRenderObserver;
  127074. /**
  127075. * Back compatibility with callback before the onAfterRenderObservable existed.
  127076. * The set callback will be triggered just after rendering the layer.
  127077. */
  127078. set onAfterRender(callback: () => void);
  127079. /**
  127080. * Instantiates a new layer.
  127081. * This represents a full screen 2d layer.
  127082. * This can be useful to display a picture in the background of your scene for instance.
  127083. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127084. * @param name Define the name of the layer in the scene
  127085. * @param imgUrl Define the url of the texture to display in the layer
  127086. * @param scene Define the scene the layer belongs to
  127087. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127088. * @param color Defines a color for the layer
  127089. */
  127090. constructor(
  127091. /**
  127092. * Define the name of the layer.
  127093. */
  127094. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127095. private _createIndexBuffer;
  127096. /** @hidden */
  127097. _rebuild(): void;
  127098. /**
  127099. * Renders the layer in the scene.
  127100. */
  127101. render(): void;
  127102. /**
  127103. * Disposes and releases the associated ressources.
  127104. */
  127105. dispose(): void;
  127106. }
  127107. }
  127108. declare module BABYLON {
  127109. /** @hidden */
  127110. export var lensFlarePixelShader: {
  127111. name: string;
  127112. shader: string;
  127113. };
  127114. }
  127115. declare module BABYLON {
  127116. /** @hidden */
  127117. export var lensFlareVertexShader: {
  127118. name: string;
  127119. shader: string;
  127120. };
  127121. }
  127122. declare module BABYLON {
  127123. /**
  127124. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127125. * It is usually composed of several `lensFlare`.
  127126. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127127. */
  127128. export class LensFlareSystem {
  127129. /**
  127130. * Define the name of the lens flare system
  127131. */
  127132. name: string;
  127133. /**
  127134. * List of lens flares used in this system.
  127135. */
  127136. lensFlares: LensFlare[];
  127137. /**
  127138. * Define a limit from the border the lens flare can be visible.
  127139. */
  127140. borderLimit: number;
  127141. /**
  127142. * Define a viewport border we do not want to see the lens flare in.
  127143. */
  127144. viewportBorder: number;
  127145. /**
  127146. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127147. */
  127148. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127149. /**
  127150. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127151. */
  127152. layerMask: number;
  127153. /**
  127154. * Define the id of the lens flare system in the scene.
  127155. * (equal to name by default)
  127156. */
  127157. id: string;
  127158. private _scene;
  127159. private _emitter;
  127160. private _vertexBuffers;
  127161. private _indexBuffer;
  127162. private _effect;
  127163. private _positionX;
  127164. private _positionY;
  127165. private _isEnabled;
  127166. /** @hidden */
  127167. static _SceneComponentInitialization: (scene: Scene) => void;
  127168. /**
  127169. * Instantiates a lens flare system.
  127170. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127171. * It is usually composed of several `lensFlare`.
  127172. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127173. * @param name Define the name of the lens flare system in the scene
  127174. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127175. * @param scene Define the scene the lens flare system belongs to
  127176. */
  127177. constructor(
  127178. /**
  127179. * Define the name of the lens flare system
  127180. */
  127181. name: string, emitter: any, scene: Scene);
  127182. /**
  127183. * Define if the lens flare system is enabled.
  127184. */
  127185. get isEnabled(): boolean;
  127186. set isEnabled(value: boolean);
  127187. /**
  127188. * Get the scene the effects belongs to.
  127189. * @returns the scene holding the lens flare system
  127190. */
  127191. getScene(): Scene;
  127192. /**
  127193. * Get the emitter of the lens flare system.
  127194. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127195. * @returns the emitter of the lens flare system
  127196. */
  127197. getEmitter(): any;
  127198. /**
  127199. * Set the emitter of the lens flare system.
  127200. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127201. * @param newEmitter Define the new emitter of the system
  127202. */
  127203. setEmitter(newEmitter: any): void;
  127204. /**
  127205. * Get the lens flare system emitter position.
  127206. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127207. * @returns the position
  127208. */
  127209. getEmitterPosition(): Vector3;
  127210. /**
  127211. * @hidden
  127212. */
  127213. computeEffectivePosition(globalViewport: Viewport): boolean;
  127214. /** @hidden */
  127215. _isVisible(): boolean;
  127216. /**
  127217. * @hidden
  127218. */
  127219. render(): boolean;
  127220. /**
  127221. * Dispose and release the lens flare with its associated resources.
  127222. */
  127223. dispose(): void;
  127224. /**
  127225. * Parse a lens flare system from a JSON repressentation
  127226. * @param parsedLensFlareSystem Define the JSON to parse
  127227. * @param scene Define the scene the parsed system should be instantiated in
  127228. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127229. * @returns the parsed system
  127230. */
  127231. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127232. /**
  127233. * Serialize the current Lens Flare System into a JSON representation.
  127234. * @returns the serialized JSON
  127235. */
  127236. serialize(): any;
  127237. }
  127238. }
  127239. declare module BABYLON {
  127240. /**
  127241. * This represents one of the lens effect in a `lensFlareSystem`.
  127242. * It controls one of the indiviual texture used in the effect.
  127243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127244. */
  127245. export class LensFlare {
  127246. /**
  127247. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127248. */
  127249. size: number;
  127250. /**
  127251. * 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.
  127252. */
  127253. position: number;
  127254. /**
  127255. * Define the lens color.
  127256. */
  127257. color: Color3;
  127258. /**
  127259. * Define the lens texture.
  127260. */
  127261. texture: Nullable<Texture>;
  127262. /**
  127263. * Define the alpha mode to render this particular lens.
  127264. */
  127265. alphaMode: number;
  127266. private _system;
  127267. /**
  127268. * Creates a new Lens Flare.
  127269. * This represents one of the lens effect in a `lensFlareSystem`.
  127270. * It controls one of the indiviual texture used in the effect.
  127271. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127272. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127273. * @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.
  127274. * @param color Define the lens color
  127275. * @param imgUrl Define the lens texture url
  127276. * @param system Define the `lensFlareSystem` this flare is part of
  127277. * @returns The newly created Lens Flare
  127278. */
  127279. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127280. /**
  127281. * Instantiates a new Lens Flare.
  127282. * This represents one of the lens effect in a `lensFlareSystem`.
  127283. * It controls one of the indiviual texture used in the effect.
  127284. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127285. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127286. * @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.
  127287. * @param color Define the lens color
  127288. * @param imgUrl Define the lens texture url
  127289. * @param system Define the `lensFlareSystem` this flare is part of
  127290. */
  127291. constructor(
  127292. /**
  127293. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127294. */
  127295. size: number,
  127296. /**
  127297. * 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.
  127298. */
  127299. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127300. /**
  127301. * Dispose and release the lens flare with its associated resources.
  127302. */
  127303. dispose(): void;
  127304. }
  127305. }
  127306. declare module BABYLON {
  127307. interface AbstractScene {
  127308. /**
  127309. * The list of lens flare system added to the scene
  127310. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127311. */
  127312. lensFlareSystems: Array<LensFlareSystem>;
  127313. /**
  127314. * Removes the given lens flare system from this scene.
  127315. * @param toRemove The lens flare system to remove
  127316. * @returns The index of the removed lens flare system
  127317. */
  127318. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127319. /**
  127320. * Adds the given lens flare system to this scene
  127321. * @param newLensFlareSystem The lens flare system to add
  127322. */
  127323. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127324. /**
  127325. * Gets a lens flare system using its name
  127326. * @param name defines the name to look for
  127327. * @returns the lens flare system or null if not found
  127328. */
  127329. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127330. /**
  127331. * Gets a lens flare system using its id
  127332. * @param id defines the id to look for
  127333. * @returns the lens flare system or null if not found
  127334. */
  127335. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127336. }
  127337. /**
  127338. * Defines the lens flare scene component responsible to manage any lens flares
  127339. * in a given scene.
  127340. */
  127341. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127342. /**
  127343. * The component name helpfull to identify the component in the list of scene components.
  127344. */
  127345. readonly name: string;
  127346. /**
  127347. * The scene the component belongs to.
  127348. */
  127349. scene: Scene;
  127350. /**
  127351. * Creates a new instance of the component for the given scene
  127352. * @param scene Defines the scene to register the component in
  127353. */
  127354. constructor(scene: Scene);
  127355. /**
  127356. * Registers the component in a given scene
  127357. */
  127358. register(): void;
  127359. /**
  127360. * Rebuilds the elements related to this component in case of
  127361. * context lost for instance.
  127362. */
  127363. rebuild(): void;
  127364. /**
  127365. * Adds all the elements from the container to the scene
  127366. * @param container the container holding the elements
  127367. */
  127368. addFromContainer(container: AbstractScene): void;
  127369. /**
  127370. * Removes all the elements in the container from the scene
  127371. * @param container contains the elements to remove
  127372. * @param dispose if the removed element should be disposed (default: false)
  127373. */
  127374. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127375. /**
  127376. * Serializes the component data to the specified json object
  127377. * @param serializationObject The object to serialize to
  127378. */
  127379. serialize(serializationObject: any): void;
  127380. /**
  127381. * Disposes the component and the associated ressources.
  127382. */
  127383. dispose(): void;
  127384. private _draw;
  127385. }
  127386. }
  127387. declare module BABYLON {
  127388. /** @hidden */
  127389. export var depthPixelShader: {
  127390. name: string;
  127391. shader: string;
  127392. };
  127393. }
  127394. declare module BABYLON {
  127395. /** @hidden */
  127396. export var depthVertexShader: {
  127397. name: string;
  127398. shader: string;
  127399. };
  127400. }
  127401. declare module BABYLON {
  127402. /**
  127403. * This represents a depth renderer in Babylon.
  127404. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127405. */
  127406. export class DepthRenderer {
  127407. private _scene;
  127408. private _depthMap;
  127409. private _effect;
  127410. private readonly _storeNonLinearDepth;
  127411. private readonly _clearColor;
  127412. /** Get if the depth renderer is using packed depth or not */
  127413. readonly isPacked: boolean;
  127414. private _cachedDefines;
  127415. private _camera;
  127416. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127417. enabled: boolean;
  127418. /**
  127419. * Specifiess that the depth renderer will only be used within
  127420. * the camera it is created for.
  127421. * This can help forcing its rendering during the camera processing.
  127422. */
  127423. useOnlyInActiveCamera: boolean;
  127424. /** @hidden */
  127425. static _SceneComponentInitialization: (scene: Scene) => void;
  127426. /**
  127427. * Instantiates a depth renderer
  127428. * @param scene The scene the renderer belongs to
  127429. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127430. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127431. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127432. */
  127433. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127434. /**
  127435. * Creates the depth rendering effect and checks if the effect is ready.
  127436. * @param subMesh The submesh to be used to render the depth map of
  127437. * @param useInstances If multiple world instances should be used
  127438. * @returns if the depth renderer is ready to render the depth map
  127439. */
  127440. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127441. /**
  127442. * Gets the texture which the depth map will be written to.
  127443. * @returns The depth map texture
  127444. */
  127445. getDepthMap(): RenderTargetTexture;
  127446. /**
  127447. * Disposes of the depth renderer.
  127448. */
  127449. dispose(): void;
  127450. }
  127451. }
  127452. declare module BABYLON {
  127453. /** @hidden */
  127454. export var minmaxReduxPixelShader: {
  127455. name: string;
  127456. shader: string;
  127457. };
  127458. }
  127459. declare module BABYLON {
  127460. /**
  127461. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127462. * and maximum values from all values of the texture.
  127463. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127464. * The source values are read from the red channel of the texture.
  127465. */
  127466. export class MinMaxReducer {
  127467. /**
  127468. * Observable triggered when the computation has been performed
  127469. */
  127470. onAfterReductionPerformed: Observable<{
  127471. min: number;
  127472. max: number;
  127473. }>;
  127474. protected _camera: Camera;
  127475. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127476. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127477. protected _postProcessManager: PostProcessManager;
  127478. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127479. protected _forceFullscreenViewport: boolean;
  127480. /**
  127481. * Creates a min/max reducer
  127482. * @param camera The camera to use for the post processes
  127483. */
  127484. constructor(camera: Camera);
  127485. /**
  127486. * Gets the texture used to read the values from.
  127487. */
  127488. get sourceTexture(): Nullable<RenderTargetTexture>;
  127489. /**
  127490. * Sets the source texture to read the values from.
  127491. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127492. * because in such textures '1' value must not be taken into account to compute the maximum
  127493. * as this value is used to clear the texture.
  127494. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127495. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127496. * @param depthRedux Indicates if the texture is a depth texture or not
  127497. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127498. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127499. */
  127500. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127501. /**
  127502. * Defines the refresh rate of the computation.
  127503. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127504. */
  127505. get refreshRate(): number;
  127506. set refreshRate(value: number);
  127507. protected _activated: boolean;
  127508. /**
  127509. * Gets the activation status of the reducer
  127510. */
  127511. get activated(): boolean;
  127512. /**
  127513. * Activates the reduction computation.
  127514. * When activated, the observers registered in onAfterReductionPerformed are
  127515. * called after the compuation is performed
  127516. */
  127517. activate(): void;
  127518. /**
  127519. * Deactivates the reduction computation.
  127520. */
  127521. deactivate(): void;
  127522. /**
  127523. * Disposes the min/max reducer
  127524. * @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.
  127525. */
  127526. dispose(disposeAll?: boolean): void;
  127527. }
  127528. }
  127529. declare module BABYLON {
  127530. /**
  127531. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127532. */
  127533. export class DepthReducer extends MinMaxReducer {
  127534. private _depthRenderer;
  127535. private _depthRendererId;
  127536. /**
  127537. * Gets the depth renderer used for the computation.
  127538. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127539. */
  127540. get depthRenderer(): Nullable<DepthRenderer>;
  127541. /**
  127542. * Creates a depth reducer
  127543. * @param camera The camera used to render the depth texture
  127544. */
  127545. constructor(camera: Camera);
  127546. /**
  127547. * Sets the depth renderer to use to generate the depth map
  127548. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127549. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127550. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127551. */
  127552. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127553. /** @hidden */
  127554. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127555. /**
  127556. * Activates the reduction computation.
  127557. * When activated, the observers registered in onAfterReductionPerformed are
  127558. * called after the compuation is performed
  127559. */
  127560. activate(): void;
  127561. /**
  127562. * Deactivates the reduction computation.
  127563. */
  127564. deactivate(): void;
  127565. /**
  127566. * Disposes the depth reducer
  127567. * @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.
  127568. */
  127569. dispose(disposeAll?: boolean): void;
  127570. }
  127571. }
  127572. declare module BABYLON {
  127573. /**
  127574. * A CSM implementation allowing casting shadows on large scenes.
  127575. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127576. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127577. */
  127578. export class CascadedShadowGenerator extends ShadowGenerator {
  127579. private static readonly frustumCornersNDCSpace;
  127580. /**
  127581. * Name of the CSM class
  127582. */
  127583. static CLASSNAME: string;
  127584. /**
  127585. * Defines the default number of cascades used by the CSM.
  127586. */
  127587. static readonly DEFAULT_CASCADES_COUNT: number;
  127588. /**
  127589. * Defines the minimum number of cascades used by the CSM.
  127590. */
  127591. static readonly MIN_CASCADES_COUNT: number;
  127592. /**
  127593. * Defines the maximum number of cascades used by the CSM.
  127594. */
  127595. static readonly MAX_CASCADES_COUNT: number;
  127596. protected _validateFilter(filter: number): number;
  127597. /**
  127598. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127599. */
  127600. penumbraDarkness: number;
  127601. private _numCascades;
  127602. /**
  127603. * Gets or set the number of cascades used by the CSM.
  127604. */
  127605. get numCascades(): number;
  127606. set numCascades(value: number);
  127607. /**
  127608. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127609. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127610. */
  127611. stabilizeCascades: boolean;
  127612. private _freezeShadowCastersBoundingInfo;
  127613. private _freezeShadowCastersBoundingInfoObservable;
  127614. /**
  127615. * Enables or disables the shadow casters bounding info computation.
  127616. * If your shadow casters don't move, you can disable this feature.
  127617. * If it is enabled, the bounding box computation is done every frame.
  127618. */
  127619. get freezeShadowCastersBoundingInfo(): boolean;
  127620. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127621. private _scbiMin;
  127622. private _scbiMax;
  127623. protected _computeShadowCastersBoundingInfo(): void;
  127624. protected _shadowCastersBoundingInfo: BoundingInfo;
  127625. /**
  127626. * Gets or sets the shadow casters bounding info.
  127627. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127628. * so that the system won't overwrite the bounds you provide
  127629. */
  127630. get shadowCastersBoundingInfo(): BoundingInfo;
  127631. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127632. protected _breaksAreDirty: boolean;
  127633. protected _minDistance: number;
  127634. protected _maxDistance: number;
  127635. /**
  127636. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127637. *
  127638. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127639. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127640. * @param min minimal distance for the breaks (default to 0.)
  127641. * @param max maximal distance for the breaks (default to 1.)
  127642. */
  127643. setMinMaxDistance(min: number, max: number): void;
  127644. /** Gets the minimal distance used in the cascade break computation */
  127645. get minDistance(): number;
  127646. /** Gets the maximal distance used in the cascade break computation */
  127647. get maxDistance(): number;
  127648. /**
  127649. * Gets the class name of that object
  127650. * @returns "CascadedShadowGenerator"
  127651. */
  127652. getClassName(): string;
  127653. private _cascadeMinExtents;
  127654. private _cascadeMaxExtents;
  127655. /**
  127656. * Gets a cascade minimum extents
  127657. * @param cascadeIndex index of the cascade
  127658. * @returns the minimum cascade extents
  127659. */
  127660. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127661. /**
  127662. * Gets a cascade maximum extents
  127663. * @param cascadeIndex index of the cascade
  127664. * @returns the maximum cascade extents
  127665. */
  127666. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127667. private _cascades;
  127668. private _currentLayer;
  127669. private _viewSpaceFrustumsZ;
  127670. private _viewMatrices;
  127671. private _projectionMatrices;
  127672. private _transformMatrices;
  127673. private _transformMatricesAsArray;
  127674. private _frustumLengths;
  127675. private _lightSizeUVCorrection;
  127676. private _depthCorrection;
  127677. private _frustumCornersWorldSpace;
  127678. private _frustumCenter;
  127679. private _shadowCameraPos;
  127680. private _shadowMaxZ;
  127681. /**
  127682. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127683. * It defaults to camera.maxZ
  127684. */
  127685. get shadowMaxZ(): number;
  127686. /**
  127687. * Sets the shadow max z distance.
  127688. */
  127689. set shadowMaxZ(value: number);
  127690. protected _debug: boolean;
  127691. /**
  127692. * Gets or sets the debug flag.
  127693. * When enabled, the cascades are materialized by different colors on the screen.
  127694. */
  127695. get debug(): boolean;
  127696. set debug(dbg: boolean);
  127697. private _depthClamp;
  127698. /**
  127699. * Gets or sets the depth clamping value.
  127700. *
  127701. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127702. * to account for the shadow casters far away.
  127703. *
  127704. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127705. */
  127706. get depthClamp(): boolean;
  127707. set depthClamp(value: boolean);
  127708. private _cascadeBlendPercentage;
  127709. /**
  127710. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127711. * It defaults to 0.1 (10% blending).
  127712. */
  127713. get cascadeBlendPercentage(): number;
  127714. set cascadeBlendPercentage(value: number);
  127715. private _lambda;
  127716. /**
  127717. * Gets or set the lambda parameter.
  127718. * This parameter is used to split the camera frustum and create the cascades.
  127719. * 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.
  127720. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127721. */
  127722. get lambda(): number;
  127723. set lambda(value: number);
  127724. /**
  127725. * Gets the view matrix corresponding to a given cascade
  127726. * @param cascadeNum cascade to retrieve the view matrix from
  127727. * @returns the cascade view matrix
  127728. */
  127729. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127730. /**
  127731. * Gets the projection matrix corresponding to a given cascade
  127732. * @param cascadeNum cascade to retrieve the projection matrix from
  127733. * @returns the cascade projection matrix
  127734. */
  127735. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127736. /**
  127737. * Gets the transformation matrix corresponding to a given cascade
  127738. * @param cascadeNum cascade to retrieve the transformation matrix from
  127739. * @returns the cascade transformation matrix
  127740. */
  127741. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127742. private _depthRenderer;
  127743. /**
  127744. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127745. *
  127746. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127747. *
  127748. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127749. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127750. * @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
  127751. */
  127752. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127753. private _depthReducer;
  127754. private _autoCalcDepthBounds;
  127755. /**
  127756. * Gets or sets the autoCalcDepthBounds property.
  127757. *
  127758. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127759. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127760. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127761. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127762. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127763. */
  127764. get autoCalcDepthBounds(): boolean;
  127765. set autoCalcDepthBounds(value: boolean);
  127766. /**
  127767. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127768. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127769. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127770. * for setting the refresh rate on the renderer yourself!
  127771. */
  127772. get autoCalcDepthBoundsRefreshRate(): number;
  127773. set autoCalcDepthBoundsRefreshRate(value: number);
  127774. /**
  127775. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127776. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127777. * you change the camera near/far planes!
  127778. */
  127779. splitFrustum(): void;
  127780. private _splitFrustum;
  127781. private _computeMatrices;
  127782. private _computeFrustumInWorldSpace;
  127783. private _computeCascadeFrustum;
  127784. /** @hidden */
  127785. static _SceneComponentInitialization: (scene: Scene) => void;
  127786. /**
  127787. * Creates a Cascaded Shadow Generator object.
  127788. * A ShadowGenerator is the required tool to use the shadows.
  127789. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127790. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127791. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127792. * @param light The directional light object generating the shadows.
  127793. * @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.
  127794. */
  127795. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127796. protected _initializeGenerator(): void;
  127797. protected _createTargetRenderTexture(): void;
  127798. protected _initializeShadowMap(): void;
  127799. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127800. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127801. /**
  127802. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127803. * @param defines Defines of the material we want to update
  127804. * @param lightIndex Index of the light in the enabled light list of the material
  127805. */
  127806. prepareDefines(defines: any, lightIndex: number): void;
  127807. /**
  127808. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127809. * defined in the generator but impacting the effect).
  127810. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127811. * @param effect The effect we are binfing the information for
  127812. */
  127813. bindShadowLight(lightIndex: string, effect: Effect): void;
  127814. /**
  127815. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127816. * (eq to view projection * shadow projection matrices)
  127817. * @returns The transform matrix used to create the shadow map
  127818. */
  127819. getTransformMatrix(): Matrix;
  127820. /**
  127821. * Disposes the ShadowGenerator.
  127822. * Returns nothing.
  127823. */
  127824. dispose(): void;
  127825. /**
  127826. * Serializes the shadow generator setup to a json object.
  127827. * @returns The serialized JSON object
  127828. */
  127829. serialize(): any;
  127830. /**
  127831. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127832. * @param parsedShadowGenerator The JSON object to parse
  127833. * @param scene The scene to create the shadow map for
  127834. * @returns The parsed shadow generator
  127835. */
  127836. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127837. }
  127838. }
  127839. declare module BABYLON {
  127840. /**
  127841. * Defines the shadow generator component responsible to manage any shadow generators
  127842. * in a given scene.
  127843. */
  127844. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127845. /**
  127846. * The component name helpfull to identify the component in the list of scene components.
  127847. */
  127848. readonly name: string;
  127849. /**
  127850. * The scene the component belongs to.
  127851. */
  127852. scene: Scene;
  127853. /**
  127854. * Creates a new instance of the component for the given scene
  127855. * @param scene Defines the scene to register the component in
  127856. */
  127857. constructor(scene: Scene);
  127858. /**
  127859. * Registers the component in a given scene
  127860. */
  127861. register(): void;
  127862. /**
  127863. * Rebuilds the elements related to this component in case of
  127864. * context lost for instance.
  127865. */
  127866. rebuild(): void;
  127867. /**
  127868. * Serializes the component data to the specified json object
  127869. * @param serializationObject The object to serialize to
  127870. */
  127871. serialize(serializationObject: any): void;
  127872. /**
  127873. * Adds all the elements from the container to the scene
  127874. * @param container the container holding the elements
  127875. */
  127876. addFromContainer(container: AbstractScene): void;
  127877. /**
  127878. * Removes all the elements in the container from the scene
  127879. * @param container contains the elements to remove
  127880. * @param dispose if the removed element should be disposed (default: false)
  127881. */
  127882. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127883. /**
  127884. * Rebuilds the elements related to this component in case of
  127885. * context lost for instance.
  127886. */
  127887. dispose(): void;
  127888. private _gatherRenderTargets;
  127889. }
  127890. }
  127891. declare module BABYLON {
  127892. /**
  127893. * A point light is a light defined by an unique point in world space.
  127894. * The light is emitted in every direction from this point.
  127895. * A good example of a point light is a standard light bulb.
  127896. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127897. */
  127898. export class PointLight extends ShadowLight {
  127899. private _shadowAngle;
  127900. /**
  127901. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127902. * This specifies what angle the shadow will use to be created.
  127903. *
  127904. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127905. */
  127906. get shadowAngle(): number;
  127907. /**
  127908. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127909. * This specifies what angle the shadow will use to be created.
  127910. *
  127911. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127912. */
  127913. set shadowAngle(value: number);
  127914. /**
  127915. * Gets the direction if it has been set.
  127916. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127917. */
  127918. get direction(): Vector3;
  127919. /**
  127920. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127921. */
  127922. set direction(value: Vector3);
  127923. /**
  127924. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127925. * A PointLight emits the light in every direction.
  127926. * It can cast shadows.
  127927. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127928. * ```javascript
  127929. * var pointLight = new PointLight("pl", camera.position, scene);
  127930. * ```
  127931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127932. * @param name The light friendly name
  127933. * @param position The position of the point light in the scene
  127934. * @param scene The scene the lights belongs to
  127935. */
  127936. constructor(name: string, position: Vector3, scene: Scene);
  127937. /**
  127938. * Returns the string "PointLight"
  127939. * @returns the class name
  127940. */
  127941. getClassName(): string;
  127942. /**
  127943. * Returns the integer 0.
  127944. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127945. */
  127946. getTypeID(): number;
  127947. /**
  127948. * Specifies wether or not the shadowmap should be a cube texture.
  127949. * @returns true if the shadowmap needs to be a cube texture.
  127950. */
  127951. needCube(): boolean;
  127952. /**
  127953. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127954. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127955. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127956. */
  127957. getShadowDirection(faceIndex?: number): Vector3;
  127958. /**
  127959. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127960. * - fov = PI / 2
  127961. * - aspect ratio : 1.0
  127962. * - z-near and far equal to the active camera minZ and maxZ.
  127963. * Returns the PointLight.
  127964. */
  127965. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127966. protected _buildUniformLayout(): void;
  127967. /**
  127968. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127969. * @param effect The effect to update
  127970. * @param lightIndex The index of the light in the effect to update
  127971. * @returns The point light
  127972. */
  127973. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127974. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127975. /**
  127976. * Prepares the list of defines specific to the light type.
  127977. * @param defines the list of defines
  127978. * @param lightIndex defines the index of the light for the effect
  127979. */
  127980. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127981. }
  127982. }
  127983. declare module BABYLON {
  127984. /**
  127985. * Header information of HDR texture files.
  127986. */
  127987. export interface HDRInfo {
  127988. /**
  127989. * The height of the texture in pixels.
  127990. */
  127991. height: number;
  127992. /**
  127993. * The width of the texture in pixels.
  127994. */
  127995. width: number;
  127996. /**
  127997. * The index of the beginning of the data in the binary file.
  127998. */
  127999. dataPosition: number;
  128000. }
  128001. /**
  128002. * This groups tools to convert HDR texture to native colors array.
  128003. */
  128004. export class HDRTools {
  128005. private static Ldexp;
  128006. private static Rgbe2float;
  128007. private static readStringLine;
  128008. /**
  128009. * Reads header information from an RGBE texture stored in a native array.
  128010. * More information on this format are available here:
  128011. * https://en.wikipedia.org/wiki/RGBE_image_format
  128012. *
  128013. * @param uint8array The binary file stored in native array.
  128014. * @return The header information.
  128015. */
  128016. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  128017. /**
  128018. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  128019. * This RGBE texture needs to store the information as a panorama.
  128020. *
  128021. * More information on this format are available here:
  128022. * https://en.wikipedia.org/wiki/RGBE_image_format
  128023. *
  128024. * @param buffer The binary file stored in an array buffer.
  128025. * @param size The expected size of the extracted cubemap.
  128026. * @return The Cube Map information.
  128027. */
  128028. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  128029. /**
  128030. * Returns the pixels data extracted from an RGBE texture.
  128031. * This pixels will be stored left to right up to down in the R G B order in one array.
  128032. *
  128033. * More information on this format are available here:
  128034. * https://en.wikipedia.org/wiki/RGBE_image_format
  128035. *
  128036. * @param uint8array The binary file stored in an array buffer.
  128037. * @param hdrInfo The header information of the file.
  128038. * @return The pixels data in RGB right to left up to down order.
  128039. */
  128040. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  128041. private static RGBE_ReadPixels_RLE;
  128042. }
  128043. }
  128044. declare module BABYLON {
  128045. /**
  128046. * This represents a texture coming from an HDR input.
  128047. *
  128048. * The only supported format is currently panorama picture stored in RGBE format.
  128049. * Example of such files can be found on HDRLib: http://hdrlib.com/
  128050. */
  128051. export class HDRCubeTexture extends BaseTexture {
  128052. private static _facesMapping;
  128053. private _generateHarmonics;
  128054. private _noMipmap;
  128055. private _textureMatrix;
  128056. private _size;
  128057. private _onLoad;
  128058. private _onError;
  128059. /**
  128060. * The texture URL.
  128061. */
  128062. url: string;
  128063. /**
  128064. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128065. */
  128066. coordinatesMode: number;
  128067. protected _isBlocking: boolean;
  128068. /**
  128069. * Sets wether or not the texture is blocking during loading.
  128070. */
  128071. set isBlocking(value: boolean);
  128072. /**
  128073. * Gets wether or not the texture is blocking during loading.
  128074. */
  128075. get isBlocking(): boolean;
  128076. protected _rotationY: number;
  128077. /**
  128078. * Sets texture matrix rotation angle around Y axis in radians.
  128079. */
  128080. set rotationY(value: number);
  128081. /**
  128082. * Gets texture matrix rotation angle around Y axis radians.
  128083. */
  128084. get rotationY(): number;
  128085. /**
  128086. * Gets or sets the center of the bounding box associated with the cube texture
  128087. * It must define where the camera used to render the texture was set
  128088. */
  128089. boundingBoxPosition: Vector3;
  128090. private _boundingBoxSize;
  128091. /**
  128092. * Gets or sets the size of the bounding box associated with the cube texture
  128093. * When defined, the cubemap will switch to local mode
  128094. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128095. * @example https://www.babylonjs-playground.com/#RNASML
  128096. */
  128097. set boundingBoxSize(value: Vector3);
  128098. get boundingBoxSize(): Vector3;
  128099. /**
  128100. * Instantiates an HDRTexture from the following parameters.
  128101. *
  128102. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128103. * @param scene The scene the texture will be used in
  128104. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128105. * @param noMipmap Forces to not generate the mipmap if true
  128106. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128107. * @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)
  128108. * @param reserved Reserved flag for internal use.
  128109. */
  128110. 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>);
  128111. /**
  128112. * Get the current class name of the texture useful for serialization or dynamic coding.
  128113. * @returns "HDRCubeTexture"
  128114. */
  128115. getClassName(): string;
  128116. /**
  128117. * Occurs when the file is raw .hdr file.
  128118. */
  128119. private loadTexture;
  128120. clone(): HDRCubeTexture;
  128121. delayLoad(): void;
  128122. /**
  128123. * Get the texture reflection matrix used to rotate/transform the reflection.
  128124. * @returns the reflection matrix
  128125. */
  128126. getReflectionTextureMatrix(): Matrix;
  128127. /**
  128128. * Set the texture reflection matrix used to rotate/transform the reflection.
  128129. * @param value Define the reflection matrix to set
  128130. */
  128131. setReflectionTextureMatrix(value: Matrix): void;
  128132. /**
  128133. * Parses a JSON representation of an HDR Texture in order to create the texture
  128134. * @param parsedTexture Define the JSON representation
  128135. * @param scene Define the scene the texture should be created in
  128136. * @param rootUrl Define the root url in case we need to load relative dependencies
  128137. * @returns the newly created texture after parsing
  128138. */
  128139. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128140. serialize(): any;
  128141. }
  128142. }
  128143. declare module BABYLON {
  128144. /**
  128145. * Class used to control physics engine
  128146. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128147. */
  128148. export class PhysicsEngine implements IPhysicsEngine {
  128149. private _physicsPlugin;
  128150. /**
  128151. * Global value used to control the smallest number supported by the simulation
  128152. */
  128153. static Epsilon: number;
  128154. private _impostors;
  128155. private _joints;
  128156. private _subTimeStep;
  128157. /**
  128158. * Gets the gravity vector used by the simulation
  128159. */
  128160. gravity: Vector3;
  128161. /**
  128162. * Factory used to create the default physics plugin.
  128163. * @returns The default physics plugin
  128164. */
  128165. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128166. /**
  128167. * Creates a new Physics Engine
  128168. * @param gravity defines the gravity vector used by the simulation
  128169. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128170. */
  128171. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128172. /**
  128173. * Sets the gravity vector used by the simulation
  128174. * @param gravity defines the gravity vector to use
  128175. */
  128176. setGravity(gravity: Vector3): void;
  128177. /**
  128178. * Set the time step of the physics engine.
  128179. * Default is 1/60.
  128180. * To slow it down, enter 1/600 for example.
  128181. * To speed it up, 1/30
  128182. * @param newTimeStep defines the new timestep to apply to this world.
  128183. */
  128184. setTimeStep(newTimeStep?: number): void;
  128185. /**
  128186. * Get the time step of the physics engine.
  128187. * @returns the current time step
  128188. */
  128189. getTimeStep(): number;
  128190. /**
  128191. * Set the sub time step of the physics engine.
  128192. * Default is 0 meaning there is no sub steps
  128193. * To increase physics resolution precision, set a small value (like 1 ms)
  128194. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128195. */
  128196. setSubTimeStep(subTimeStep?: number): void;
  128197. /**
  128198. * Get the sub time step of the physics engine.
  128199. * @returns the current sub time step
  128200. */
  128201. getSubTimeStep(): number;
  128202. /**
  128203. * Release all resources
  128204. */
  128205. dispose(): void;
  128206. /**
  128207. * Gets the name of the current physics plugin
  128208. * @returns the name of the plugin
  128209. */
  128210. getPhysicsPluginName(): string;
  128211. /**
  128212. * Adding a new impostor for the impostor tracking.
  128213. * This will be done by the impostor itself.
  128214. * @param impostor the impostor to add
  128215. */
  128216. addImpostor(impostor: PhysicsImpostor): void;
  128217. /**
  128218. * Remove an impostor from the engine.
  128219. * This impostor and its mesh will not longer be updated by the physics engine.
  128220. * @param impostor the impostor to remove
  128221. */
  128222. removeImpostor(impostor: PhysicsImpostor): void;
  128223. /**
  128224. * Add a joint to the physics engine
  128225. * @param mainImpostor defines the main impostor to which the joint is added.
  128226. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128227. * @param joint defines the joint that will connect both impostors.
  128228. */
  128229. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128230. /**
  128231. * Removes a joint from the simulation
  128232. * @param mainImpostor defines the impostor used with the joint
  128233. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128234. * @param joint defines the joint to remove
  128235. */
  128236. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128237. /**
  128238. * Called by the scene. No need to call it.
  128239. * @param delta defines the timespam between frames
  128240. */
  128241. _step(delta: number): void;
  128242. /**
  128243. * Gets the current plugin used to run the simulation
  128244. * @returns current plugin
  128245. */
  128246. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128247. /**
  128248. * Gets the list of physic impostors
  128249. * @returns an array of PhysicsImpostor
  128250. */
  128251. getImpostors(): Array<PhysicsImpostor>;
  128252. /**
  128253. * Gets the impostor for a physics enabled object
  128254. * @param object defines the object impersonated by the impostor
  128255. * @returns the PhysicsImpostor or null if not found
  128256. */
  128257. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128258. /**
  128259. * Gets the impostor for a physics body object
  128260. * @param body defines physics body used by the impostor
  128261. * @returns the PhysicsImpostor or null if not found
  128262. */
  128263. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128264. /**
  128265. * Does a raycast in the physics world
  128266. * @param from when should the ray start?
  128267. * @param to when should the ray end?
  128268. * @returns PhysicsRaycastResult
  128269. */
  128270. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128271. }
  128272. }
  128273. declare module BABYLON {
  128274. /** @hidden */
  128275. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128276. private _useDeltaForWorldStep;
  128277. world: any;
  128278. name: string;
  128279. private _physicsMaterials;
  128280. private _fixedTimeStep;
  128281. private _cannonRaycastResult;
  128282. private _raycastResult;
  128283. private _physicsBodysToRemoveAfterStep;
  128284. BJSCANNON: any;
  128285. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128286. setGravity(gravity: Vector3): void;
  128287. setTimeStep(timeStep: number): void;
  128288. getTimeStep(): number;
  128289. executeStep(delta: number): void;
  128290. private _removeMarkedPhysicsBodiesFromWorld;
  128291. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128292. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128293. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128294. private _processChildMeshes;
  128295. removePhysicsBody(impostor: PhysicsImpostor): void;
  128296. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128297. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128298. private _addMaterial;
  128299. private _checkWithEpsilon;
  128300. private _createShape;
  128301. private _createHeightmap;
  128302. private _minus90X;
  128303. private _plus90X;
  128304. private _tmpPosition;
  128305. private _tmpDeltaPosition;
  128306. private _tmpUnityRotation;
  128307. private _updatePhysicsBodyTransformation;
  128308. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128309. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128310. isSupported(): boolean;
  128311. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128312. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128313. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128314. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128315. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128316. getBodyMass(impostor: PhysicsImpostor): number;
  128317. getBodyFriction(impostor: PhysicsImpostor): number;
  128318. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128319. getBodyRestitution(impostor: PhysicsImpostor): number;
  128320. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128321. sleepBody(impostor: PhysicsImpostor): void;
  128322. wakeUpBody(impostor: PhysicsImpostor): void;
  128323. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128324. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128325. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128326. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128327. getRadius(impostor: PhysicsImpostor): number;
  128328. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128329. dispose(): void;
  128330. private _extendNamespace;
  128331. /**
  128332. * Does a raycast in the physics world
  128333. * @param from when should the ray start?
  128334. * @param to when should the ray end?
  128335. * @returns PhysicsRaycastResult
  128336. */
  128337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128338. }
  128339. }
  128340. declare module BABYLON {
  128341. /** @hidden */
  128342. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128343. world: any;
  128344. name: string;
  128345. BJSOIMO: any;
  128346. private _raycastResult;
  128347. constructor(iterations?: number, oimoInjection?: any);
  128348. setGravity(gravity: Vector3): void;
  128349. setTimeStep(timeStep: number): void;
  128350. getTimeStep(): number;
  128351. private _tmpImpostorsArray;
  128352. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128353. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128354. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128355. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128356. private _tmpPositionVector;
  128357. removePhysicsBody(impostor: PhysicsImpostor): void;
  128358. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128359. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128360. isSupported(): boolean;
  128361. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128362. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128363. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128364. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128365. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128366. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128367. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128368. getBodyMass(impostor: PhysicsImpostor): number;
  128369. getBodyFriction(impostor: PhysicsImpostor): number;
  128370. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128371. getBodyRestitution(impostor: PhysicsImpostor): number;
  128372. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128373. sleepBody(impostor: PhysicsImpostor): void;
  128374. wakeUpBody(impostor: PhysicsImpostor): void;
  128375. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128376. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128377. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128378. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128379. getRadius(impostor: PhysicsImpostor): number;
  128380. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128381. dispose(): void;
  128382. /**
  128383. * Does a raycast in the physics world
  128384. * @param from when should the ray start?
  128385. * @param to when should the ray end?
  128386. * @returns PhysicsRaycastResult
  128387. */
  128388. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128389. }
  128390. }
  128391. declare module BABYLON {
  128392. /**
  128393. * Class containing static functions to help procedurally build meshes
  128394. */
  128395. export class RibbonBuilder {
  128396. /**
  128397. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128398. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128399. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128400. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128401. * * 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
  128402. * * 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
  128403. * * 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
  128404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128406. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128407. * * 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
  128408. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128409. * * 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
  128410. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128412. * @param name defines the name of the mesh
  128413. * @param options defines the options used to create the mesh
  128414. * @param scene defines the hosting scene
  128415. * @returns the ribbon mesh
  128416. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128418. */
  128419. static CreateRibbon(name: string, options: {
  128420. pathArray: Vector3[][];
  128421. closeArray?: boolean;
  128422. closePath?: boolean;
  128423. offset?: number;
  128424. updatable?: boolean;
  128425. sideOrientation?: number;
  128426. frontUVs?: Vector4;
  128427. backUVs?: Vector4;
  128428. instance?: Mesh;
  128429. invertUV?: boolean;
  128430. uvs?: Vector2[];
  128431. colors?: Color4[];
  128432. }, scene?: Nullable<Scene>): Mesh;
  128433. }
  128434. }
  128435. declare module BABYLON {
  128436. /**
  128437. * Class containing static functions to help procedurally build meshes
  128438. */
  128439. export class ShapeBuilder {
  128440. /**
  128441. * 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.
  128442. * * 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.
  128443. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128444. * * 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.
  128445. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128446. * * 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
  128447. * * 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
  128448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128453. * @param name defines the name of the mesh
  128454. * @param options defines the options used to create the mesh
  128455. * @param scene defines the hosting scene
  128456. * @returns the extruded shape mesh
  128457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128459. */
  128460. static ExtrudeShape(name: string, options: {
  128461. shape: Vector3[];
  128462. path: Vector3[];
  128463. scale?: number;
  128464. rotation?: number;
  128465. cap?: number;
  128466. updatable?: boolean;
  128467. sideOrientation?: number;
  128468. frontUVs?: Vector4;
  128469. backUVs?: Vector4;
  128470. instance?: Mesh;
  128471. invertUV?: boolean;
  128472. }, scene?: Nullable<Scene>): Mesh;
  128473. /**
  128474. * Creates an custom extruded shape mesh.
  128475. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128476. * * 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.
  128477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128478. * * 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
  128479. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128480. * * 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
  128481. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128482. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128483. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128484. * * 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
  128485. * * 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
  128486. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128491. * @param name defines the name of the mesh
  128492. * @param options defines the options used to create the mesh
  128493. * @param scene defines the hosting scene
  128494. * @returns the custom extruded shape mesh
  128495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128498. */
  128499. static ExtrudeShapeCustom(name: string, options: {
  128500. shape: Vector3[];
  128501. path: Vector3[];
  128502. scaleFunction?: any;
  128503. rotationFunction?: any;
  128504. ribbonCloseArray?: boolean;
  128505. ribbonClosePath?: boolean;
  128506. cap?: number;
  128507. updatable?: boolean;
  128508. sideOrientation?: number;
  128509. frontUVs?: Vector4;
  128510. backUVs?: Vector4;
  128511. instance?: Mesh;
  128512. invertUV?: boolean;
  128513. }, scene?: Nullable<Scene>): Mesh;
  128514. private static _ExtrudeShapeGeneric;
  128515. }
  128516. }
  128517. declare module BABYLON {
  128518. /**
  128519. * AmmoJS Physics plugin
  128520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128521. * @see https://github.com/kripken/ammo.js/
  128522. */
  128523. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128524. private _useDeltaForWorldStep;
  128525. /**
  128526. * Reference to the Ammo library
  128527. */
  128528. bjsAMMO: any;
  128529. /**
  128530. * Created ammoJS world which physics bodies are added to
  128531. */
  128532. world: any;
  128533. /**
  128534. * Name of the plugin
  128535. */
  128536. name: string;
  128537. private _timeStep;
  128538. private _fixedTimeStep;
  128539. private _maxSteps;
  128540. private _tmpQuaternion;
  128541. private _tmpAmmoTransform;
  128542. private _tmpAmmoQuaternion;
  128543. private _tmpAmmoConcreteContactResultCallback;
  128544. private _collisionConfiguration;
  128545. private _dispatcher;
  128546. private _overlappingPairCache;
  128547. private _solver;
  128548. private _softBodySolver;
  128549. private _tmpAmmoVectorA;
  128550. private _tmpAmmoVectorB;
  128551. private _tmpAmmoVectorC;
  128552. private _tmpAmmoVectorD;
  128553. private _tmpContactCallbackResult;
  128554. private _tmpAmmoVectorRCA;
  128555. private _tmpAmmoVectorRCB;
  128556. private _raycastResult;
  128557. private static readonly DISABLE_COLLISION_FLAG;
  128558. private static readonly KINEMATIC_FLAG;
  128559. private static readonly DISABLE_DEACTIVATION_FLAG;
  128560. /**
  128561. * Initializes the ammoJS plugin
  128562. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128563. * @param ammoInjection can be used to inject your own ammo reference
  128564. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128565. */
  128566. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128567. /**
  128568. * Sets the gravity of the physics world (m/(s^2))
  128569. * @param gravity Gravity to set
  128570. */
  128571. setGravity(gravity: Vector3): void;
  128572. /**
  128573. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128574. * @param timeStep timestep to use in seconds
  128575. */
  128576. setTimeStep(timeStep: number): void;
  128577. /**
  128578. * 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)
  128579. * @param fixedTimeStep fixedTimeStep to use in seconds
  128580. */
  128581. setFixedTimeStep(fixedTimeStep: number): void;
  128582. /**
  128583. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128584. * @param maxSteps the maximum number of steps by the physics engine per frame
  128585. */
  128586. setMaxSteps(maxSteps: number): void;
  128587. /**
  128588. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128589. * @returns the current timestep in seconds
  128590. */
  128591. getTimeStep(): number;
  128592. /**
  128593. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128594. */
  128595. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128596. private _isImpostorInContact;
  128597. private _isImpostorPairInContact;
  128598. private _stepSimulation;
  128599. /**
  128600. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128601. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128602. * After the step the babylon meshes are set to the position of the physics imposters
  128603. * @param delta amount of time to step forward
  128604. * @param impostors array of imposters to update before/after the step
  128605. */
  128606. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128607. /**
  128608. * Update babylon mesh to match physics world object
  128609. * @param impostor imposter to match
  128610. */
  128611. private _afterSoftStep;
  128612. /**
  128613. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128614. * @param impostor imposter to match
  128615. */
  128616. private _ropeStep;
  128617. /**
  128618. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128619. * @param impostor imposter to match
  128620. */
  128621. private _softbodyOrClothStep;
  128622. private _tmpVector;
  128623. private _tmpMatrix;
  128624. /**
  128625. * Applies an impulse on the imposter
  128626. * @param impostor imposter to apply impulse to
  128627. * @param force amount of force to be applied to the imposter
  128628. * @param contactPoint the location to apply the impulse on the imposter
  128629. */
  128630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128631. /**
  128632. * Applies a force on the imposter
  128633. * @param impostor imposter to apply force
  128634. * @param force amount of force to be applied to the imposter
  128635. * @param contactPoint the location to apply the force on the imposter
  128636. */
  128637. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128638. /**
  128639. * Creates a physics body using the plugin
  128640. * @param impostor the imposter to create the physics body on
  128641. */
  128642. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128643. /**
  128644. * Removes the physics body from the imposter and disposes of the body's memory
  128645. * @param impostor imposter to remove the physics body from
  128646. */
  128647. removePhysicsBody(impostor: PhysicsImpostor): void;
  128648. /**
  128649. * Generates a joint
  128650. * @param impostorJoint the imposter joint to create the joint with
  128651. */
  128652. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128653. /**
  128654. * Removes a joint
  128655. * @param impostorJoint the imposter joint to remove the joint from
  128656. */
  128657. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128658. private _addMeshVerts;
  128659. /**
  128660. * Initialise the soft body vertices to match its object's (mesh) vertices
  128661. * Softbody vertices (nodes) are in world space and to match this
  128662. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128663. * @param impostor to create the softbody for
  128664. */
  128665. private _softVertexData;
  128666. /**
  128667. * Create an impostor's soft body
  128668. * @param impostor to create the softbody for
  128669. */
  128670. private _createSoftbody;
  128671. /**
  128672. * Create cloth for an impostor
  128673. * @param impostor to create the softbody for
  128674. */
  128675. private _createCloth;
  128676. /**
  128677. * Create rope for an impostor
  128678. * @param impostor to create the softbody for
  128679. */
  128680. private _createRope;
  128681. /**
  128682. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128683. * @param impostor to create the custom physics shape for
  128684. */
  128685. private _createCustom;
  128686. private _addHullVerts;
  128687. private _createShape;
  128688. /**
  128689. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128690. * @param impostor imposter containing the physics body and babylon object
  128691. */
  128692. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128693. /**
  128694. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128695. * @param impostor imposter containing the physics body and babylon object
  128696. * @param newPosition new position
  128697. * @param newRotation new rotation
  128698. */
  128699. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128700. /**
  128701. * If this plugin is supported
  128702. * @returns true if its supported
  128703. */
  128704. isSupported(): boolean;
  128705. /**
  128706. * Sets the linear velocity of the physics body
  128707. * @param impostor imposter to set the velocity on
  128708. * @param velocity velocity to set
  128709. */
  128710. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128711. /**
  128712. * Sets the angular velocity of the physics body
  128713. * @param impostor imposter to set the velocity on
  128714. * @param velocity velocity to set
  128715. */
  128716. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128717. /**
  128718. * gets the linear velocity
  128719. * @param impostor imposter to get linear velocity from
  128720. * @returns linear velocity
  128721. */
  128722. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128723. /**
  128724. * gets the angular velocity
  128725. * @param impostor imposter to get angular velocity from
  128726. * @returns angular velocity
  128727. */
  128728. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128729. /**
  128730. * Sets the mass of physics body
  128731. * @param impostor imposter to set the mass on
  128732. * @param mass mass to set
  128733. */
  128734. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128735. /**
  128736. * Gets the mass of the physics body
  128737. * @param impostor imposter to get the mass from
  128738. * @returns mass
  128739. */
  128740. getBodyMass(impostor: PhysicsImpostor): number;
  128741. /**
  128742. * Gets friction of the impostor
  128743. * @param impostor impostor to get friction from
  128744. * @returns friction value
  128745. */
  128746. getBodyFriction(impostor: PhysicsImpostor): number;
  128747. /**
  128748. * Sets friction of the impostor
  128749. * @param impostor impostor to set friction on
  128750. * @param friction friction value
  128751. */
  128752. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128753. /**
  128754. * Gets restitution of the impostor
  128755. * @param impostor impostor to get restitution from
  128756. * @returns restitution value
  128757. */
  128758. getBodyRestitution(impostor: PhysicsImpostor): number;
  128759. /**
  128760. * Sets resitution of the impostor
  128761. * @param impostor impostor to set resitution on
  128762. * @param restitution resitution value
  128763. */
  128764. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128765. /**
  128766. * Gets pressure inside the impostor
  128767. * @param impostor impostor to get pressure from
  128768. * @returns pressure value
  128769. */
  128770. getBodyPressure(impostor: PhysicsImpostor): number;
  128771. /**
  128772. * Sets pressure inside a soft body impostor
  128773. * Cloth and rope must remain 0 pressure
  128774. * @param impostor impostor to set pressure on
  128775. * @param pressure pressure value
  128776. */
  128777. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128778. /**
  128779. * Gets stiffness of the impostor
  128780. * @param impostor impostor to get stiffness from
  128781. * @returns pressure value
  128782. */
  128783. getBodyStiffness(impostor: PhysicsImpostor): number;
  128784. /**
  128785. * Sets stiffness of the impostor
  128786. * @param impostor impostor to set stiffness on
  128787. * @param stiffness stiffness value from 0 to 1
  128788. */
  128789. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128790. /**
  128791. * Gets velocityIterations of the impostor
  128792. * @param impostor impostor to get velocity iterations from
  128793. * @returns velocityIterations value
  128794. */
  128795. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128796. /**
  128797. * Sets velocityIterations of the impostor
  128798. * @param impostor impostor to set velocity iterations on
  128799. * @param velocityIterations velocityIterations value
  128800. */
  128801. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128802. /**
  128803. * Gets positionIterations of the impostor
  128804. * @param impostor impostor to get position iterations from
  128805. * @returns positionIterations value
  128806. */
  128807. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128808. /**
  128809. * Sets positionIterations of the impostor
  128810. * @param impostor impostor to set position on
  128811. * @param positionIterations positionIterations value
  128812. */
  128813. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128814. /**
  128815. * Append an anchor to a cloth object
  128816. * @param impostor is the cloth impostor to add anchor to
  128817. * @param otherImpostor is the rigid impostor to anchor to
  128818. * @param width ratio across width from 0 to 1
  128819. * @param height ratio up height from 0 to 1
  128820. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128821. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128822. */
  128823. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128824. /**
  128825. * Append an hook to a rope object
  128826. * @param impostor is the rope impostor to add hook to
  128827. * @param otherImpostor is the rigid impostor to hook to
  128828. * @param length ratio along the rope from 0 to 1
  128829. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128830. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128831. */
  128832. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128833. /**
  128834. * Sleeps the physics body and stops it from being active
  128835. * @param impostor impostor to sleep
  128836. */
  128837. sleepBody(impostor: PhysicsImpostor): void;
  128838. /**
  128839. * Activates the physics body
  128840. * @param impostor impostor to activate
  128841. */
  128842. wakeUpBody(impostor: PhysicsImpostor): void;
  128843. /**
  128844. * Updates the distance parameters of the joint
  128845. * @param joint joint to update
  128846. * @param maxDistance maximum distance of the joint
  128847. * @param minDistance minimum distance of the joint
  128848. */
  128849. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128850. /**
  128851. * Sets a motor on the joint
  128852. * @param joint joint to set motor on
  128853. * @param speed speed of the motor
  128854. * @param maxForce maximum force of the motor
  128855. * @param motorIndex index of the motor
  128856. */
  128857. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128858. /**
  128859. * Sets the motors limit
  128860. * @param joint joint to set limit on
  128861. * @param upperLimit upper limit
  128862. * @param lowerLimit lower limit
  128863. */
  128864. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128865. /**
  128866. * Syncs the position and rotation of a mesh with the impostor
  128867. * @param mesh mesh to sync
  128868. * @param impostor impostor to update the mesh with
  128869. */
  128870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128871. /**
  128872. * Gets the radius of the impostor
  128873. * @param impostor impostor to get radius from
  128874. * @returns the radius
  128875. */
  128876. getRadius(impostor: PhysicsImpostor): number;
  128877. /**
  128878. * Gets the box size of the impostor
  128879. * @param impostor impostor to get box size from
  128880. * @param result the resulting box size
  128881. */
  128882. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128883. /**
  128884. * Disposes of the impostor
  128885. */
  128886. dispose(): void;
  128887. /**
  128888. * Does a raycast in the physics world
  128889. * @param from when should the ray start?
  128890. * @param to when should the ray end?
  128891. * @returns PhysicsRaycastResult
  128892. */
  128893. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128894. }
  128895. }
  128896. declare module BABYLON {
  128897. interface AbstractScene {
  128898. /**
  128899. * The list of reflection probes added to the scene
  128900. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128901. */
  128902. reflectionProbes: Array<ReflectionProbe>;
  128903. /**
  128904. * Removes the given reflection probe from this scene.
  128905. * @param toRemove The reflection probe to remove
  128906. * @returns The index of the removed reflection probe
  128907. */
  128908. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128909. /**
  128910. * Adds the given reflection probe to this scene.
  128911. * @param newReflectionProbe The reflection probe to add
  128912. */
  128913. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128914. }
  128915. /**
  128916. * Class used to generate realtime reflection / refraction cube textures
  128917. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128918. */
  128919. export class ReflectionProbe {
  128920. /** defines the name of the probe */
  128921. name: string;
  128922. private _scene;
  128923. private _renderTargetTexture;
  128924. private _projectionMatrix;
  128925. private _viewMatrix;
  128926. private _target;
  128927. private _add;
  128928. private _attachedMesh;
  128929. private _invertYAxis;
  128930. /** Gets or sets probe position (center of the cube map) */
  128931. position: Vector3;
  128932. /**
  128933. * Creates a new reflection probe
  128934. * @param name defines the name of the probe
  128935. * @param size defines the texture resolution (for each face)
  128936. * @param scene defines the hosting scene
  128937. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128938. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128939. */
  128940. constructor(
  128941. /** defines the name of the probe */
  128942. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128943. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128944. get samples(): number;
  128945. set samples(value: number);
  128946. /** Gets or sets the refresh rate to use (on every frame by default) */
  128947. get refreshRate(): number;
  128948. set refreshRate(value: number);
  128949. /**
  128950. * Gets the hosting scene
  128951. * @returns a Scene
  128952. */
  128953. getScene(): Scene;
  128954. /** Gets the internal CubeTexture used to render to */
  128955. get cubeTexture(): RenderTargetTexture;
  128956. /** Gets the list of meshes to render */
  128957. get renderList(): Nullable<AbstractMesh[]>;
  128958. /**
  128959. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128960. * @param mesh defines the mesh to attach to
  128961. */
  128962. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128963. /**
  128964. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128965. * @param renderingGroupId The rendering group id corresponding to its index
  128966. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128967. */
  128968. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128969. /**
  128970. * Clean all associated resources
  128971. */
  128972. dispose(): void;
  128973. /**
  128974. * Converts the reflection probe information to a readable string for debug purpose.
  128975. * @param fullDetails Supports for multiple levels of logging within scene loading
  128976. * @returns the human readable reflection probe info
  128977. */
  128978. toString(fullDetails?: boolean): string;
  128979. /**
  128980. * Get the class name of the relfection probe.
  128981. * @returns "ReflectionProbe"
  128982. */
  128983. getClassName(): string;
  128984. /**
  128985. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128986. * @returns The JSON representation of the texture
  128987. */
  128988. serialize(): any;
  128989. /**
  128990. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128991. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128992. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128993. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128994. * @returns The parsed reflection probe if successful
  128995. */
  128996. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128997. }
  128998. }
  128999. declare module BABYLON {
  129000. /** @hidden */
  129001. export var _BabylonLoaderRegistered: boolean;
  129002. /**
  129003. * Helps setting up some configuration for the babylon file loader.
  129004. */
  129005. export class BabylonFileLoaderConfiguration {
  129006. /**
  129007. * The loader does not allow injecting custom physix engine into the plugins.
  129008. * Unfortunately in ES6, we need to manually inject them into the plugin.
  129009. * So you could set this variable to your engine import to make it work.
  129010. */
  129011. static LoaderInjectedPhysicsEngine: any;
  129012. }
  129013. }
  129014. declare module BABYLON {
  129015. /**
  129016. * The Physically based simple base material of BJS.
  129017. *
  129018. * This enables better naming and convention enforcements on top of the pbrMaterial.
  129019. * It is used as the base class for both the specGloss and metalRough conventions.
  129020. */
  129021. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  129022. /**
  129023. * Number of Simultaneous lights allowed on the material.
  129024. */
  129025. maxSimultaneousLights: number;
  129026. /**
  129027. * If sets to true, disables all the lights affecting the material.
  129028. */
  129029. disableLighting: boolean;
  129030. /**
  129031. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  129032. */
  129033. environmentTexture: BaseTexture;
  129034. /**
  129035. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  129036. */
  129037. invertNormalMapX: boolean;
  129038. /**
  129039. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  129040. */
  129041. invertNormalMapY: boolean;
  129042. /**
  129043. * Normal map used in the model.
  129044. */
  129045. normalTexture: BaseTexture;
  129046. /**
  129047. * Emissivie color used to self-illuminate the model.
  129048. */
  129049. emissiveColor: Color3;
  129050. /**
  129051. * Emissivie texture used to self-illuminate the model.
  129052. */
  129053. emissiveTexture: BaseTexture;
  129054. /**
  129055. * Occlusion Channel Strenght.
  129056. */
  129057. occlusionStrength: number;
  129058. /**
  129059. * Occlusion Texture of the material (adding extra occlusion effects).
  129060. */
  129061. occlusionTexture: BaseTexture;
  129062. /**
  129063. * Defines the alpha limits in alpha test mode.
  129064. */
  129065. alphaCutOff: number;
  129066. /**
  129067. * Gets the current double sided mode.
  129068. */
  129069. get doubleSided(): boolean;
  129070. /**
  129071. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129072. */
  129073. set doubleSided(value: boolean);
  129074. /**
  129075. * Stores the pre-calculated light information of a mesh in a texture.
  129076. */
  129077. lightmapTexture: BaseTexture;
  129078. /**
  129079. * If true, the light map contains occlusion information instead of lighting info.
  129080. */
  129081. useLightmapAsShadowmap: boolean;
  129082. /**
  129083. * Instantiates a new PBRMaterial instance.
  129084. *
  129085. * @param name The material name
  129086. * @param scene The scene the material will be use in.
  129087. */
  129088. constructor(name: string, scene: Scene);
  129089. getClassName(): string;
  129090. }
  129091. }
  129092. declare module BABYLON {
  129093. /**
  129094. * The PBR material of BJS following the metal roughness convention.
  129095. *
  129096. * This fits to the PBR convention in the GLTF definition:
  129097. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129098. */
  129099. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129100. /**
  129101. * The base color has two different interpretations depending on the value of metalness.
  129102. * When the material is a metal, the base color is the specific measured reflectance value
  129103. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129104. * of the material.
  129105. */
  129106. baseColor: Color3;
  129107. /**
  129108. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129109. * well as opacity information in the alpha channel.
  129110. */
  129111. baseTexture: BaseTexture;
  129112. /**
  129113. * Specifies the metallic scalar value of the material.
  129114. * Can also be used to scale the metalness values of the metallic texture.
  129115. */
  129116. metallic: number;
  129117. /**
  129118. * Specifies the roughness scalar value of the material.
  129119. * Can also be used to scale the roughness values of the metallic texture.
  129120. */
  129121. roughness: number;
  129122. /**
  129123. * Texture containing both the metallic value in the B channel and the
  129124. * roughness value in the G channel to keep better precision.
  129125. */
  129126. metallicRoughnessTexture: BaseTexture;
  129127. /**
  129128. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129129. *
  129130. * @param name The material name
  129131. * @param scene The scene the material will be use in.
  129132. */
  129133. constructor(name: string, scene: Scene);
  129134. /**
  129135. * Return the currrent class name of the material.
  129136. */
  129137. getClassName(): string;
  129138. /**
  129139. * Makes a duplicate of the current material.
  129140. * @param name - name to use for the new material.
  129141. */
  129142. clone(name: string): PBRMetallicRoughnessMaterial;
  129143. /**
  129144. * Serialize the material to a parsable JSON object.
  129145. */
  129146. serialize(): any;
  129147. /**
  129148. * Parses a JSON object correponding to the serialize function.
  129149. */
  129150. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129151. }
  129152. }
  129153. declare module BABYLON {
  129154. /**
  129155. * The PBR material of BJS following the specular glossiness convention.
  129156. *
  129157. * This fits to the PBR convention in the GLTF definition:
  129158. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129159. */
  129160. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129161. /**
  129162. * Specifies the diffuse color of the material.
  129163. */
  129164. diffuseColor: Color3;
  129165. /**
  129166. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129167. * channel.
  129168. */
  129169. diffuseTexture: BaseTexture;
  129170. /**
  129171. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129172. */
  129173. specularColor: Color3;
  129174. /**
  129175. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129176. */
  129177. glossiness: number;
  129178. /**
  129179. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129180. */
  129181. specularGlossinessTexture: BaseTexture;
  129182. /**
  129183. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129184. *
  129185. * @param name The material name
  129186. * @param scene The scene the material will be use in.
  129187. */
  129188. constructor(name: string, scene: Scene);
  129189. /**
  129190. * Return the currrent class name of the material.
  129191. */
  129192. getClassName(): string;
  129193. /**
  129194. * Makes a duplicate of the current material.
  129195. * @param name - name to use for the new material.
  129196. */
  129197. clone(name: string): PBRSpecularGlossinessMaterial;
  129198. /**
  129199. * Serialize the material to a parsable JSON object.
  129200. */
  129201. serialize(): any;
  129202. /**
  129203. * Parses a JSON object correponding to the serialize function.
  129204. */
  129205. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129206. }
  129207. }
  129208. declare module BABYLON {
  129209. /**
  129210. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129211. * It can help converting any input color in a desired output one. This can then be used to create effects
  129212. * from sepia, black and white to sixties or futuristic rendering...
  129213. *
  129214. * The only supported format is currently 3dl.
  129215. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129216. */
  129217. export class ColorGradingTexture extends BaseTexture {
  129218. /**
  129219. * The current texture matrix. (will always be identity in color grading texture)
  129220. */
  129221. private _textureMatrix;
  129222. /**
  129223. * The texture URL.
  129224. */
  129225. url: string;
  129226. /**
  129227. * Empty line regex stored for GC.
  129228. */
  129229. private static _noneEmptyLineRegex;
  129230. private _engine;
  129231. /**
  129232. * Instantiates a ColorGradingTexture from the following parameters.
  129233. *
  129234. * @param url The location of the color gradind data (currently only supporting 3dl)
  129235. * @param scene The scene the texture will be used in
  129236. */
  129237. constructor(url: string, scene: Scene);
  129238. /**
  129239. * Returns the texture matrix used in most of the material.
  129240. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129241. */
  129242. getTextureMatrix(): Matrix;
  129243. /**
  129244. * Occurs when the file being loaded is a .3dl LUT file.
  129245. */
  129246. private load3dlTexture;
  129247. /**
  129248. * Starts the loading process of the texture.
  129249. */
  129250. private loadTexture;
  129251. /**
  129252. * Clones the color gradind texture.
  129253. */
  129254. clone(): ColorGradingTexture;
  129255. /**
  129256. * Called during delayed load for textures.
  129257. */
  129258. delayLoad(): void;
  129259. /**
  129260. * Parses a color grading texture serialized by Babylon.
  129261. * @param parsedTexture The texture information being parsedTexture
  129262. * @param scene The scene to load the texture in
  129263. * @param rootUrl The root url of the data assets to load
  129264. * @return A color gradind texture
  129265. */
  129266. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129267. /**
  129268. * Serializes the LUT texture to json format.
  129269. */
  129270. serialize(): any;
  129271. }
  129272. }
  129273. declare module BABYLON {
  129274. /**
  129275. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129276. */
  129277. export class EquiRectangularCubeTexture extends BaseTexture {
  129278. /** The six faces of the cube. */
  129279. private static _FacesMapping;
  129280. private _noMipmap;
  129281. private _onLoad;
  129282. private _onError;
  129283. /** The size of the cubemap. */
  129284. private _size;
  129285. /** The buffer of the image. */
  129286. private _buffer;
  129287. /** The width of the input image. */
  129288. private _width;
  129289. /** The height of the input image. */
  129290. private _height;
  129291. /** The URL to the image. */
  129292. url: string;
  129293. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129294. coordinatesMode: number;
  129295. /**
  129296. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129297. * @param url The location of the image
  129298. * @param scene The scene the texture will be used in
  129299. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129300. * @param noMipmap Forces to not generate the mipmap if true
  129301. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129302. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129303. * @param onLoad — defines a callback called when texture is loaded
  129304. * @param onError — defines a callback called if there is an error
  129305. */
  129306. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129307. /**
  129308. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129309. */
  129310. private loadImage;
  129311. /**
  129312. * Convert the image buffer into a cubemap and create a CubeTexture.
  129313. */
  129314. private loadTexture;
  129315. /**
  129316. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129317. * @param buffer The ArrayBuffer that should be converted.
  129318. * @returns The buffer as Float32Array.
  129319. */
  129320. private getFloat32ArrayFromArrayBuffer;
  129321. /**
  129322. * Get the current class name of the texture useful for serialization or dynamic coding.
  129323. * @returns "EquiRectangularCubeTexture"
  129324. */
  129325. getClassName(): string;
  129326. /**
  129327. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129328. * @returns A clone of the current EquiRectangularCubeTexture.
  129329. */
  129330. clone(): EquiRectangularCubeTexture;
  129331. }
  129332. }
  129333. declare module BABYLON {
  129334. /**
  129335. * Based on jsTGALoader - Javascript loader for TGA file
  129336. * By Vincent Thibault
  129337. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129338. */
  129339. export class TGATools {
  129340. private static _TYPE_INDEXED;
  129341. private static _TYPE_RGB;
  129342. private static _TYPE_GREY;
  129343. private static _TYPE_RLE_INDEXED;
  129344. private static _TYPE_RLE_RGB;
  129345. private static _TYPE_RLE_GREY;
  129346. private static _ORIGIN_MASK;
  129347. private static _ORIGIN_SHIFT;
  129348. private static _ORIGIN_BL;
  129349. private static _ORIGIN_BR;
  129350. private static _ORIGIN_UL;
  129351. private static _ORIGIN_UR;
  129352. /**
  129353. * Gets the header of a TGA file
  129354. * @param data defines the TGA data
  129355. * @returns the header
  129356. */
  129357. static GetTGAHeader(data: Uint8Array): any;
  129358. /**
  129359. * Uploads TGA content to a Babylon Texture
  129360. * @hidden
  129361. */
  129362. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129363. /** @hidden */
  129364. 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;
  129365. /** @hidden */
  129366. 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;
  129367. /** @hidden */
  129368. 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;
  129369. /** @hidden */
  129370. 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;
  129371. /** @hidden */
  129372. 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;
  129373. /** @hidden */
  129374. 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;
  129375. }
  129376. }
  129377. declare module BABYLON {
  129378. /**
  129379. * Implementation of the TGA Texture Loader.
  129380. * @hidden
  129381. */
  129382. export class _TGATextureLoader implements IInternalTextureLoader {
  129383. /**
  129384. * Defines wether the loader supports cascade loading the different faces.
  129385. */
  129386. readonly supportCascades: boolean;
  129387. /**
  129388. * This returns if the loader support the current file information.
  129389. * @param extension defines the file extension of the file being loaded
  129390. * @returns true if the loader can load the specified file
  129391. */
  129392. canLoad(extension: string): boolean;
  129393. /**
  129394. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129395. * @param data contains the texture data
  129396. * @param texture defines the BabylonJS internal texture
  129397. * @param createPolynomials will be true if polynomials have been requested
  129398. * @param onLoad defines the callback to trigger once the texture is ready
  129399. * @param onError defines the callback to trigger in case of error
  129400. */
  129401. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129402. /**
  129403. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129404. * @param data contains the texture data
  129405. * @param texture defines the BabylonJS internal texture
  129406. * @param callback defines the method to call once ready to upload
  129407. */
  129408. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129409. }
  129410. }
  129411. declare module BABYLON {
  129412. /**
  129413. * Info about the .basis files
  129414. */
  129415. class BasisFileInfo {
  129416. /**
  129417. * If the file has alpha
  129418. */
  129419. hasAlpha: boolean;
  129420. /**
  129421. * Info about each image of the basis file
  129422. */
  129423. images: Array<{
  129424. levels: Array<{
  129425. width: number;
  129426. height: number;
  129427. transcodedPixels: ArrayBufferView;
  129428. }>;
  129429. }>;
  129430. }
  129431. /**
  129432. * Result of transcoding a basis file
  129433. */
  129434. class TranscodeResult {
  129435. /**
  129436. * Info about the .basis file
  129437. */
  129438. fileInfo: BasisFileInfo;
  129439. /**
  129440. * Format to use when loading the file
  129441. */
  129442. format: number;
  129443. }
  129444. /**
  129445. * Configuration options for the Basis transcoder
  129446. */
  129447. export class BasisTranscodeConfiguration {
  129448. /**
  129449. * Supported compression formats used to determine the supported output format of the transcoder
  129450. */
  129451. supportedCompressionFormats?: {
  129452. /**
  129453. * etc1 compression format
  129454. */
  129455. etc1?: boolean;
  129456. /**
  129457. * s3tc compression format
  129458. */
  129459. s3tc?: boolean;
  129460. /**
  129461. * pvrtc compression format
  129462. */
  129463. pvrtc?: boolean;
  129464. /**
  129465. * etc2 compression format
  129466. */
  129467. etc2?: boolean;
  129468. };
  129469. /**
  129470. * If mipmap levels should be loaded for transcoded images (Default: true)
  129471. */
  129472. loadMipmapLevels?: boolean;
  129473. /**
  129474. * Index of a single image to load (Default: all images)
  129475. */
  129476. loadSingleImage?: number;
  129477. }
  129478. /**
  129479. * Used to load .Basis files
  129480. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129481. */
  129482. export class BasisTools {
  129483. private static _IgnoreSupportedFormats;
  129484. /**
  129485. * URL to use when loading the basis transcoder
  129486. */
  129487. static JSModuleURL: string;
  129488. /**
  129489. * URL to use when loading the wasm module for the transcoder
  129490. */
  129491. static WasmModuleURL: string;
  129492. /**
  129493. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129494. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129495. * @returns internal format corresponding to the Basis format
  129496. */
  129497. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129498. private static _WorkerPromise;
  129499. private static _Worker;
  129500. private static _actionId;
  129501. private static _CreateWorkerAsync;
  129502. /**
  129503. * Transcodes a loaded image file to compressed pixel data
  129504. * @param data image data to transcode
  129505. * @param config configuration options for the transcoding
  129506. * @returns a promise resulting in the transcoded image
  129507. */
  129508. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129509. /**
  129510. * Loads a texture from the transcode result
  129511. * @param texture texture load to
  129512. * @param transcodeResult the result of transcoding the basis file to load from
  129513. */
  129514. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129515. }
  129516. }
  129517. declare module BABYLON {
  129518. /**
  129519. * Loader for .basis file format
  129520. */
  129521. export class _BasisTextureLoader implements IInternalTextureLoader {
  129522. /**
  129523. * Defines whether the loader supports cascade loading the different faces.
  129524. */
  129525. readonly supportCascades: boolean;
  129526. /**
  129527. * This returns if the loader support the current file information.
  129528. * @param extension defines the file extension of the file being loaded
  129529. * @returns true if the loader can load the specified file
  129530. */
  129531. canLoad(extension: string): boolean;
  129532. /**
  129533. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129534. * @param data contains the texture data
  129535. * @param texture defines the BabylonJS internal texture
  129536. * @param createPolynomials will be true if polynomials have been requested
  129537. * @param onLoad defines the callback to trigger once the texture is ready
  129538. * @param onError defines the callback to trigger in case of error
  129539. */
  129540. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129541. /**
  129542. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129543. * @param data contains the texture data
  129544. * @param texture defines the BabylonJS internal texture
  129545. * @param callback defines the method to call once ready to upload
  129546. */
  129547. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129548. }
  129549. }
  129550. declare module BABYLON {
  129551. /**
  129552. * 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.
  129553. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129554. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129555. */
  129556. export class CustomProceduralTexture extends ProceduralTexture {
  129557. private _animate;
  129558. private _time;
  129559. private _config;
  129560. private _texturePath;
  129561. /**
  129562. * Instantiates a new Custom Procedural Texture.
  129563. * 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.
  129564. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129565. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129566. * @param name Define the name of the texture
  129567. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129568. * @param size Define the size of the texture to create
  129569. * @param scene Define the scene the texture belongs to
  129570. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129571. * @param generateMipMaps Define if the texture should creates mip maps or not
  129572. */
  129573. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129574. private _loadJson;
  129575. /**
  129576. * Is the texture ready to be used ? (rendered at least once)
  129577. * @returns true if ready, otherwise, false.
  129578. */
  129579. isReady(): boolean;
  129580. /**
  129581. * Render the texture to its associated render target.
  129582. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129583. */
  129584. render(useCameraPostProcess?: boolean): void;
  129585. /**
  129586. * Update the list of dependant textures samplers in the shader.
  129587. */
  129588. updateTextures(): void;
  129589. /**
  129590. * Update the uniform values of the procedural texture in the shader.
  129591. */
  129592. updateShaderUniforms(): void;
  129593. /**
  129594. * Define if the texture animates or not.
  129595. */
  129596. get animate(): boolean;
  129597. set animate(value: boolean);
  129598. }
  129599. }
  129600. declare module BABYLON {
  129601. /** @hidden */
  129602. export var noisePixelShader: {
  129603. name: string;
  129604. shader: string;
  129605. };
  129606. }
  129607. declare module BABYLON {
  129608. /**
  129609. * Class used to generate noise procedural textures
  129610. */
  129611. export class NoiseProceduralTexture extends ProceduralTexture {
  129612. private _time;
  129613. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129614. brightness: number;
  129615. /** Defines the number of octaves to process */
  129616. octaves: number;
  129617. /** Defines the level of persistence (0.8 by default) */
  129618. persistence: number;
  129619. /** Gets or sets animation speed factor (default is 1) */
  129620. animationSpeedFactor: number;
  129621. /**
  129622. * Creates a new NoiseProceduralTexture
  129623. * @param name defines the name fo the texture
  129624. * @param size defines the size of the texture (default is 256)
  129625. * @param scene defines the hosting scene
  129626. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129627. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129628. */
  129629. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129630. private _updateShaderUniforms;
  129631. protected _getDefines(): string;
  129632. /** Generate the current state of the procedural texture */
  129633. render(useCameraPostProcess?: boolean): void;
  129634. /**
  129635. * Serializes this noise procedural texture
  129636. * @returns a serialized noise procedural texture object
  129637. */
  129638. serialize(): any;
  129639. /**
  129640. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129641. * @param parsedTexture defines parsed texture data
  129642. * @param scene defines the current scene
  129643. * @param rootUrl defines the root URL containing noise procedural texture information
  129644. * @returns a parsed NoiseProceduralTexture
  129645. */
  129646. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129647. }
  129648. }
  129649. declare module BABYLON {
  129650. /**
  129651. * Raw cube texture where the raw buffers are passed in
  129652. */
  129653. export class RawCubeTexture extends CubeTexture {
  129654. /**
  129655. * Creates a cube texture where the raw buffers are passed in.
  129656. * @param scene defines the scene the texture is attached to
  129657. * @param data defines the array of data to use to create each face
  129658. * @param size defines the size of the textures
  129659. * @param format defines the format of the data
  129660. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129661. * @param generateMipMaps defines if the engine should generate the mip levels
  129662. * @param invertY defines if data must be stored with Y axis inverted
  129663. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129664. * @param compression defines the compression used (null by default)
  129665. */
  129666. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129667. /**
  129668. * Updates the raw cube texture.
  129669. * @param data defines the data to store
  129670. * @param format defines the data format
  129671. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129672. * @param invertY defines if data must be stored with Y axis inverted
  129673. * @param compression defines the compression used (null by default)
  129674. * @param level defines which level of the texture to update
  129675. */
  129676. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129677. /**
  129678. * Updates a raw cube texture with RGBD encoded data.
  129679. * @param data defines the array of data [mipmap][face] to use to create each face
  129680. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129681. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129682. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129683. * @returns a promsie that resolves when the operation is complete
  129684. */
  129685. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129686. /**
  129687. * Clones the raw cube texture.
  129688. * @return a new cube texture
  129689. */
  129690. clone(): CubeTexture;
  129691. /** @hidden */
  129692. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129693. }
  129694. }
  129695. declare module BABYLON {
  129696. /**
  129697. * Class used to store 3D textures containing user data
  129698. */
  129699. export class RawTexture3D extends Texture {
  129700. /** Gets or sets the texture format to use */
  129701. format: number;
  129702. private _engine;
  129703. /**
  129704. * Create a new RawTexture3D
  129705. * @param data defines the data of the texture
  129706. * @param width defines the width of the texture
  129707. * @param height defines the height of the texture
  129708. * @param depth defines the depth of the texture
  129709. * @param format defines the texture format to use
  129710. * @param scene defines the hosting scene
  129711. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129712. * @param invertY defines if texture must be stored with Y axis inverted
  129713. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129714. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129715. */
  129716. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129717. /** Gets or sets the texture format to use */
  129718. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129719. /**
  129720. * Update the texture with new data
  129721. * @param data defines the data to store in the texture
  129722. */
  129723. update(data: ArrayBufferView): void;
  129724. }
  129725. }
  129726. declare module BABYLON {
  129727. /**
  129728. * Class used to store 2D array textures containing user data
  129729. */
  129730. export class RawTexture2DArray extends Texture {
  129731. /** Gets or sets the texture format to use */
  129732. format: number;
  129733. private _engine;
  129734. /**
  129735. * Create a new RawTexture2DArray
  129736. * @param data defines the data of the texture
  129737. * @param width defines the width of the texture
  129738. * @param height defines the height of the texture
  129739. * @param depth defines the number of layers of the texture
  129740. * @param format defines the texture format to use
  129741. * @param scene defines the hosting scene
  129742. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129743. * @param invertY defines if texture must be stored with Y axis inverted
  129744. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129745. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129746. */
  129747. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129748. /** Gets or sets the texture format to use */
  129749. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129750. /**
  129751. * Update the texture with new data
  129752. * @param data defines the data to store in the texture
  129753. */
  129754. update(data: ArrayBufferView): void;
  129755. }
  129756. }
  129757. declare module BABYLON {
  129758. /**
  129759. * Creates a refraction texture used by refraction channel of the standard material.
  129760. * It is like a mirror but to see through a material.
  129761. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129762. */
  129763. export class RefractionTexture extends RenderTargetTexture {
  129764. /**
  129765. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129766. * 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.
  129767. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129768. */
  129769. refractionPlane: Plane;
  129770. /**
  129771. * Define how deep under the surface we should see.
  129772. */
  129773. depth: number;
  129774. /**
  129775. * Creates a refraction texture used by refraction channel of the standard material.
  129776. * It is like a mirror but to see through a material.
  129777. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129778. * @param name Define the texture name
  129779. * @param size Define the size of the underlying texture
  129780. * @param scene Define the scene the refraction belongs to
  129781. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129782. */
  129783. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129784. /**
  129785. * Clone the refraction texture.
  129786. * @returns the cloned texture
  129787. */
  129788. clone(): RefractionTexture;
  129789. /**
  129790. * Serialize the texture to a JSON representation you could use in Parse later on
  129791. * @returns the serialized JSON representation
  129792. */
  129793. serialize(): any;
  129794. }
  129795. }
  129796. declare module BABYLON {
  129797. /**
  129798. * Defines the options related to the creation of an HtmlElementTexture
  129799. */
  129800. export interface IHtmlElementTextureOptions {
  129801. /**
  129802. * Defines wether mip maps should be created or not.
  129803. */
  129804. generateMipMaps?: boolean;
  129805. /**
  129806. * Defines the sampling mode of the texture.
  129807. */
  129808. samplingMode?: number;
  129809. /**
  129810. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129811. */
  129812. engine: Nullable<ThinEngine>;
  129813. /**
  129814. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129815. */
  129816. scene: Nullable<Scene>;
  129817. }
  129818. /**
  129819. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129820. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129821. * is automatically managed.
  129822. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129823. * in your application.
  129824. *
  129825. * As the update is not automatic, you need to call them manually.
  129826. */
  129827. export class HtmlElementTexture extends BaseTexture {
  129828. /**
  129829. * The texture URL.
  129830. */
  129831. element: HTMLVideoElement | HTMLCanvasElement;
  129832. private static readonly DefaultOptions;
  129833. private _textureMatrix;
  129834. private _engine;
  129835. private _isVideo;
  129836. private _generateMipMaps;
  129837. private _samplingMode;
  129838. /**
  129839. * Instantiates a HtmlElementTexture from the following parameters.
  129840. *
  129841. * @param name Defines the name of the texture
  129842. * @param element Defines the video or canvas the texture is filled with
  129843. * @param options Defines the other none mandatory texture creation options
  129844. */
  129845. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129846. private _createInternalTexture;
  129847. /**
  129848. * Returns the texture matrix used in most of the material.
  129849. */
  129850. getTextureMatrix(): Matrix;
  129851. /**
  129852. * Updates the content of the texture.
  129853. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129854. */
  129855. update(invertY?: Nullable<boolean>): void;
  129856. }
  129857. }
  129858. declare module BABYLON {
  129859. /**
  129860. * Defines the basic options interface of a TexturePacker Frame
  129861. */
  129862. export interface ITexturePackerFrame {
  129863. /**
  129864. * The frame ID
  129865. */
  129866. id: number;
  129867. /**
  129868. * The frames Scale
  129869. */
  129870. scale: Vector2;
  129871. /**
  129872. * The Frames offset
  129873. */
  129874. offset: Vector2;
  129875. }
  129876. /**
  129877. * This is a support class for frame Data on texture packer sets.
  129878. */
  129879. export class TexturePackerFrame implements ITexturePackerFrame {
  129880. /**
  129881. * The frame ID
  129882. */
  129883. id: number;
  129884. /**
  129885. * The frames Scale
  129886. */
  129887. scale: Vector2;
  129888. /**
  129889. * The Frames offset
  129890. */
  129891. offset: Vector2;
  129892. /**
  129893. * Initializes a texture package frame.
  129894. * @param id The numerical frame identifier
  129895. * @param scale Scalar Vector2 for UV frame
  129896. * @param offset Vector2 for the frame position in UV units.
  129897. * @returns TexturePackerFrame
  129898. */
  129899. constructor(id: number, scale: Vector2, offset: Vector2);
  129900. }
  129901. }
  129902. declare module BABYLON {
  129903. /**
  129904. * Defines the basic options interface of a TexturePacker
  129905. */
  129906. export interface ITexturePackerOptions {
  129907. /**
  129908. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129909. */
  129910. map?: string[];
  129911. /**
  129912. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129913. */
  129914. uvsIn?: string;
  129915. /**
  129916. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129917. */
  129918. uvsOut?: string;
  129919. /**
  129920. * number representing the layout style. Defaults to LAYOUT_STRIP
  129921. */
  129922. layout?: number;
  129923. /**
  129924. * number of columns if using custom column count layout(2). This defaults to 4.
  129925. */
  129926. colnum?: number;
  129927. /**
  129928. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129929. */
  129930. updateInputMeshes?: boolean;
  129931. /**
  129932. * boolean flag to dispose all the source textures. Defaults to true.
  129933. */
  129934. disposeSources?: boolean;
  129935. /**
  129936. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129937. */
  129938. fillBlanks?: boolean;
  129939. /**
  129940. * string value representing the context fill style color. Defaults to 'black'.
  129941. */
  129942. customFillColor?: string;
  129943. /**
  129944. * Width and Height Value of each Frame in the TexturePacker Sets
  129945. */
  129946. frameSize?: number;
  129947. /**
  129948. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129949. */
  129950. paddingRatio?: number;
  129951. /**
  129952. * Number that declares the fill method for the padding gutter.
  129953. */
  129954. paddingMode?: number;
  129955. /**
  129956. * If in SUBUV_COLOR padding mode what color to use.
  129957. */
  129958. paddingColor?: Color3 | Color4;
  129959. }
  129960. /**
  129961. * Defines the basic interface of a TexturePacker JSON File
  129962. */
  129963. export interface ITexturePackerJSON {
  129964. /**
  129965. * The frame ID
  129966. */
  129967. name: string;
  129968. /**
  129969. * The base64 channel data
  129970. */
  129971. sets: any;
  129972. /**
  129973. * The options of the Packer
  129974. */
  129975. options: ITexturePackerOptions;
  129976. /**
  129977. * The frame data of the Packer
  129978. */
  129979. frames: Array<number>;
  129980. }
  129981. /**
  129982. * This is a support class that generates a series of packed texture sets.
  129983. * @see https://doc.babylonjs.com/babylon101/materials
  129984. */
  129985. export class TexturePacker {
  129986. /** Packer Layout Constant 0 */
  129987. static readonly LAYOUT_STRIP: number;
  129988. /** Packer Layout Constant 1 */
  129989. static readonly LAYOUT_POWER2: number;
  129990. /** Packer Layout Constant 2 */
  129991. static readonly LAYOUT_COLNUM: number;
  129992. /** Packer Layout Constant 0 */
  129993. static readonly SUBUV_WRAP: number;
  129994. /** Packer Layout Constant 1 */
  129995. static readonly SUBUV_EXTEND: number;
  129996. /** Packer Layout Constant 2 */
  129997. static readonly SUBUV_COLOR: number;
  129998. /** The Name of the Texture Package */
  129999. name: string;
  130000. /** The scene scope of the TexturePacker */
  130001. scene: Scene;
  130002. /** The Meshes to target */
  130003. meshes: AbstractMesh[];
  130004. /** Arguments passed with the Constructor */
  130005. options: ITexturePackerOptions;
  130006. /** The promise that is started upon initialization */
  130007. promise: Nullable<Promise<TexturePacker | string>>;
  130008. /** The Container object for the channel sets that are generated */
  130009. sets: object;
  130010. /** The Container array for the frames that are generated */
  130011. frames: TexturePackerFrame[];
  130012. /** The expected number of textures the system is parsing. */
  130013. private _expecting;
  130014. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  130015. private _paddingValue;
  130016. /**
  130017. * Initializes a texture package series from an array of meshes or a single mesh.
  130018. * @param name The name of the package
  130019. * @param meshes The target meshes to compose the package from
  130020. * @param options The arguments that texture packer should follow while building.
  130021. * @param scene The scene which the textures are scoped to.
  130022. * @returns TexturePacker
  130023. */
  130024. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  130025. /**
  130026. * Starts the package process
  130027. * @param resolve The promises resolution function
  130028. * @returns TexturePacker
  130029. */
  130030. private _createFrames;
  130031. /**
  130032. * Calculates the Size of the Channel Sets
  130033. * @returns Vector2
  130034. */
  130035. private _calculateSize;
  130036. /**
  130037. * Calculates the UV data for the frames.
  130038. * @param baseSize the base frameSize
  130039. * @param padding the base frame padding
  130040. * @param dtSize size of the Dynamic Texture for that channel
  130041. * @param dtUnits is 1/dtSize
  130042. * @param update flag to update the input meshes
  130043. */
  130044. private _calculateMeshUVFrames;
  130045. /**
  130046. * Calculates the frames Offset.
  130047. * @param index of the frame
  130048. * @returns Vector2
  130049. */
  130050. private _getFrameOffset;
  130051. /**
  130052. * Updates a Mesh to the frame data
  130053. * @param mesh that is the target
  130054. * @param frameID or the frame index
  130055. */
  130056. private _updateMeshUV;
  130057. /**
  130058. * Updates a Meshes materials to use the texture packer channels
  130059. * @param m is the mesh to target
  130060. * @param force all channels on the packer to be set.
  130061. */
  130062. private _updateTextureReferences;
  130063. /**
  130064. * Public method to set a Mesh to a frame
  130065. * @param m that is the target
  130066. * @param frameID or the frame index
  130067. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130068. */
  130069. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130070. /**
  130071. * Starts the async promise to compile the texture packer.
  130072. * @returns Promise<void>
  130073. */
  130074. processAsync(): Promise<void>;
  130075. /**
  130076. * Disposes all textures associated with this packer
  130077. */
  130078. dispose(): void;
  130079. /**
  130080. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130081. * @param imageType is the image type to use.
  130082. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130083. */
  130084. download(imageType?: string, quality?: number): void;
  130085. /**
  130086. * Public method to load a texturePacker JSON file.
  130087. * @param data of the JSON file in string format.
  130088. */
  130089. updateFromJSON(data: string): void;
  130090. }
  130091. }
  130092. declare module BABYLON {
  130093. /**
  130094. * Enum used to define the target of a block
  130095. */
  130096. export enum NodeMaterialBlockTargets {
  130097. /** Vertex shader */
  130098. Vertex = 1,
  130099. /** Fragment shader */
  130100. Fragment = 2,
  130101. /** Neutral */
  130102. Neutral = 4,
  130103. /** Vertex and Fragment */
  130104. VertexAndFragment = 3
  130105. }
  130106. }
  130107. declare module BABYLON {
  130108. /**
  130109. * Defines the kind of connection point for node based material
  130110. */
  130111. export enum NodeMaterialBlockConnectionPointTypes {
  130112. /** Float */
  130113. Float = 1,
  130114. /** Int */
  130115. Int = 2,
  130116. /** Vector2 */
  130117. Vector2 = 4,
  130118. /** Vector3 */
  130119. Vector3 = 8,
  130120. /** Vector4 */
  130121. Vector4 = 16,
  130122. /** Color3 */
  130123. Color3 = 32,
  130124. /** Color4 */
  130125. Color4 = 64,
  130126. /** Matrix */
  130127. Matrix = 128,
  130128. /** Detect type based on connection */
  130129. AutoDetect = 1024,
  130130. /** Output type that will be defined by input type */
  130131. BasedOnInput = 2048
  130132. }
  130133. }
  130134. declare module BABYLON {
  130135. /**
  130136. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130137. */
  130138. export enum NodeMaterialBlockConnectionPointMode {
  130139. /** Value is an uniform */
  130140. Uniform = 0,
  130141. /** Value is a mesh attribute */
  130142. Attribute = 1,
  130143. /** Value is a varying between vertex and fragment shaders */
  130144. Varying = 2,
  130145. /** Mode is undefined */
  130146. Undefined = 3
  130147. }
  130148. }
  130149. declare module BABYLON {
  130150. /**
  130151. * Enum used to define system values e.g. values automatically provided by the system
  130152. */
  130153. export enum NodeMaterialSystemValues {
  130154. /** World */
  130155. World = 1,
  130156. /** View */
  130157. View = 2,
  130158. /** Projection */
  130159. Projection = 3,
  130160. /** ViewProjection */
  130161. ViewProjection = 4,
  130162. /** WorldView */
  130163. WorldView = 5,
  130164. /** WorldViewProjection */
  130165. WorldViewProjection = 6,
  130166. /** CameraPosition */
  130167. CameraPosition = 7,
  130168. /** Fog Color */
  130169. FogColor = 8,
  130170. /** Delta time */
  130171. DeltaTime = 9
  130172. }
  130173. }
  130174. declare module BABYLON {
  130175. /**
  130176. * Root class for all node material optimizers
  130177. */
  130178. export class NodeMaterialOptimizer {
  130179. /**
  130180. * Function used to optimize a NodeMaterial graph
  130181. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130182. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130183. */
  130184. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130185. }
  130186. }
  130187. declare module BABYLON {
  130188. /**
  130189. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130190. */
  130191. export class TransformBlock extends NodeMaterialBlock {
  130192. /**
  130193. * Defines the value to use to complement W value to transform it to a Vector4
  130194. */
  130195. complementW: number;
  130196. /**
  130197. * Defines the value to use to complement z value to transform it to a Vector4
  130198. */
  130199. complementZ: number;
  130200. /**
  130201. * Creates a new TransformBlock
  130202. * @param name defines the block name
  130203. */
  130204. constructor(name: string);
  130205. /**
  130206. * Gets the current class name
  130207. * @returns the class name
  130208. */
  130209. getClassName(): string;
  130210. /**
  130211. * Gets the vector input
  130212. */
  130213. get vector(): NodeMaterialConnectionPoint;
  130214. /**
  130215. * Gets the output component
  130216. */
  130217. get output(): NodeMaterialConnectionPoint;
  130218. /**
  130219. * Gets the xyz output component
  130220. */
  130221. get xyz(): NodeMaterialConnectionPoint;
  130222. /**
  130223. * Gets the matrix transform input
  130224. */
  130225. get transform(): NodeMaterialConnectionPoint;
  130226. protected _buildBlock(state: NodeMaterialBuildState): this;
  130227. serialize(): any;
  130228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130229. protected _dumpPropertiesCode(): string;
  130230. }
  130231. }
  130232. declare module BABYLON {
  130233. /**
  130234. * Block used to output the vertex position
  130235. */
  130236. export class VertexOutputBlock extends NodeMaterialBlock {
  130237. /**
  130238. * Creates a new VertexOutputBlock
  130239. * @param name defines the block name
  130240. */
  130241. constructor(name: string);
  130242. /**
  130243. * Gets the current class name
  130244. * @returns the class name
  130245. */
  130246. getClassName(): string;
  130247. /**
  130248. * Gets the vector input component
  130249. */
  130250. get vector(): NodeMaterialConnectionPoint;
  130251. protected _buildBlock(state: NodeMaterialBuildState): this;
  130252. }
  130253. }
  130254. declare module BABYLON {
  130255. /**
  130256. * Block used to output the final color
  130257. */
  130258. export class FragmentOutputBlock extends NodeMaterialBlock {
  130259. /**
  130260. * Create a new FragmentOutputBlock
  130261. * @param name defines the block name
  130262. */
  130263. constructor(name: string);
  130264. /**
  130265. * Gets the current class name
  130266. * @returns the class name
  130267. */
  130268. getClassName(): string;
  130269. /**
  130270. * Gets the rgba input component
  130271. */
  130272. get rgba(): NodeMaterialConnectionPoint;
  130273. /**
  130274. * Gets the rgb input component
  130275. */
  130276. get rgb(): NodeMaterialConnectionPoint;
  130277. /**
  130278. * Gets the a input component
  130279. */
  130280. get a(): NodeMaterialConnectionPoint;
  130281. protected _buildBlock(state: NodeMaterialBuildState): this;
  130282. }
  130283. }
  130284. declare module BABYLON {
  130285. /**
  130286. * Block used to read a reflection texture from a sampler
  130287. */
  130288. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130289. private _define3DName;
  130290. private _defineCubicName;
  130291. private _defineExplicitName;
  130292. private _defineProjectionName;
  130293. private _defineLocalCubicName;
  130294. private _defineSphericalName;
  130295. private _definePlanarName;
  130296. private _defineEquirectangularName;
  130297. private _defineMirroredEquirectangularFixedName;
  130298. private _defineEquirectangularFixedName;
  130299. private _defineSkyboxName;
  130300. private _cubeSamplerName;
  130301. private _2DSamplerName;
  130302. private _positionUVWName;
  130303. private _directionWName;
  130304. private _reflectionCoordsName;
  130305. private _reflection2DCoordsName;
  130306. private _reflectionColorName;
  130307. private _reflectionMatrixName;
  130308. /**
  130309. * Gets or sets the texture associated with the node
  130310. */
  130311. texture: Nullable<BaseTexture>;
  130312. /**
  130313. * Create a new TextureBlock
  130314. * @param name defines the block name
  130315. */
  130316. constructor(name: string);
  130317. /**
  130318. * Gets the current class name
  130319. * @returns the class name
  130320. */
  130321. getClassName(): string;
  130322. /**
  130323. * Gets the world position input component
  130324. */
  130325. get position(): NodeMaterialConnectionPoint;
  130326. /**
  130327. * Gets the world position input component
  130328. */
  130329. get worldPosition(): NodeMaterialConnectionPoint;
  130330. /**
  130331. * Gets the world normal input component
  130332. */
  130333. get worldNormal(): NodeMaterialConnectionPoint;
  130334. /**
  130335. * Gets the world input component
  130336. */
  130337. get world(): NodeMaterialConnectionPoint;
  130338. /**
  130339. * Gets the camera (or eye) position component
  130340. */
  130341. get cameraPosition(): NodeMaterialConnectionPoint;
  130342. /**
  130343. * Gets the view input component
  130344. */
  130345. get view(): NodeMaterialConnectionPoint;
  130346. /**
  130347. * Gets the rgb output component
  130348. */
  130349. get rgb(): NodeMaterialConnectionPoint;
  130350. /**
  130351. * Gets the r output component
  130352. */
  130353. get r(): NodeMaterialConnectionPoint;
  130354. /**
  130355. * Gets the g output component
  130356. */
  130357. get g(): NodeMaterialConnectionPoint;
  130358. /**
  130359. * Gets the b output component
  130360. */
  130361. get b(): NodeMaterialConnectionPoint;
  130362. autoConfigure(material: NodeMaterial): void;
  130363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130364. isReady(): boolean;
  130365. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130366. private _injectVertexCode;
  130367. private _writeOutput;
  130368. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130369. protected _dumpPropertiesCode(): string;
  130370. serialize(): any;
  130371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130372. }
  130373. }
  130374. declare module BABYLON {
  130375. /**
  130376. * Interface used to configure the node material editor
  130377. */
  130378. export interface INodeMaterialEditorOptions {
  130379. /** Define the URl to load node editor script */
  130380. editorURL?: string;
  130381. }
  130382. /** @hidden */
  130383. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130384. NORMAL: boolean;
  130385. TANGENT: boolean;
  130386. UV1: boolean;
  130387. /** BONES */
  130388. NUM_BONE_INFLUENCERS: number;
  130389. BonesPerMesh: number;
  130390. BONETEXTURE: boolean;
  130391. /** MORPH TARGETS */
  130392. MORPHTARGETS: boolean;
  130393. MORPHTARGETS_NORMAL: boolean;
  130394. MORPHTARGETS_TANGENT: boolean;
  130395. MORPHTARGETS_UV: boolean;
  130396. NUM_MORPH_INFLUENCERS: number;
  130397. /** IMAGE PROCESSING */
  130398. IMAGEPROCESSING: boolean;
  130399. VIGNETTE: boolean;
  130400. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130401. VIGNETTEBLENDMODEOPAQUE: boolean;
  130402. TONEMAPPING: boolean;
  130403. TONEMAPPING_ACES: boolean;
  130404. CONTRAST: boolean;
  130405. EXPOSURE: boolean;
  130406. COLORCURVES: boolean;
  130407. COLORGRADING: boolean;
  130408. COLORGRADING3D: boolean;
  130409. SAMPLER3DGREENDEPTH: boolean;
  130410. SAMPLER3DBGRMAP: boolean;
  130411. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130412. /** MISC. */
  130413. BUMPDIRECTUV: number;
  130414. constructor();
  130415. setValue(name: string, value: boolean): void;
  130416. }
  130417. /**
  130418. * Class used to configure NodeMaterial
  130419. */
  130420. export interface INodeMaterialOptions {
  130421. /**
  130422. * Defines if blocks should emit comments
  130423. */
  130424. emitComments: boolean;
  130425. }
  130426. /**
  130427. * Class used to create a node based material built by assembling shader blocks
  130428. */
  130429. export class NodeMaterial extends PushMaterial {
  130430. private static _BuildIdGenerator;
  130431. private _options;
  130432. private _vertexCompilationState;
  130433. private _fragmentCompilationState;
  130434. private _sharedData;
  130435. private _buildId;
  130436. private _buildWasSuccessful;
  130437. private _cachedWorldViewMatrix;
  130438. private _cachedWorldViewProjectionMatrix;
  130439. private _optimizers;
  130440. private _animationFrame;
  130441. /** Define the Url to load node editor script */
  130442. static EditorURL: string;
  130443. /** Define the Url to load snippets */
  130444. static SnippetUrl: string;
  130445. private BJSNODEMATERIALEDITOR;
  130446. /** Get the inspector from bundle or global */
  130447. private _getGlobalNodeMaterialEditor;
  130448. /**
  130449. * Gets or sets data used by visual editor
  130450. * @see https://nme.babylonjs.com
  130451. */
  130452. editorData: any;
  130453. /**
  130454. * 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)
  130455. */
  130456. ignoreAlpha: boolean;
  130457. /**
  130458. * Defines the maximum number of lights that can be used in the material
  130459. */
  130460. maxSimultaneousLights: number;
  130461. /**
  130462. * Observable raised when the material is built
  130463. */
  130464. onBuildObservable: Observable<NodeMaterial>;
  130465. /**
  130466. * Gets or sets the root nodes of the material vertex shader
  130467. */
  130468. _vertexOutputNodes: NodeMaterialBlock[];
  130469. /**
  130470. * Gets or sets the root nodes of the material fragment (pixel) shader
  130471. */
  130472. _fragmentOutputNodes: NodeMaterialBlock[];
  130473. /** Gets or sets options to control the node material overall behavior */
  130474. get options(): INodeMaterialOptions;
  130475. set options(options: INodeMaterialOptions);
  130476. /**
  130477. * Default configuration related to image processing available in the standard Material.
  130478. */
  130479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130480. /**
  130481. * Gets the image processing configuration used either in this material.
  130482. */
  130483. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130484. /**
  130485. * Sets the Default image processing configuration used either in the this material.
  130486. *
  130487. * If sets to null, the scene one is in use.
  130488. */
  130489. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130490. /**
  130491. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130492. */
  130493. attachedBlocks: NodeMaterialBlock[];
  130494. /**
  130495. * Create a new node based material
  130496. * @param name defines the material name
  130497. * @param scene defines the hosting scene
  130498. * @param options defines creation option
  130499. */
  130500. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130501. /**
  130502. * Gets the current class name of the material e.g. "NodeMaterial"
  130503. * @returns the class name
  130504. */
  130505. getClassName(): string;
  130506. /**
  130507. * Keep track of the image processing observer to allow dispose and replace.
  130508. */
  130509. private _imageProcessingObserver;
  130510. /**
  130511. * Attaches a new image processing configuration to the Standard Material.
  130512. * @param configuration
  130513. */
  130514. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130515. /**
  130516. * Get a block by its name
  130517. * @param name defines the name of the block to retrieve
  130518. * @returns the required block or null if not found
  130519. */
  130520. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130521. /**
  130522. * Get a block by its name
  130523. * @param predicate defines the predicate used to find the good candidate
  130524. * @returns the required block or null if not found
  130525. */
  130526. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130527. /**
  130528. * Get an input block by its name
  130529. * @param predicate defines the predicate used to find the good candidate
  130530. * @returns the required input block or null if not found
  130531. */
  130532. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130533. /**
  130534. * Gets the list of input blocks attached to this material
  130535. * @returns an array of InputBlocks
  130536. */
  130537. getInputBlocks(): InputBlock[];
  130538. /**
  130539. * Adds a new optimizer to the list of optimizers
  130540. * @param optimizer defines the optimizers to add
  130541. * @returns the current material
  130542. */
  130543. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130544. /**
  130545. * Remove an optimizer from the list of optimizers
  130546. * @param optimizer defines the optimizers to remove
  130547. * @returns the current material
  130548. */
  130549. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130550. /**
  130551. * Add a new block to the list of output nodes
  130552. * @param node defines the node to add
  130553. * @returns the current material
  130554. */
  130555. addOutputNode(node: NodeMaterialBlock): this;
  130556. /**
  130557. * Remove a block from the list of root nodes
  130558. * @param node defines the node to remove
  130559. * @returns the current material
  130560. */
  130561. removeOutputNode(node: NodeMaterialBlock): this;
  130562. private _addVertexOutputNode;
  130563. private _removeVertexOutputNode;
  130564. private _addFragmentOutputNode;
  130565. private _removeFragmentOutputNode;
  130566. /**
  130567. * Specifies if the material will require alpha blending
  130568. * @returns a boolean specifying if alpha blending is needed
  130569. */
  130570. needAlphaBlending(): boolean;
  130571. /**
  130572. * Specifies if this material should be rendered in alpha test mode
  130573. * @returns a boolean specifying if an alpha test is needed.
  130574. */
  130575. needAlphaTesting(): boolean;
  130576. private _initializeBlock;
  130577. private _resetDualBlocks;
  130578. /**
  130579. * Remove a block from the current node material
  130580. * @param block defines the block to remove
  130581. */
  130582. removeBlock(block: NodeMaterialBlock): void;
  130583. /**
  130584. * Build the material and generates the inner effect
  130585. * @param verbose defines if the build should log activity
  130586. */
  130587. build(verbose?: boolean): void;
  130588. /**
  130589. * Runs an otpimization phase to try to improve the shader code
  130590. */
  130591. optimize(): void;
  130592. private _prepareDefinesForAttributes;
  130593. /**
  130594. * Get if the submesh is ready to be used and all its information available.
  130595. * Child classes can use it to update shaders
  130596. * @param mesh defines the mesh to check
  130597. * @param subMesh defines which submesh to check
  130598. * @param useInstances specifies that instances should be used
  130599. * @returns a boolean indicating that the submesh is ready or not
  130600. */
  130601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130602. /**
  130603. * Get a string representing the shaders built by the current node graph
  130604. */
  130605. get compiledShaders(): string;
  130606. /**
  130607. * Binds the world matrix to the material
  130608. * @param world defines the world transformation matrix
  130609. */
  130610. bindOnlyWorldMatrix(world: Matrix): void;
  130611. /**
  130612. * Binds the submesh to this material by preparing the effect and shader to draw
  130613. * @param world defines the world transformation matrix
  130614. * @param mesh defines the mesh containing the submesh
  130615. * @param subMesh defines the submesh to bind the material to
  130616. */
  130617. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130618. /**
  130619. * Gets the active textures from the material
  130620. * @returns an array of textures
  130621. */
  130622. getActiveTextures(): BaseTexture[];
  130623. /**
  130624. * Gets the list of texture blocks
  130625. * @returns an array of texture blocks
  130626. */
  130627. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130628. /**
  130629. * Specifies if the material uses a texture
  130630. * @param texture defines the texture to check against the material
  130631. * @returns a boolean specifying if the material uses the texture
  130632. */
  130633. hasTexture(texture: BaseTexture): boolean;
  130634. /**
  130635. * Disposes the material
  130636. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130637. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130638. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130639. */
  130640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130641. /** Creates the node editor window. */
  130642. private _createNodeEditor;
  130643. /**
  130644. * Launch the node material editor
  130645. * @param config Define the configuration of the editor
  130646. * @return a promise fulfilled when the node editor is visible
  130647. */
  130648. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130649. /**
  130650. * Clear the current material
  130651. */
  130652. clear(): void;
  130653. /**
  130654. * Clear the current material and set it to a default state
  130655. */
  130656. setToDefault(): void;
  130657. /**
  130658. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130659. * @param url defines the url to load from
  130660. * @returns a promise that will fullfil when the material is fully loaded
  130661. */
  130662. loadAsync(url: string): Promise<void>;
  130663. private _gatherBlocks;
  130664. /**
  130665. * Generate a string containing the code declaration required to create an equivalent of this material
  130666. * @returns a string
  130667. */
  130668. generateCode(): string;
  130669. /**
  130670. * Serializes this material in a JSON representation
  130671. * @returns the serialized material object
  130672. */
  130673. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130674. private _restoreConnections;
  130675. /**
  130676. * Clear the current graph and load a new one from a serialization object
  130677. * @param source defines the JSON representation of the material
  130678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130679. */
  130680. loadFromSerialization(source: any, rootUrl?: string): void;
  130681. /**
  130682. * Creates a node material from parsed material data
  130683. * @param source defines the JSON representation of the material
  130684. * @param scene defines the hosting scene
  130685. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130686. * @returns a new node material
  130687. */
  130688. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130689. /**
  130690. * Creates a node material from a snippet saved in a remote file
  130691. * @param name defines the name of the material to create
  130692. * @param url defines the url to load from
  130693. * @param scene defines the hosting scene
  130694. * @returns a promise that will resolve to the new node material
  130695. */
  130696. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130697. /**
  130698. * Creates a node material from a snippet saved by the node material editor
  130699. * @param snippetId defines the snippet to load
  130700. * @param scene defines the hosting scene
  130701. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130702. * @returns a promise that will resolve to the new node material
  130703. */
  130704. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130705. /**
  130706. * Creates a new node material set to default basic configuration
  130707. * @param name defines the name of the material
  130708. * @param scene defines the hosting scene
  130709. * @returns a new NodeMaterial
  130710. */
  130711. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130712. }
  130713. }
  130714. declare module BABYLON {
  130715. /**
  130716. * Block used to read a texture from a sampler
  130717. */
  130718. export class TextureBlock extends NodeMaterialBlock {
  130719. private _defineName;
  130720. private _linearDefineName;
  130721. private _tempTextureRead;
  130722. private _samplerName;
  130723. private _transformedUVName;
  130724. private _textureTransformName;
  130725. private _textureInfoName;
  130726. private _mainUVName;
  130727. private _mainUVDefineName;
  130728. /**
  130729. * Gets or sets the texture associated with the node
  130730. */
  130731. texture: Nullable<Texture>;
  130732. /**
  130733. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130734. */
  130735. convertToGammaSpace: boolean;
  130736. /**
  130737. * Create a new TextureBlock
  130738. * @param name defines the block name
  130739. */
  130740. constructor(name: string);
  130741. /**
  130742. * Gets the current class name
  130743. * @returns the class name
  130744. */
  130745. getClassName(): string;
  130746. /**
  130747. * Gets the uv input component
  130748. */
  130749. get uv(): NodeMaterialConnectionPoint;
  130750. /**
  130751. * Gets the rgba output component
  130752. */
  130753. get rgba(): NodeMaterialConnectionPoint;
  130754. /**
  130755. * Gets the rgb output component
  130756. */
  130757. get rgb(): NodeMaterialConnectionPoint;
  130758. /**
  130759. * Gets the r output component
  130760. */
  130761. get r(): NodeMaterialConnectionPoint;
  130762. /**
  130763. * Gets the g output component
  130764. */
  130765. get g(): NodeMaterialConnectionPoint;
  130766. /**
  130767. * Gets the b output component
  130768. */
  130769. get b(): NodeMaterialConnectionPoint;
  130770. /**
  130771. * Gets the a output component
  130772. */
  130773. get a(): NodeMaterialConnectionPoint;
  130774. get target(): NodeMaterialBlockTargets;
  130775. autoConfigure(material: NodeMaterial): void;
  130776. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130778. isReady(): boolean;
  130779. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130780. private get _isMixed();
  130781. private _injectVertexCode;
  130782. private _writeTextureRead;
  130783. private _writeOutput;
  130784. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130785. protected _dumpPropertiesCode(): string;
  130786. serialize(): any;
  130787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130788. }
  130789. }
  130790. declare module BABYLON {
  130791. /**
  130792. * Class used to store shared data between 2 NodeMaterialBuildState
  130793. */
  130794. export class NodeMaterialBuildStateSharedData {
  130795. /**
  130796. * Gets the list of emitted varyings
  130797. */
  130798. temps: string[];
  130799. /**
  130800. * Gets the list of emitted varyings
  130801. */
  130802. varyings: string[];
  130803. /**
  130804. * Gets the varying declaration string
  130805. */
  130806. varyingDeclaration: string;
  130807. /**
  130808. * Input blocks
  130809. */
  130810. inputBlocks: InputBlock[];
  130811. /**
  130812. * Input blocks
  130813. */
  130814. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130815. /**
  130816. * Bindable blocks (Blocks that need to set data to the effect)
  130817. */
  130818. bindableBlocks: NodeMaterialBlock[];
  130819. /**
  130820. * List of blocks that can provide a compilation fallback
  130821. */
  130822. blocksWithFallbacks: NodeMaterialBlock[];
  130823. /**
  130824. * List of blocks that can provide a define update
  130825. */
  130826. blocksWithDefines: NodeMaterialBlock[];
  130827. /**
  130828. * List of blocks that can provide a repeatable content
  130829. */
  130830. repeatableContentBlocks: NodeMaterialBlock[];
  130831. /**
  130832. * List of blocks that can provide a dynamic list of uniforms
  130833. */
  130834. dynamicUniformBlocks: NodeMaterialBlock[];
  130835. /**
  130836. * List of blocks that can block the isReady function for the material
  130837. */
  130838. blockingBlocks: NodeMaterialBlock[];
  130839. /**
  130840. * Gets the list of animated inputs
  130841. */
  130842. animatedInputs: InputBlock[];
  130843. /**
  130844. * Build Id used to avoid multiple recompilations
  130845. */
  130846. buildId: number;
  130847. /** List of emitted variables */
  130848. variableNames: {
  130849. [key: string]: number;
  130850. };
  130851. /** List of emitted defines */
  130852. defineNames: {
  130853. [key: string]: number;
  130854. };
  130855. /** Should emit comments? */
  130856. emitComments: boolean;
  130857. /** Emit build activity */
  130858. verbose: boolean;
  130859. /** Gets or sets the hosting scene */
  130860. scene: Scene;
  130861. /**
  130862. * Gets the compilation hints emitted at compilation time
  130863. */
  130864. hints: {
  130865. needWorldViewMatrix: boolean;
  130866. needWorldViewProjectionMatrix: boolean;
  130867. needAlphaBlending: boolean;
  130868. needAlphaTesting: boolean;
  130869. };
  130870. /**
  130871. * List of compilation checks
  130872. */
  130873. checks: {
  130874. emitVertex: boolean;
  130875. emitFragment: boolean;
  130876. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130877. };
  130878. /** Creates a new shared data */
  130879. constructor();
  130880. /**
  130881. * Emits console errors and exceptions if there is a failing check
  130882. */
  130883. emitErrors(): void;
  130884. }
  130885. }
  130886. declare module BABYLON {
  130887. /**
  130888. * Class used to store node based material build state
  130889. */
  130890. export class NodeMaterialBuildState {
  130891. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130892. supportUniformBuffers: boolean;
  130893. /**
  130894. * Gets the list of emitted attributes
  130895. */
  130896. attributes: string[];
  130897. /**
  130898. * Gets the list of emitted uniforms
  130899. */
  130900. uniforms: string[];
  130901. /**
  130902. * Gets the list of emitted constants
  130903. */
  130904. constants: string[];
  130905. /**
  130906. * Gets the list of emitted samplers
  130907. */
  130908. samplers: string[];
  130909. /**
  130910. * Gets the list of emitted functions
  130911. */
  130912. functions: {
  130913. [key: string]: string;
  130914. };
  130915. /**
  130916. * Gets the list of emitted extensions
  130917. */
  130918. extensions: {
  130919. [key: string]: string;
  130920. };
  130921. /**
  130922. * Gets the target of the compilation state
  130923. */
  130924. target: NodeMaterialBlockTargets;
  130925. /**
  130926. * Gets the list of emitted counters
  130927. */
  130928. counters: {
  130929. [key: string]: number;
  130930. };
  130931. /**
  130932. * Shared data between multiple NodeMaterialBuildState instances
  130933. */
  130934. sharedData: NodeMaterialBuildStateSharedData;
  130935. /** @hidden */
  130936. _vertexState: NodeMaterialBuildState;
  130937. /** @hidden */
  130938. _attributeDeclaration: string;
  130939. /** @hidden */
  130940. _uniformDeclaration: string;
  130941. /** @hidden */
  130942. _constantDeclaration: string;
  130943. /** @hidden */
  130944. _samplerDeclaration: string;
  130945. /** @hidden */
  130946. _varyingTransfer: string;
  130947. private _repeatableContentAnchorIndex;
  130948. /** @hidden */
  130949. _builtCompilationString: string;
  130950. /**
  130951. * Gets the emitted compilation strings
  130952. */
  130953. compilationString: string;
  130954. /**
  130955. * Finalize the compilation strings
  130956. * @param state defines the current compilation state
  130957. */
  130958. finalize(state: NodeMaterialBuildState): void;
  130959. /** @hidden */
  130960. get _repeatableContentAnchor(): string;
  130961. /** @hidden */
  130962. _getFreeVariableName(prefix: string): string;
  130963. /** @hidden */
  130964. _getFreeDefineName(prefix: string): string;
  130965. /** @hidden */
  130966. _excludeVariableName(name: string): void;
  130967. /** @hidden */
  130968. _emit2DSampler(name: string): void;
  130969. /** @hidden */
  130970. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130971. /** @hidden */
  130972. _emitExtension(name: string, extension: string): void;
  130973. /** @hidden */
  130974. _emitFunction(name: string, code: string, comments: string): void;
  130975. /** @hidden */
  130976. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130977. replaceStrings?: {
  130978. search: RegExp;
  130979. replace: string;
  130980. }[];
  130981. repeatKey?: string;
  130982. }): string;
  130983. /** @hidden */
  130984. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130985. repeatKey?: string;
  130986. removeAttributes?: boolean;
  130987. removeUniforms?: boolean;
  130988. removeVaryings?: boolean;
  130989. removeIfDef?: boolean;
  130990. replaceStrings?: {
  130991. search: RegExp;
  130992. replace: string;
  130993. }[];
  130994. }, storeKey?: string): void;
  130995. /** @hidden */
  130996. _registerTempVariable(name: string): boolean;
  130997. /** @hidden */
  130998. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130999. /** @hidden */
  131000. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  131001. /** @hidden */
  131002. _emitFloat(value: number): string;
  131003. }
  131004. }
  131005. declare module BABYLON {
  131006. /**
  131007. * Defines a block that can be used inside a node based material
  131008. */
  131009. export class NodeMaterialBlock {
  131010. private _buildId;
  131011. private _buildTarget;
  131012. private _target;
  131013. private _isFinalMerger;
  131014. private _isInput;
  131015. protected _isUnique: boolean;
  131016. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  131017. inputsAreExclusive: boolean;
  131018. /** @hidden */
  131019. _codeVariableName: string;
  131020. /** @hidden */
  131021. _inputs: NodeMaterialConnectionPoint[];
  131022. /** @hidden */
  131023. _outputs: NodeMaterialConnectionPoint[];
  131024. /** @hidden */
  131025. _preparationId: number;
  131026. /**
  131027. * Gets or sets the name of the block
  131028. */
  131029. name: string;
  131030. /**
  131031. * Gets or sets the unique id of the node
  131032. */
  131033. uniqueId: number;
  131034. /**
  131035. * Gets or sets the comments associated with this block
  131036. */
  131037. comments: string;
  131038. /**
  131039. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131040. */
  131041. get isUnique(): boolean;
  131042. /**
  131043. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131044. */
  131045. get isFinalMerger(): boolean;
  131046. /**
  131047. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131048. */
  131049. get isInput(): boolean;
  131050. /**
  131051. * Gets or sets the build Id
  131052. */
  131053. get buildId(): number;
  131054. set buildId(value: number);
  131055. /**
  131056. * Gets or sets the target of the block
  131057. */
  131058. get target(): NodeMaterialBlockTargets;
  131059. set target(value: NodeMaterialBlockTargets);
  131060. /**
  131061. * Gets the list of input points
  131062. */
  131063. get inputs(): NodeMaterialConnectionPoint[];
  131064. /** Gets the list of output points */
  131065. get outputs(): NodeMaterialConnectionPoint[];
  131066. /**
  131067. * Find an input by its name
  131068. * @param name defines the name of the input to look for
  131069. * @returns the input or null if not found
  131070. */
  131071. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131072. /**
  131073. * Find an output by its name
  131074. * @param name defines the name of the outputto look for
  131075. * @returns the output or null if not found
  131076. */
  131077. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131078. /**
  131079. * Creates a new NodeMaterialBlock
  131080. * @param name defines the block name
  131081. * @param target defines the target of that block (Vertex by default)
  131082. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131083. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131084. */
  131085. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131086. /**
  131087. * Initialize the block and prepare the context for build
  131088. * @param state defines the state that will be used for the build
  131089. */
  131090. initialize(state: NodeMaterialBuildState): void;
  131091. /**
  131092. * Bind data to effect. Will only be called for blocks with isBindable === true
  131093. * @param effect defines the effect to bind data to
  131094. * @param nodeMaterial defines the hosting NodeMaterial
  131095. * @param mesh defines the mesh that will be rendered
  131096. */
  131097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131098. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131099. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131100. protected _writeFloat(value: number): string;
  131101. /**
  131102. * Gets the current class name e.g. "NodeMaterialBlock"
  131103. * @returns the class name
  131104. */
  131105. getClassName(): string;
  131106. /**
  131107. * Register a new input. Must be called inside a block constructor
  131108. * @param name defines the connection point name
  131109. * @param type defines the connection point type
  131110. * @param isOptional defines a boolean indicating that this input can be omitted
  131111. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131112. * @returns the current block
  131113. */
  131114. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131115. /**
  131116. * Register a new output. Must be called inside a block constructor
  131117. * @param name defines the connection point name
  131118. * @param type defines the connection point type
  131119. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131120. * @returns the current block
  131121. */
  131122. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131123. /**
  131124. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131125. * @param forOutput defines an optional connection point to check compatibility with
  131126. * @returns the first available input or null
  131127. */
  131128. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131129. /**
  131130. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131131. * @param forBlock defines an optional block to check compatibility with
  131132. * @returns the first available input or null
  131133. */
  131134. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131135. /**
  131136. * Gets the sibling of the given output
  131137. * @param current defines the current output
  131138. * @returns the next output in the list or null
  131139. */
  131140. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131141. /**
  131142. * Connect current block with another block
  131143. * @param other defines the block to connect with
  131144. * @param options define the various options to help pick the right connections
  131145. * @returns the current block
  131146. */
  131147. connectTo(other: NodeMaterialBlock, options?: {
  131148. input?: string;
  131149. output?: string;
  131150. outputSwizzle?: string;
  131151. }): this | undefined;
  131152. protected _buildBlock(state: NodeMaterialBuildState): void;
  131153. /**
  131154. * Add uniforms, samplers and uniform buffers at compilation time
  131155. * @param state defines the state to update
  131156. * @param nodeMaterial defines the node material requesting the update
  131157. * @param defines defines the material defines to update
  131158. * @param uniformBuffers defines the list of uniform buffer names
  131159. */
  131160. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131161. /**
  131162. * Add potential fallbacks if shader compilation fails
  131163. * @param mesh defines the mesh to be rendered
  131164. * @param fallbacks defines the current prioritized list of fallbacks
  131165. */
  131166. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131167. /**
  131168. * Initialize defines for shader compilation
  131169. * @param mesh defines the mesh to be rendered
  131170. * @param nodeMaterial defines the node material requesting the update
  131171. * @param defines defines the material defines to update
  131172. * @param useInstances specifies that instances should be used
  131173. */
  131174. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131175. /**
  131176. * Update defines for shader compilation
  131177. * @param mesh defines the mesh to be rendered
  131178. * @param nodeMaterial defines the node material requesting the update
  131179. * @param defines defines the material defines to update
  131180. * @param useInstances specifies that instances should be used
  131181. */
  131182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131183. /**
  131184. * Lets the block try to connect some inputs automatically
  131185. * @param material defines the hosting NodeMaterial
  131186. */
  131187. autoConfigure(material: NodeMaterial): void;
  131188. /**
  131189. * Function called when a block is declared as repeatable content generator
  131190. * @param vertexShaderState defines the current compilation state for the vertex shader
  131191. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131192. * @param mesh defines the mesh to be rendered
  131193. * @param defines defines the material defines to update
  131194. */
  131195. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131196. /**
  131197. * Checks if the block is ready
  131198. * @param mesh defines the mesh to be rendered
  131199. * @param nodeMaterial defines the node material requesting the update
  131200. * @param defines defines the material defines to update
  131201. * @param useInstances specifies that instances should be used
  131202. * @returns true if the block is ready
  131203. */
  131204. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131205. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131206. private _processBuild;
  131207. /**
  131208. * Compile the current node and generate the shader code
  131209. * @param state defines the current compilation state (uniforms, samplers, current string)
  131210. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131211. * @returns true if already built
  131212. */
  131213. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131214. protected _inputRename(name: string): string;
  131215. protected _outputRename(name: string): string;
  131216. protected _dumpPropertiesCode(): string;
  131217. /** @hidden */
  131218. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131219. /** @hidden */
  131220. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131221. /**
  131222. * Clone the current block to a new identical block
  131223. * @param scene defines the hosting scene
  131224. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131225. * @returns a copy of the current block
  131226. */
  131227. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131228. /**
  131229. * Serializes this block in a JSON representation
  131230. * @returns the serialized block object
  131231. */
  131232. serialize(): any;
  131233. /** @hidden */
  131234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131235. /**
  131236. * Release resources
  131237. */
  131238. dispose(): void;
  131239. }
  131240. }
  131241. declare module BABYLON {
  131242. /**
  131243. * Enum defining the type of animations supported by InputBlock
  131244. */
  131245. export enum AnimatedInputBlockTypes {
  131246. /** No animation */
  131247. None = 0,
  131248. /** Time based animation. Will only work for floats */
  131249. Time = 1
  131250. }
  131251. }
  131252. declare module BABYLON {
  131253. /**
  131254. * Block used to expose an input value
  131255. */
  131256. export class InputBlock extends NodeMaterialBlock {
  131257. private _mode;
  131258. private _associatedVariableName;
  131259. private _storedValue;
  131260. private _valueCallback;
  131261. private _type;
  131262. private _animationType;
  131263. /** Gets or set a value used to limit the range of float values */
  131264. min: number;
  131265. /** Gets or set a value used to limit the range of float values */
  131266. max: number;
  131267. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131268. isBoolean: boolean;
  131269. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131270. matrixMode: number;
  131271. /** @hidden */
  131272. _systemValue: Nullable<NodeMaterialSystemValues>;
  131273. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131274. visibleInInspector: boolean;
  131275. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131276. isConstant: boolean;
  131277. /** Gets or sets the group to use to display this block in the Inspector */
  131278. groupInInspector: string;
  131279. /** Gets an observable raised when the value is changed */
  131280. onValueChangedObservable: Observable<InputBlock>;
  131281. /**
  131282. * Gets or sets the connection point type (default is float)
  131283. */
  131284. get type(): NodeMaterialBlockConnectionPointTypes;
  131285. /**
  131286. * Creates a new InputBlock
  131287. * @param name defines the block name
  131288. * @param target defines the target of that block (Vertex by default)
  131289. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131290. */
  131291. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131292. /**
  131293. * Gets the output component
  131294. */
  131295. get output(): NodeMaterialConnectionPoint;
  131296. /**
  131297. * Set the source of this connection point to a vertex attribute
  131298. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131299. * @returns the current connection point
  131300. */
  131301. setAsAttribute(attributeName?: string): InputBlock;
  131302. /**
  131303. * Set the source of this connection point to a system value
  131304. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131305. * @returns the current connection point
  131306. */
  131307. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131308. /**
  131309. * Gets or sets the value of that point.
  131310. * Please note that this value will be ignored if valueCallback is defined
  131311. */
  131312. get value(): any;
  131313. set value(value: any);
  131314. /**
  131315. * Gets or sets a callback used to get the value of that point.
  131316. * Please note that setting this value will force the connection point to ignore the value property
  131317. */
  131318. get valueCallback(): () => any;
  131319. set valueCallback(value: () => any);
  131320. /**
  131321. * Gets or sets the associated variable name in the shader
  131322. */
  131323. get associatedVariableName(): string;
  131324. set associatedVariableName(value: string);
  131325. /** Gets or sets the type of animation applied to the input */
  131326. get animationType(): AnimatedInputBlockTypes;
  131327. set animationType(value: AnimatedInputBlockTypes);
  131328. /**
  131329. * Gets a boolean indicating that this connection point not defined yet
  131330. */
  131331. get isUndefined(): boolean;
  131332. /**
  131333. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131334. * In this case the connection point name must be the name of the uniform to use.
  131335. * Can only be set on inputs
  131336. */
  131337. get isUniform(): boolean;
  131338. set isUniform(value: boolean);
  131339. /**
  131340. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131341. * In this case the connection point name must be the name of the attribute to use
  131342. * Can only be set on inputs
  131343. */
  131344. get isAttribute(): boolean;
  131345. set isAttribute(value: boolean);
  131346. /**
  131347. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131348. * Can only be set on exit points
  131349. */
  131350. get isVarying(): boolean;
  131351. set isVarying(value: boolean);
  131352. /**
  131353. * Gets a boolean indicating that the current connection point is a system value
  131354. */
  131355. get isSystemValue(): boolean;
  131356. /**
  131357. * Gets or sets the current well known value or null if not defined as a system value
  131358. */
  131359. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131360. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131361. /**
  131362. * Gets the current class name
  131363. * @returns the class name
  131364. */
  131365. getClassName(): string;
  131366. /**
  131367. * Animate the input if animationType !== None
  131368. * @param scene defines the rendering scene
  131369. */
  131370. animate(scene: Scene): void;
  131371. private _emitDefine;
  131372. initialize(state: NodeMaterialBuildState): void;
  131373. /**
  131374. * Set the input block to its default value (based on its type)
  131375. */
  131376. setDefaultValue(): void;
  131377. private _emitConstant;
  131378. private _emit;
  131379. /** @hidden */
  131380. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131381. /** @hidden */
  131382. _transmit(effect: Effect, scene: Scene): void;
  131383. protected _buildBlock(state: NodeMaterialBuildState): void;
  131384. protected _dumpPropertiesCode(): string;
  131385. dispose(): void;
  131386. serialize(): any;
  131387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131388. }
  131389. }
  131390. declare module BABYLON {
  131391. /**
  131392. * Enum used to define the compatibility state between two connection points
  131393. */
  131394. export enum NodeMaterialConnectionPointCompatibilityStates {
  131395. /** Points are compatibles */
  131396. Compatible = 0,
  131397. /** Points are incompatible because of their types */
  131398. TypeIncompatible = 1,
  131399. /** Points are incompatible because of their targets (vertex vs fragment) */
  131400. TargetIncompatible = 2
  131401. }
  131402. /**
  131403. * Defines the direction of a connection point
  131404. */
  131405. export enum NodeMaterialConnectionPointDirection {
  131406. /** Input */
  131407. Input = 0,
  131408. /** Output */
  131409. Output = 1
  131410. }
  131411. /**
  131412. * Defines a connection point for a block
  131413. */
  131414. export class NodeMaterialConnectionPoint {
  131415. /** @hidden */
  131416. _ownerBlock: NodeMaterialBlock;
  131417. /** @hidden */
  131418. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131419. private _endpoints;
  131420. private _associatedVariableName;
  131421. private _direction;
  131422. /** @hidden */
  131423. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131424. /** @hidden */
  131425. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131426. private _type;
  131427. /** @hidden */
  131428. _enforceAssociatedVariableName: boolean;
  131429. /** Gets the direction of the point */
  131430. get direction(): NodeMaterialConnectionPointDirection;
  131431. /**
  131432. * Gets or sets the additional types supported by this connection point
  131433. */
  131434. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131435. /**
  131436. * Gets or sets the additional types excluded by this connection point
  131437. */
  131438. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131439. /**
  131440. * Observable triggered when this point is connected
  131441. */
  131442. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131443. /**
  131444. * Gets or sets the associated variable name in the shader
  131445. */
  131446. get associatedVariableName(): string;
  131447. set associatedVariableName(value: string);
  131448. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131449. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131450. /**
  131451. * Gets or sets the connection point type (default is float)
  131452. */
  131453. get type(): NodeMaterialBlockConnectionPointTypes;
  131454. set type(value: NodeMaterialBlockConnectionPointTypes);
  131455. /**
  131456. * Gets or sets the connection point name
  131457. */
  131458. name: string;
  131459. /**
  131460. * Gets or sets a boolean indicating that this connection point can be omitted
  131461. */
  131462. isOptional: boolean;
  131463. /**
  131464. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131465. */
  131466. define: string;
  131467. /** @hidden */
  131468. _prioritizeVertex: boolean;
  131469. private _target;
  131470. /** Gets or sets the target of that connection point */
  131471. get target(): NodeMaterialBlockTargets;
  131472. set target(value: NodeMaterialBlockTargets);
  131473. /**
  131474. * Gets a boolean indicating that the current point is connected
  131475. */
  131476. get isConnected(): boolean;
  131477. /**
  131478. * Gets a boolean indicating that the current point is connected to an input block
  131479. */
  131480. get isConnectedToInputBlock(): boolean;
  131481. /**
  131482. * Gets a the connected input block (if any)
  131483. */
  131484. get connectInputBlock(): Nullable<InputBlock>;
  131485. /** Get the other side of the connection (if any) */
  131486. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131487. /** Get the block that owns this connection point */
  131488. get ownerBlock(): NodeMaterialBlock;
  131489. /** Get the block connected on the other side of this connection (if any) */
  131490. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131491. /** Get the block connected on the endpoints of this connection (if any) */
  131492. get connectedBlocks(): Array<NodeMaterialBlock>;
  131493. /** Gets the list of connected endpoints */
  131494. get endpoints(): NodeMaterialConnectionPoint[];
  131495. /** Gets a boolean indicating if that output point is connected to at least one input */
  131496. get hasEndpoints(): boolean;
  131497. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131498. get isConnectedInVertexShader(): boolean;
  131499. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131500. get isConnectedInFragmentShader(): boolean;
  131501. /**
  131502. * Creates a new connection point
  131503. * @param name defines the connection point name
  131504. * @param ownerBlock defines the block hosting this connection point
  131505. * @param direction defines the direction of the connection point
  131506. */
  131507. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131508. /**
  131509. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131510. * @returns the class name
  131511. */
  131512. getClassName(): string;
  131513. /**
  131514. * Gets a boolean indicating if the current point can be connected to another point
  131515. * @param connectionPoint defines the other connection point
  131516. * @returns a boolean
  131517. */
  131518. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131519. /**
  131520. * Gets a number indicating if the current point can be connected to another point
  131521. * @param connectionPoint defines the other connection point
  131522. * @returns a number defining the compatibility state
  131523. */
  131524. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131525. /**
  131526. * Connect this point to another connection point
  131527. * @param connectionPoint defines the other connection point
  131528. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131529. * @returns the current connection point
  131530. */
  131531. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131532. /**
  131533. * Disconnect this point from one of his endpoint
  131534. * @param endpoint defines the other connection point
  131535. * @returns the current connection point
  131536. */
  131537. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131538. /**
  131539. * Serializes this point in a JSON representation
  131540. * @returns the serialized point object
  131541. */
  131542. serialize(): any;
  131543. /**
  131544. * Release resources
  131545. */
  131546. dispose(): void;
  131547. }
  131548. }
  131549. declare module BABYLON {
  131550. /**
  131551. * Block used to add support for vertex skinning (bones)
  131552. */
  131553. export class BonesBlock extends NodeMaterialBlock {
  131554. /**
  131555. * Creates a new BonesBlock
  131556. * @param name defines the block name
  131557. */
  131558. constructor(name: string);
  131559. /**
  131560. * Initialize the block and prepare the context for build
  131561. * @param state defines the state that will be used for the build
  131562. */
  131563. initialize(state: NodeMaterialBuildState): void;
  131564. /**
  131565. * Gets the current class name
  131566. * @returns the class name
  131567. */
  131568. getClassName(): string;
  131569. /**
  131570. * Gets the matrix indices input component
  131571. */
  131572. get matricesIndices(): NodeMaterialConnectionPoint;
  131573. /**
  131574. * Gets the matrix weights input component
  131575. */
  131576. get matricesWeights(): NodeMaterialConnectionPoint;
  131577. /**
  131578. * Gets the extra matrix indices input component
  131579. */
  131580. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131581. /**
  131582. * Gets the extra matrix weights input component
  131583. */
  131584. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131585. /**
  131586. * Gets the world input component
  131587. */
  131588. get world(): NodeMaterialConnectionPoint;
  131589. /**
  131590. * Gets the output component
  131591. */
  131592. get output(): NodeMaterialConnectionPoint;
  131593. autoConfigure(material: NodeMaterial): void;
  131594. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131596. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131597. protected _buildBlock(state: NodeMaterialBuildState): this;
  131598. }
  131599. }
  131600. declare module BABYLON {
  131601. /**
  131602. * Block used to add support for instances
  131603. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131604. */
  131605. export class InstancesBlock extends NodeMaterialBlock {
  131606. /**
  131607. * Creates a new InstancesBlock
  131608. * @param name defines the block name
  131609. */
  131610. constructor(name: string);
  131611. /**
  131612. * Gets the current class name
  131613. * @returns the class name
  131614. */
  131615. getClassName(): string;
  131616. /**
  131617. * Gets the first world row input component
  131618. */
  131619. get world0(): NodeMaterialConnectionPoint;
  131620. /**
  131621. * Gets the second world row input component
  131622. */
  131623. get world1(): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Gets the third world row input component
  131626. */
  131627. get world2(): NodeMaterialConnectionPoint;
  131628. /**
  131629. * Gets the forth world row input component
  131630. */
  131631. get world3(): NodeMaterialConnectionPoint;
  131632. /**
  131633. * Gets the world input component
  131634. */
  131635. get world(): NodeMaterialConnectionPoint;
  131636. /**
  131637. * Gets the output component
  131638. */
  131639. get output(): NodeMaterialConnectionPoint;
  131640. /**
  131641. * Gets the isntanceID component
  131642. */
  131643. get instanceID(): NodeMaterialConnectionPoint;
  131644. autoConfigure(material: NodeMaterial): void;
  131645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131646. protected _buildBlock(state: NodeMaterialBuildState): this;
  131647. }
  131648. }
  131649. declare module BABYLON {
  131650. /**
  131651. * Block used to add morph targets support to vertex shader
  131652. */
  131653. export class MorphTargetsBlock extends NodeMaterialBlock {
  131654. private _repeatableContentAnchor;
  131655. /**
  131656. * Create a new MorphTargetsBlock
  131657. * @param name defines the block name
  131658. */
  131659. constructor(name: string);
  131660. /**
  131661. * Gets the current class name
  131662. * @returns the class name
  131663. */
  131664. getClassName(): string;
  131665. /**
  131666. * Gets the position input component
  131667. */
  131668. get position(): NodeMaterialConnectionPoint;
  131669. /**
  131670. * Gets the normal input component
  131671. */
  131672. get normal(): NodeMaterialConnectionPoint;
  131673. /**
  131674. * Gets the tangent input component
  131675. */
  131676. get tangent(): NodeMaterialConnectionPoint;
  131677. /**
  131678. * Gets the tangent input component
  131679. */
  131680. get uv(): NodeMaterialConnectionPoint;
  131681. /**
  131682. * Gets the position output component
  131683. */
  131684. get positionOutput(): NodeMaterialConnectionPoint;
  131685. /**
  131686. * Gets the normal output component
  131687. */
  131688. get normalOutput(): NodeMaterialConnectionPoint;
  131689. /**
  131690. * Gets the tangent output component
  131691. */
  131692. get tangentOutput(): NodeMaterialConnectionPoint;
  131693. /**
  131694. * Gets the tangent output component
  131695. */
  131696. get uvOutput(): NodeMaterialConnectionPoint;
  131697. initialize(state: NodeMaterialBuildState): void;
  131698. autoConfigure(material: NodeMaterial): void;
  131699. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131700. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131701. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131702. protected _buildBlock(state: NodeMaterialBuildState): this;
  131703. }
  131704. }
  131705. declare module BABYLON {
  131706. /**
  131707. * Block used to get data information from a light
  131708. */
  131709. export class LightInformationBlock extends NodeMaterialBlock {
  131710. private _lightDataUniformName;
  131711. private _lightColorUniformName;
  131712. private _lightTypeDefineName;
  131713. /**
  131714. * Gets or sets the light associated with this block
  131715. */
  131716. light: Nullable<Light>;
  131717. /**
  131718. * Creates a new LightInformationBlock
  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 direction output component
  131733. */
  131734. get direction(): NodeMaterialConnectionPoint;
  131735. /**
  131736. * Gets the direction output component
  131737. */
  131738. get color(): NodeMaterialConnectionPoint;
  131739. /**
  131740. * Gets the direction output component
  131741. */
  131742. get intensity(): NodeMaterialConnectionPoint;
  131743. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131745. protected _buildBlock(state: NodeMaterialBuildState): this;
  131746. serialize(): any;
  131747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131748. }
  131749. }
  131750. declare module BABYLON {
  131751. /**
  131752. * Block used to add image processing support to fragment shader
  131753. */
  131754. export class ImageProcessingBlock extends NodeMaterialBlock {
  131755. /**
  131756. * Create a new ImageProcessingBlock
  131757. * @param name defines the block name
  131758. */
  131759. constructor(name: string);
  131760. /**
  131761. * Gets the current class name
  131762. * @returns the class name
  131763. */
  131764. getClassName(): string;
  131765. /**
  131766. * Gets the color input component
  131767. */
  131768. get color(): NodeMaterialConnectionPoint;
  131769. /**
  131770. * Gets the output component
  131771. */
  131772. get output(): NodeMaterialConnectionPoint;
  131773. /**
  131774. * Initialize the block and prepare the context for build
  131775. * @param state defines the state that will be used for the build
  131776. */
  131777. initialize(state: NodeMaterialBuildState): void;
  131778. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131781. protected _buildBlock(state: NodeMaterialBuildState): this;
  131782. }
  131783. }
  131784. declare module BABYLON {
  131785. /**
  131786. * Block used to pertub normals based on a normal map
  131787. */
  131788. export class PerturbNormalBlock extends NodeMaterialBlock {
  131789. private _tangentSpaceParameterName;
  131790. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131791. invertX: boolean;
  131792. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131793. invertY: boolean;
  131794. /**
  131795. * Create a new PerturbNormalBlock
  131796. * @param name defines the block name
  131797. */
  131798. constructor(name: string);
  131799. /**
  131800. * Gets the current class name
  131801. * @returns the class name
  131802. */
  131803. getClassName(): string;
  131804. /**
  131805. * Gets the world position input component
  131806. */
  131807. get worldPosition(): NodeMaterialConnectionPoint;
  131808. /**
  131809. * Gets the world normal input component
  131810. */
  131811. get worldNormal(): NodeMaterialConnectionPoint;
  131812. /**
  131813. * Gets the world tangent input component
  131814. */
  131815. get worldTangent(): NodeMaterialConnectionPoint;
  131816. /**
  131817. * Gets the uv input component
  131818. */
  131819. get uv(): NodeMaterialConnectionPoint;
  131820. /**
  131821. * Gets the normal map color input component
  131822. */
  131823. get normalMapColor(): NodeMaterialConnectionPoint;
  131824. /**
  131825. * Gets the strength input component
  131826. */
  131827. get strength(): NodeMaterialConnectionPoint;
  131828. /**
  131829. * Gets the output component
  131830. */
  131831. get output(): NodeMaterialConnectionPoint;
  131832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131834. autoConfigure(material: NodeMaterial): void;
  131835. protected _buildBlock(state: NodeMaterialBuildState): this;
  131836. protected _dumpPropertiesCode(): string;
  131837. serialize(): any;
  131838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131839. }
  131840. }
  131841. declare module BABYLON {
  131842. /**
  131843. * Block used to discard a pixel if a value is smaller than a cutoff
  131844. */
  131845. export class DiscardBlock extends NodeMaterialBlock {
  131846. /**
  131847. * Create a new DiscardBlock
  131848. * @param name defines the block name
  131849. */
  131850. constructor(name: string);
  131851. /**
  131852. * Gets the current class name
  131853. * @returns the class name
  131854. */
  131855. getClassName(): string;
  131856. /**
  131857. * Gets the color input component
  131858. */
  131859. get value(): NodeMaterialConnectionPoint;
  131860. /**
  131861. * Gets the cutoff input component
  131862. */
  131863. get cutoff(): NodeMaterialConnectionPoint;
  131864. protected _buildBlock(state: NodeMaterialBuildState): this;
  131865. }
  131866. }
  131867. declare module BABYLON {
  131868. /**
  131869. * Block used to test if the fragment shader is front facing
  131870. */
  131871. export class FrontFacingBlock extends NodeMaterialBlock {
  131872. /**
  131873. * Creates a new FrontFacingBlock
  131874. * @param name defines the block name
  131875. */
  131876. constructor(name: string);
  131877. /**
  131878. * Gets the current class name
  131879. * @returns the class name
  131880. */
  131881. getClassName(): string;
  131882. /**
  131883. * Gets the output component
  131884. */
  131885. get output(): NodeMaterialConnectionPoint;
  131886. protected _buildBlock(state: NodeMaterialBuildState): this;
  131887. }
  131888. }
  131889. declare module BABYLON {
  131890. /**
  131891. * Block used to get the derivative value on x and y of a given input
  131892. */
  131893. export class DerivativeBlock extends NodeMaterialBlock {
  131894. /**
  131895. * Create a new DerivativeBlock
  131896. * @param name defines the block name
  131897. */
  131898. constructor(name: string);
  131899. /**
  131900. * Gets the current class name
  131901. * @returns the class name
  131902. */
  131903. getClassName(): string;
  131904. /**
  131905. * Gets the input component
  131906. */
  131907. get input(): NodeMaterialConnectionPoint;
  131908. /**
  131909. * Gets the derivative output on x
  131910. */
  131911. get dx(): NodeMaterialConnectionPoint;
  131912. /**
  131913. * Gets the derivative output on y
  131914. */
  131915. get dy(): NodeMaterialConnectionPoint;
  131916. protected _buildBlock(state: NodeMaterialBuildState): this;
  131917. }
  131918. }
  131919. declare module BABYLON {
  131920. /**
  131921. * Block used to add support for scene fog
  131922. */
  131923. export class FogBlock extends NodeMaterialBlock {
  131924. private _fogDistanceName;
  131925. private _fogParameters;
  131926. /**
  131927. * Create a new FogBlock
  131928. * @param name defines the block name
  131929. */
  131930. constructor(name: string);
  131931. /**
  131932. * Gets the current class name
  131933. * @returns the class name
  131934. */
  131935. getClassName(): string;
  131936. /**
  131937. * Gets the world position input component
  131938. */
  131939. get worldPosition(): NodeMaterialConnectionPoint;
  131940. /**
  131941. * Gets the view input component
  131942. */
  131943. get view(): NodeMaterialConnectionPoint;
  131944. /**
  131945. * Gets the color input component
  131946. */
  131947. get input(): NodeMaterialConnectionPoint;
  131948. /**
  131949. * Gets the fog color input component
  131950. */
  131951. get fogColor(): NodeMaterialConnectionPoint;
  131952. /**
  131953. * Gets the output component
  131954. */
  131955. get output(): NodeMaterialConnectionPoint;
  131956. autoConfigure(material: NodeMaterial): void;
  131957. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131958. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131959. protected _buildBlock(state: NodeMaterialBuildState): this;
  131960. }
  131961. }
  131962. declare module BABYLON {
  131963. /**
  131964. * Block used to add light in the fragment shader
  131965. */
  131966. export class LightBlock extends NodeMaterialBlock {
  131967. private _lightId;
  131968. /**
  131969. * Gets or sets the light associated with this block
  131970. */
  131971. light: Nullable<Light>;
  131972. /**
  131973. * Create a new LightBlock
  131974. * @param name defines the block name
  131975. */
  131976. constructor(name: string);
  131977. /**
  131978. * Gets the current class name
  131979. * @returns the class name
  131980. */
  131981. getClassName(): string;
  131982. /**
  131983. * Gets the world position input component
  131984. */
  131985. get worldPosition(): NodeMaterialConnectionPoint;
  131986. /**
  131987. * Gets the world normal input component
  131988. */
  131989. get worldNormal(): NodeMaterialConnectionPoint;
  131990. /**
  131991. * Gets the camera (or eye) position component
  131992. */
  131993. get cameraPosition(): NodeMaterialConnectionPoint;
  131994. /**
  131995. * Gets the glossiness component
  131996. */
  131997. get glossiness(): NodeMaterialConnectionPoint;
  131998. /**
  131999. * Gets the glossinness power component
  132000. */
  132001. get glossPower(): NodeMaterialConnectionPoint;
  132002. /**
  132003. * Gets the diffuse color component
  132004. */
  132005. get diffuseColor(): NodeMaterialConnectionPoint;
  132006. /**
  132007. * Gets the specular color component
  132008. */
  132009. get specularColor(): NodeMaterialConnectionPoint;
  132010. /**
  132011. * Gets the diffuse output component
  132012. */
  132013. get diffuseOutput(): NodeMaterialConnectionPoint;
  132014. /**
  132015. * Gets the specular output component
  132016. */
  132017. get specularOutput(): NodeMaterialConnectionPoint;
  132018. /**
  132019. * Gets the shadow output component
  132020. */
  132021. get shadow(): NodeMaterialConnectionPoint;
  132022. autoConfigure(material: NodeMaterial): void;
  132023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132024. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132025. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132026. private _injectVertexCode;
  132027. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132028. serialize(): any;
  132029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132030. }
  132031. }
  132032. declare module BABYLON {
  132033. /**
  132034. * Block used to multiply 2 values
  132035. */
  132036. export class MultiplyBlock extends NodeMaterialBlock {
  132037. /**
  132038. * Creates a new MultiplyBlock
  132039. * @param name defines the block name
  132040. */
  132041. constructor(name: string);
  132042. /**
  132043. * Gets the current class name
  132044. * @returns the class name
  132045. */
  132046. getClassName(): string;
  132047. /**
  132048. * Gets the left operand input component
  132049. */
  132050. get left(): NodeMaterialConnectionPoint;
  132051. /**
  132052. * Gets the right operand input component
  132053. */
  132054. get right(): NodeMaterialConnectionPoint;
  132055. /**
  132056. * Gets the output component
  132057. */
  132058. get output(): NodeMaterialConnectionPoint;
  132059. protected _buildBlock(state: NodeMaterialBuildState): this;
  132060. }
  132061. }
  132062. declare module BABYLON {
  132063. /**
  132064. * Block used to add 2 vectors
  132065. */
  132066. export class AddBlock extends NodeMaterialBlock {
  132067. /**
  132068. * Creates a new AddBlock
  132069. * @param name defines the block name
  132070. */
  132071. constructor(name: string);
  132072. /**
  132073. * Gets the current class name
  132074. * @returns the class name
  132075. */
  132076. getClassName(): string;
  132077. /**
  132078. * Gets the left operand input component
  132079. */
  132080. get left(): NodeMaterialConnectionPoint;
  132081. /**
  132082. * Gets the right operand input component
  132083. */
  132084. get right(): NodeMaterialConnectionPoint;
  132085. /**
  132086. * Gets the output component
  132087. */
  132088. get output(): NodeMaterialConnectionPoint;
  132089. protected _buildBlock(state: NodeMaterialBuildState): this;
  132090. }
  132091. }
  132092. declare module BABYLON {
  132093. /**
  132094. * Block used to scale a vector by a float
  132095. */
  132096. export class ScaleBlock extends NodeMaterialBlock {
  132097. /**
  132098. * Creates a new ScaleBlock
  132099. * @param name defines the block name
  132100. */
  132101. constructor(name: string);
  132102. /**
  132103. * Gets the current class name
  132104. * @returns the class name
  132105. */
  132106. getClassName(): string;
  132107. /**
  132108. * Gets the input component
  132109. */
  132110. get input(): NodeMaterialConnectionPoint;
  132111. /**
  132112. * Gets the factor input component
  132113. */
  132114. get factor(): NodeMaterialConnectionPoint;
  132115. /**
  132116. * Gets the output component
  132117. */
  132118. get output(): NodeMaterialConnectionPoint;
  132119. protected _buildBlock(state: NodeMaterialBuildState): this;
  132120. }
  132121. }
  132122. declare module BABYLON {
  132123. /**
  132124. * Block used to clamp a float
  132125. */
  132126. export class ClampBlock extends NodeMaterialBlock {
  132127. /** Gets or sets the minimum range */
  132128. minimum: number;
  132129. /** Gets or sets the maximum range */
  132130. maximum: number;
  132131. /**
  132132. * Creates a new ClampBlock
  132133. * @param name defines the block name
  132134. */
  132135. constructor(name: string);
  132136. /**
  132137. * Gets the current class name
  132138. * @returns the class name
  132139. */
  132140. getClassName(): string;
  132141. /**
  132142. * Gets the value input component
  132143. */
  132144. get value(): NodeMaterialConnectionPoint;
  132145. /**
  132146. * Gets the output component
  132147. */
  132148. get output(): NodeMaterialConnectionPoint;
  132149. protected _buildBlock(state: NodeMaterialBuildState): this;
  132150. protected _dumpPropertiesCode(): string;
  132151. serialize(): any;
  132152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132153. }
  132154. }
  132155. declare module BABYLON {
  132156. /**
  132157. * Block used to apply a cross product between 2 vectors
  132158. */
  132159. export class CrossBlock extends NodeMaterialBlock {
  132160. /**
  132161. * Creates a new CrossBlock
  132162. * @param name defines the block name
  132163. */
  132164. constructor(name: string);
  132165. /**
  132166. * Gets the current class name
  132167. * @returns the class name
  132168. */
  132169. getClassName(): string;
  132170. /**
  132171. * Gets the left operand input component
  132172. */
  132173. get left(): NodeMaterialConnectionPoint;
  132174. /**
  132175. * Gets the right operand input component
  132176. */
  132177. get right(): NodeMaterialConnectionPoint;
  132178. /**
  132179. * Gets the output component
  132180. */
  132181. get output(): NodeMaterialConnectionPoint;
  132182. protected _buildBlock(state: NodeMaterialBuildState): this;
  132183. }
  132184. }
  132185. declare module BABYLON {
  132186. /**
  132187. * Block used to apply a dot product between 2 vectors
  132188. */
  132189. export class DotBlock extends NodeMaterialBlock {
  132190. /**
  132191. * Creates a new DotBlock
  132192. * @param name defines the block name
  132193. */
  132194. constructor(name: string);
  132195. /**
  132196. * Gets the current class name
  132197. * @returns the class name
  132198. */
  132199. getClassName(): string;
  132200. /**
  132201. * Gets the left operand input component
  132202. */
  132203. get left(): NodeMaterialConnectionPoint;
  132204. /**
  132205. * Gets the right operand input component
  132206. */
  132207. get right(): NodeMaterialConnectionPoint;
  132208. /**
  132209. * Gets the output component
  132210. */
  132211. get output(): NodeMaterialConnectionPoint;
  132212. protected _buildBlock(state: NodeMaterialBuildState): this;
  132213. }
  132214. }
  132215. declare module BABYLON {
  132216. /**
  132217. * Block used to remap a float from a range to a new one
  132218. */
  132219. export class RemapBlock extends NodeMaterialBlock {
  132220. /**
  132221. * Gets or sets the source range
  132222. */
  132223. sourceRange: Vector2;
  132224. /**
  132225. * Gets or sets the target range
  132226. */
  132227. targetRange: Vector2;
  132228. /**
  132229. * Creates a new RemapBlock
  132230. * @param name defines the block name
  132231. */
  132232. constructor(name: string);
  132233. /**
  132234. * Gets the current class name
  132235. * @returns the class name
  132236. */
  132237. getClassName(): string;
  132238. /**
  132239. * Gets the input component
  132240. */
  132241. get input(): NodeMaterialConnectionPoint;
  132242. /**
  132243. * Gets the source min input component
  132244. */
  132245. get sourceMin(): NodeMaterialConnectionPoint;
  132246. /**
  132247. * Gets the source max input component
  132248. */
  132249. get sourceMax(): NodeMaterialConnectionPoint;
  132250. /**
  132251. * Gets the target min input component
  132252. */
  132253. get targetMin(): NodeMaterialConnectionPoint;
  132254. /**
  132255. * Gets the target max input component
  132256. */
  132257. get targetMax(): NodeMaterialConnectionPoint;
  132258. /**
  132259. * Gets the output component
  132260. */
  132261. get output(): NodeMaterialConnectionPoint;
  132262. protected _buildBlock(state: NodeMaterialBuildState): this;
  132263. protected _dumpPropertiesCode(): string;
  132264. serialize(): any;
  132265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132266. }
  132267. }
  132268. declare module BABYLON {
  132269. /**
  132270. * Block used to normalize a vector
  132271. */
  132272. export class NormalizeBlock extends NodeMaterialBlock {
  132273. /**
  132274. * Creates a new NormalizeBlock
  132275. * @param name defines the block name
  132276. */
  132277. constructor(name: string);
  132278. /**
  132279. * Gets the current class name
  132280. * @returns the class name
  132281. */
  132282. getClassName(): string;
  132283. /**
  132284. * Gets the input component
  132285. */
  132286. get input(): NodeMaterialConnectionPoint;
  132287. /**
  132288. * Gets the output component
  132289. */
  132290. get output(): NodeMaterialConnectionPoint;
  132291. protected _buildBlock(state: NodeMaterialBuildState): this;
  132292. }
  132293. }
  132294. declare module BABYLON {
  132295. /**
  132296. * Operations supported by the Trigonometry block
  132297. */
  132298. export enum TrigonometryBlockOperations {
  132299. /** Cos */
  132300. Cos = 0,
  132301. /** Sin */
  132302. Sin = 1,
  132303. /** Abs */
  132304. Abs = 2,
  132305. /** Exp */
  132306. Exp = 3,
  132307. /** Exp2 */
  132308. Exp2 = 4,
  132309. /** Round */
  132310. Round = 5,
  132311. /** Floor */
  132312. Floor = 6,
  132313. /** Ceiling */
  132314. Ceiling = 7,
  132315. /** Square root */
  132316. Sqrt = 8,
  132317. /** Log */
  132318. Log = 9,
  132319. /** Tangent */
  132320. Tan = 10,
  132321. /** Arc tangent */
  132322. ArcTan = 11,
  132323. /** Arc cosinus */
  132324. ArcCos = 12,
  132325. /** Arc sinus */
  132326. ArcSin = 13,
  132327. /** Fraction */
  132328. Fract = 14,
  132329. /** Sign */
  132330. Sign = 15,
  132331. /** To radians (from degrees) */
  132332. Radians = 16,
  132333. /** To degrees (from radians) */
  132334. Degrees = 17
  132335. }
  132336. /**
  132337. * Block used to apply trigonometry operation to floats
  132338. */
  132339. export class TrigonometryBlock extends NodeMaterialBlock {
  132340. /**
  132341. * Gets or sets the operation applied by the block
  132342. */
  132343. operation: TrigonometryBlockOperations;
  132344. /**
  132345. * Creates a new TrigonometryBlock
  132346. * @param name defines the block name
  132347. */
  132348. constructor(name: string);
  132349. /**
  132350. * Gets the current class name
  132351. * @returns the class name
  132352. */
  132353. getClassName(): string;
  132354. /**
  132355. * Gets the input component
  132356. */
  132357. get input(): NodeMaterialConnectionPoint;
  132358. /**
  132359. * Gets the output component
  132360. */
  132361. get output(): NodeMaterialConnectionPoint;
  132362. protected _buildBlock(state: NodeMaterialBuildState): this;
  132363. serialize(): any;
  132364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132365. protected _dumpPropertiesCode(): string;
  132366. }
  132367. }
  132368. declare module BABYLON {
  132369. /**
  132370. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132371. */
  132372. export class ColorMergerBlock extends NodeMaterialBlock {
  132373. /**
  132374. * Create a new ColorMergerBlock
  132375. * @param name defines the block name
  132376. */
  132377. constructor(name: string);
  132378. /**
  132379. * Gets the current class name
  132380. * @returns the class name
  132381. */
  132382. getClassName(): string;
  132383. /**
  132384. * Gets the rgb component (input)
  132385. */
  132386. get rgbIn(): NodeMaterialConnectionPoint;
  132387. /**
  132388. * Gets the r component (input)
  132389. */
  132390. get r(): NodeMaterialConnectionPoint;
  132391. /**
  132392. * Gets the g component (input)
  132393. */
  132394. get g(): NodeMaterialConnectionPoint;
  132395. /**
  132396. * Gets the b component (input)
  132397. */
  132398. get b(): NodeMaterialConnectionPoint;
  132399. /**
  132400. * Gets the a component (input)
  132401. */
  132402. get a(): NodeMaterialConnectionPoint;
  132403. /**
  132404. * Gets the rgba component (output)
  132405. */
  132406. get rgba(): NodeMaterialConnectionPoint;
  132407. /**
  132408. * Gets the rgb component (output)
  132409. */
  132410. get rgbOut(): NodeMaterialConnectionPoint;
  132411. /**
  132412. * Gets the rgb component (output)
  132413. * @deprecated Please use rgbOut instead.
  132414. */
  132415. get rgb(): NodeMaterialConnectionPoint;
  132416. protected _buildBlock(state: NodeMaterialBuildState): this;
  132417. }
  132418. }
  132419. declare module BABYLON {
  132420. /**
  132421. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132422. */
  132423. export class VectorMergerBlock extends NodeMaterialBlock {
  132424. /**
  132425. * Create a new VectorMergerBlock
  132426. * @param name defines the block name
  132427. */
  132428. constructor(name: string);
  132429. /**
  132430. * Gets the current class name
  132431. * @returns the class name
  132432. */
  132433. getClassName(): string;
  132434. /**
  132435. * Gets the xyz component (input)
  132436. */
  132437. get xyzIn(): NodeMaterialConnectionPoint;
  132438. /**
  132439. * Gets the xy component (input)
  132440. */
  132441. get xyIn(): NodeMaterialConnectionPoint;
  132442. /**
  132443. * Gets the x component (input)
  132444. */
  132445. get x(): NodeMaterialConnectionPoint;
  132446. /**
  132447. * Gets the y component (input)
  132448. */
  132449. get y(): NodeMaterialConnectionPoint;
  132450. /**
  132451. * Gets the z component (input)
  132452. */
  132453. get z(): NodeMaterialConnectionPoint;
  132454. /**
  132455. * Gets the w component (input)
  132456. */
  132457. get w(): NodeMaterialConnectionPoint;
  132458. /**
  132459. * Gets the xyzw component (output)
  132460. */
  132461. get xyzw(): NodeMaterialConnectionPoint;
  132462. /**
  132463. * Gets the xyz component (output)
  132464. */
  132465. get xyzOut(): NodeMaterialConnectionPoint;
  132466. /**
  132467. * Gets the xy component (output)
  132468. */
  132469. get xyOut(): NodeMaterialConnectionPoint;
  132470. /**
  132471. * Gets the xy component (output)
  132472. * @deprecated Please use xyOut instead.
  132473. */
  132474. get xy(): NodeMaterialConnectionPoint;
  132475. /**
  132476. * Gets the xyz component (output)
  132477. * @deprecated Please use xyzOut instead.
  132478. */
  132479. get xyz(): NodeMaterialConnectionPoint;
  132480. protected _buildBlock(state: NodeMaterialBuildState): this;
  132481. }
  132482. }
  132483. declare module BABYLON {
  132484. /**
  132485. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132486. */
  132487. export class ColorSplitterBlock extends NodeMaterialBlock {
  132488. /**
  132489. * Create a new ColorSplitterBlock
  132490. * @param name defines the block name
  132491. */
  132492. constructor(name: string);
  132493. /**
  132494. * Gets the current class name
  132495. * @returns the class name
  132496. */
  132497. getClassName(): string;
  132498. /**
  132499. * Gets the rgba component (input)
  132500. */
  132501. get rgba(): NodeMaterialConnectionPoint;
  132502. /**
  132503. * Gets the rgb component (input)
  132504. */
  132505. get rgbIn(): NodeMaterialConnectionPoint;
  132506. /**
  132507. * Gets the rgb component (output)
  132508. */
  132509. get rgbOut(): NodeMaterialConnectionPoint;
  132510. /**
  132511. * Gets the r component (output)
  132512. */
  132513. get r(): NodeMaterialConnectionPoint;
  132514. /**
  132515. * Gets the g component (output)
  132516. */
  132517. get g(): NodeMaterialConnectionPoint;
  132518. /**
  132519. * Gets the b component (output)
  132520. */
  132521. get b(): NodeMaterialConnectionPoint;
  132522. /**
  132523. * Gets the a component (output)
  132524. */
  132525. get a(): NodeMaterialConnectionPoint;
  132526. protected _inputRename(name: string): string;
  132527. protected _outputRename(name: string): string;
  132528. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132529. }
  132530. }
  132531. declare module BABYLON {
  132532. /**
  132533. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132534. */
  132535. export class VectorSplitterBlock extends NodeMaterialBlock {
  132536. /**
  132537. * Create a new VectorSplitterBlock
  132538. * @param name defines the block name
  132539. */
  132540. constructor(name: string);
  132541. /**
  132542. * Gets the current class name
  132543. * @returns the class name
  132544. */
  132545. getClassName(): string;
  132546. /**
  132547. * Gets the xyzw component (input)
  132548. */
  132549. get xyzw(): NodeMaterialConnectionPoint;
  132550. /**
  132551. * Gets the xyz component (input)
  132552. */
  132553. get xyzIn(): NodeMaterialConnectionPoint;
  132554. /**
  132555. * Gets the xy component (input)
  132556. */
  132557. get xyIn(): NodeMaterialConnectionPoint;
  132558. /**
  132559. * Gets the xyz component (output)
  132560. */
  132561. get xyzOut(): NodeMaterialConnectionPoint;
  132562. /**
  132563. * Gets the xy component (output)
  132564. */
  132565. get xyOut(): NodeMaterialConnectionPoint;
  132566. /**
  132567. * Gets the x component (output)
  132568. */
  132569. get x(): NodeMaterialConnectionPoint;
  132570. /**
  132571. * Gets the y component (output)
  132572. */
  132573. get y(): NodeMaterialConnectionPoint;
  132574. /**
  132575. * Gets the z component (output)
  132576. */
  132577. get z(): NodeMaterialConnectionPoint;
  132578. /**
  132579. * Gets the w component (output)
  132580. */
  132581. get w(): NodeMaterialConnectionPoint;
  132582. protected _inputRename(name: string): string;
  132583. protected _outputRename(name: string): string;
  132584. protected _buildBlock(state: NodeMaterialBuildState): this;
  132585. }
  132586. }
  132587. declare module BABYLON {
  132588. /**
  132589. * Block used to lerp between 2 values
  132590. */
  132591. export class LerpBlock extends NodeMaterialBlock {
  132592. /**
  132593. * Creates a new LerpBlock
  132594. * @param name defines the block name
  132595. */
  132596. constructor(name: string);
  132597. /**
  132598. * Gets the current class name
  132599. * @returns the class name
  132600. */
  132601. getClassName(): string;
  132602. /**
  132603. * Gets the left operand input component
  132604. */
  132605. get left(): NodeMaterialConnectionPoint;
  132606. /**
  132607. * Gets the right operand input component
  132608. */
  132609. get right(): NodeMaterialConnectionPoint;
  132610. /**
  132611. * Gets the gradient operand input component
  132612. */
  132613. get gradient(): NodeMaterialConnectionPoint;
  132614. /**
  132615. * Gets the output component
  132616. */
  132617. get output(): NodeMaterialConnectionPoint;
  132618. protected _buildBlock(state: NodeMaterialBuildState): this;
  132619. }
  132620. }
  132621. declare module BABYLON {
  132622. /**
  132623. * Block used to divide 2 vectors
  132624. */
  132625. export class DivideBlock extends NodeMaterialBlock {
  132626. /**
  132627. * Creates a new DivideBlock
  132628. * @param name defines the block name
  132629. */
  132630. constructor(name: string);
  132631. /**
  132632. * Gets the current class name
  132633. * @returns the class name
  132634. */
  132635. getClassName(): string;
  132636. /**
  132637. * Gets the left operand input component
  132638. */
  132639. get left(): NodeMaterialConnectionPoint;
  132640. /**
  132641. * Gets the right operand input component
  132642. */
  132643. get right(): NodeMaterialConnectionPoint;
  132644. /**
  132645. * Gets the output component
  132646. */
  132647. get output(): NodeMaterialConnectionPoint;
  132648. protected _buildBlock(state: NodeMaterialBuildState): this;
  132649. }
  132650. }
  132651. declare module BABYLON {
  132652. /**
  132653. * Block used to subtract 2 vectors
  132654. */
  132655. export class SubtractBlock extends NodeMaterialBlock {
  132656. /**
  132657. * Creates a new SubtractBlock
  132658. * @param name defines the block name
  132659. */
  132660. constructor(name: string);
  132661. /**
  132662. * Gets the current class name
  132663. * @returns the class name
  132664. */
  132665. getClassName(): string;
  132666. /**
  132667. * Gets the left operand input component
  132668. */
  132669. get left(): NodeMaterialConnectionPoint;
  132670. /**
  132671. * Gets the right operand input component
  132672. */
  132673. get right(): NodeMaterialConnectionPoint;
  132674. /**
  132675. * Gets the output component
  132676. */
  132677. get output(): NodeMaterialConnectionPoint;
  132678. protected _buildBlock(state: NodeMaterialBuildState): this;
  132679. }
  132680. }
  132681. declare module BABYLON {
  132682. /**
  132683. * Block used to step a value
  132684. */
  132685. export class StepBlock extends NodeMaterialBlock {
  132686. /**
  132687. * Creates a new StepBlock
  132688. * @param name defines the block name
  132689. */
  132690. constructor(name: string);
  132691. /**
  132692. * Gets the current class name
  132693. * @returns the class name
  132694. */
  132695. getClassName(): string;
  132696. /**
  132697. * Gets the value operand input component
  132698. */
  132699. get value(): NodeMaterialConnectionPoint;
  132700. /**
  132701. * Gets the edge operand input component
  132702. */
  132703. get edge(): NodeMaterialConnectionPoint;
  132704. /**
  132705. * Gets the output component
  132706. */
  132707. get output(): NodeMaterialConnectionPoint;
  132708. protected _buildBlock(state: NodeMaterialBuildState): this;
  132709. }
  132710. }
  132711. declare module BABYLON {
  132712. /**
  132713. * Block used to get the opposite (1 - x) of a value
  132714. */
  132715. export class OneMinusBlock extends NodeMaterialBlock {
  132716. /**
  132717. * Creates a new OneMinusBlock
  132718. * @param name defines the block name
  132719. */
  132720. constructor(name: string);
  132721. /**
  132722. * Gets the current class name
  132723. * @returns the class name
  132724. */
  132725. getClassName(): string;
  132726. /**
  132727. * Gets the input component
  132728. */
  132729. get input(): NodeMaterialConnectionPoint;
  132730. /**
  132731. * Gets the output component
  132732. */
  132733. get output(): NodeMaterialConnectionPoint;
  132734. protected _buildBlock(state: NodeMaterialBuildState): this;
  132735. }
  132736. }
  132737. declare module BABYLON {
  132738. /**
  132739. * Block used to get the view direction
  132740. */
  132741. export class ViewDirectionBlock extends NodeMaterialBlock {
  132742. /**
  132743. * Creates a new ViewDirectionBlock
  132744. * @param name defines the block name
  132745. */
  132746. constructor(name: string);
  132747. /**
  132748. * Gets the current class name
  132749. * @returns the class name
  132750. */
  132751. getClassName(): string;
  132752. /**
  132753. * Gets the world position component
  132754. */
  132755. get worldPosition(): NodeMaterialConnectionPoint;
  132756. /**
  132757. * Gets the camera position component
  132758. */
  132759. get cameraPosition(): NodeMaterialConnectionPoint;
  132760. /**
  132761. * Gets the output component
  132762. */
  132763. get output(): NodeMaterialConnectionPoint;
  132764. autoConfigure(material: NodeMaterial): void;
  132765. protected _buildBlock(state: NodeMaterialBuildState): this;
  132766. }
  132767. }
  132768. declare module BABYLON {
  132769. /**
  132770. * Block used to compute fresnel value
  132771. */
  132772. export class FresnelBlock extends NodeMaterialBlock {
  132773. /**
  132774. * Create a new FresnelBlock
  132775. * @param name defines the block name
  132776. */
  132777. constructor(name: string);
  132778. /**
  132779. * Gets the current class name
  132780. * @returns the class name
  132781. */
  132782. getClassName(): string;
  132783. /**
  132784. * Gets the world normal input component
  132785. */
  132786. get worldNormal(): NodeMaterialConnectionPoint;
  132787. /**
  132788. * Gets the view direction input component
  132789. */
  132790. get viewDirection(): NodeMaterialConnectionPoint;
  132791. /**
  132792. * Gets the bias input component
  132793. */
  132794. get bias(): NodeMaterialConnectionPoint;
  132795. /**
  132796. * Gets the camera (or eye) position component
  132797. */
  132798. get power(): NodeMaterialConnectionPoint;
  132799. /**
  132800. * Gets the fresnel output component
  132801. */
  132802. get fresnel(): NodeMaterialConnectionPoint;
  132803. autoConfigure(material: NodeMaterial): void;
  132804. protected _buildBlock(state: NodeMaterialBuildState): this;
  132805. }
  132806. }
  132807. declare module BABYLON {
  132808. /**
  132809. * Block used to get the max of 2 values
  132810. */
  132811. export class MaxBlock extends NodeMaterialBlock {
  132812. /**
  132813. * Creates a new MaxBlock
  132814. * @param name defines the block name
  132815. */
  132816. constructor(name: string);
  132817. /**
  132818. * Gets the current class name
  132819. * @returns the class name
  132820. */
  132821. getClassName(): string;
  132822. /**
  132823. * Gets the left operand input component
  132824. */
  132825. get left(): NodeMaterialConnectionPoint;
  132826. /**
  132827. * Gets the right operand input component
  132828. */
  132829. get right(): NodeMaterialConnectionPoint;
  132830. /**
  132831. * Gets the output component
  132832. */
  132833. get output(): NodeMaterialConnectionPoint;
  132834. protected _buildBlock(state: NodeMaterialBuildState): this;
  132835. }
  132836. }
  132837. declare module BABYLON {
  132838. /**
  132839. * Block used to get the min of 2 values
  132840. */
  132841. export class MinBlock extends NodeMaterialBlock {
  132842. /**
  132843. * Creates a new MinBlock
  132844. * @param name defines the block name
  132845. */
  132846. constructor(name: string);
  132847. /**
  132848. * Gets the current class name
  132849. * @returns the class name
  132850. */
  132851. getClassName(): string;
  132852. /**
  132853. * Gets the left operand input component
  132854. */
  132855. get left(): NodeMaterialConnectionPoint;
  132856. /**
  132857. * Gets the right operand input component
  132858. */
  132859. get right(): NodeMaterialConnectionPoint;
  132860. /**
  132861. * Gets the output component
  132862. */
  132863. get output(): NodeMaterialConnectionPoint;
  132864. protected _buildBlock(state: NodeMaterialBuildState): this;
  132865. }
  132866. }
  132867. declare module BABYLON {
  132868. /**
  132869. * Block used to get the distance between 2 values
  132870. */
  132871. export class DistanceBlock extends NodeMaterialBlock {
  132872. /**
  132873. * Creates a new DistanceBlock
  132874. * @param name defines the block name
  132875. */
  132876. constructor(name: string);
  132877. /**
  132878. * Gets the current class name
  132879. * @returns the class name
  132880. */
  132881. getClassName(): string;
  132882. /**
  132883. * Gets the left operand input component
  132884. */
  132885. get left(): NodeMaterialConnectionPoint;
  132886. /**
  132887. * Gets the right operand input component
  132888. */
  132889. get right(): NodeMaterialConnectionPoint;
  132890. /**
  132891. * Gets the output component
  132892. */
  132893. get output(): NodeMaterialConnectionPoint;
  132894. protected _buildBlock(state: NodeMaterialBuildState): this;
  132895. }
  132896. }
  132897. declare module BABYLON {
  132898. /**
  132899. * Block used to get the length of a vector
  132900. */
  132901. export class LengthBlock extends NodeMaterialBlock {
  132902. /**
  132903. * Creates a new LengthBlock
  132904. * @param name defines the block name
  132905. */
  132906. constructor(name: string);
  132907. /**
  132908. * Gets the current class name
  132909. * @returns the class name
  132910. */
  132911. getClassName(): string;
  132912. /**
  132913. * Gets the value input component
  132914. */
  132915. get value(): NodeMaterialConnectionPoint;
  132916. /**
  132917. * Gets the output component
  132918. */
  132919. get output(): NodeMaterialConnectionPoint;
  132920. protected _buildBlock(state: NodeMaterialBuildState): this;
  132921. }
  132922. }
  132923. declare module BABYLON {
  132924. /**
  132925. * Block used to get negative version of a value (i.e. x * -1)
  132926. */
  132927. export class NegateBlock extends NodeMaterialBlock {
  132928. /**
  132929. * Creates a new NegateBlock
  132930. * @param name defines the block name
  132931. */
  132932. constructor(name: string);
  132933. /**
  132934. * Gets the current class name
  132935. * @returns the class name
  132936. */
  132937. getClassName(): string;
  132938. /**
  132939. * Gets the value input component
  132940. */
  132941. get value(): NodeMaterialConnectionPoint;
  132942. /**
  132943. * Gets the output component
  132944. */
  132945. get output(): NodeMaterialConnectionPoint;
  132946. protected _buildBlock(state: NodeMaterialBuildState): this;
  132947. }
  132948. }
  132949. declare module BABYLON {
  132950. /**
  132951. * Block used to get the value of the first parameter raised to the power of the second
  132952. */
  132953. export class PowBlock extends NodeMaterialBlock {
  132954. /**
  132955. * Creates a new PowBlock
  132956. * @param name defines the block name
  132957. */
  132958. constructor(name: string);
  132959. /**
  132960. * Gets the current class name
  132961. * @returns the class name
  132962. */
  132963. getClassName(): string;
  132964. /**
  132965. * Gets the value operand input component
  132966. */
  132967. get value(): NodeMaterialConnectionPoint;
  132968. /**
  132969. * Gets the power operand input component
  132970. */
  132971. get power(): NodeMaterialConnectionPoint;
  132972. /**
  132973. * Gets the output component
  132974. */
  132975. get output(): NodeMaterialConnectionPoint;
  132976. protected _buildBlock(state: NodeMaterialBuildState): this;
  132977. }
  132978. }
  132979. declare module BABYLON {
  132980. /**
  132981. * Block used to get a random number
  132982. */
  132983. export class RandomNumberBlock extends NodeMaterialBlock {
  132984. /**
  132985. * Creates a new RandomNumberBlock
  132986. * @param name defines the block name
  132987. */
  132988. constructor(name: string);
  132989. /**
  132990. * Gets the current class name
  132991. * @returns the class name
  132992. */
  132993. getClassName(): string;
  132994. /**
  132995. * Gets the seed input component
  132996. */
  132997. get seed(): NodeMaterialConnectionPoint;
  132998. /**
  132999. * Gets the output component
  133000. */
  133001. get output(): NodeMaterialConnectionPoint;
  133002. protected _buildBlock(state: NodeMaterialBuildState): this;
  133003. }
  133004. }
  133005. declare module BABYLON {
  133006. /**
  133007. * Block used to compute arc tangent of 2 values
  133008. */
  133009. export class ArcTan2Block extends NodeMaterialBlock {
  133010. /**
  133011. * Creates a new ArcTan2Block
  133012. * @param name defines the block name
  133013. */
  133014. constructor(name: string);
  133015. /**
  133016. * Gets the current class name
  133017. * @returns the class name
  133018. */
  133019. getClassName(): string;
  133020. /**
  133021. * Gets the x operand input component
  133022. */
  133023. get x(): NodeMaterialConnectionPoint;
  133024. /**
  133025. * Gets the y operand input component
  133026. */
  133027. get y(): NodeMaterialConnectionPoint;
  133028. /**
  133029. * Gets the output component
  133030. */
  133031. get output(): NodeMaterialConnectionPoint;
  133032. protected _buildBlock(state: NodeMaterialBuildState): this;
  133033. }
  133034. }
  133035. declare module BABYLON {
  133036. /**
  133037. * Block used to smooth step a value
  133038. */
  133039. export class SmoothStepBlock extends NodeMaterialBlock {
  133040. /**
  133041. * Creates a new SmoothStepBlock
  133042. * @param name defines the block name
  133043. */
  133044. constructor(name: string);
  133045. /**
  133046. * Gets the current class name
  133047. * @returns the class name
  133048. */
  133049. getClassName(): string;
  133050. /**
  133051. * Gets the value operand input component
  133052. */
  133053. get value(): NodeMaterialConnectionPoint;
  133054. /**
  133055. * Gets the first edge operand input component
  133056. */
  133057. get edge0(): NodeMaterialConnectionPoint;
  133058. /**
  133059. * Gets the second edge operand input component
  133060. */
  133061. get edge1(): NodeMaterialConnectionPoint;
  133062. /**
  133063. * Gets the output component
  133064. */
  133065. get output(): NodeMaterialConnectionPoint;
  133066. protected _buildBlock(state: NodeMaterialBuildState): this;
  133067. }
  133068. }
  133069. declare module BABYLON {
  133070. /**
  133071. * Block used to get the reciprocal (1 / x) of a value
  133072. */
  133073. export class ReciprocalBlock extends NodeMaterialBlock {
  133074. /**
  133075. * Creates a new ReciprocalBlock
  133076. * @param name defines the block name
  133077. */
  133078. constructor(name: string);
  133079. /**
  133080. * Gets the current class name
  133081. * @returns the class name
  133082. */
  133083. getClassName(): string;
  133084. /**
  133085. * Gets the input component
  133086. */
  133087. get input(): NodeMaterialConnectionPoint;
  133088. /**
  133089. * Gets the output component
  133090. */
  133091. get output(): NodeMaterialConnectionPoint;
  133092. protected _buildBlock(state: NodeMaterialBuildState): this;
  133093. }
  133094. }
  133095. declare module BABYLON {
  133096. /**
  133097. * Block used to replace a color by another one
  133098. */
  133099. export class ReplaceColorBlock extends NodeMaterialBlock {
  133100. /**
  133101. * Creates a new ReplaceColorBlock
  133102. * @param name defines the block name
  133103. */
  133104. constructor(name: string);
  133105. /**
  133106. * Gets the current class name
  133107. * @returns the class name
  133108. */
  133109. getClassName(): string;
  133110. /**
  133111. * Gets the value input component
  133112. */
  133113. get value(): NodeMaterialConnectionPoint;
  133114. /**
  133115. * Gets the reference input component
  133116. */
  133117. get reference(): NodeMaterialConnectionPoint;
  133118. /**
  133119. * Gets the distance input component
  133120. */
  133121. get distance(): NodeMaterialConnectionPoint;
  133122. /**
  133123. * Gets the replacement input component
  133124. */
  133125. get replacement(): NodeMaterialConnectionPoint;
  133126. /**
  133127. * Gets the output component
  133128. */
  133129. get output(): NodeMaterialConnectionPoint;
  133130. protected _buildBlock(state: NodeMaterialBuildState): this;
  133131. }
  133132. }
  133133. declare module BABYLON {
  133134. /**
  133135. * Block used to posterize a value
  133136. * @see https://en.wikipedia.org/wiki/Posterization
  133137. */
  133138. export class PosterizeBlock extends NodeMaterialBlock {
  133139. /**
  133140. * Creates a new PosterizeBlock
  133141. * @param name defines the block name
  133142. */
  133143. constructor(name: string);
  133144. /**
  133145. * Gets the current class name
  133146. * @returns the class name
  133147. */
  133148. getClassName(): string;
  133149. /**
  133150. * Gets the value input component
  133151. */
  133152. get value(): NodeMaterialConnectionPoint;
  133153. /**
  133154. * Gets the steps input component
  133155. */
  133156. get steps(): NodeMaterialConnectionPoint;
  133157. /**
  133158. * Gets the output component
  133159. */
  133160. get output(): NodeMaterialConnectionPoint;
  133161. protected _buildBlock(state: NodeMaterialBuildState): this;
  133162. }
  133163. }
  133164. declare module BABYLON {
  133165. /**
  133166. * Operations supported by the Wave block
  133167. */
  133168. export enum WaveBlockKind {
  133169. /** SawTooth */
  133170. SawTooth = 0,
  133171. /** Square */
  133172. Square = 1,
  133173. /** Triangle */
  133174. Triangle = 2
  133175. }
  133176. /**
  133177. * Block used to apply wave operation to floats
  133178. */
  133179. export class WaveBlock extends NodeMaterialBlock {
  133180. /**
  133181. * Gets or sets the kibnd of wave to be applied by the block
  133182. */
  133183. kind: WaveBlockKind;
  133184. /**
  133185. * Creates a new WaveBlock
  133186. * @param name defines the block name
  133187. */
  133188. constructor(name: string);
  133189. /**
  133190. * Gets the current class name
  133191. * @returns the class name
  133192. */
  133193. getClassName(): string;
  133194. /**
  133195. * Gets the input component
  133196. */
  133197. get input(): NodeMaterialConnectionPoint;
  133198. /**
  133199. * Gets the output component
  133200. */
  133201. get output(): NodeMaterialConnectionPoint;
  133202. protected _buildBlock(state: NodeMaterialBuildState): this;
  133203. serialize(): any;
  133204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133205. }
  133206. }
  133207. declare module BABYLON {
  133208. /**
  133209. * Class used to store a color step for the GradientBlock
  133210. */
  133211. export class GradientBlockColorStep {
  133212. /**
  133213. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133214. */
  133215. step: number;
  133216. /**
  133217. * Gets or sets the color associated with this step
  133218. */
  133219. color: Color3;
  133220. /**
  133221. * Creates a new GradientBlockColorStep
  133222. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133223. * @param color defines the color associated with this step
  133224. */
  133225. constructor(
  133226. /**
  133227. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133228. */
  133229. step: number,
  133230. /**
  133231. * Gets or sets the color associated with this step
  133232. */
  133233. color: Color3);
  133234. }
  133235. /**
  133236. * Block used to return a color from a gradient based on an input value between 0 and 1
  133237. */
  133238. export class GradientBlock extends NodeMaterialBlock {
  133239. /**
  133240. * Gets or sets the list of color steps
  133241. */
  133242. colorSteps: GradientBlockColorStep[];
  133243. /**
  133244. * Creates a new GradientBlock
  133245. * @param name defines the block name
  133246. */
  133247. constructor(name: string);
  133248. /**
  133249. * Gets the current class name
  133250. * @returns the class name
  133251. */
  133252. getClassName(): string;
  133253. /**
  133254. * Gets the gradient input component
  133255. */
  133256. get gradient(): NodeMaterialConnectionPoint;
  133257. /**
  133258. * Gets the output component
  133259. */
  133260. get output(): NodeMaterialConnectionPoint;
  133261. private _writeColorConstant;
  133262. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133263. serialize(): any;
  133264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133265. protected _dumpPropertiesCode(): string;
  133266. }
  133267. }
  133268. declare module BABYLON {
  133269. /**
  133270. * Block used to normalize lerp between 2 values
  133271. */
  133272. export class NLerpBlock extends NodeMaterialBlock {
  133273. /**
  133274. * Creates a new NLerpBlock
  133275. * @param name defines the block name
  133276. */
  133277. constructor(name: string);
  133278. /**
  133279. * Gets the current class name
  133280. * @returns the class name
  133281. */
  133282. getClassName(): string;
  133283. /**
  133284. * Gets the left operand input component
  133285. */
  133286. get left(): NodeMaterialConnectionPoint;
  133287. /**
  133288. * Gets the right operand input component
  133289. */
  133290. get right(): NodeMaterialConnectionPoint;
  133291. /**
  133292. * Gets the gradient operand input component
  133293. */
  133294. get gradient(): NodeMaterialConnectionPoint;
  133295. /**
  133296. * Gets the output component
  133297. */
  133298. get output(): NodeMaterialConnectionPoint;
  133299. protected _buildBlock(state: NodeMaterialBuildState): this;
  133300. }
  133301. }
  133302. declare module BABYLON {
  133303. /**
  133304. * block used to Generate a Worley Noise 3D Noise Pattern
  133305. */
  133306. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133307. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133308. manhattanDistance: boolean;
  133309. /**
  133310. * Creates a new WorleyNoise3DBlock
  133311. * @param name defines the block name
  133312. */
  133313. constructor(name: string);
  133314. /**
  133315. * Gets the current class name
  133316. * @returns the class name
  133317. */
  133318. getClassName(): string;
  133319. /**
  133320. * Gets the seed input component
  133321. */
  133322. get seed(): NodeMaterialConnectionPoint;
  133323. /**
  133324. * Gets the jitter input component
  133325. */
  133326. get jitter(): NodeMaterialConnectionPoint;
  133327. /**
  133328. * Gets the output component
  133329. */
  133330. get output(): NodeMaterialConnectionPoint;
  133331. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133332. /**
  133333. * Exposes the properties to the UI?
  133334. */
  133335. protected _dumpPropertiesCode(): string;
  133336. /**
  133337. * Exposes the properties to the Seralize?
  133338. */
  133339. serialize(): any;
  133340. /**
  133341. * Exposes the properties to the deseralize?
  133342. */
  133343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133344. }
  133345. }
  133346. declare module BABYLON {
  133347. /**
  133348. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133349. */
  133350. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133351. /**
  133352. * Creates a new SimplexPerlin3DBlock
  133353. * @param name defines the block name
  133354. */
  133355. constructor(name: string);
  133356. /**
  133357. * Gets the current class name
  133358. * @returns the class name
  133359. */
  133360. getClassName(): string;
  133361. /**
  133362. * Gets the seed operand input component
  133363. */
  133364. get seed(): NodeMaterialConnectionPoint;
  133365. /**
  133366. * Gets the output component
  133367. */
  133368. get output(): NodeMaterialConnectionPoint;
  133369. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133370. }
  133371. }
  133372. declare module BABYLON {
  133373. /**
  133374. * Block used to blend normals
  133375. */
  133376. export class NormalBlendBlock extends NodeMaterialBlock {
  133377. /**
  133378. * Creates a new NormalBlendBlock
  133379. * @param name defines the block name
  133380. */
  133381. constructor(name: string);
  133382. /**
  133383. * Gets the current class name
  133384. * @returns the class name
  133385. */
  133386. getClassName(): string;
  133387. /**
  133388. * Gets the first input component
  133389. */
  133390. get normalMap0(): NodeMaterialConnectionPoint;
  133391. /**
  133392. * Gets the second input component
  133393. */
  133394. get normalMap1(): NodeMaterialConnectionPoint;
  133395. /**
  133396. * Gets the output component
  133397. */
  133398. get output(): NodeMaterialConnectionPoint;
  133399. protected _buildBlock(state: NodeMaterialBuildState): this;
  133400. }
  133401. }
  133402. declare module BABYLON {
  133403. /**
  133404. * Block used to rotate a 2d vector by a given angle
  133405. */
  133406. export class Rotate2dBlock extends NodeMaterialBlock {
  133407. /**
  133408. * Creates a new Rotate2dBlock
  133409. * @param name defines the block name
  133410. */
  133411. constructor(name: string);
  133412. /**
  133413. * Gets the current class name
  133414. * @returns the class name
  133415. */
  133416. getClassName(): string;
  133417. /**
  133418. * Gets the input vector
  133419. */
  133420. get input(): NodeMaterialConnectionPoint;
  133421. /**
  133422. * Gets the input angle
  133423. */
  133424. get angle(): NodeMaterialConnectionPoint;
  133425. /**
  133426. * Gets the output component
  133427. */
  133428. get output(): NodeMaterialConnectionPoint;
  133429. autoConfigure(material: NodeMaterial): void;
  133430. protected _buildBlock(state: NodeMaterialBuildState): this;
  133431. }
  133432. }
  133433. declare module BABYLON {
  133434. /**
  133435. * Block used to get the reflected vector from a direction and a normal
  133436. */
  133437. export class ReflectBlock extends NodeMaterialBlock {
  133438. /**
  133439. * Creates a new ReflectBlock
  133440. * @param name defines the block name
  133441. */
  133442. constructor(name: string);
  133443. /**
  133444. * Gets the current class name
  133445. * @returns the class name
  133446. */
  133447. getClassName(): string;
  133448. /**
  133449. * Gets the incident component
  133450. */
  133451. get incident(): NodeMaterialConnectionPoint;
  133452. /**
  133453. * Gets the normal component
  133454. */
  133455. get normal(): NodeMaterialConnectionPoint;
  133456. /**
  133457. * Gets the output component
  133458. */
  133459. get output(): NodeMaterialConnectionPoint;
  133460. protected _buildBlock(state: NodeMaterialBuildState): this;
  133461. }
  133462. }
  133463. declare module BABYLON {
  133464. /**
  133465. * Block used to get the refracted vector from a direction and a normal
  133466. */
  133467. export class RefractBlock extends NodeMaterialBlock {
  133468. /**
  133469. * Creates a new RefractBlock
  133470. * @param name defines the block name
  133471. */
  133472. constructor(name: string);
  133473. /**
  133474. * Gets the current class name
  133475. * @returns the class name
  133476. */
  133477. getClassName(): string;
  133478. /**
  133479. * Gets the incident component
  133480. */
  133481. get incident(): NodeMaterialConnectionPoint;
  133482. /**
  133483. * Gets the normal component
  133484. */
  133485. get normal(): NodeMaterialConnectionPoint;
  133486. /**
  133487. * Gets the index of refraction component
  133488. */
  133489. get ior(): NodeMaterialConnectionPoint;
  133490. /**
  133491. * Gets the output component
  133492. */
  133493. get output(): NodeMaterialConnectionPoint;
  133494. protected _buildBlock(state: NodeMaterialBuildState): this;
  133495. }
  133496. }
  133497. declare module BABYLON {
  133498. /**
  133499. * Block used to desaturate a color
  133500. */
  133501. export class DesaturateBlock extends NodeMaterialBlock {
  133502. /**
  133503. * Creates a new DesaturateBlock
  133504. * @param name defines the block name
  133505. */
  133506. constructor(name: string);
  133507. /**
  133508. * Gets the current class name
  133509. * @returns the class name
  133510. */
  133511. getClassName(): string;
  133512. /**
  133513. * Gets the color operand input component
  133514. */
  133515. get color(): NodeMaterialConnectionPoint;
  133516. /**
  133517. * Gets the level operand input component
  133518. */
  133519. get level(): NodeMaterialConnectionPoint;
  133520. /**
  133521. * Gets the output component
  133522. */
  133523. get output(): NodeMaterialConnectionPoint;
  133524. protected _buildBlock(state: NodeMaterialBuildState): this;
  133525. }
  133526. }
  133527. declare module BABYLON {
  133528. /**
  133529. * Effect Render Options
  133530. */
  133531. export interface IEffectRendererOptions {
  133532. /**
  133533. * Defines the vertices positions.
  133534. */
  133535. positions?: number[];
  133536. /**
  133537. * Defines the indices.
  133538. */
  133539. indices?: number[];
  133540. }
  133541. /**
  133542. * Helper class to render one or more effects
  133543. */
  133544. export class EffectRenderer {
  133545. private engine;
  133546. private static _DefaultOptions;
  133547. private _vertexBuffers;
  133548. private _indexBuffer;
  133549. private _ringBufferIndex;
  133550. private _ringScreenBuffer;
  133551. private _fullscreenViewport;
  133552. private _getNextFrameBuffer;
  133553. /**
  133554. * Creates an effect renderer
  133555. * @param engine the engine to use for rendering
  133556. * @param options defines the options of the effect renderer
  133557. */
  133558. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133559. /**
  133560. * Sets the current viewport in normalized coordinates 0-1
  133561. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133562. */
  133563. setViewport(viewport?: Viewport): void;
  133564. /**
  133565. * Binds the embedded attributes buffer to the effect.
  133566. * @param effect Defines the effect to bind the attributes for
  133567. */
  133568. bindBuffers(effect: Effect): void;
  133569. /**
  133570. * Sets the current effect wrapper to use during draw.
  133571. * The effect needs to be ready before calling this api.
  133572. * This also sets the default full screen position attribute.
  133573. * @param effectWrapper Defines the effect to draw with
  133574. */
  133575. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133576. /**
  133577. * Draws a full screen quad.
  133578. */
  133579. draw(): void;
  133580. /**
  133581. * renders one or more effects to a specified texture
  133582. * @param effectWrappers list of effects to renderer
  133583. * @param outputTexture texture to draw to, if null it will render to the screen
  133584. */
  133585. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133586. /**
  133587. * Disposes of the effect renderer
  133588. */
  133589. dispose(): void;
  133590. }
  133591. /**
  133592. * Options to create an EffectWrapper
  133593. */
  133594. interface EffectWrapperCreationOptions {
  133595. /**
  133596. * Engine to use to create the effect
  133597. */
  133598. engine: ThinEngine;
  133599. /**
  133600. * Fragment shader for the effect
  133601. */
  133602. fragmentShader: string;
  133603. /**
  133604. * Vertex shader for the effect
  133605. */
  133606. vertexShader?: string;
  133607. /**
  133608. * Attributes to use in the shader
  133609. */
  133610. attributeNames?: Array<string>;
  133611. /**
  133612. * Uniforms to use in the shader
  133613. */
  133614. uniformNames?: Array<string>;
  133615. /**
  133616. * Texture sampler names to use in the shader
  133617. */
  133618. samplerNames?: Array<string>;
  133619. /**
  133620. * The friendly name of the effect displayed in Spector.
  133621. */
  133622. name?: string;
  133623. }
  133624. /**
  133625. * Wraps an effect to be used for rendering
  133626. */
  133627. export class EffectWrapper {
  133628. /**
  133629. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133630. */
  133631. onApplyObservable: Observable<{}>;
  133632. /**
  133633. * The underlying effect
  133634. */
  133635. effect: Effect;
  133636. /**
  133637. * Creates an effect to be renderer
  133638. * @param creationOptions options to create the effect
  133639. */
  133640. constructor(creationOptions: EffectWrapperCreationOptions);
  133641. /**
  133642. * Disposes of the effect wrapper
  133643. */
  133644. dispose(): void;
  133645. }
  133646. }
  133647. declare module BABYLON {
  133648. /**
  133649. * Helper class to push actions to a pool of workers.
  133650. */
  133651. export class WorkerPool implements IDisposable {
  133652. private _workerInfos;
  133653. private _pendingActions;
  133654. /**
  133655. * Constructor
  133656. * @param workers Array of workers to use for actions
  133657. */
  133658. constructor(workers: Array<Worker>);
  133659. /**
  133660. * Terminates all workers and clears any pending actions.
  133661. */
  133662. dispose(): void;
  133663. /**
  133664. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133665. * pended until a worker has completed its action.
  133666. * @param action The action to perform. Call onComplete when the action is complete.
  133667. */
  133668. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133669. private _execute;
  133670. }
  133671. }
  133672. declare module BABYLON {
  133673. /**
  133674. * Configuration for Draco compression
  133675. */
  133676. export interface IDracoCompressionConfiguration {
  133677. /**
  133678. * Configuration for the decoder.
  133679. */
  133680. decoder: {
  133681. /**
  133682. * The url to the WebAssembly module.
  133683. */
  133684. wasmUrl?: string;
  133685. /**
  133686. * The url to the WebAssembly binary.
  133687. */
  133688. wasmBinaryUrl?: string;
  133689. /**
  133690. * The url to the fallback JavaScript module.
  133691. */
  133692. fallbackUrl?: string;
  133693. };
  133694. }
  133695. /**
  133696. * Draco compression (https://google.github.io/draco/)
  133697. *
  133698. * This class wraps the Draco module.
  133699. *
  133700. * **Encoder**
  133701. *
  133702. * The encoder is not currently implemented.
  133703. *
  133704. * **Decoder**
  133705. *
  133706. * 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.
  133707. *
  133708. * To update the configuration, use the following code:
  133709. * ```javascript
  133710. * DracoCompression.Configuration = {
  133711. * decoder: {
  133712. * wasmUrl: "<url to the WebAssembly library>",
  133713. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133714. * fallbackUrl: "<url to the fallback JavaScript library>",
  133715. * }
  133716. * };
  133717. * ```
  133718. *
  133719. * 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.
  133720. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133721. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133722. *
  133723. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133724. * ```javascript
  133725. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133726. * ```
  133727. *
  133728. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133729. */
  133730. export class DracoCompression implements IDisposable {
  133731. private _workerPoolPromise?;
  133732. private _decoderModulePromise?;
  133733. /**
  133734. * The configuration. Defaults to the following urls:
  133735. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133736. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133737. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133738. */
  133739. static Configuration: IDracoCompressionConfiguration;
  133740. /**
  133741. * Returns true if the decoder configuration is available.
  133742. */
  133743. static get DecoderAvailable(): boolean;
  133744. /**
  133745. * Default number of workers to create when creating the draco compression object.
  133746. */
  133747. static DefaultNumWorkers: number;
  133748. private static GetDefaultNumWorkers;
  133749. private static _Default;
  133750. /**
  133751. * Default instance for the draco compression object.
  133752. */
  133753. static get Default(): DracoCompression;
  133754. /**
  133755. * Constructor
  133756. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133757. */
  133758. constructor(numWorkers?: number);
  133759. /**
  133760. * Stop all async operations and release resources.
  133761. */
  133762. dispose(): void;
  133763. /**
  133764. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133765. * @returns a promise that resolves when ready
  133766. */
  133767. whenReadyAsync(): Promise<void>;
  133768. /**
  133769. * Decode Draco compressed mesh data to vertex data.
  133770. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133771. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133772. * @returns A promise that resolves with the decoded vertex data
  133773. */
  133774. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133775. [kind: string]: number;
  133776. }): Promise<VertexData>;
  133777. }
  133778. }
  133779. declare module BABYLON {
  133780. /**
  133781. * Class for building Constructive Solid Geometry
  133782. */
  133783. export class CSG {
  133784. private polygons;
  133785. /**
  133786. * The world matrix
  133787. */
  133788. matrix: Matrix;
  133789. /**
  133790. * Stores the position
  133791. */
  133792. position: Vector3;
  133793. /**
  133794. * Stores the rotation
  133795. */
  133796. rotation: Vector3;
  133797. /**
  133798. * Stores the rotation quaternion
  133799. */
  133800. rotationQuaternion: Nullable<Quaternion>;
  133801. /**
  133802. * Stores the scaling vector
  133803. */
  133804. scaling: Vector3;
  133805. /**
  133806. * Convert the Mesh to CSG
  133807. * @param mesh The Mesh to convert to CSG
  133808. * @returns A new CSG from the Mesh
  133809. */
  133810. static FromMesh(mesh: Mesh): CSG;
  133811. /**
  133812. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133813. * @param polygons Polygons used to construct a CSG solid
  133814. */
  133815. private static FromPolygons;
  133816. /**
  133817. * Clones, or makes a deep copy, of the CSG
  133818. * @returns A new CSG
  133819. */
  133820. clone(): CSG;
  133821. /**
  133822. * Unions this CSG with another CSG
  133823. * @param csg The CSG to union against this CSG
  133824. * @returns The unioned CSG
  133825. */
  133826. union(csg: CSG): CSG;
  133827. /**
  133828. * Unions this CSG with another CSG in place
  133829. * @param csg The CSG to union against this CSG
  133830. */
  133831. unionInPlace(csg: CSG): void;
  133832. /**
  133833. * Subtracts this CSG with another CSG
  133834. * @param csg The CSG to subtract against this CSG
  133835. * @returns A new CSG
  133836. */
  133837. subtract(csg: CSG): CSG;
  133838. /**
  133839. * Subtracts this CSG with another CSG in place
  133840. * @param csg The CSG to subtact against this CSG
  133841. */
  133842. subtractInPlace(csg: CSG): void;
  133843. /**
  133844. * Intersect this CSG with another CSG
  133845. * @param csg The CSG to intersect against this CSG
  133846. * @returns A new CSG
  133847. */
  133848. intersect(csg: CSG): CSG;
  133849. /**
  133850. * Intersects this CSG with another CSG in place
  133851. * @param csg The CSG to intersect against this CSG
  133852. */
  133853. intersectInPlace(csg: CSG): void;
  133854. /**
  133855. * Return a new CSG solid with solid and empty space switched. This solid is
  133856. * not modified.
  133857. * @returns A new CSG solid with solid and empty space switched
  133858. */
  133859. inverse(): CSG;
  133860. /**
  133861. * Inverses the CSG in place
  133862. */
  133863. inverseInPlace(): void;
  133864. /**
  133865. * This is used to keep meshes transformations so they can be restored
  133866. * when we build back a Babylon Mesh
  133867. * NB : All CSG operations are performed in world coordinates
  133868. * @param csg The CSG to copy the transform attributes from
  133869. * @returns This CSG
  133870. */
  133871. copyTransformAttributes(csg: CSG): CSG;
  133872. /**
  133873. * Build Raw mesh from CSG
  133874. * Coordinates here are in world space
  133875. * @param name The name of the mesh geometry
  133876. * @param scene The Scene
  133877. * @param keepSubMeshes Specifies if the submeshes should be kept
  133878. * @returns A new Mesh
  133879. */
  133880. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133881. /**
  133882. * Build Mesh from CSG taking material and transforms into account
  133883. * @param name The name of the Mesh
  133884. * @param material The material of the Mesh
  133885. * @param scene The Scene
  133886. * @param keepSubMeshes Specifies if submeshes should be kept
  133887. * @returns The new Mesh
  133888. */
  133889. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133890. }
  133891. }
  133892. declare module BABYLON {
  133893. /**
  133894. * Class used to create a trail following a mesh
  133895. */
  133896. export class TrailMesh extends Mesh {
  133897. private _generator;
  133898. private _autoStart;
  133899. private _running;
  133900. private _diameter;
  133901. private _length;
  133902. private _sectionPolygonPointsCount;
  133903. private _sectionVectors;
  133904. private _sectionNormalVectors;
  133905. private _beforeRenderObserver;
  133906. /**
  133907. * @constructor
  133908. * @param name The value used by scene.getMeshByName() to do a lookup.
  133909. * @param generator The mesh or transform node to generate a trail.
  133910. * @param scene The scene to add this mesh to.
  133911. * @param diameter Diameter of trailing mesh. Default is 1.
  133912. * @param length Length of trailing mesh. Default is 60.
  133913. * @param autoStart Automatically start trailing mesh. Default true.
  133914. */
  133915. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133916. /**
  133917. * "TrailMesh"
  133918. * @returns "TrailMesh"
  133919. */
  133920. getClassName(): string;
  133921. private _createMesh;
  133922. /**
  133923. * Start trailing mesh.
  133924. */
  133925. start(): void;
  133926. /**
  133927. * Stop trailing mesh.
  133928. */
  133929. stop(): void;
  133930. /**
  133931. * Update trailing mesh geometry.
  133932. */
  133933. update(): void;
  133934. /**
  133935. * Returns a new TrailMesh object.
  133936. * @param name is a string, the name given to the new mesh
  133937. * @param newGenerator use new generator object for cloned trail mesh
  133938. * @returns a new mesh
  133939. */
  133940. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133941. /**
  133942. * Serializes this trail mesh
  133943. * @param serializationObject object to write serialization to
  133944. */
  133945. serialize(serializationObject: any): void;
  133946. /**
  133947. * Parses a serialized trail mesh
  133948. * @param parsedMesh the serialized mesh
  133949. * @param scene the scene to create the trail mesh in
  133950. * @returns the created trail mesh
  133951. */
  133952. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133953. }
  133954. }
  133955. declare module BABYLON {
  133956. /**
  133957. * Class containing static functions to help procedurally build meshes
  133958. */
  133959. export class TiledBoxBuilder {
  133960. /**
  133961. * Creates a box mesh
  133962. * 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)
  133963. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133967. * @param name defines the name of the mesh
  133968. * @param options defines the options used to create the mesh
  133969. * @param scene defines the hosting scene
  133970. * @returns the box mesh
  133971. */
  133972. static CreateTiledBox(name: string, options: {
  133973. pattern?: number;
  133974. width?: number;
  133975. height?: number;
  133976. depth?: number;
  133977. tileSize?: number;
  133978. tileWidth?: number;
  133979. tileHeight?: number;
  133980. alignHorizontal?: number;
  133981. alignVertical?: number;
  133982. faceUV?: Vector4[];
  133983. faceColors?: Color4[];
  133984. sideOrientation?: number;
  133985. updatable?: boolean;
  133986. }, scene?: Nullable<Scene>): Mesh;
  133987. }
  133988. }
  133989. declare module BABYLON {
  133990. /**
  133991. * Class containing static functions to help procedurally build meshes
  133992. */
  133993. export class TorusKnotBuilder {
  133994. /**
  133995. * Creates a torus knot mesh
  133996. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133997. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133998. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133999. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134003. * @param name defines the name of the mesh
  134004. * @param options defines the options used to create the mesh
  134005. * @param scene defines the hosting scene
  134006. * @returns the torus knot mesh
  134007. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134008. */
  134009. static CreateTorusKnot(name: string, options: {
  134010. radius?: number;
  134011. tube?: number;
  134012. radialSegments?: number;
  134013. tubularSegments?: number;
  134014. p?: number;
  134015. q?: number;
  134016. updatable?: boolean;
  134017. sideOrientation?: number;
  134018. frontUVs?: Vector4;
  134019. backUVs?: Vector4;
  134020. }, scene: any): Mesh;
  134021. }
  134022. }
  134023. declare module BABYLON {
  134024. /**
  134025. * Polygon
  134026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  134027. */
  134028. export class Polygon {
  134029. /**
  134030. * Creates a rectangle
  134031. * @param xmin bottom X coord
  134032. * @param ymin bottom Y coord
  134033. * @param xmax top X coord
  134034. * @param ymax top Y coord
  134035. * @returns points that make the resulting rectation
  134036. */
  134037. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134038. /**
  134039. * Creates a circle
  134040. * @param radius radius of circle
  134041. * @param cx scale in x
  134042. * @param cy scale in y
  134043. * @param numberOfSides number of sides that make up the circle
  134044. * @returns points that make the resulting circle
  134045. */
  134046. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134047. /**
  134048. * Creates a polygon from input string
  134049. * @param input Input polygon data
  134050. * @returns the parsed points
  134051. */
  134052. static Parse(input: string): Vector2[];
  134053. /**
  134054. * Starts building a polygon from x and y coordinates
  134055. * @param x x coordinate
  134056. * @param y y coordinate
  134057. * @returns the started path2
  134058. */
  134059. static StartingAt(x: number, y: number): Path2;
  134060. }
  134061. /**
  134062. * Builds a polygon
  134063. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134064. */
  134065. export class PolygonMeshBuilder {
  134066. private _points;
  134067. private _outlinepoints;
  134068. private _holes;
  134069. private _name;
  134070. private _scene;
  134071. private _epoints;
  134072. private _eholes;
  134073. private _addToepoint;
  134074. /**
  134075. * Babylon reference to the earcut plugin.
  134076. */
  134077. bjsEarcut: any;
  134078. /**
  134079. * Creates a PolygonMeshBuilder
  134080. * @param name name of the builder
  134081. * @param contours Path of the polygon
  134082. * @param scene scene to add to when creating the mesh
  134083. * @param earcutInjection can be used to inject your own earcut reference
  134084. */
  134085. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134086. /**
  134087. * Adds a whole within the polygon
  134088. * @param hole Array of points defining the hole
  134089. * @returns this
  134090. */
  134091. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134092. /**
  134093. * Creates the polygon
  134094. * @param updatable If the mesh should be updatable
  134095. * @param depth The depth of the mesh created
  134096. * @returns the created mesh
  134097. */
  134098. build(updatable?: boolean, depth?: number): Mesh;
  134099. /**
  134100. * Creates the polygon
  134101. * @param depth The depth of the mesh created
  134102. * @returns the created VertexData
  134103. */
  134104. buildVertexData(depth?: number): VertexData;
  134105. /**
  134106. * Adds a side to the polygon
  134107. * @param positions points that make the polygon
  134108. * @param normals normals of the polygon
  134109. * @param uvs uvs of the polygon
  134110. * @param indices indices of the polygon
  134111. * @param bounds bounds of the polygon
  134112. * @param points points of the polygon
  134113. * @param depth depth of the polygon
  134114. * @param flip flip of the polygon
  134115. */
  134116. private addSide;
  134117. }
  134118. }
  134119. declare module BABYLON {
  134120. /**
  134121. * Class containing static functions to help procedurally build meshes
  134122. */
  134123. export class PolygonBuilder {
  134124. /**
  134125. * Creates a polygon mesh
  134126. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134127. * * 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
  134128. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134131. * * Remember you can only change the shape positions, not their number when updating a polygon
  134132. * @param name defines the name of the mesh
  134133. * @param options defines the options used to create the mesh
  134134. * @param scene defines the hosting scene
  134135. * @param earcutInjection can be used to inject your own earcut reference
  134136. * @returns the polygon mesh
  134137. */
  134138. static CreatePolygon(name: string, options: {
  134139. shape: Vector3[];
  134140. holes?: Vector3[][];
  134141. depth?: number;
  134142. faceUV?: Vector4[];
  134143. faceColors?: Color4[];
  134144. updatable?: boolean;
  134145. sideOrientation?: number;
  134146. frontUVs?: Vector4;
  134147. backUVs?: Vector4;
  134148. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134149. /**
  134150. * Creates an extruded polygon mesh, with depth in the Y direction.
  134151. * * 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)
  134152. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134153. * @param name defines the name of the mesh
  134154. * @param options defines the options used to create the mesh
  134155. * @param scene defines the hosting scene
  134156. * @param earcutInjection can be used to inject your own earcut reference
  134157. * @returns the polygon mesh
  134158. */
  134159. static ExtrudePolygon(name: string, options: {
  134160. shape: Vector3[];
  134161. holes?: Vector3[][];
  134162. depth?: number;
  134163. faceUV?: Vector4[];
  134164. faceColors?: Color4[];
  134165. updatable?: boolean;
  134166. sideOrientation?: number;
  134167. frontUVs?: Vector4;
  134168. backUVs?: Vector4;
  134169. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134170. }
  134171. }
  134172. declare module BABYLON {
  134173. /**
  134174. * Class containing static functions to help procedurally build meshes
  134175. */
  134176. export class LatheBuilder {
  134177. /**
  134178. * Creates lathe mesh.
  134179. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134180. * * 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
  134181. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134182. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134183. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134184. * * 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
  134185. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134186. * * 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
  134187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134191. * @param name defines the name of the mesh
  134192. * @param options defines the options used to create the mesh
  134193. * @param scene defines the hosting scene
  134194. * @returns the lathe mesh
  134195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134196. */
  134197. static CreateLathe(name: string, options: {
  134198. shape: Vector3[];
  134199. radius?: number;
  134200. tessellation?: number;
  134201. clip?: number;
  134202. arc?: number;
  134203. closed?: boolean;
  134204. updatable?: boolean;
  134205. sideOrientation?: number;
  134206. frontUVs?: Vector4;
  134207. backUVs?: Vector4;
  134208. cap?: number;
  134209. invertUV?: boolean;
  134210. }, scene?: Nullable<Scene>): Mesh;
  134211. }
  134212. }
  134213. declare module BABYLON {
  134214. /**
  134215. * Class containing static functions to help procedurally build meshes
  134216. */
  134217. export class TiledPlaneBuilder {
  134218. /**
  134219. * Creates a tiled plane mesh
  134220. * * The parameter `pattern` will, depending on value, do nothing or
  134221. * * * flip (reflect about central vertical) alternate tiles across and up
  134222. * * * flip every tile on alternate rows
  134223. * * * rotate (180 degs) alternate tiles across and up
  134224. * * * rotate every tile on alternate rows
  134225. * * * flip and rotate alternate tiles across and up
  134226. * * * flip and rotate every tile on alternate rows
  134227. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134228. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134231. * * 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)
  134232. * * 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)
  134233. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134234. * @param name defines the name of the mesh
  134235. * @param options defines the options used to create the mesh
  134236. * @param scene defines the hosting scene
  134237. * @returns the box mesh
  134238. */
  134239. static CreateTiledPlane(name: string, options: {
  134240. pattern?: number;
  134241. tileSize?: number;
  134242. tileWidth?: number;
  134243. tileHeight?: number;
  134244. size?: number;
  134245. width?: number;
  134246. height?: number;
  134247. alignHorizontal?: number;
  134248. alignVertical?: number;
  134249. sideOrientation?: number;
  134250. frontUVs?: Vector4;
  134251. backUVs?: Vector4;
  134252. updatable?: boolean;
  134253. }, scene?: Nullable<Scene>): Mesh;
  134254. }
  134255. }
  134256. declare module BABYLON {
  134257. /**
  134258. * Class containing static functions to help procedurally build meshes
  134259. */
  134260. export class TubeBuilder {
  134261. /**
  134262. * Creates a tube mesh.
  134263. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134264. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134265. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134266. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134267. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134268. * * 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)
  134269. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134270. * * 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
  134271. * * 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
  134272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134276. * @param name defines the name of the mesh
  134277. * @param options defines the options used to create the mesh
  134278. * @param scene defines the hosting scene
  134279. * @returns the tube mesh
  134280. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134281. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134282. */
  134283. static CreateTube(name: string, options: {
  134284. path: Vector3[];
  134285. radius?: number;
  134286. tessellation?: number;
  134287. radiusFunction?: {
  134288. (i: number, distance: number): number;
  134289. };
  134290. cap?: number;
  134291. arc?: number;
  134292. updatable?: boolean;
  134293. sideOrientation?: number;
  134294. frontUVs?: Vector4;
  134295. backUVs?: Vector4;
  134296. instance?: Mesh;
  134297. invertUV?: boolean;
  134298. }, scene?: Nullable<Scene>): Mesh;
  134299. }
  134300. }
  134301. declare module BABYLON {
  134302. /**
  134303. * Class containing static functions to help procedurally build meshes
  134304. */
  134305. export class IcoSphereBuilder {
  134306. /**
  134307. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134308. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134309. * * 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`)
  134310. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134311. * * 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
  134312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134315. * @param name defines the name of the mesh
  134316. * @param options defines the options used to create the mesh
  134317. * @param scene defines the hosting scene
  134318. * @returns the icosahedron mesh
  134319. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134320. */
  134321. static CreateIcoSphere(name: string, options: {
  134322. radius?: number;
  134323. radiusX?: number;
  134324. radiusY?: number;
  134325. radiusZ?: number;
  134326. flat?: boolean;
  134327. subdivisions?: number;
  134328. sideOrientation?: number;
  134329. frontUVs?: Vector4;
  134330. backUVs?: Vector4;
  134331. updatable?: boolean;
  134332. }, scene?: Nullable<Scene>): Mesh;
  134333. }
  134334. }
  134335. declare module BABYLON {
  134336. /**
  134337. * Class containing static functions to help procedurally build meshes
  134338. */
  134339. export class DecalBuilder {
  134340. /**
  134341. * Creates a decal mesh.
  134342. * 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
  134343. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134344. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134345. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134346. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134347. * @param name defines the name of the mesh
  134348. * @param sourceMesh defines the mesh where the decal must be applied
  134349. * @param options defines the options used to create the mesh
  134350. * @param scene defines the hosting scene
  134351. * @returns the decal mesh
  134352. * @see https://doc.babylonjs.com/how_to/decals
  134353. */
  134354. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134355. position?: Vector3;
  134356. normal?: Vector3;
  134357. size?: Vector3;
  134358. angle?: number;
  134359. }): Mesh;
  134360. }
  134361. }
  134362. declare module BABYLON {
  134363. /**
  134364. * Class containing static functions to help procedurally build meshes
  134365. */
  134366. export class MeshBuilder {
  134367. /**
  134368. * Creates a box mesh
  134369. * * The parameter `size` sets the size (float) of each box side (default 1)
  134370. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134371. * * 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)
  134372. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134376. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134377. * @param name defines the name of the mesh
  134378. * @param options defines the options used to create the mesh
  134379. * @param scene defines the hosting scene
  134380. * @returns the box mesh
  134381. */
  134382. static CreateBox(name: string, options: {
  134383. size?: number;
  134384. width?: number;
  134385. height?: number;
  134386. depth?: number;
  134387. faceUV?: Vector4[];
  134388. faceColors?: Color4[];
  134389. sideOrientation?: number;
  134390. frontUVs?: Vector4;
  134391. backUVs?: Vector4;
  134392. updatable?: boolean;
  134393. }, scene?: Nullable<Scene>): Mesh;
  134394. /**
  134395. * Creates a tiled box mesh
  134396. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134398. * @param name defines the name of the mesh
  134399. * @param options defines the options used to create the mesh
  134400. * @param scene defines the hosting scene
  134401. * @returns the tiled box mesh
  134402. */
  134403. static CreateTiledBox(name: string, options: {
  134404. pattern?: number;
  134405. size?: number;
  134406. width?: number;
  134407. height?: number;
  134408. depth: number;
  134409. tileSize?: number;
  134410. tileWidth?: number;
  134411. tileHeight?: number;
  134412. faceUV?: Vector4[];
  134413. faceColors?: Color4[];
  134414. alignHorizontal?: number;
  134415. alignVertical?: number;
  134416. sideOrientation?: number;
  134417. updatable?: boolean;
  134418. }, scene?: Nullable<Scene>): Mesh;
  134419. /**
  134420. * Creates a sphere mesh
  134421. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134422. * * 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`)
  134423. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134424. * * 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
  134425. * * 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)
  134426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134429. * @param name defines the name of the mesh
  134430. * @param options defines the options used to create the mesh
  134431. * @param scene defines the hosting scene
  134432. * @returns the sphere mesh
  134433. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134434. */
  134435. static CreateSphere(name: string, options: {
  134436. segments?: number;
  134437. diameter?: number;
  134438. diameterX?: number;
  134439. diameterY?: number;
  134440. diameterZ?: number;
  134441. arc?: number;
  134442. slice?: number;
  134443. sideOrientation?: number;
  134444. frontUVs?: Vector4;
  134445. backUVs?: Vector4;
  134446. updatable?: boolean;
  134447. }, scene?: Nullable<Scene>): Mesh;
  134448. /**
  134449. * Creates a plane polygonal mesh. By default, this is a disc
  134450. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134451. * * 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
  134452. * * 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
  134453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134456. * @param name defines the name of the mesh
  134457. * @param options defines the options used to create the mesh
  134458. * @param scene defines the hosting scene
  134459. * @returns the plane polygonal mesh
  134460. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134461. */
  134462. static CreateDisc(name: string, options: {
  134463. radius?: number;
  134464. tessellation?: number;
  134465. arc?: number;
  134466. updatable?: boolean;
  134467. sideOrientation?: number;
  134468. frontUVs?: Vector4;
  134469. backUVs?: Vector4;
  134470. }, scene?: Nullable<Scene>): Mesh;
  134471. /**
  134472. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134473. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134474. * * 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`)
  134475. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134476. * * 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
  134477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134480. * @param name defines the name of the mesh
  134481. * @param options defines the options used to create the mesh
  134482. * @param scene defines the hosting scene
  134483. * @returns the icosahedron mesh
  134484. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134485. */
  134486. static CreateIcoSphere(name: string, options: {
  134487. radius?: number;
  134488. radiusX?: number;
  134489. radiusY?: number;
  134490. radiusZ?: number;
  134491. flat?: boolean;
  134492. subdivisions?: number;
  134493. sideOrientation?: number;
  134494. frontUVs?: Vector4;
  134495. backUVs?: Vector4;
  134496. updatable?: boolean;
  134497. }, scene?: Nullable<Scene>): Mesh;
  134498. /**
  134499. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134500. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134501. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134502. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134503. * * 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
  134504. * * 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
  134505. * * 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
  134506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134509. * * 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
  134510. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134511. * * 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
  134512. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134514. * @param name defines the name of the mesh
  134515. * @param options defines the options used to create the mesh
  134516. * @param scene defines the hosting scene
  134517. * @returns the ribbon mesh
  134518. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134520. */
  134521. static CreateRibbon(name: string, options: {
  134522. pathArray: Vector3[][];
  134523. closeArray?: boolean;
  134524. closePath?: boolean;
  134525. offset?: number;
  134526. updatable?: boolean;
  134527. sideOrientation?: number;
  134528. frontUVs?: Vector4;
  134529. backUVs?: Vector4;
  134530. instance?: Mesh;
  134531. invertUV?: boolean;
  134532. uvs?: Vector2[];
  134533. colors?: Color4[];
  134534. }, scene?: Nullable<Scene>): Mesh;
  134535. /**
  134536. * Creates a cylinder or a cone mesh
  134537. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134538. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134539. * * 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.
  134540. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134541. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134542. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134543. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134544. * * 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).
  134545. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134546. * * 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).
  134547. * * 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
  134548. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134549. * * 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
  134550. * * 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.
  134551. * * If `enclose` is false, a ring surface is one element.
  134552. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134553. * * 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
  134554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134557. * @param name defines the name of the mesh
  134558. * @param options defines the options used to create the mesh
  134559. * @param scene defines the hosting scene
  134560. * @returns the cylinder mesh
  134561. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134562. */
  134563. static CreateCylinder(name: string, options: {
  134564. height?: number;
  134565. diameterTop?: number;
  134566. diameterBottom?: number;
  134567. diameter?: number;
  134568. tessellation?: number;
  134569. subdivisions?: number;
  134570. arc?: number;
  134571. faceColors?: Color4[];
  134572. faceUV?: Vector4[];
  134573. updatable?: boolean;
  134574. hasRings?: boolean;
  134575. enclose?: boolean;
  134576. cap?: number;
  134577. sideOrientation?: number;
  134578. frontUVs?: Vector4;
  134579. backUVs?: Vector4;
  134580. }, scene?: Nullable<Scene>): Mesh;
  134581. /**
  134582. * Creates a torus mesh
  134583. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134584. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134585. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134589. * @param name defines the name of the mesh
  134590. * @param options defines the options used to create the mesh
  134591. * @param scene defines the hosting scene
  134592. * @returns the torus mesh
  134593. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134594. */
  134595. static CreateTorus(name: string, options: {
  134596. diameter?: number;
  134597. thickness?: number;
  134598. tessellation?: number;
  134599. updatable?: boolean;
  134600. sideOrientation?: number;
  134601. frontUVs?: Vector4;
  134602. backUVs?: Vector4;
  134603. }, scene?: Nullable<Scene>): Mesh;
  134604. /**
  134605. * Creates a torus knot mesh
  134606. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134607. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134608. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134609. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134613. * @param name defines the name of the mesh
  134614. * @param options defines the options used to create the mesh
  134615. * @param scene defines the hosting scene
  134616. * @returns the torus knot mesh
  134617. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134618. */
  134619. static CreateTorusKnot(name: string, options: {
  134620. radius?: number;
  134621. tube?: number;
  134622. radialSegments?: number;
  134623. tubularSegments?: number;
  134624. p?: number;
  134625. q?: number;
  134626. updatable?: boolean;
  134627. sideOrientation?: number;
  134628. frontUVs?: Vector4;
  134629. backUVs?: Vector4;
  134630. }, scene?: Nullable<Scene>): Mesh;
  134631. /**
  134632. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134633. * * 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
  134634. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134635. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134636. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134637. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134638. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134639. * * 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
  134640. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134643. * @param name defines the name of the new line system
  134644. * @param options defines the options used to create the line system
  134645. * @param scene defines the hosting scene
  134646. * @returns a new line system mesh
  134647. */
  134648. static CreateLineSystem(name: string, options: {
  134649. lines: Vector3[][];
  134650. updatable?: boolean;
  134651. instance?: Nullable<LinesMesh>;
  134652. colors?: Nullable<Color4[][]>;
  134653. useVertexAlpha?: boolean;
  134654. }, scene: Nullable<Scene>): LinesMesh;
  134655. /**
  134656. * Creates a line mesh
  134657. * 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
  134658. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134659. * * The parameter `points` is an array successive Vector3
  134660. * * 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
  134661. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134662. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134663. * * When updating an instance, remember that only point positions can change, not the number of points
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134666. * @param name defines the name of the new line system
  134667. * @param options defines the options used to create the line system
  134668. * @param scene defines the hosting scene
  134669. * @returns a new line mesh
  134670. */
  134671. static CreateLines(name: string, options: {
  134672. points: Vector3[];
  134673. updatable?: boolean;
  134674. instance?: Nullable<LinesMesh>;
  134675. colors?: Color4[];
  134676. useVertexAlpha?: boolean;
  134677. }, scene?: Nullable<Scene>): LinesMesh;
  134678. /**
  134679. * Creates a dashed line mesh
  134680. * * 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
  134681. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134682. * * The parameter `points` is an array successive Vector3
  134683. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134684. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134685. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134686. * * 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
  134687. * * When updating an instance, remember that only point positions can change, not the number of points
  134688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134689. * @param name defines the name of the mesh
  134690. * @param options defines the options used to create the mesh
  134691. * @param scene defines the hosting scene
  134692. * @returns the dashed line mesh
  134693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134694. */
  134695. static CreateDashedLines(name: string, options: {
  134696. points: Vector3[];
  134697. dashSize?: number;
  134698. gapSize?: number;
  134699. dashNb?: number;
  134700. updatable?: boolean;
  134701. instance?: LinesMesh;
  134702. }, scene?: Nullable<Scene>): LinesMesh;
  134703. /**
  134704. * 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.
  134705. * * 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.
  134706. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134707. * * 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.
  134708. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134709. * * 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
  134710. * * 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
  134711. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134716. * @param name defines the name of the mesh
  134717. * @param options defines the options used to create the mesh
  134718. * @param scene defines the hosting scene
  134719. * @returns the extruded shape mesh
  134720. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134722. */
  134723. static ExtrudeShape(name: string, options: {
  134724. shape: Vector3[];
  134725. path: Vector3[];
  134726. scale?: number;
  134727. rotation?: number;
  134728. cap?: number;
  134729. updatable?: boolean;
  134730. sideOrientation?: number;
  134731. frontUVs?: Vector4;
  134732. backUVs?: Vector4;
  134733. instance?: Mesh;
  134734. invertUV?: boolean;
  134735. }, scene?: Nullable<Scene>): Mesh;
  134736. /**
  134737. * Creates an custom extruded shape mesh.
  134738. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134739. * * 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.
  134740. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134741. * * 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
  134742. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134743. * * 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
  134744. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134745. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134746. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134747. * * 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
  134748. * * 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
  134749. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134754. * @param name defines the name of the mesh
  134755. * @param options defines the options used to create the mesh
  134756. * @param scene defines the hosting scene
  134757. * @returns the custom extruded shape mesh
  134758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134761. */
  134762. static ExtrudeShapeCustom(name: string, options: {
  134763. shape: Vector3[];
  134764. path: Vector3[];
  134765. scaleFunction?: any;
  134766. rotationFunction?: any;
  134767. ribbonCloseArray?: boolean;
  134768. ribbonClosePath?: boolean;
  134769. cap?: number;
  134770. updatable?: boolean;
  134771. sideOrientation?: number;
  134772. frontUVs?: Vector4;
  134773. backUVs?: Vector4;
  134774. instance?: Mesh;
  134775. invertUV?: boolean;
  134776. }, scene?: Nullable<Scene>): Mesh;
  134777. /**
  134778. * Creates lathe mesh.
  134779. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134780. * * 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
  134781. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134782. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134783. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134784. * * 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
  134785. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134786. * * 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
  134787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134789. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134791. * @param name defines the name of the mesh
  134792. * @param options defines the options used to create the mesh
  134793. * @param scene defines the hosting scene
  134794. * @returns the lathe mesh
  134795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134796. */
  134797. static CreateLathe(name: string, options: {
  134798. shape: Vector3[];
  134799. radius?: number;
  134800. tessellation?: number;
  134801. clip?: number;
  134802. arc?: number;
  134803. closed?: boolean;
  134804. updatable?: boolean;
  134805. sideOrientation?: number;
  134806. frontUVs?: Vector4;
  134807. backUVs?: Vector4;
  134808. cap?: number;
  134809. invertUV?: boolean;
  134810. }, scene?: Nullable<Scene>): Mesh;
  134811. /**
  134812. * Creates a tiled plane mesh
  134813. * * You can set a limited pattern arrangement with the tiles
  134814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134817. * @param name defines the name of the mesh
  134818. * @param options defines the options used to create the mesh
  134819. * @param scene defines the hosting scene
  134820. * @returns the plane mesh
  134821. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134822. */
  134823. static CreateTiledPlane(name: string, options: {
  134824. pattern?: number;
  134825. tileSize?: number;
  134826. tileWidth?: number;
  134827. tileHeight?: number;
  134828. size?: number;
  134829. width?: number;
  134830. height?: number;
  134831. alignHorizontal?: number;
  134832. alignVertical?: number;
  134833. sideOrientation?: number;
  134834. frontUVs?: Vector4;
  134835. backUVs?: Vector4;
  134836. updatable?: boolean;
  134837. }, scene?: Nullable<Scene>): Mesh;
  134838. /**
  134839. * Creates a plane mesh
  134840. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134841. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134842. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134846. * @param name defines the name of the mesh
  134847. * @param options defines the options used to create the mesh
  134848. * @param scene defines the hosting scene
  134849. * @returns the plane mesh
  134850. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134851. */
  134852. static CreatePlane(name: string, options: {
  134853. size?: number;
  134854. width?: number;
  134855. height?: number;
  134856. sideOrientation?: number;
  134857. frontUVs?: Vector4;
  134858. backUVs?: Vector4;
  134859. updatable?: boolean;
  134860. sourcePlane?: Plane;
  134861. }, scene?: Nullable<Scene>): Mesh;
  134862. /**
  134863. * Creates a ground mesh
  134864. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134865. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134867. * @param name defines the name of the mesh
  134868. * @param options defines the options used to create the mesh
  134869. * @param scene defines the hosting scene
  134870. * @returns the ground mesh
  134871. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134872. */
  134873. static CreateGround(name: string, options: {
  134874. width?: number;
  134875. height?: number;
  134876. subdivisions?: number;
  134877. subdivisionsX?: number;
  134878. subdivisionsY?: number;
  134879. updatable?: boolean;
  134880. }, scene?: Nullable<Scene>): Mesh;
  134881. /**
  134882. * Creates a tiled ground mesh
  134883. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134884. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134885. * * 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
  134886. * * 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
  134887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134888. * @param name defines the name of the mesh
  134889. * @param options defines the options used to create the mesh
  134890. * @param scene defines the hosting scene
  134891. * @returns the tiled ground mesh
  134892. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134893. */
  134894. static CreateTiledGround(name: string, options: {
  134895. xmin: number;
  134896. zmin: number;
  134897. xmax: number;
  134898. zmax: number;
  134899. subdivisions?: {
  134900. w: number;
  134901. h: number;
  134902. };
  134903. precision?: {
  134904. w: number;
  134905. h: number;
  134906. };
  134907. updatable?: boolean;
  134908. }, scene?: Nullable<Scene>): Mesh;
  134909. /**
  134910. * Creates a ground mesh from a height map
  134911. * * The parameter `url` sets the URL of the height map image resource.
  134912. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134913. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134914. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134915. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134916. * * 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.
  134917. * * 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).
  134918. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134920. * @param name defines the name of the mesh
  134921. * @param url defines the url to the height map
  134922. * @param options defines the options used to create the mesh
  134923. * @param scene defines the hosting scene
  134924. * @returns the ground mesh
  134925. * @see https://doc.babylonjs.com/babylon101/height_map
  134926. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134927. */
  134928. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134929. width?: number;
  134930. height?: number;
  134931. subdivisions?: number;
  134932. minHeight?: number;
  134933. maxHeight?: number;
  134934. colorFilter?: Color3;
  134935. alphaFilter?: number;
  134936. updatable?: boolean;
  134937. onReady?: (mesh: GroundMesh) => void;
  134938. }, scene?: Nullable<Scene>): GroundMesh;
  134939. /**
  134940. * Creates a polygon mesh
  134941. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134942. * * 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
  134943. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134946. * * Remember you can only change the shape positions, not their number when updating a polygon
  134947. * @param name defines the name of the mesh
  134948. * @param options defines the options used to create the mesh
  134949. * @param scene defines the hosting scene
  134950. * @param earcutInjection can be used to inject your own earcut reference
  134951. * @returns the polygon mesh
  134952. */
  134953. static CreatePolygon(name: string, options: {
  134954. shape: Vector3[];
  134955. holes?: Vector3[][];
  134956. depth?: number;
  134957. faceUV?: Vector4[];
  134958. faceColors?: Color4[];
  134959. updatable?: boolean;
  134960. sideOrientation?: number;
  134961. frontUVs?: Vector4;
  134962. backUVs?: Vector4;
  134963. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134964. /**
  134965. * Creates an extruded polygon mesh, with depth in the Y direction.
  134966. * * 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)
  134967. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134968. * @param name defines the name of the mesh
  134969. * @param options defines the options used to create the mesh
  134970. * @param scene defines the hosting scene
  134971. * @param earcutInjection can be used to inject your own earcut reference
  134972. * @returns the polygon mesh
  134973. */
  134974. static ExtrudePolygon(name: string, options: {
  134975. shape: Vector3[];
  134976. holes?: Vector3[][];
  134977. depth?: number;
  134978. faceUV?: Vector4[];
  134979. faceColors?: Color4[];
  134980. updatable?: boolean;
  134981. sideOrientation?: number;
  134982. frontUVs?: Vector4;
  134983. backUVs?: Vector4;
  134984. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134985. /**
  134986. * Creates a tube mesh.
  134987. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134988. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134989. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134990. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134991. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134992. * * 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)
  134993. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134994. * * 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
  134995. * * 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
  134996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135000. * @param name defines the name of the mesh
  135001. * @param options defines the options used to create the mesh
  135002. * @param scene defines the hosting scene
  135003. * @returns the tube mesh
  135004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135005. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135006. */
  135007. static CreateTube(name: string, options: {
  135008. path: Vector3[];
  135009. radius?: number;
  135010. tessellation?: number;
  135011. radiusFunction?: {
  135012. (i: number, distance: number): number;
  135013. };
  135014. cap?: number;
  135015. arc?: number;
  135016. updatable?: boolean;
  135017. sideOrientation?: number;
  135018. frontUVs?: Vector4;
  135019. backUVs?: Vector4;
  135020. instance?: Mesh;
  135021. invertUV?: boolean;
  135022. }, scene?: Nullable<Scene>): Mesh;
  135023. /**
  135024. * Creates a polyhedron mesh
  135025. * * 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
  135026. * * The parameter `size` (positive float, default 1) sets the polygon size
  135027. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135028. * * 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`
  135029. * * 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
  135030. * * 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)`)
  135031. * * 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
  135032. * * 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
  135033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135036. * @param name defines the name of the mesh
  135037. * @param options defines the options used to create the mesh
  135038. * @param scene defines the hosting scene
  135039. * @returns the polyhedron mesh
  135040. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135041. */
  135042. static CreatePolyhedron(name: string, options: {
  135043. type?: number;
  135044. size?: number;
  135045. sizeX?: number;
  135046. sizeY?: number;
  135047. sizeZ?: number;
  135048. custom?: any;
  135049. faceUV?: Vector4[];
  135050. faceColors?: Color4[];
  135051. flat?: boolean;
  135052. updatable?: boolean;
  135053. sideOrientation?: number;
  135054. frontUVs?: Vector4;
  135055. backUVs?: Vector4;
  135056. }, scene?: Nullable<Scene>): Mesh;
  135057. /**
  135058. * Creates a decal mesh.
  135059. * 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
  135060. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135061. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135062. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135063. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135064. * @param name defines the name of the mesh
  135065. * @param sourceMesh defines the mesh where the decal must be applied
  135066. * @param options defines the options used to create the mesh
  135067. * @param scene defines the hosting scene
  135068. * @returns the decal mesh
  135069. * @see https://doc.babylonjs.com/how_to/decals
  135070. */
  135071. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135072. position?: Vector3;
  135073. normal?: Vector3;
  135074. size?: Vector3;
  135075. angle?: number;
  135076. }): Mesh;
  135077. }
  135078. }
  135079. declare module BABYLON {
  135080. /**
  135081. * A simplifier interface for future simplification implementations
  135082. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135083. */
  135084. export interface ISimplifier {
  135085. /**
  135086. * Simplification of a given mesh according to the given settings.
  135087. * Since this requires computation, it is assumed that the function runs async.
  135088. * @param settings The settings of the simplification, including quality and distance
  135089. * @param successCallback A callback that will be called after the mesh was simplified.
  135090. * @param errorCallback in case of an error, this callback will be called. optional.
  135091. */
  135092. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135093. }
  135094. /**
  135095. * Expected simplification settings.
  135096. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135098. */
  135099. export interface ISimplificationSettings {
  135100. /**
  135101. * Gets or sets the expected quality
  135102. */
  135103. quality: number;
  135104. /**
  135105. * Gets or sets the distance when this optimized version should be used
  135106. */
  135107. distance: number;
  135108. /**
  135109. * Gets an already optimized mesh
  135110. */
  135111. optimizeMesh?: boolean;
  135112. }
  135113. /**
  135114. * Class used to specify simplification options
  135115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135116. */
  135117. export class SimplificationSettings implements ISimplificationSettings {
  135118. /** expected quality */
  135119. quality: number;
  135120. /** distance when this optimized version should be used */
  135121. distance: number;
  135122. /** already optimized mesh */
  135123. optimizeMesh?: boolean | undefined;
  135124. /**
  135125. * Creates a SimplificationSettings
  135126. * @param quality expected quality
  135127. * @param distance distance when this optimized version should be used
  135128. * @param optimizeMesh already optimized mesh
  135129. */
  135130. constructor(
  135131. /** expected quality */
  135132. quality: number,
  135133. /** distance when this optimized version should be used */
  135134. distance: number,
  135135. /** already optimized mesh */
  135136. optimizeMesh?: boolean | undefined);
  135137. }
  135138. /**
  135139. * Interface used to define a simplification task
  135140. */
  135141. export interface ISimplificationTask {
  135142. /**
  135143. * Array of settings
  135144. */
  135145. settings: Array<ISimplificationSettings>;
  135146. /**
  135147. * Simplification type
  135148. */
  135149. simplificationType: SimplificationType;
  135150. /**
  135151. * Mesh to simplify
  135152. */
  135153. mesh: Mesh;
  135154. /**
  135155. * Callback called on success
  135156. */
  135157. successCallback?: () => void;
  135158. /**
  135159. * Defines if parallel processing can be used
  135160. */
  135161. parallelProcessing: boolean;
  135162. }
  135163. /**
  135164. * Queue used to order the simplification tasks
  135165. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135166. */
  135167. export class SimplificationQueue {
  135168. private _simplificationArray;
  135169. /**
  135170. * Gets a boolean indicating that the process is still running
  135171. */
  135172. running: boolean;
  135173. /**
  135174. * Creates a new queue
  135175. */
  135176. constructor();
  135177. /**
  135178. * Adds a new simplification task
  135179. * @param task defines a task to add
  135180. */
  135181. addTask(task: ISimplificationTask): void;
  135182. /**
  135183. * Execute next task
  135184. */
  135185. executeNext(): void;
  135186. /**
  135187. * Execute a simplification task
  135188. * @param task defines the task to run
  135189. */
  135190. runSimplification(task: ISimplificationTask): void;
  135191. private getSimplifier;
  135192. }
  135193. /**
  135194. * The implemented types of simplification
  135195. * At the moment only Quadratic Error Decimation is implemented
  135196. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135197. */
  135198. export enum SimplificationType {
  135199. /** Quadratic error decimation */
  135200. QUADRATIC = 0
  135201. }
  135202. /**
  135203. * An implementation of the Quadratic Error simplification algorithm.
  135204. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  135205. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  135206. * @author RaananW
  135207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135208. */
  135209. export class QuadraticErrorSimplification implements ISimplifier {
  135210. private _mesh;
  135211. private triangles;
  135212. private vertices;
  135213. private references;
  135214. private _reconstructedMesh;
  135215. /** Gets or sets the number pf sync interations */
  135216. syncIterations: number;
  135217. /** Gets or sets the aggressiveness of the simplifier */
  135218. aggressiveness: number;
  135219. /** Gets or sets the number of allowed iterations for decimation */
  135220. decimationIterations: number;
  135221. /** Gets or sets the espilon to use for bounding box computation */
  135222. boundingBoxEpsilon: number;
  135223. /**
  135224. * Creates a new QuadraticErrorSimplification
  135225. * @param _mesh defines the target mesh
  135226. */
  135227. constructor(_mesh: Mesh);
  135228. /**
  135229. * Simplification of a given mesh according to the given settings.
  135230. * Since this requires computation, it is assumed that the function runs async.
  135231. * @param settings The settings of the simplification, including quality and distance
  135232. * @param successCallback A callback that will be called after the mesh was simplified.
  135233. */
  135234. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  135235. private runDecimation;
  135236. private initWithMesh;
  135237. private init;
  135238. private reconstructMesh;
  135239. private initDecimatedMesh;
  135240. private isFlipped;
  135241. private updateTriangles;
  135242. private identifyBorder;
  135243. private updateMesh;
  135244. private vertexError;
  135245. private calculateError;
  135246. }
  135247. }
  135248. declare module BABYLON {
  135249. interface Scene {
  135250. /** @hidden (Backing field) */
  135251. _simplificationQueue: SimplificationQueue;
  135252. /**
  135253. * Gets or sets the simplification queue attached to the scene
  135254. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135255. */
  135256. simplificationQueue: SimplificationQueue;
  135257. }
  135258. interface Mesh {
  135259. /**
  135260. * Simplify the mesh according to the given array of settings.
  135261. * Function will return immediately and will simplify async
  135262. * @param settings a collection of simplification settings
  135263. * @param parallelProcessing should all levels calculate parallel or one after the other
  135264. * @param simplificationType the type of simplification to run
  135265. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135266. * @returns the current mesh
  135267. */
  135268. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135269. }
  135270. /**
  135271. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135272. * created in a scene
  135273. */
  135274. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135275. /**
  135276. * The component name helpfull to identify the component in the list of scene components.
  135277. */
  135278. readonly name: string;
  135279. /**
  135280. * The scene the component belongs to.
  135281. */
  135282. scene: Scene;
  135283. /**
  135284. * Creates a new instance of the component for the given scene
  135285. * @param scene Defines the scene to register the component in
  135286. */
  135287. constructor(scene: Scene);
  135288. /**
  135289. * Registers the component in a given scene
  135290. */
  135291. register(): void;
  135292. /**
  135293. * Rebuilds the elements related to this component in case of
  135294. * context lost for instance.
  135295. */
  135296. rebuild(): void;
  135297. /**
  135298. * Disposes the component and the associated ressources
  135299. */
  135300. dispose(): void;
  135301. private _beforeCameraUpdate;
  135302. }
  135303. }
  135304. declare module BABYLON {
  135305. /**
  135306. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135307. */
  135308. export interface INavigationEnginePlugin {
  135309. /**
  135310. * plugin name
  135311. */
  135312. name: string;
  135313. /**
  135314. * Creates a navigation mesh
  135315. * @param meshes array of all the geometry used to compute the navigatio mesh
  135316. * @param parameters bunch of parameters used to filter geometry
  135317. */
  135318. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135319. /**
  135320. * Create a navigation mesh debug mesh
  135321. * @param scene is where the mesh will be added
  135322. * @returns debug display mesh
  135323. */
  135324. createDebugNavMesh(scene: Scene): Mesh;
  135325. /**
  135326. * Get a navigation mesh constrained position, closest to the parameter position
  135327. * @param position world position
  135328. * @returns the closest point to position constrained by the navigation mesh
  135329. */
  135330. getClosestPoint(position: Vector3): Vector3;
  135331. /**
  135332. * Get a navigation mesh constrained position, within a particular radius
  135333. * @param position world position
  135334. * @param maxRadius the maximum distance to the constrained world position
  135335. * @returns the closest point to position constrained by the navigation mesh
  135336. */
  135337. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135338. /**
  135339. * Compute the final position from a segment made of destination-position
  135340. * @param position world position
  135341. * @param destination world position
  135342. * @returns the resulting point along the navmesh
  135343. */
  135344. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135345. /**
  135346. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135347. * @param start world position
  135348. * @param end world position
  135349. * @returns array containing world position composing the path
  135350. */
  135351. computePath(start: Vector3, end: Vector3): Vector3[];
  135352. /**
  135353. * If this plugin is supported
  135354. * @returns true if plugin is supported
  135355. */
  135356. isSupported(): boolean;
  135357. /**
  135358. * Create a new Crowd so you can add agents
  135359. * @param maxAgents the maximum agent count in the crowd
  135360. * @param maxAgentRadius the maximum radius an agent can have
  135361. * @param scene to attach the crowd to
  135362. * @returns the crowd you can add agents to
  135363. */
  135364. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135365. /**
  135366. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135367. * The queries will try to find a solution within those bounds
  135368. * default is (1,1,1)
  135369. * @param extent x,y,z value that define the extent around the queries point of reference
  135370. */
  135371. setDefaultQueryExtent(extent: Vector3): void;
  135372. /**
  135373. * Get the Bounding box extent specified by setDefaultQueryExtent
  135374. * @returns the box extent values
  135375. */
  135376. getDefaultQueryExtent(): Vector3;
  135377. /**
  135378. * Release all resources
  135379. */
  135380. dispose(): void;
  135381. }
  135382. /**
  135383. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135384. */
  135385. export interface ICrowd {
  135386. /**
  135387. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135388. * You can attach anything to that node. The node position is updated in the scene update tick.
  135389. * @param pos world position that will be constrained by the navigation mesh
  135390. * @param parameters agent parameters
  135391. * @param transform hooked to the agent that will be update by the scene
  135392. * @returns agent index
  135393. */
  135394. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135395. /**
  135396. * Returns the agent position in world space
  135397. * @param index agent index returned by addAgent
  135398. * @returns world space position
  135399. */
  135400. getAgentPosition(index: number): Vector3;
  135401. /**
  135402. * Gets the agent velocity in world space
  135403. * @param index agent index returned by addAgent
  135404. * @returns world space velocity
  135405. */
  135406. getAgentVelocity(index: number): Vector3;
  135407. /**
  135408. * remove a particular agent previously created
  135409. * @param index agent index returned by addAgent
  135410. */
  135411. removeAgent(index: number): void;
  135412. /**
  135413. * get the list of all agents attached to this crowd
  135414. * @returns list of agent indices
  135415. */
  135416. getAgents(): number[];
  135417. /**
  135418. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135419. * @param deltaTime in seconds
  135420. */
  135421. update(deltaTime: number): void;
  135422. /**
  135423. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135424. * @param index agent index returned by addAgent
  135425. * @param destination targeted world position
  135426. */
  135427. agentGoto(index: number, destination: Vector3): void;
  135428. /**
  135429. * Teleport the agent to a new position
  135430. * @param index agent index returned by addAgent
  135431. * @param destination targeted world position
  135432. */
  135433. agentTeleport(index: number, destination: Vector3): void;
  135434. /**
  135435. * Update agent parameters
  135436. * @param index agent index returned by addAgent
  135437. * @param parameters agent parameters
  135438. */
  135439. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135440. /**
  135441. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135442. * The queries will try to find a solution within those bounds
  135443. * default is (1,1,1)
  135444. * @param extent x,y,z value that define the extent around the queries point of reference
  135445. */
  135446. setDefaultQueryExtent(extent: Vector3): void;
  135447. /**
  135448. * Get the Bounding box extent specified by setDefaultQueryExtent
  135449. * @returns the box extent values
  135450. */
  135451. getDefaultQueryExtent(): Vector3;
  135452. /**
  135453. * Release all resources
  135454. */
  135455. dispose(): void;
  135456. }
  135457. /**
  135458. * Configures an agent
  135459. */
  135460. export interface IAgentParameters {
  135461. /**
  135462. * Agent radius. [Limit: >= 0]
  135463. */
  135464. radius: number;
  135465. /**
  135466. * Agent height. [Limit: > 0]
  135467. */
  135468. height: number;
  135469. /**
  135470. * Maximum allowed acceleration. [Limit: >= 0]
  135471. */
  135472. maxAcceleration: number;
  135473. /**
  135474. * Maximum allowed speed. [Limit: >= 0]
  135475. */
  135476. maxSpeed: number;
  135477. /**
  135478. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135479. */
  135480. collisionQueryRange: number;
  135481. /**
  135482. * The path visibility optimization range. [Limit: > 0]
  135483. */
  135484. pathOptimizationRange: number;
  135485. /**
  135486. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135487. */
  135488. separationWeight: number;
  135489. }
  135490. /**
  135491. * Configures the navigation mesh creation
  135492. */
  135493. export interface INavMeshParameters {
  135494. /**
  135495. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135496. */
  135497. cs: number;
  135498. /**
  135499. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135500. */
  135501. ch: number;
  135502. /**
  135503. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135504. */
  135505. walkableSlopeAngle: number;
  135506. /**
  135507. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135508. * be considered walkable. [Limit: >= 3] [Units: vx]
  135509. */
  135510. walkableHeight: number;
  135511. /**
  135512. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135513. */
  135514. walkableClimb: number;
  135515. /**
  135516. * The distance to erode/shrink the walkable area of the heightfield away from
  135517. * obstructions. [Limit: >=0] [Units: vx]
  135518. */
  135519. walkableRadius: number;
  135520. /**
  135521. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135522. */
  135523. maxEdgeLen: number;
  135524. /**
  135525. * The maximum distance a simplfied contour's border edges should deviate
  135526. * the original raw contour. [Limit: >=0] [Units: vx]
  135527. */
  135528. maxSimplificationError: number;
  135529. /**
  135530. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135531. */
  135532. minRegionArea: number;
  135533. /**
  135534. * Any regions with a span count smaller than this value will, if possible,
  135535. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135536. */
  135537. mergeRegionArea: number;
  135538. /**
  135539. * The maximum number of vertices allowed for polygons generated during the
  135540. * contour to polygon conversion process. [Limit: >= 3]
  135541. */
  135542. maxVertsPerPoly: number;
  135543. /**
  135544. * Sets the sampling distance to use when generating the detail mesh.
  135545. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135546. */
  135547. detailSampleDist: number;
  135548. /**
  135549. * The maximum distance the detail mesh surface should deviate from heightfield
  135550. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135551. */
  135552. detailSampleMaxError: number;
  135553. }
  135554. }
  135555. declare module BABYLON {
  135556. /**
  135557. * RecastJS navigation plugin
  135558. */
  135559. export class RecastJSPlugin implements INavigationEnginePlugin {
  135560. /**
  135561. * Reference to the Recast library
  135562. */
  135563. bjsRECAST: any;
  135564. /**
  135565. * plugin name
  135566. */
  135567. name: string;
  135568. /**
  135569. * the first navmesh created. We might extend this to support multiple navmeshes
  135570. */
  135571. navMesh: any;
  135572. /**
  135573. * Initializes the recastJS plugin
  135574. * @param recastInjection can be used to inject your own recast reference
  135575. */
  135576. constructor(recastInjection?: any);
  135577. /**
  135578. * Creates a navigation mesh
  135579. * @param meshes array of all the geometry used to compute the navigatio mesh
  135580. * @param parameters bunch of parameters used to filter geometry
  135581. */
  135582. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135583. /**
  135584. * Create a navigation mesh debug mesh
  135585. * @param scene is where the mesh will be added
  135586. * @returns debug display mesh
  135587. */
  135588. createDebugNavMesh(scene: Scene): Mesh;
  135589. /**
  135590. * Get a navigation mesh constrained position, closest to the parameter position
  135591. * @param position world position
  135592. * @returns the closest point to position constrained by the navigation mesh
  135593. */
  135594. getClosestPoint(position: Vector3): Vector3;
  135595. /**
  135596. * Get a navigation mesh constrained position, within a particular radius
  135597. * @param position world position
  135598. * @param maxRadius the maximum distance to the constrained world position
  135599. * @returns the closest point to position constrained by the navigation mesh
  135600. */
  135601. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135602. /**
  135603. * Compute the final position from a segment made of destination-position
  135604. * @param position world position
  135605. * @param destination world position
  135606. * @returns the resulting point along the navmesh
  135607. */
  135608. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135609. /**
  135610. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135611. * @param start world position
  135612. * @param end world position
  135613. * @returns array containing world position composing the path
  135614. */
  135615. computePath(start: Vector3, end: Vector3): Vector3[];
  135616. /**
  135617. * Create a new Crowd so you can add agents
  135618. * @param maxAgents the maximum agent count in the crowd
  135619. * @param maxAgentRadius the maximum radius an agent can have
  135620. * @param scene to attach the crowd to
  135621. * @returns the crowd you can add agents to
  135622. */
  135623. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135624. /**
  135625. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135626. * The queries will try to find a solution within those bounds
  135627. * default is (1,1,1)
  135628. * @param extent x,y,z value that define the extent around the queries point of reference
  135629. */
  135630. setDefaultQueryExtent(extent: Vector3): void;
  135631. /**
  135632. * Get the Bounding box extent specified by setDefaultQueryExtent
  135633. * @returns the box extent values
  135634. */
  135635. getDefaultQueryExtent(): Vector3;
  135636. /**
  135637. * Disposes
  135638. */
  135639. dispose(): void;
  135640. /**
  135641. * If this plugin is supported
  135642. * @returns true if plugin is supported
  135643. */
  135644. isSupported(): boolean;
  135645. }
  135646. /**
  135647. * Recast detour crowd implementation
  135648. */
  135649. export class RecastJSCrowd implements ICrowd {
  135650. /**
  135651. * Recast/detour plugin
  135652. */
  135653. bjsRECASTPlugin: RecastJSPlugin;
  135654. /**
  135655. * Link to the detour crowd
  135656. */
  135657. recastCrowd: any;
  135658. /**
  135659. * One transform per agent
  135660. */
  135661. transforms: TransformNode[];
  135662. /**
  135663. * All agents created
  135664. */
  135665. agents: number[];
  135666. /**
  135667. * Link to the scene is kept to unregister the crowd from the scene
  135668. */
  135669. private _scene;
  135670. /**
  135671. * Observer for crowd updates
  135672. */
  135673. private _onBeforeAnimationsObserver;
  135674. /**
  135675. * Constructor
  135676. * @param plugin recastJS plugin
  135677. * @param maxAgents the maximum agent count in the crowd
  135678. * @param maxAgentRadius the maximum radius an agent can have
  135679. * @param scene to attach the crowd to
  135680. * @returns the crowd you can add agents to
  135681. */
  135682. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135683. /**
  135684. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135685. * You can attach anything to that node. The node position is updated in the scene update tick.
  135686. * @param pos world position that will be constrained by the navigation mesh
  135687. * @param parameters agent parameters
  135688. * @param transform hooked to the agent that will be update by the scene
  135689. * @returns agent index
  135690. */
  135691. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135692. /**
  135693. * Returns the agent position in world space
  135694. * @param index agent index returned by addAgent
  135695. * @returns world space position
  135696. */
  135697. getAgentPosition(index: number): Vector3;
  135698. /**
  135699. * Returns the agent velocity in world space
  135700. * @param index agent index returned by addAgent
  135701. * @returns world space velocity
  135702. */
  135703. getAgentVelocity(index: number): Vector3;
  135704. /**
  135705. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135706. * @param index agent index returned by addAgent
  135707. * @param destination targeted world position
  135708. */
  135709. agentGoto(index: number, destination: Vector3): void;
  135710. /**
  135711. * Teleport the agent to a new position
  135712. * @param index agent index returned by addAgent
  135713. * @param destination targeted world position
  135714. */
  135715. agentTeleport(index: number, destination: Vector3): void;
  135716. /**
  135717. * Update agent parameters
  135718. * @param index agent index returned by addAgent
  135719. * @param parameters agent parameters
  135720. */
  135721. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135722. /**
  135723. * remove a particular agent previously created
  135724. * @param index agent index returned by addAgent
  135725. */
  135726. removeAgent(index: number): void;
  135727. /**
  135728. * get the list of all agents attached to this crowd
  135729. * @returns list of agent indices
  135730. */
  135731. getAgents(): number[];
  135732. /**
  135733. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135734. * @param deltaTime in seconds
  135735. */
  135736. update(deltaTime: number): void;
  135737. /**
  135738. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135739. * The queries will try to find a solution within those bounds
  135740. * default is (1,1,1)
  135741. * @param extent x,y,z value that define the extent around the queries point of reference
  135742. */
  135743. setDefaultQueryExtent(extent: Vector3): void;
  135744. /**
  135745. * Get the Bounding box extent specified by setDefaultQueryExtent
  135746. * @returns the box extent values
  135747. */
  135748. getDefaultQueryExtent(): Vector3;
  135749. /**
  135750. * Release all resources
  135751. */
  135752. dispose(): void;
  135753. }
  135754. }
  135755. declare module BABYLON {
  135756. /**
  135757. * Class used to enable access to IndexedDB
  135758. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135759. */
  135760. export class Database implements IOfflineProvider {
  135761. private _callbackManifestChecked;
  135762. private _currentSceneUrl;
  135763. private _db;
  135764. private _enableSceneOffline;
  135765. private _enableTexturesOffline;
  135766. private _manifestVersionFound;
  135767. private _mustUpdateRessources;
  135768. private _hasReachedQuota;
  135769. private _isSupported;
  135770. private _idbFactory;
  135771. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135772. private static IsUASupportingBlobStorage;
  135773. /**
  135774. * Gets a boolean indicating if Database storate is enabled (off by default)
  135775. */
  135776. static IDBStorageEnabled: boolean;
  135777. /**
  135778. * Gets a boolean indicating if scene must be saved in the database
  135779. */
  135780. get enableSceneOffline(): boolean;
  135781. /**
  135782. * Gets a boolean indicating if textures must be saved in the database
  135783. */
  135784. get enableTexturesOffline(): boolean;
  135785. /**
  135786. * Creates a new Database
  135787. * @param urlToScene defines the url to load the scene
  135788. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135789. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135790. */
  135791. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135792. private static _ParseURL;
  135793. private static _ReturnFullUrlLocation;
  135794. private _checkManifestFile;
  135795. /**
  135796. * Open the database and make it available
  135797. * @param successCallback defines the callback to call on success
  135798. * @param errorCallback defines the callback to call on error
  135799. */
  135800. open(successCallback: () => void, errorCallback: () => void): void;
  135801. /**
  135802. * Loads an image from the database
  135803. * @param url defines the url to load from
  135804. * @param image defines the target DOM image
  135805. */
  135806. loadImage(url: string, image: HTMLImageElement): void;
  135807. private _loadImageFromDBAsync;
  135808. private _saveImageIntoDBAsync;
  135809. private _checkVersionFromDB;
  135810. private _loadVersionFromDBAsync;
  135811. private _saveVersionIntoDBAsync;
  135812. /**
  135813. * Loads a file from database
  135814. * @param url defines the URL to load from
  135815. * @param sceneLoaded defines a callback to call on success
  135816. * @param progressCallBack defines a callback to call when progress changed
  135817. * @param errorCallback defines a callback to call on error
  135818. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135819. */
  135820. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135821. private _loadFileAsync;
  135822. private _saveFileAsync;
  135823. /**
  135824. * Validates if xhr data is correct
  135825. * @param xhr defines the request to validate
  135826. * @param dataType defines the expected data type
  135827. * @returns true if data is correct
  135828. */
  135829. private static _ValidateXHRData;
  135830. }
  135831. }
  135832. declare module BABYLON {
  135833. /** @hidden */
  135834. export var gpuUpdateParticlesPixelShader: {
  135835. name: string;
  135836. shader: string;
  135837. };
  135838. }
  135839. declare module BABYLON {
  135840. /** @hidden */
  135841. export var gpuUpdateParticlesVertexShader: {
  135842. name: string;
  135843. shader: string;
  135844. };
  135845. }
  135846. declare module BABYLON {
  135847. /** @hidden */
  135848. export var clipPlaneFragmentDeclaration2: {
  135849. name: string;
  135850. shader: string;
  135851. };
  135852. }
  135853. declare module BABYLON {
  135854. /** @hidden */
  135855. export var gpuRenderParticlesPixelShader: {
  135856. name: string;
  135857. shader: string;
  135858. };
  135859. }
  135860. declare module BABYLON {
  135861. /** @hidden */
  135862. export var clipPlaneVertexDeclaration2: {
  135863. name: string;
  135864. shader: string;
  135865. };
  135866. }
  135867. declare module BABYLON {
  135868. /** @hidden */
  135869. export var gpuRenderParticlesVertexShader: {
  135870. name: string;
  135871. shader: string;
  135872. };
  135873. }
  135874. declare module BABYLON {
  135875. /**
  135876. * This represents a GPU particle system in Babylon
  135877. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135878. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135879. */
  135880. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135881. /**
  135882. * The layer mask we are rendering the particles through.
  135883. */
  135884. layerMask: number;
  135885. private _capacity;
  135886. private _activeCount;
  135887. private _currentActiveCount;
  135888. private _accumulatedCount;
  135889. private _renderEffect;
  135890. private _updateEffect;
  135891. private _buffer0;
  135892. private _buffer1;
  135893. private _spriteBuffer;
  135894. private _updateVAO;
  135895. private _renderVAO;
  135896. private _targetIndex;
  135897. private _sourceBuffer;
  135898. private _targetBuffer;
  135899. private _engine;
  135900. private _currentRenderId;
  135901. private _started;
  135902. private _stopped;
  135903. private _timeDelta;
  135904. private _randomTexture;
  135905. private _randomTexture2;
  135906. private _attributesStrideSize;
  135907. private _updateEffectOptions;
  135908. private _randomTextureSize;
  135909. private _actualFrame;
  135910. private readonly _rawTextureWidth;
  135911. /**
  135912. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135913. */
  135914. static get IsSupported(): boolean;
  135915. /**
  135916. * An event triggered when the system is disposed.
  135917. */
  135918. onDisposeObservable: Observable<GPUParticleSystem>;
  135919. /**
  135920. * Gets the maximum number of particles active at the same time.
  135921. * @returns The max number of active particles.
  135922. */
  135923. getCapacity(): number;
  135924. /**
  135925. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135926. * to override the particles.
  135927. */
  135928. forceDepthWrite: boolean;
  135929. /**
  135930. * Gets or set the number of active particles
  135931. */
  135932. get activeParticleCount(): number;
  135933. set activeParticleCount(value: number);
  135934. private _preWarmDone;
  135935. /**
  135936. * Specifies if the particles are updated in emitter local space or world space.
  135937. * This is always false for GPU particles
  135938. */
  135939. get isLocal(): boolean;
  135940. set isLocal(value: boolean);
  135941. /**
  135942. * Is this system ready to be used/rendered
  135943. * @return true if the system is ready
  135944. */
  135945. isReady(): boolean;
  135946. /**
  135947. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135948. * @returns True if it has been started, otherwise false.
  135949. */
  135950. isStarted(): boolean;
  135951. /**
  135952. * Starts the particle system and begins to emit
  135953. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135954. */
  135955. start(delay?: number): void;
  135956. /**
  135957. * Stops the particle system.
  135958. */
  135959. stop(): void;
  135960. /**
  135961. * Remove all active particles
  135962. */
  135963. reset(): void;
  135964. /**
  135965. * Returns the string "GPUParticleSystem"
  135966. * @returns a string containing the class name
  135967. */
  135968. getClassName(): string;
  135969. private _colorGradientsTexture;
  135970. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135971. /**
  135972. * Adds a new color gradient
  135973. * @param gradient defines the gradient to use (between 0 and 1)
  135974. * @param color1 defines the color to affect to the specified gradient
  135975. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135976. * @returns the current particle system
  135977. */
  135978. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135979. /**
  135980. * Remove a specific color gradient
  135981. * @param gradient defines the gradient to remove
  135982. * @returns the current particle system
  135983. */
  135984. removeColorGradient(gradient: number): GPUParticleSystem;
  135985. private _angularSpeedGradientsTexture;
  135986. private _sizeGradientsTexture;
  135987. private _velocityGradientsTexture;
  135988. private _limitVelocityGradientsTexture;
  135989. private _dragGradientsTexture;
  135990. private _addFactorGradient;
  135991. /**
  135992. * Adds a new size gradient
  135993. * @param gradient defines the gradient to use (between 0 and 1)
  135994. * @param factor defines the size factor to affect to the specified gradient
  135995. * @returns the current particle system
  135996. */
  135997. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135998. /**
  135999. * Remove a specific size gradient
  136000. * @param gradient defines the gradient to remove
  136001. * @returns the current particle system
  136002. */
  136003. removeSizeGradient(gradient: number): GPUParticleSystem;
  136004. /**
  136005. * Adds a new angular speed gradient
  136006. * @param gradient defines the gradient to use (between 0 and 1)
  136007. * @param factor defines the angular speed to affect to the specified gradient
  136008. * @returns the current particle system
  136009. */
  136010. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  136011. /**
  136012. * Remove a specific angular speed gradient
  136013. * @param gradient defines the gradient to remove
  136014. * @returns the current particle system
  136015. */
  136016. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  136017. /**
  136018. * Adds a new velocity gradient
  136019. * @param gradient defines the gradient to use (between 0 and 1)
  136020. * @param factor defines the velocity to affect to the specified gradient
  136021. * @returns the current particle system
  136022. */
  136023. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136024. /**
  136025. * Remove a specific velocity gradient
  136026. * @param gradient defines the gradient to remove
  136027. * @returns the current particle system
  136028. */
  136029. removeVelocityGradient(gradient: number): GPUParticleSystem;
  136030. /**
  136031. * Adds a new limit velocity gradient
  136032. * @param gradient defines the gradient to use (between 0 and 1)
  136033. * @param factor defines the limit velocity value to affect to the specified gradient
  136034. * @returns the current particle system
  136035. */
  136036. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136037. /**
  136038. * Remove a specific limit velocity gradient
  136039. * @param gradient defines the gradient to remove
  136040. * @returns the current particle system
  136041. */
  136042. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  136043. /**
  136044. * Adds a new drag gradient
  136045. * @param gradient defines the gradient to use (between 0 and 1)
  136046. * @param factor defines the drag value to affect to the specified gradient
  136047. * @returns the current particle system
  136048. */
  136049. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  136050. /**
  136051. * Remove a specific drag gradient
  136052. * @param gradient defines the gradient to remove
  136053. * @returns the current particle system
  136054. */
  136055. removeDragGradient(gradient: number): GPUParticleSystem;
  136056. /**
  136057. * Not supported by GPUParticleSystem
  136058. * @param gradient defines the gradient to use (between 0 and 1)
  136059. * @param factor defines the emit rate value to affect to the specified gradient
  136060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136061. * @returns the current particle system
  136062. */
  136063. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136064. /**
  136065. * Not supported by GPUParticleSystem
  136066. * @param gradient defines the gradient to remove
  136067. * @returns the current particle system
  136068. */
  136069. removeEmitRateGradient(gradient: number): IParticleSystem;
  136070. /**
  136071. * Not supported by GPUParticleSystem
  136072. * @param gradient defines the gradient to use (between 0 and 1)
  136073. * @param factor defines the start size value to affect to the specified gradient
  136074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136075. * @returns the current particle system
  136076. */
  136077. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136078. /**
  136079. * Not supported by GPUParticleSystem
  136080. * @param gradient defines the gradient to remove
  136081. * @returns the current particle system
  136082. */
  136083. removeStartSizeGradient(gradient: number): IParticleSystem;
  136084. /**
  136085. * Not supported by GPUParticleSystem
  136086. * @param gradient defines the gradient to use (between 0 and 1)
  136087. * @param min defines the color remap minimal range
  136088. * @param max defines the color remap maximal range
  136089. * @returns the current particle system
  136090. */
  136091. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136092. /**
  136093. * Not supported by GPUParticleSystem
  136094. * @param gradient defines the gradient to remove
  136095. * @returns the current particle system
  136096. */
  136097. removeColorRemapGradient(): IParticleSystem;
  136098. /**
  136099. * Not supported by GPUParticleSystem
  136100. * @param gradient defines the gradient to use (between 0 and 1)
  136101. * @param min defines the alpha remap minimal range
  136102. * @param max defines the alpha remap maximal range
  136103. * @returns the current particle system
  136104. */
  136105. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136106. /**
  136107. * Not supported by GPUParticleSystem
  136108. * @param gradient defines the gradient to remove
  136109. * @returns the current particle system
  136110. */
  136111. removeAlphaRemapGradient(): IParticleSystem;
  136112. /**
  136113. * Not supported by GPUParticleSystem
  136114. * @param gradient defines the gradient to use (between 0 and 1)
  136115. * @param color defines the color to affect to the specified gradient
  136116. * @returns the current particle system
  136117. */
  136118. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136119. /**
  136120. * Not supported by GPUParticleSystem
  136121. * @param gradient defines the gradient to remove
  136122. * @returns the current particle system
  136123. */
  136124. removeRampGradient(): IParticleSystem;
  136125. /**
  136126. * Not supported by GPUParticleSystem
  136127. * @returns the list of ramp gradients
  136128. */
  136129. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136130. /**
  136131. * Not supported by GPUParticleSystem
  136132. * Gets or sets a boolean indicating that ramp gradients must be used
  136133. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136134. */
  136135. get useRampGradients(): boolean;
  136136. set useRampGradients(value: boolean);
  136137. /**
  136138. * Not supported by GPUParticleSystem
  136139. * @param gradient defines the gradient to use (between 0 and 1)
  136140. * @param factor defines the life time factor to affect to the specified gradient
  136141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136142. * @returns the current particle system
  136143. */
  136144. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136145. /**
  136146. * Not supported by GPUParticleSystem
  136147. * @param gradient defines the gradient to remove
  136148. * @returns the current particle system
  136149. */
  136150. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136151. /**
  136152. * Instantiates a GPU particle system.
  136153. * 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.
  136154. * @param name The name of the particle system
  136155. * @param options The options used to create the system
  136156. * @param scene The scene the particle system belongs to
  136157. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136158. */
  136159. constructor(name: string, options: Partial<{
  136160. capacity: number;
  136161. randomTextureSize: number;
  136162. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136163. protected _reset(): void;
  136164. private _createUpdateVAO;
  136165. private _createRenderVAO;
  136166. private _initialize;
  136167. /** @hidden */
  136168. _recreateUpdateEffect(): void;
  136169. /** @hidden */
  136170. _recreateRenderEffect(): void;
  136171. /**
  136172. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136173. * @param preWarm defines if we are in the pre-warmimg phase
  136174. */
  136175. animate(preWarm?: boolean): void;
  136176. private _createFactorGradientTexture;
  136177. private _createSizeGradientTexture;
  136178. private _createAngularSpeedGradientTexture;
  136179. private _createVelocityGradientTexture;
  136180. private _createLimitVelocityGradientTexture;
  136181. private _createDragGradientTexture;
  136182. private _createColorGradientTexture;
  136183. /**
  136184. * Renders the particle system in its current state
  136185. * @param preWarm defines if the system should only update the particles but not render them
  136186. * @returns the current number of particles
  136187. */
  136188. render(preWarm?: boolean): number;
  136189. /**
  136190. * Rebuilds the particle system
  136191. */
  136192. rebuild(): void;
  136193. private _releaseBuffers;
  136194. private _releaseVAOs;
  136195. /**
  136196. * Disposes the particle system and free the associated resources
  136197. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136198. */
  136199. dispose(disposeTexture?: boolean): void;
  136200. /**
  136201. * Clones the particle system.
  136202. * @param name The name of the cloned object
  136203. * @param newEmitter The new emitter to use
  136204. * @returns the cloned particle system
  136205. */
  136206. clone(name: string, newEmitter: any): GPUParticleSystem;
  136207. /**
  136208. * Serializes the particle system to a JSON object.
  136209. * @returns the JSON object
  136210. */
  136211. serialize(): any;
  136212. /**
  136213. * Parses a JSON object to create a GPU particle system.
  136214. * @param parsedParticleSystem The JSON object to parse
  136215. * @param scene The scene to create the particle system in
  136216. * @param rootUrl The root url to use to load external dependencies like texture
  136217. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136218. * @returns the parsed GPU particle system
  136219. */
  136220. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136221. }
  136222. }
  136223. declare module BABYLON {
  136224. /**
  136225. * Represents a set of particle systems working together to create a specific effect
  136226. */
  136227. export class ParticleSystemSet implements IDisposable {
  136228. /**
  136229. * Gets or sets base Assets URL
  136230. */
  136231. static BaseAssetsUrl: string;
  136232. private _emitterCreationOptions;
  136233. private _emitterNode;
  136234. /**
  136235. * Gets the particle system list
  136236. */
  136237. systems: IParticleSystem[];
  136238. /**
  136239. * Gets the emitter node used with this set
  136240. */
  136241. get emitterNode(): Nullable<TransformNode>;
  136242. /**
  136243. * Creates a new emitter mesh as a sphere
  136244. * @param options defines the options used to create the sphere
  136245. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136246. * @param scene defines the hosting scene
  136247. */
  136248. setEmitterAsSphere(options: {
  136249. diameter: number;
  136250. segments: number;
  136251. color: Color3;
  136252. }, renderingGroupId: number, scene: Scene): void;
  136253. /**
  136254. * Starts all particle systems of the set
  136255. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136256. */
  136257. start(emitter?: AbstractMesh): void;
  136258. /**
  136259. * Release all associated resources
  136260. */
  136261. dispose(): void;
  136262. /**
  136263. * Serialize the set into a JSON compatible object
  136264. * @returns a JSON compatible representation of the set
  136265. */
  136266. serialize(): any;
  136267. /**
  136268. * Parse a new ParticleSystemSet from a serialized source
  136269. * @param data defines a JSON compatible representation of the set
  136270. * @param scene defines the hosting scene
  136271. * @param gpu defines if we want GPU particles or CPU particles
  136272. * @returns a new ParticleSystemSet
  136273. */
  136274. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136275. }
  136276. }
  136277. declare module BABYLON {
  136278. /**
  136279. * This class is made for on one-liner static method to help creating particle system set.
  136280. */
  136281. export class ParticleHelper {
  136282. /**
  136283. * Gets or sets base Assets URL
  136284. */
  136285. static BaseAssetsUrl: string;
  136286. /**
  136287. * Create a default particle system that you can tweak
  136288. * @param emitter defines the emitter to use
  136289. * @param capacity defines the system capacity (default is 500 particles)
  136290. * @param scene defines the hosting scene
  136291. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136292. * @returns the new Particle system
  136293. */
  136294. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136295. /**
  136296. * This is the main static method (one-liner) of this helper to create different particle systems
  136297. * @param type This string represents the type to the particle system to create
  136298. * @param scene The scene where the particle system should live
  136299. * @param gpu If the system will use gpu
  136300. * @returns the ParticleSystemSet created
  136301. */
  136302. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136303. /**
  136304. * Static function used to export a particle system to a ParticleSystemSet variable.
  136305. * Please note that the emitter shape is not exported
  136306. * @param systems defines the particle systems to export
  136307. * @returns the created particle system set
  136308. */
  136309. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136310. }
  136311. }
  136312. declare module BABYLON {
  136313. interface Engine {
  136314. /**
  136315. * Create an effect to use with particle systems.
  136316. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136317. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136318. * @param uniformsNames defines a list of attribute names
  136319. * @param samplers defines an array of string used to represent textures
  136320. * @param defines defines the string containing the defines to use to compile the shaders
  136321. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136322. * @param onCompiled defines a function to call when the effect creation is successful
  136323. * @param onError defines a function to call when the effect creation has failed
  136324. * @returns the new Effect
  136325. */
  136326. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136327. }
  136328. interface Mesh {
  136329. /**
  136330. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136331. * @returns an array of IParticleSystem
  136332. */
  136333. getEmittedParticleSystems(): IParticleSystem[];
  136334. /**
  136335. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136336. * @returns an array of IParticleSystem
  136337. */
  136338. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136339. }
  136340. /**
  136341. * @hidden
  136342. */
  136343. export var _IDoNeedToBeInTheBuild: number;
  136344. }
  136345. declare module BABYLON {
  136346. /** Defines the 4 color options */
  136347. export enum PointColor {
  136348. /** color value */
  136349. Color = 2,
  136350. /** uv value */
  136351. UV = 1,
  136352. /** random value */
  136353. Random = 0,
  136354. /** stated value */
  136355. Stated = 3
  136356. }
  136357. /**
  136358. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136359. * 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.
  136360. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136361. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136362. *
  136363. * Full documentation here : TO BE ENTERED
  136364. */
  136365. export class PointsCloudSystem implements IDisposable {
  136366. /**
  136367. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136368. * Example : var p = SPS.particles[i];
  136369. */
  136370. particles: CloudPoint[];
  136371. /**
  136372. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136373. */
  136374. nbParticles: number;
  136375. /**
  136376. * This a counter for your own usage. It's not set by any SPS functions.
  136377. */
  136378. counter: number;
  136379. /**
  136380. * The PCS name. This name is also given to the underlying mesh.
  136381. */
  136382. name: string;
  136383. /**
  136384. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136385. */
  136386. mesh: Mesh;
  136387. /**
  136388. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136389. * Please read :
  136390. */
  136391. vars: any;
  136392. /**
  136393. * @hidden
  136394. */
  136395. _size: number;
  136396. private _scene;
  136397. private _promises;
  136398. private _positions;
  136399. private _indices;
  136400. private _normals;
  136401. private _colors;
  136402. private _uvs;
  136403. private _indices32;
  136404. private _positions32;
  136405. private _colors32;
  136406. private _uvs32;
  136407. private _updatable;
  136408. private _isVisibilityBoxLocked;
  136409. private _alwaysVisible;
  136410. private _groups;
  136411. private _groupCounter;
  136412. private _computeParticleColor;
  136413. private _computeParticleTexture;
  136414. private _computeParticleRotation;
  136415. private _computeBoundingBox;
  136416. private _isReady;
  136417. /**
  136418. * Creates a PCS (Points Cloud System) object
  136419. * @param name (String) is the PCS name, this will be the underlying mesh name
  136420. * @param pointSize (number) is the size for each point
  136421. * @param scene (Scene) is the scene in which the PCS is added
  136422. * @param options defines the options of the PCS e.g.
  136423. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136424. */
  136425. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136426. updatable?: boolean;
  136427. });
  136428. /**
  136429. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136430. * If no points were added to the PCS, the returned mesh is just a single point.
  136431. * @returns a promise for the created mesh
  136432. */
  136433. buildMeshAsync(): Promise<Mesh>;
  136434. /**
  136435. * @hidden
  136436. */
  136437. private _buildMesh;
  136438. private _addParticle;
  136439. private _randomUnitVector;
  136440. private _getColorIndicesForCoord;
  136441. private _setPointsColorOrUV;
  136442. private _colorFromTexture;
  136443. private _calculateDensity;
  136444. /**
  136445. * Adds points to the PCS in random positions within a unit sphere
  136446. * @param nb (positive integer) the number of particles to be created from this model
  136447. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136448. * @returns the number of groups in the system
  136449. */
  136450. addPoints(nb: number, pointFunction?: any): number;
  136451. /**
  136452. * Adds points to the PCS from the surface of the model shape
  136453. * @param mesh is any Mesh object that will be used as a surface model for the points
  136454. * @param nb (positive integer) the number of particles to be created from this model
  136455. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136456. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136457. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136458. * @returns the number of groups in the system
  136459. */
  136460. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136461. /**
  136462. * Adds points to the PCS inside the model shape
  136463. * @param mesh is any Mesh object that will be used as a surface model for the points
  136464. * @param nb (positive integer) the number of particles to be created from this model
  136465. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136466. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136467. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136468. * @returns the number of groups in the system
  136469. */
  136470. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136471. /**
  136472. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136473. * This method calls `updateParticle()` for each particle of the SPS.
  136474. * For an animated SPS, it is usually called within the render loop.
  136475. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136476. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136477. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136478. * @returns the PCS.
  136479. */
  136480. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136481. /**
  136482. * Disposes the PCS.
  136483. */
  136484. dispose(): void;
  136485. /**
  136486. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136487. * doc :
  136488. * @returns the PCS.
  136489. */
  136490. refreshVisibleSize(): PointsCloudSystem;
  136491. /**
  136492. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136493. * @param size the size (float) of the visibility box
  136494. * note : this doesn't lock the PCS mesh bounding box.
  136495. * doc :
  136496. */
  136497. setVisibilityBox(size: number): void;
  136498. /**
  136499. * Gets whether the PCS is always visible or not
  136500. * doc :
  136501. */
  136502. get isAlwaysVisible(): boolean;
  136503. /**
  136504. * Sets the PCS as always visible or not
  136505. * doc :
  136506. */
  136507. set isAlwaysVisible(val: boolean);
  136508. /**
  136509. * Tells to `setParticles()` to compute the particle rotations or not
  136510. * Default value : false. The PCS is faster when it's set to false
  136511. * Note : particle rotations are only applied to parent particles
  136512. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136513. */
  136514. set computeParticleRotation(val: boolean);
  136515. /**
  136516. * Tells to `setParticles()` to compute the particle colors or not.
  136517. * Default value : true. The PCS is faster when it's set to false.
  136518. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136519. */
  136520. set computeParticleColor(val: boolean);
  136521. set computeParticleTexture(val: boolean);
  136522. /**
  136523. * Gets if `setParticles()` computes the particle colors or not.
  136524. * Default value : false. The PCS is faster when it's set to false.
  136525. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136526. */
  136527. get computeParticleColor(): boolean;
  136528. /**
  136529. * Gets if `setParticles()` computes the particle textures or not.
  136530. * Default value : false. The PCS is faster when it's set to false.
  136531. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136532. */
  136533. get computeParticleTexture(): boolean;
  136534. /**
  136535. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136536. */
  136537. set computeBoundingBox(val: boolean);
  136538. /**
  136539. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136540. */
  136541. get computeBoundingBox(): boolean;
  136542. /**
  136543. * This function does nothing. It may be overwritten to set all the particle first values.
  136544. * The PCS doesn't call this function, you may have to call it by your own.
  136545. * doc :
  136546. */
  136547. initParticles(): void;
  136548. /**
  136549. * This function does nothing. It may be overwritten to recycle a particle
  136550. * The PCS doesn't call this function, you can to call it
  136551. * doc :
  136552. * @param particle The particle to recycle
  136553. * @returns the recycled particle
  136554. */
  136555. recycleParticle(particle: CloudPoint): CloudPoint;
  136556. /**
  136557. * Updates a particle : this function should be overwritten by the user.
  136558. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136559. * doc :
  136560. * @example : just set a particle position or velocity and recycle conditions
  136561. * @param particle The particle to update
  136562. * @returns the updated particle
  136563. */
  136564. updateParticle(particle: CloudPoint): CloudPoint;
  136565. /**
  136566. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136567. * This does nothing and may be overwritten by the user.
  136568. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136569. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136570. * @param update the boolean update value actually passed to setParticles()
  136571. */
  136572. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136573. /**
  136574. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136575. * This will be passed three parameters.
  136576. * This does nothing and may be overwritten by the user.
  136577. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136578. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136579. * @param update the boolean update value actually passed to setParticles()
  136580. */
  136581. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136582. }
  136583. }
  136584. declare module BABYLON {
  136585. /**
  136586. * Represents one particle of a points cloud system.
  136587. */
  136588. export class CloudPoint {
  136589. /**
  136590. * particle global index
  136591. */
  136592. idx: number;
  136593. /**
  136594. * The color of the particle
  136595. */
  136596. color: Nullable<Color4>;
  136597. /**
  136598. * The world space position of the particle.
  136599. */
  136600. position: Vector3;
  136601. /**
  136602. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136603. */
  136604. rotation: Vector3;
  136605. /**
  136606. * The world space rotation quaternion of the particle.
  136607. */
  136608. rotationQuaternion: Nullable<Quaternion>;
  136609. /**
  136610. * The uv of the particle.
  136611. */
  136612. uv: Nullable<Vector2>;
  136613. /**
  136614. * The current speed of the particle.
  136615. */
  136616. velocity: Vector3;
  136617. /**
  136618. * The pivot point in the particle local space.
  136619. */
  136620. pivot: Vector3;
  136621. /**
  136622. * Must the particle be translated from its pivot point in its local space ?
  136623. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136624. * Default : false
  136625. */
  136626. translateFromPivot: boolean;
  136627. /**
  136628. * Index of this particle in the global "positions" array (Internal use)
  136629. * @hidden
  136630. */
  136631. _pos: number;
  136632. /**
  136633. * @hidden Index of this particle in the global "indices" array (Internal use)
  136634. */
  136635. _ind: number;
  136636. /**
  136637. * Group this particle belongs to
  136638. */
  136639. _group: PointsGroup;
  136640. /**
  136641. * Group id of this particle
  136642. */
  136643. groupId: number;
  136644. /**
  136645. * Index of the particle in its group id (Internal use)
  136646. */
  136647. idxInGroup: number;
  136648. /**
  136649. * @hidden Particle BoundingInfo object (Internal use)
  136650. */
  136651. _boundingInfo: BoundingInfo;
  136652. /**
  136653. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136654. */
  136655. _pcs: PointsCloudSystem;
  136656. /**
  136657. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136658. */
  136659. _stillInvisible: boolean;
  136660. /**
  136661. * @hidden Last computed particle rotation matrix
  136662. */
  136663. _rotationMatrix: number[];
  136664. /**
  136665. * Parent particle Id, if any.
  136666. * Default null.
  136667. */
  136668. parentId: Nullable<number>;
  136669. /**
  136670. * @hidden Internal global position in the PCS.
  136671. */
  136672. _globalPosition: Vector3;
  136673. /**
  136674. * Creates a Point Cloud object.
  136675. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136676. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136677. * @param group (PointsGroup) is the group the particle belongs to
  136678. * @param groupId (integer) is the group identifier in the PCS.
  136679. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136680. * @param pcs defines the PCS it is associated to
  136681. */
  136682. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136683. /**
  136684. * get point size
  136685. */
  136686. get size(): Vector3;
  136687. /**
  136688. * Set point size
  136689. */
  136690. set size(scale: Vector3);
  136691. /**
  136692. * Legacy support, changed quaternion to rotationQuaternion
  136693. */
  136694. get quaternion(): Nullable<Quaternion>;
  136695. /**
  136696. * Legacy support, changed quaternion to rotationQuaternion
  136697. */
  136698. set quaternion(q: Nullable<Quaternion>);
  136699. /**
  136700. * Returns a boolean. True if the particle intersects a mesh, else false
  136701. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136702. * @param target is the object (point or mesh) what the intersection is computed against
  136703. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136704. * @returns true if it intersects
  136705. */
  136706. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136707. /**
  136708. * get the rotation matrix of the particle
  136709. * @hidden
  136710. */
  136711. getRotationMatrix(m: Matrix): void;
  136712. }
  136713. /**
  136714. * Represents a group of points in a points cloud system
  136715. * * PCS internal tool, don't use it manually.
  136716. */
  136717. export class PointsGroup {
  136718. /**
  136719. * The group id
  136720. * @hidden
  136721. */
  136722. groupID: number;
  136723. /**
  136724. * image data for group (internal use)
  136725. * @hidden
  136726. */
  136727. _groupImageData: Nullable<ArrayBufferView>;
  136728. /**
  136729. * Image Width (internal use)
  136730. * @hidden
  136731. */
  136732. _groupImgWidth: number;
  136733. /**
  136734. * Image Height (internal use)
  136735. * @hidden
  136736. */
  136737. _groupImgHeight: number;
  136738. /**
  136739. * Custom position function (internal use)
  136740. * @hidden
  136741. */
  136742. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136743. /**
  136744. * density per facet for surface points
  136745. * @hidden
  136746. */
  136747. _groupDensity: number[];
  136748. /**
  136749. * Only when points are colored by texture carries pointer to texture list array
  136750. * @hidden
  136751. */
  136752. _textureNb: number;
  136753. /**
  136754. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136755. * PCS internal tool, don't use it manually.
  136756. * @hidden
  136757. */
  136758. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136759. }
  136760. }
  136761. declare module BABYLON {
  136762. interface Scene {
  136763. /** @hidden (Backing field) */
  136764. _physicsEngine: Nullable<IPhysicsEngine>;
  136765. /** @hidden */
  136766. _physicsTimeAccumulator: number;
  136767. /**
  136768. * Gets the current physics engine
  136769. * @returns a IPhysicsEngine or null if none attached
  136770. */
  136771. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136772. /**
  136773. * Enables physics to the current scene
  136774. * @param gravity defines the scene's gravity for the physics engine
  136775. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136776. * @return a boolean indicating if the physics engine was initialized
  136777. */
  136778. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136779. /**
  136780. * Disables and disposes the physics engine associated with the scene
  136781. */
  136782. disablePhysicsEngine(): void;
  136783. /**
  136784. * Gets a boolean indicating if there is an active physics engine
  136785. * @returns a boolean indicating if there is an active physics engine
  136786. */
  136787. isPhysicsEnabled(): boolean;
  136788. /**
  136789. * Deletes a physics compound impostor
  136790. * @param compound defines the compound to delete
  136791. */
  136792. deleteCompoundImpostor(compound: any): void;
  136793. /**
  136794. * An event triggered when physic simulation is about to be run
  136795. */
  136796. onBeforePhysicsObservable: Observable<Scene>;
  136797. /**
  136798. * An event triggered when physic simulation has been done
  136799. */
  136800. onAfterPhysicsObservable: Observable<Scene>;
  136801. }
  136802. interface AbstractMesh {
  136803. /** @hidden */
  136804. _physicsImpostor: Nullable<PhysicsImpostor>;
  136805. /**
  136806. * Gets or sets impostor used for physic simulation
  136807. * @see http://doc.babylonjs.com/features/physics_engine
  136808. */
  136809. physicsImpostor: Nullable<PhysicsImpostor>;
  136810. /**
  136811. * Gets the current physics impostor
  136812. * @see http://doc.babylonjs.com/features/physics_engine
  136813. * @returns a physics impostor or null
  136814. */
  136815. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136816. /** Apply a physic impulse to the mesh
  136817. * @param force defines the force to apply
  136818. * @param contactPoint defines where to apply the force
  136819. * @returns the current mesh
  136820. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136821. */
  136822. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136823. /**
  136824. * Creates a physic joint between two meshes
  136825. * @param otherMesh defines the other mesh to use
  136826. * @param pivot1 defines the pivot to use on this mesh
  136827. * @param pivot2 defines the pivot to use on the other mesh
  136828. * @param options defines additional options (can be plugin dependent)
  136829. * @returns the current mesh
  136830. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136831. */
  136832. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136833. /** @hidden */
  136834. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136835. }
  136836. /**
  136837. * Defines the physics engine scene component responsible to manage a physics engine
  136838. */
  136839. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136840. /**
  136841. * The component name helpful to identify the component in the list of scene components.
  136842. */
  136843. readonly name: string;
  136844. /**
  136845. * The scene the component belongs to.
  136846. */
  136847. scene: Scene;
  136848. /**
  136849. * Creates a new instance of the component for the given scene
  136850. * @param scene Defines the scene to register the component in
  136851. */
  136852. constructor(scene: Scene);
  136853. /**
  136854. * Registers the component in a given scene
  136855. */
  136856. register(): void;
  136857. /**
  136858. * Rebuilds the elements related to this component in case of
  136859. * context lost for instance.
  136860. */
  136861. rebuild(): void;
  136862. /**
  136863. * Disposes the component and the associated ressources
  136864. */
  136865. dispose(): void;
  136866. }
  136867. }
  136868. declare module BABYLON {
  136869. /**
  136870. * A helper for physics simulations
  136871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136872. */
  136873. export class PhysicsHelper {
  136874. private _scene;
  136875. private _physicsEngine;
  136876. /**
  136877. * Initializes the Physics helper
  136878. * @param scene Babylon.js scene
  136879. */
  136880. constructor(scene: Scene);
  136881. /**
  136882. * Applies a radial explosion impulse
  136883. * @param origin the origin of the explosion
  136884. * @param radiusOrEventOptions the radius or the options of radial explosion
  136885. * @param strength the explosion strength
  136886. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136887. * @returns A physics radial explosion event, or null
  136888. */
  136889. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136890. /**
  136891. * Applies a radial explosion force
  136892. * @param origin the origin of the explosion
  136893. * @param radiusOrEventOptions the radius or the options of radial explosion
  136894. * @param strength the explosion strength
  136895. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136896. * @returns A physics radial explosion event, or null
  136897. */
  136898. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136899. /**
  136900. * Creates a gravitational field
  136901. * @param origin the origin of the explosion
  136902. * @param radiusOrEventOptions the radius or the options of radial explosion
  136903. * @param strength the explosion strength
  136904. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136905. * @returns A physics gravitational field event, or null
  136906. */
  136907. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136908. /**
  136909. * Creates a physics updraft event
  136910. * @param origin the origin of the updraft
  136911. * @param radiusOrEventOptions the radius or the options of the updraft
  136912. * @param strength the strength of the updraft
  136913. * @param height the height of the updraft
  136914. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136915. * @returns A physics updraft event, or null
  136916. */
  136917. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136918. /**
  136919. * Creates a physics vortex event
  136920. * @param origin the of the vortex
  136921. * @param radiusOrEventOptions the radius or the options of the vortex
  136922. * @param strength the strength of the vortex
  136923. * @param height the height of the vortex
  136924. * @returns a Physics vortex event, or null
  136925. * A physics vortex event or null
  136926. */
  136927. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136928. }
  136929. /**
  136930. * Represents a physics radial explosion event
  136931. */
  136932. class PhysicsRadialExplosionEvent {
  136933. private _scene;
  136934. private _options;
  136935. private _sphere;
  136936. private _dataFetched;
  136937. /**
  136938. * Initializes a radial explosioin event
  136939. * @param _scene BabylonJS scene
  136940. * @param _options The options for the vortex event
  136941. */
  136942. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136943. /**
  136944. * Returns the data related to the radial explosion event (sphere).
  136945. * @returns The radial explosion event data
  136946. */
  136947. getData(): PhysicsRadialExplosionEventData;
  136948. /**
  136949. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136950. * @param impostor A physics imposter
  136951. * @param origin the origin of the explosion
  136952. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136953. */
  136954. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136955. /**
  136956. * Triggers affecterd impostors callbacks
  136957. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136958. */
  136959. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136960. /**
  136961. * Disposes the sphere.
  136962. * @param force Specifies if the sphere should be disposed by force
  136963. */
  136964. dispose(force?: boolean): void;
  136965. /*** Helpers ***/
  136966. private _prepareSphere;
  136967. private _intersectsWithSphere;
  136968. }
  136969. /**
  136970. * Represents a gravitational field event
  136971. */
  136972. class PhysicsGravitationalFieldEvent {
  136973. private _physicsHelper;
  136974. private _scene;
  136975. private _origin;
  136976. private _options;
  136977. private _tickCallback;
  136978. private _sphere;
  136979. private _dataFetched;
  136980. /**
  136981. * Initializes the physics gravitational field event
  136982. * @param _physicsHelper A physics helper
  136983. * @param _scene BabylonJS scene
  136984. * @param _origin The origin position of the gravitational field event
  136985. * @param _options The options for the vortex event
  136986. */
  136987. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136988. /**
  136989. * Returns the data related to the gravitational field event (sphere).
  136990. * @returns A gravitational field event
  136991. */
  136992. getData(): PhysicsGravitationalFieldEventData;
  136993. /**
  136994. * Enables the gravitational field.
  136995. */
  136996. enable(): void;
  136997. /**
  136998. * Disables the gravitational field.
  136999. */
  137000. disable(): void;
  137001. /**
  137002. * Disposes the sphere.
  137003. * @param force The force to dispose from the gravitational field event
  137004. */
  137005. dispose(force?: boolean): void;
  137006. private _tick;
  137007. }
  137008. /**
  137009. * Represents a physics updraft event
  137010. */
  137011. class PhysicsUpdraftEvent {
  137012. private _scene;
  137013. private _origin;
  137014. private _options;
  137015. private _physicsEngine;
  137016. private _originTop;
  137017. private _originDirection;
  137018. private _tickCallback;
  137019. private _cylinder;
  137020. private _cylinderPosition;
  137021. private _dataFetched;
  137022. /**
  137023. * Initializes the physics updraft event
  137024. * @param _scene BabylonJS scene
  137025. * @param _origin The origin position of the updraft
  137026. * @param _options The options for the updraft event
  137027. */
  137028. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  137029. /**
  137030. * Returns the data related to the updraft event (cylinder).
  137031. * @returns A physics updraft event
  137032. */
  137033. getData(): PhysicsUpdraftEventData;
  137034. /**
  137035. * Enables the updraft.
  137036. */
  137037. enable(): void;
  137038. /**
  137039. * Disables the updraft.
  137040. */
  137041. disable(): void;
  137042. /**
  137043. * Disposes the cylinder.
  137044. * @param force Specifies if the updraft should be disposed by force
  137045. */
  137046. dispose(force?: boolean): void;
  137047. private getImpostorHitData;
  137048. private _tick;
  137049. /*** Helpers ***/
  137050. private _prepareCylinder;
  137051. private _intersectsWithCylinder;
  137052. }
  137053. /**
  137054. * Represents a physics vortex event
  137055. */
  137056. class PhysicsVortexEvent {
  137057. private _scene;
  137058. private _origin;
  137059. private _options;
  137060. private _physicsEngine;
  137061. private _originTop;
  137062. private _tickCallback;
  137063. private _cylinder;
  137064. private _cylinderPosition;
  137065. private _dataFetched;
  137066. /**
  137067. * Initializes the physics vortex event
  137068. * @param _scene The BabylonJS scene
  137069. * @param _origin The origin position of the vortex
  137070. * @param _options The options for the vortex event
  137071. */
  137072. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  137073. /**
  137074. * Returns the data related to the vortex event (cylinder).
  137075. * @returns The physics vortex event data
  137076. */
  137077. getData(): PhysicsVortexEventData;
  137078. /**
  137079. * Enables the vortex.
  137080. */
  137081. enable(): void;
  137082. /**
  137083. * Disables the cortex.
  137084. */
  137085. disable(): void;
  137086. /**
  137087. * Disposes the sphere.
  137088. * @param force
  137089. */
  137090. dispose(force?: boolean): void;
  137091. private getImpostorHitData;
  137092. private _tick;
  137093. /*** Helpers ***/
  137094. private _prepareCylinder;
  137095. private _intersectsWithCylinder;
  137096. }
  137097. /**
  137098. * Options fot the radial explosion event
  137099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137100. */
  137101. export class PhysicsRadialExplosionEventOptions {
  137102. /**
  137103. * The radius of the sphere for the radial explosion.
  137104. */
  137105. radius: number;
  137106. /**
  137107. * The strenth of the explosion.
  137108. */
  137109. strength: number;
  137110. /**
  137111. * The strenght of the force in correspondence to the distance of the affected object
  137112. */
  137113. falloff: PhysicsRadialImpulseFalloff;
  137114. /**
  137115. * Sphere options for the radial explosion.
  137116. */
  137117. sphere: {
  137118. segments: number;
  137119. diameter: number;
  137120. };
  137121. /**
  137122. * Sphere options for the radial explosion.
  137123. */
  137124. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137125. }
  137126. /**
  137127. * Options fot the updraft event
  137128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137129. */
  137130. export class PhysicsUpdraftEventOptions {
  137131. /**
  137132. * The radius of the cylinder for the vortex
  137133. */
  137134. radius: number;
  137135. /**
  137136. * The strenth of the updraft.
  137137. */
  137138. strength: number;
  137139. /**
  137140. * The height of the cylinder for the updraft.
  137141. */
  137142. height: number;
  137143. /**
  137144. * The mode for the the updraft.
  137145. */
  137146. updraftMode: PhysicsUpdraftMode;
  137147. }
  137148. /**
  137149. * Options fot the vortex event
  137150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137151. */
  137152. export class PhysicsVortexEventOptions {
  137153. /**
  137154. * The radius of the cylinder for the vortex
  137155. */
  137156. radius: number;
  137157. /**
  137158. * The strenth of the vortex.
  137159. */
  137160. strength: number;
  137161. /**
  137162. * The height of the cylinder for the vortex.
  137163. */
  137164. height: number;
  137165. /**
  137166. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137167. */
  137168. centripetalForceThreshold: number;
  137169. /**
  137170. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137171. */
  137172. centripetalForceMultiplier: number;
  137173. /**
  137174. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137175. */
  137176. centrifugalForceMultiplier: number;
  137177. /**
  137178. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137179. */
  137180. updraftForceMultiplier: number;
  137181. }
  137182. /**
  137183. * The strenght of the force in correspondence to the distance of the affected object
  137184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137185. */
  137186. export enum PhysicsRadialImpulseFalloff {
  137187. /** Defines that impulse is constant in strength across it's whole radius */
  137188. Constant = 0,
  137189. /** Defines that impulse gets weaker if it's further from the origin */
  137190. Linear = 1
  137191. }
  137192. /**
  137193. * The strength of the force in correspondence to the distance of the affected object
  137194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137195. */
  137196. export enum PhysicsUpdraftMode {
  137197. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137198. Center = 0,
  137199. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137200. Perpendicular = 1
  137201. }
  137202. /**
  137203. * Interface for a physics hit data
  137204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137205. */
  137206. export interface PhysicsHitData {
  137207. /**
  137208. * The force applied at the contact point
  137209. */
  137210. force: Vector3;
  137211. /**
  137212. * The contact point
  137213. */
  137214. contactPoint: Vector3;
  137215. /**
  137216. * The distance from the origin to the contact point
  137217. */
  137218. distanceFromOrigin: number;
  137219. }
  137220. /**
  137221. * Interface for radial explosion event data
  137222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137223. */
  137224. export interface PhysicsRadialExplosionEventData {
  137225. /**
  137226. * A sphere used for the radial explosion event
  137227. */
  137228. sphere: Mesh;
  137229. }
  137230. /**
  137231. * Interface for gravitational field event data
  137232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137233. */
  137234. export interface PhysicsGravitationalFieldEventData {
  137235. /**
  137236. * A sphere mesh used for the gravitational field event
  137237. */
  137238. sphere: Mesh;
  137239. }
  137240. /**
  137241. * Interface for updraft event data
  137242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137243. */
  137244. export interface PhysicsUpdraftEventData {
  137245. /**
  137246. * A cylinder used for the updraft event
  137247. */
  137248. cylinder: Mesh;
  137249. }
  137250. /**
  137251. * Interface for vortex event data
  137252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137253. */
  137254. export interface PhysicsVortexEventData {
  137255. /**
  137256. * A cylinder used for the vortex event
  137257. */
  137258. cylinder: Mesh;
  137259. }
  137260. /**
  137261. * Interface for an affected physics impostor
  137262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137263. */
  137264. export interface PhysicsAffectedImpostorWithData {
  137265. /**
  137266. * The impostor affected by the effect
  137267. */
  137268. impostor: PhysicsImpostor;
  137269. /**
  137270. * The data about the hit/horce from the explosion
  137271. */
  137272. hitData: PhysicsHitData;
  137273. }
  137274. }
  137275. declare module BABYLON {
  137276. /** @hidden */
  137277. export var blackAndWhitePixelShader: {
  137278. name: string;
  137279. shader: string;
  137280. };
  137281. }
  137282. declare module BABYLON {
  137283. /**
  137284. * Post process used to render in black and white
  137285. */
  137286. export class BlackAndWhitePostProcess extends PostProcess {
  137287. /**
  137288. * Linear about to convert he result to black and white (default: 1)
  137289. */
  137290. degree: number;
  137291. /**
  137292. * Creates a black and white post process
  137293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137294. * @param name The name of the effect.
  137295. * @param options The required width/height ratio to downsize to before computing the render pass.
  137296. * @param camera The camera to apply the render pass to.
  137297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137298. * @param engine The engine which the post process will be applied. (default: current engine)
  137299. * @param reusable If the post process can be reused on the same frame. (default: false)
  137300. */
  137301. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137302. }
  137303. }
  137304. declare module BABYLON {
  137305. /**
  137306. * This represents a set of one or more post processes in Babylon.
  137307. * A post process can be used to apply a shader to a texture after it is rendered.
  137308. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137309. */
  137310. export class PostProcessRenderEffect {
  137311. private _postProcesses;
  137312. private _getPostProcesses;
  137313. private _singleInstance;
  137314. private _cameras;
  137315. private _indicesForCamera;
  137316. /**
  137317. * Name of the effect
  137318. * @hidden
  137319. */
  137320. _name: string;
  137321. /**
  137322. * Instantiates a post process render effect.
  137323. * A post process can be used to apply a shader to a texture after it is rendered.
  137324. * @param engine The engine the effect is tied to
  137325. * @param name The name of the effect
  137326. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137327. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137328. */
  137329. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137330. /**
  137331. * Checks if all the post processes in the effect are supported.
  137332. */
  137333. get isSupported(): boolean;
  137334. /**
  137335. * Updates the current state of the effect
  137336. * @hidden
  137337. */
  137338. _update(): void;
  137339. /**
  137340. * Attaches the effect on cameras
  137341. * @param cameras The camera to attach to.
  137342. * @hidden
  137343. */
  137344. _attachCameras(cameras: Camera): void;
  137345. /**
  137346. * Attaches the effect on cameras
  137347. * @param cameras The camera to attach to.
  137348. * @hidden
  137349. */
  137350. _attachCameras(cameras: Camera[]): void;
  137351. /**
  137352. * Detaches the effect on cameras
  137353. * @param cameras The camera to detatch from.
  137354. * @hidden
  137355. */
  137356. _detachCameras(cameras: Camera): void;
  137357. /**
  137358. * Detatches the effect on cameras
  137359. * @param cameras The camera to detatch from.
  137360. * @hidden
  137361. */
  137362. _detachCameras(cameras: Camera[]): void;
  137363. /**
  137364. * Enables the effect on given cameras
  137365. * @param cameras The camera to enable.
  137366. * @hidden
  137367. */
  137368. _enable(cameras: Camera): void;
  137369. /**
  137370. * Enables the effect on given cameras
  137371. * @param cameras The camera to enable.
  137372. * @hidden
  137373. */
  137374. _enable(cameras: Nullable<Camera[]>): void;
  137375. /**
  137376. * Disables the effect on the given cameras
  137377. * @param cameras The camera to disable.
  137378. * @hidden
  137379. */
  137380. _disable(cameras: Camera): void;
  137381. /**
  137382. * Disables the effect on the given cameras
  137383. * @param cameras The camera to disable.
  137384. * @hidden
  137385. */
  137386. _disable(cameras: Nullable<Camera[]>): void;
  137387. /**
  137388. * Gets a list of the post processes contained in the effect.
  137389. * @param camera The camera to get the post processes on.
  137390. * @returns The list of the post processes in the effect.
  137391. */
  137392. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137393. }
  137394. }
  137395. declare module BABYLON {
  137396. /** @hidden */
  137397. export var extractHighlightsPixelShader: {
  137398. name: string;
  137399. shader: string;
  137400. };
  137401. }
  137402. declare module BABYLON {
  137403. /**
  137404. * 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.
  137405. */
  137406. export class ExtractHighlightsPostProcess extends PostProcess {
  137407. /**
  137408. * The luminance threshold, pixels below this value will be set to black.
  137409. */
  137410. threshold: number;
  137411. /** @hidden */
  137412. _exposure: number;
  137413. /**
  137414. * Post process which has the input texture to be used when performing highlight extraction
  137415. * @hidden
  137416. */
  137417. _inputPostProcess: Nullable<PostProcess>;
  137418. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137419. }
  137420. }
  137421. declare module BABYLON {
  137422. /** @hidden */
  137423. export var bloomMergePixelShader: {
  137424. name: string;
  137425. shader: string;
  137426. };
  137427. }
  137428. declare module BABYLON {
  137429. /**
  137430. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137431. */
  137432. export class BloomMergePostProcess extends PostProcess {
  137433. /** Weight of the bloom to be added to the original input. */
  137434. weight: number;
  137435. /**
  137436. * Creates a new instance of @see BloomMergePostProcess
  137437. * @param name The name of the effect.
  137438. * @param originalFromInput Post process which's input will be used for the merge.
  137439. * @param blurred Blurred highlights post process which's output will be used.
  137440. * @param weight Weight of the bloom to be added to the original input.
  137441. * @param options The required width/height ratio to downsize to before computing the render pass.
  137442. * @param camera The camera to apply the render pass to.
  137443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137444. * @param engine The engine which the post process will be applied. (default: current engine)
  137445. * @param reusable If the post process can be reused on the same frame. (default: false)
  137446. * @param textureType Type of textures used when performing the post process. (default: 0)
  137447. * @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)
  137448. */
  137449. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137450. /** Weight of the bloom to be added to the original input. */
  137451. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137452. }
  137453. }
  137454. declare module BABYLON {
  137455. /**
  137456. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137457. */
  137458. export class BloomEffect extends PostProcessRenderEffect {
  137459. private bloomScale;
  137460. /**
  137461. * @hidden Internal
  137462. */
  137463. _effects: Array<PostProcess>;
  137464. /**
  137465. * @hidden Internal
  137466. */
  137467. _downscale: ExtractHighlightsPostProcess;
  137468. private _blurX;
  137469. private _blurY;
  137470. private _merge;
  137471. /**
  137472. * The luminance threshold to find bright areas of the image to bloom.
  137473. */
  137474. get threshold(): number;
  137475. set threshold(value: number);
  137476. /**
  137477. * The strength of the bloom.
  137478. */
  137479. get weight(): number;
  137480. set weight(value: number);
  137481. /**
  137482. * Specifies the size of the bloom blur kernel, relative to the final output size
  137483. */
  137484. get kernel(): number;
  137485. set kernel(value: number);
  137486. /**
  137487. * Creates a new instance of @see BloomEffect
  137488. * @param scene The scene the effect belongs to.
  137489. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137490. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137491. * @param bloomWeight The the strength of bloom.
  137492. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137493. * @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)
  137494. */
  137495. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137496. /**
  137497. * Disposes each of the internal effects for a given camera.
  137498. * @param camera The camera to dispose the effect on.
  137499. */
  137500. disposeEffects(camera: Camera): void;
  137501. /**
  137502. * @hidden Internal
  137503. */
  137504. _updateEffects(): void;
  137505. /**
  137506. * Internal
  137507. * @returns if all the contained post processes are ready.
  137508. * @hidden
  137509. */
  137510. _isReady(): boolean;
  137511. }
  137512. }
  137513. declare module BABYLON {
  137514. /** @hidden */
  137515. export var chromaticAberrationPixelShader: {
  137516. name: string;
  137517. shader: string;
  137518. };
  137519. }
  137520. declare module BABYLON {
  137521. /**
  137522. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137523. */
  137524. export class ChromaticAberrationPostProcess extends PostProcess {
  137525. /**
  137526. * The amount of seperation of rgb channels (default: 30)
  137527. */
  137528. aberrationAmount: number;
  137529. /**
  137530. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137531. */
  137532. radialIntensity: number;
  137533. /**
  137534. * 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))
  137535. */
  137536. direction: Vector2;
  137537. /**
  137538. * 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))
  137539. */
  137540. centerPosition: Vector2;
  137541. /**
  137542. * Creates a new instance ChromaticAberrationPostProcess
  137543. * @param name The name of the effect.
  137544. * @param screenWidth The width of the screen to apply the effect on.
  137545. * @param screenHeight The height of the screen to apply the effect on.
  137546. * @param options The required width/height ratio to downsize to before computing the render pass.
  137547. * @param camera The camera to apply the render pass to.
  137548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137549. * @param engine The engine which the post process will be applied. (default: current engine)
  137550. * @param reusable If the post process can be reused on the same frame. (default: false)
  137551. * @param textureType Type of textures used when performing the post process. (default: 0)
  137552. * @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)
  137553. */
  137554. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137555. }
  137556. }
  137557. declare module BABYLON {
  137558. /** @hidden */
  137559. export var circleOfConfusionPixelShader: {
  137560. name: string;
  137561. shader: string;
  137562. };
  137563. }
  137564. declare module BABYLON {
  137565. /**
  137566. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137567. */
  137568. export class CircleOfConfusionPostProcess extends PostProcess {
  137569. /**
  137570. * 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.
  137571. */
  137572. lensSize: number;
  137573. /**
  137574. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137575. */
  137576. fStop: number;
  137577. /**
  137578. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137579. */
  137580. focusDistance: number;
  137581. /**
  137582. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137583. */
  137584. focalLength: number;
  137585. private _depthTexture;
  137586. /**
  137587. * Creates a new instance CircleOfConfusionPostProcess
  137588. * @param name The name of the effect.
  137589. * @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.
  137590. * @param options The required width/height ratio to downsize to before computing the render pass.
  137591. * @param camera The camera to apply the render pass to.
  137592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137593. * @param engine The engine which the post process will be applied. (default: current engine)
  137594. * @param reusable If the post process can be reused on the same frame. (default: false)
  137595. * @param textureType Type of textures used when performing the post process. (default: 0)
  137596. * @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)
  137597. */
  137598. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137599. /**
  137600. * 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.
  137601. */
  137602. set depthTexture(value: RenderTargetTexture);
  137603. }
  137604. }
  137605. declare module BABYLON {
  137606. /** @hidden */
  137607. export var colorCorrectionPixelShader: {
  137608. name: string;
  137609. shader: string;
  137610. };
  137611. }
  137612. declare module BABYLON {
  137613. /**
  137614. *
  137615. * This post-process allows the modification of rendered colors by using
  137616. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137617. *
  137618. * The object needs to be provided an url to a texture containing the color
  137619. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137620. * Use an image editing software to tweak the LUT to match your needs.
  137621. *
  137622. * For an example of a color LUT, see here:
  137623. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137624. * For explanations on color grading, see here:
  137625. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137626. *
  137627. */
  137628. export class ColorCorrectionPostProcess extends PostProcess {
  137629. private _colorTableTexture;
  137630. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137631. }
  137632. }
  137633. declare module BABYLON {
  137634. /** @hidden */
  137635. export var convolutionPixelShader: {
  137636. name: string;
  137637. shader: string;
  137638. };
  137639. }
  137640. declare module BABYLON {
  137641. /**
  137642. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137643. * input texture to perform effects such as edge detection or sharpening
  137644. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137645. */
  137646. export class ConvolutionPostProcess extends PostProcess {
  137647. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137648. kernel: number[];
  137649. /**
  137650. * Creates a new instance ConvolutionPostProcess
  137651. * @param name The name of the effect.
  137652. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137653. * @param options The required width/height ratio to downsize to before computing the render pass.
  137654. * @param camera The camera to apply the render pass to.
  137655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137656. * @param engine The engine which the post process will be applied. (default: current engine)
  137657. * @param reusable If the post process can be reused on the same frame. (default: false)
  137658. * @param textureType Type of textures used when performing the post process. (default: 0)
  137659. */
  137660. constructor(name: string,
  137661. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137662. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137663. /**
  137664. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137665. */
  137666. static EdgeDetect0Kernel: number[];
  137667. /**
  137668. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137669. */
  137670. static EdgeDetect1Kernel: number[];
  137671. /**
  137672. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137673. */
  137674. static EdgeDetect2Kernel: number[];
  137675. /**
  137676. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137677. */
  137678. static SharpenKernel: number[];
  137679. /**
  137680. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137681. */
  137682. static EmbossKernel: number[];
  137683. /**
  137684. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137685. */
  137686. static GaussianKernel: number[];
  137687. }
  137688. }
  137689. declare module BABYLON {
  137690. /**
  137691. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137692. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137693. * based on samples that have a large difference in distance than the center pixel.
  137694. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137695. */
  137696. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137697. direction: Vector2;
  137698. /**
  137699. * Creates a new instance CircleOfConfusionPostProcess
  137700. * @param name The name of the effect.
  137701. * @param scene The scene the effect belongs to.
  137702. * @param direction The direction the blur should be applied.
  137703. * @param kernel The size of the kernel used to blur.
  137704. * @param options The required width/height ratio to downsize to before computing the render pass.
  137705. * @param camera The camera to apply the render pass to.
  137706. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137707. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137709. * @param engine The engine which the post process will be applied. (default: current engine)
  137710. * @param reusable If the post process can be reused on the same frame. (default: false)
  137711. * @param textureType Type of textures used when performing the post process. (default: 0)
  137712. * @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)
  137713. */
  137714. 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);
  137715. }
  137716. }
  137717. declare module BABYLON {
  137718. /** @hidden */
  137719. export var depthOfFieldMergePixelShader: {
  137720. name: string;
  137721. shader: string;
  137722. };
  137723. }
  137724. declare module BABYLON {
  137725. /**
  137726. * Options to be set when merging outputs from the default pipeline.
  137727. */
  137728. export class DepthOfFieldMergePostProcessOptions {
  137729. /**
  137730. * The original image to merge on top of
  137731. */
  137732. originalFromInput: PostProcess;
  137733. /**
  137734. * Parameters to perform the merge of the depth of field effect
  137735. */
  137736. depthOfField?: {
  137737. circleOfConfusion: PostProcess;
  137738. blurSteps: Array<PostProcess>;
  137739. };
  137740. /**
  137741. * Parameters to perform the merge of bloom effect
  137742. */
  137743. bloom?: {
  137744. blurred: PostProcess;
  137745. weight: number;
  137746. };
  137747. }
  137748. /**
  137749. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137750. */
  137751. export class DepthOfFieldMergePostProcess extends PostProcess {
  137752. private blurSteps;
  137753. /**
  137754. * Creates a new instance of DepthOfFieldMergePostProcess
  137755. * @param name The name of the effect.
  137756. * @param originalFromInput Post process which's input will be used for the merge.
  137757. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137758. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137759. * @param options The required width/height ratio to downsize to before computing the render pass.
  137760. * @param camera The camera to apply the render pass to.
  137761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137762. * @param engine The engine which the post process will be applied. (default: current engine)
  137763. * @param reusable If the post process can be reused on the same frame. (default: false)
  137764. * @param textureType Type of textures used when performing the post process. (default: 0)
  137765. * @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)
  137766. */
  137767. 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);
  137768. /**
  137769. * Updates the effect with the current post process compile time values and recompiles the shader.
  137770. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137771. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137772. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137773. * @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
  137774. * @param onCompiled Called when the shader has been compiled.
  137775. * @param onError Called if there is an error when compiling a shader.
  137776. */
  137777. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137778. }
  137779. }
  137780. declare module BABYLON {
  137781. /**
  137782. * Specifies the level of max blur that should be applied when using the depth of field effect
  137783. */
  137784. export enum DepthOfFieldEffectBlurLevel {
  137785. /**
  137786. * Subtle blur
  137787. */
  137788. Low = 0,
  137789. /**
  137790. * Medium blur
  137791. */
  137792. Medium = 1,
  137793. /**
  137794. * Large blur
  137795. */
  137796. High = 2
  137797. }
  137798. /**
  137799. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137800. */
  137801. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137802. private _circleOfConfusion;
  137803. /**
  137804. * @hidden Internal, blurs from high to low
  137805. */
  137806. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137807. private _depthOfFieldBlurY;
  137808. private _dofMerge;
  137809. /**
  137810. * @hidden Internal post processes in depth of field effect
  137811. */
  137812. _effects: Array<PostProcess>;
  137813. /**
  137814. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137815. */
  137816. set focalLength(value: number);
  137817. get focalLength(): number;
  137818. /**
  137819. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137820. */
  137821. set fStop(value: number);
  137822. get fStop(): number;
  137823. /**
  137824. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137825. */
  137826. set focusDistance(value: number);
  137827. get focusDistance(): number;
  137828. /**
  137829. * 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.
  137830. */
  137831. set lensSize(value: number);
  137832. get lensSize(): number;
  137833. /**
  137834. * Creates a new instance DepthOfFieldEffect
  137835. * @param scene The scene the effect belongs to.
  137836. * @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.
  137837. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137838. * @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)
  137839. */
  137840. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137841. /**
  137842. * Get the current class name of the current effet
  137843. * @returns "DepthOfFieldEffect"
  137844. */
  137845. getClassName(): string;
  137846. /**
  137847. * 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.
  137848. */
  137849. set depthTexture(value: RenderTargetTexture);
  137850. /**
  137851. * Disposes each of the internal effects for a given camera.
  137852. * @param camera The camera to dispose the effect on.
  137853. */
  137854. disposeEffects(camera: Camera): void;
  137855. /**
  137856. * @hidden Internal
  137857. */
  137858. _updateEffects(): void;
  137859. /**
  137860. * Internal
  137861. * @returns if all the contained post processes are ready.
  137862. * @hidden
  137863. */
  137864. _isReady(): boolean;
  137865. }
  137866. }
  137867. declare module BABYLON {
  137868. /** @hidden */
  137869. export var displayPassPixelShader: {
  137870. name: string;
  137871. shader: string;
  137872. };
  137873. }
  137874. declare module BABYLON {
  137875. /**
  137876. * DisplayPassPostProcess which produces an output the same as it's input
  137877. */
  137878. export class DisplayPassPostProcess extends PostProcess {
  137879. /**
  137880. * Creates the DisplayPassPostProcess
  137881. * @param name The name of the effect.
  137882. * @param options The required width/height ratio to downsize to before computing the render pass.
  137883. * @param camera The camera to apply the render pass to.
  137884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137885. * @param engine The engine which the post process will be applied. (default: current engine)
  137886. * @param reusable If the post process can be reused on the same frame. (default: false)
  137887. */
  137888. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137889. }
  137890. }
  137891. declare module BABYLON {
  137892. /** @hidden */
  137893. export var filterPixelShader: {
  137894. name: string;
  137895. shader: string;
  137896. };
  137897. }
  137898. declare module BABYLON {
  137899. /**
  137900. * Applies a kernel filter to the image
  137901. */
  137902. export class FilterPostProcess extends PostProcess {
  137903. /** The matrix to be applied to the image */
  137904. kernelMatrix: Matrix;
  137905. /**
  137906. *
  137907. * @param name The name of the effect.
  137908. * @param kernelMatrix The matrix to be applied to the image
  137909. * @param options The required width/height ratio to downsize to before computing the render pass.
  137910. * @param camera The camera to apply the render pass to.
  137911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137912. * @param engine The engine which the post process will be applied. (default: current engine)
  137913. * @param reusable If the post process can be reused on the same frame. (default: false)
  137914. */
  137915. constructor(name: string,
  137916. /** The matrix to be applied to the image */
  137917. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137918. }
  137919. }
  137920. declare module BABYLON {
  137921. /** @hidden */
  137922. export var fxaaPixelShader: {
  137923. name: string;
  137924. shader: string;
  137925. };
  137926. }
  137927. declare module BABYLON {
  137928. /** @hidden */
  137929. export var fxaaVertexShader: {
  137930. name: string;
  137931. shader: string;
  137932. };
  137933. }
  137934. declare module BABYLON {
  137935. /**
  137936. * Fxaa post process
  137937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137938. */
  137939. export class FxaaPostProcess extends PostProcess {
  137940. /** @hidden */
  137941. texelWidth: number;
  137942. /** @hidden */
  137943. texelHeight: number;
  137944. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137945. private _getDefines;
  137946. }
  137947. }
  137948. declare module BABYLON {
  137949. /** @hidden */
  137950. export var grainPixelShader: {
  137951. name: string;
  137952. shader: string;
  137953. };
  137954. }
  137955. declare module BABYLON {
  137956. /**
  137957. * The GrainPostProcess adds noise to the image at mid luminance levels
  137958. */
  137959. export class GrainPostProcess extends PostProcess {
  137960. /**
  137961. * The intensity of the grain added (default: 30)
  137962. */
  137963. intensity: number;
  137964. /**
  137965. * If the grain should be randomized on every frame
  137966. */
  137967. animated: boolean;
  137968. /**
  137969. * Creates a new instance of @see GrainPostProcess
  137970. * @param name The name of the effect.
  137971. * @param options The required width/height ratio to downsize to before computing the render pass.
  137972. * @param camera The camera to apply the render pass to.
  137973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137974. * @param engine The engine which the post process will be applied. (default: current engine)
  137975. * @param reusable If the post process can be reused on the same frame. (default: false)
  137976. * @param textureType Type of textures used when performing the post process. (default: 0)
  137977. * @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)
  137978. */
  137979. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137980. }
  137981. }
  137982. declare module BABYLON {
  137983. /** @hidden */
  137984. export var highlightsPixelShader: {
  137985. name: string;
  137986. shader: string;
  137987. };
  137988. }
  137989. declare module BABYLON {
  137990. /**
  137991. * Extracts highlights from the image
  137992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137993. */
  137994. export class HighlightsPostProcess extends PostProcess {
  137995. /**
  137996. * Extracts highlights from the image
  137997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137998. * @param name The name of the effect.
  137999. * @param options The required width/height ratio to downsize to before computing the render pass.
  138000. * @param camera The camera to apply the render pass to.
  138001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138002. * @param engine The engine which the post process will be applied. (default: current engine)
  138003. * @param reusable If the post process can be reused on the same frame. (default: false)
  138004. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  138005. */
  138006. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138007. }
  138008. }
  138009. declare module BABYLON {
  138010. /** @hidden */
  138011. export var mrtFragmentDeclaration: {
  138012. name: string;
  138013. shader: string;
  138014. };
  138015. }
  138016. declare module BABYLON {
  138017. /** @hidden */
  138018. export var geometryPixelShader: {
  138019. name: string;
  138020. shader: string;
  138021. };
  138022. }
  138023. declare module BABYLON {
  138024. /** @hidden */
  138025. export var geometryVertexShader: {
  138026. name: string;
  138027. shader: string;
  138028. };
  138029. }
  138030. declare module BABYLON {
  138031. /** @hidden */
  138032. interface ISavedTransformationMatrix {
  138033. world: Matrix;
  138034. viewProjection: Matrix;
  138035. }
  138036. /**
  138037. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  138038. */
  138039. export class GeometryBufferRenderer {
  138040. /**
  138041. * Constant used to retrieve the position texture index in the G-Buffer textures array
  138042. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  138043. */
  138044. static readonly POSITION_TEXTURE_TYPE: number;
  138045. /**
  138046. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  138047. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  138048. */
  138049. static readonly VELOCITY_TEXTURE_TYPE: number;
  138050. /**
  138051. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  138052. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  138053. */
  138054. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  138055. /**
  138056. * Dictionary used to store the previous transformation matrices of each rendered mesh
  138057. * in order to compute objects velocities when enableVelocity is set to "true"
  138058. * @hidden
  138059. */
  138060. _previousTransformationMatrices: {
  138061. [index: number]: ISavedTransformationMatrix;
  138062. };
  138063. /**
  138064. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  138065. * in order to compute objects velocities when enableVelocity is set to "true"
  138066. * @hidden
  138067. */
  138068. _previousBonesTransformationMatrices: {
  138069. [index: number]: Float32Array;
  138070. };
  138071. /**
  138072. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  138073. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  138074. */
  138075. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  138076. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  138077. renderTransparentMeshes: boolean;
  138078. private _scene;
  138079. private _multiRenderTarget;
  138080. private _ratio;
  138081. private _enablePosition;
  138082. private _enableVelocity;
  138083. private _enableReflectivity;
  138084. private _positionIndex;
  138085. private _velocityIndex;
  138086. private _reflectivityIndex;
  138087. protected _effect: Effect;
  138088. protected _cachedDefines: string;
  138089. /**
  138090. * Set the render list (meshes to be rendered) used in the G buffer.
  138091. */
  138092. set renderList(meshes: Mesh[]);
  138093. /**
  138094. * Gets wether or not G buffer are supported by the running hardware.
  138095. * This requires draw buffer supports
  138096. */
  138097. get isSupported(): boolean;
  138098. /**
  138099. * Returns the index of the given texture type in the G-Buffer textures array
  138100. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138101. * @returns the index of the given texture type in the G-Buffer textures array
  138102. */
  138103. getTextureIndex(textureType: number): number;
  138104. /**
  138105. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138106. */
  138107. get enablePosition(): boolean;
  138108. /**
  138109. * Sets whether or not objects positions are enabled for the G buffer.
  138110. */
  138111. set enablePosition(enable: boolean);
  138112. /**
  138113. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138114. */
  138115. get enableVelocity(): boolean;
  138116. /**
  138117. * Sets wether or not objects velocities are enabled for the G buffer.
  138118. */
  138119. set enableVelocity(enable: boolean);
  138120. /**
  138121. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138122. */
  138123. get enableReflectivity(): boolean;
  138124. /**
  138125. * Sets wether or not objects roughness are enabled for the G buffer.
  138126. */
  138127. set enableReflectivity(enable: boolean);
  138128. /**
  138129. * Gets the scene associated with the buffer.
  138130. */
  138131. get scene(): Scene;
  138132. /**
  138133. * Gets the ratio used by the buffer during its creation.
  138134. * How big is the buffer related to the main canvas.
  138135. */
  138136. get ratio(): number;
  138137. /** @hidden */
  138138. static _SceneComponentInitialization: (scene: Scene) => void;
  138139. /**
  138140. * Creates a new G Buffer for the scene
  138141. * @param scene The scene the buffer belongs to
  138142. * @param ratio How big is the buffer related to the main canvas.
  138143. */
  138144. constructor(scene: Scene, ratio?: number);
  138145. /**
  138146. * Checks wether everything is ready to render a submesh to the G buffer.
  138147. * @param subMesh the submesh to check readiness for
  138148. * @param useInstances is the mesh drawn using instance or not
  138149. * @returns true if ready otherwise false
  138150. */
  138151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138152. /**
  138153. * Gets the current underlying G Buffer.
  138154. * @returns the buffer
  138155. */
  138156. getGBuffer(): MultiRenderTarget;
  138157. /**
  138158. * Gets the number of samples used to render the buffer (anti aliasing).
  138159. */
  138160. get samples(): number;
  138161. /**
  138162. * Sets the number of samples used to render the buffer (anti aliasing).
  138163. */
  138164. set samples(value: number);
  138165. /**
  138166. * Disposes the renderer and frees up associated resources.
  138167. */
  138168. dispose(): void;
  138169. protected _createRenderTargets(): void;
  138170. private _copyBonesTransformationMatrices;
  138171. }
  138172. }
  138173. declare module BABYLON {
  138174. interface Scene {
  138175. /** @hidden (Backing field) */
  138176. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138177. /**
  138178. * Gets or Sets the current geometry buffer associated to the scene.
  138179. */
  138180. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138181. /**
  138182. * Enables a GeometryBufferRender and associates it with the scene
  138183. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138184. * @returns the GeometryBufferRenderer
  138185. */
  138186. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138187. /**
  138188. * Disables the GeometryBufferRender associated with the scene
  138189. */
  138190. disableGeometryBufferRenderer(): void;
  138191. }
  138192. /**
  138193. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138194. * in several rendering techniques.
  138195. */
  138196. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138197. /**
  138198. * The component name helpful to identify the component in the list of scene components.
  138199. */
  138200. readonly name: string;
  138201. /**
  138202. * The scene the component belongs to.
  138203. */
  138204. scene: Scene;
  138205. /**
  138206. * Creates a new instance of the component for the given scene
  138207. * @param scene Defines the scene to register the component in
  138208. */
  138209. constructor(scene: Scene);
  138210. /**
  138211. * Registers the component in a given scene
  138212. */
  138213. register(): void;
  138214. /**
  138215. * Rebuilds the elements related to this component in case of
  138216. * context lost for instance.
  138217. */
  138218. rebuild(): void;
  138219. /**
  138220. * Disposes the component and the associated ressources
  138221. */
  138222. dispose(): void;
  138223. private _gatherRenderTargets;
  138224. }
  138225. }
  138226. declare module BABYLON {
  138227. /** @hidden */
  138228. export var motionBlurPixelShader: {
  138229. name: string;
  138230. shader: string;
  138231. };
  138232. }
  138233. declare module BABYLON {
  138234. /**
  138235. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138236. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138237. * As an example, all you have to do is to create the post-process:
  138238. * var mb = new BABYLON.MotionBlurPostProcess(
  138239. * 'mb', // The name of the effect.
  138240. * scene, // The scene containing the objects to blur according to their velocity.
  138241. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138242. * camera // The camera to apply the render pass to.
  138243. * );
  138244. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138245. */
  138246. export class MotionBlurPostProcess extends PostProcess {
  138247. /**
  138248. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138249. */
  138250. motionStrength: number;
  138251. /**
  138252. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138253. */
  138254. get motionBlurSamples(): number;
  138255. /**
  138256. * Sets the number of iterations to be used for motion blur quality
  138257. */
  138258. set motionBlurSamples(samples: number);
  138259. private _motionBlurSamples;
  138260. private _geometryBufferRenderer;
  138261. /**
  138262. * Creates a new instance MotionBlurPostProcess
  138263. * @param name The name of the effect.
  138264. * @param scene The scene containing the objects to blur according to their velocity.
  138265. * @param options The required width/height ratio to downsize to before computing the render pass.
  138266. * @param camera The camera to apply the render pass to.
  138267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138268. * @param engine The engine which the post process will be applied. (default: current engine)
  138269. * @param reusable If the post process can be reused on the same frame. (default: false)
  138270. * @param textureType Type of textures used when performing the post process. (default: 0)
  138271. * @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)
  138272. */
  138273. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138274. /**
  138275. * Excludes the given skinned mesh from computing bones velocities.
  138276. * 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.
  138277. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138278. */
  138279. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138280. /**
  138281. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138282. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138283. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138284. */
  138285. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138286. /**
  138287. * Disposes the post process.
  138288. * @param camera The camera to dispose the post process on.
  138289. */
  138290. dispose(camera?: Camera): void;
  138291. }
  138292. }
  138293. declare module BABYLON {
  138294. /** @hidden */
  138295. export var refractionPixelShader: {
  138296. name: string;
  138297. shader: string;
  138298. };
  138299. }
  138300. declare module BABYLON {
  138301. /**
  138302. * Post process which applies a refractin texture
  138303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138304. */
  138305. export class RefractionPostProcess extends PostProcess {
  138306. /** the base color of the refraction (used to taint the rendering) */
  138307. color: Color3;
  138308. /** simulated refraction depth */
  138309. depth: number;
  138310. /** the coefficient of the base color (0 to remove base color tainting) */
  138311. colorLevel: number;
  138312. private _refTexture;
  138313. private _ownRefractionTexture;
  138314. /**
  138315. * Gets or sets the refraction texture
  138316. * Please note that you are responsible for disposing the texture if you set it manually
  138317. */
  138318. get refractionTexture(): Texture;
  138319. set refractionTexture(value: Texture);
  138320. /**
  138321. * Initializes the RefractionPostProcess
  138322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138323. * @param name The name of the effect.
  138324. * @param refractionTextureUrl Url of the refraction texture to use
  138325. * @param color the base color of the refraction (used to taint the rendering)
  138326. * @param depth simulated refraction depth
  138327. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138328. * @param camera The camera to apply the render pass to.
  138329. * @param options The required width/height ratio to downsize to before computing the render pass.
  138330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138331. * @param engine The engine which the post process will be applied. (default: current engine)
  138332. * @param reusable If the post process can be reused on the same frame. (default: false)
  138333. */
  138334. constructor(name: string, refractionTextureUrl: string,
  138335. /** the base color of the refraction (used to taint the rendering) */
  138336. color: Color3,
  138337. /** simulated refraction depth */
  138338. depth: number,
  138339. /** the coefficient of the base color (0 to remove base color tainting) */
  138340. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138341. /**
  138342. * Disposes of the post process
  138343. * @param camera Camera to dispose post process on
  138344. */
  138345. dispose(camera: Camera): void;
  138346. }
  138347. }
  138348. declare module BABYLON {
  138349. /** @hidden */
  138350. export var sharpenPixelShader: {
  138351. name: string;
  138352. shader: string;
  138353. };
  138354. }
  138355. declare module BABYLON {
  138356. /**
  138357. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138358. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138359. */
  138360. export class SharpenPostProcess extends PostProcess {
  138361. /**
  138362. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138363. */
  138364. colorAmount: number;
  138365. /**
  138366. * How much sharpness should be applied (default: 0.3)
  138367. */
  138368. edgeAmount: number;
  138369. /**
  138370. * Creates a new instance ConvolutionPostProcess
  138371. * @param name The name of the effect.
  138372. * @param options The required width/height ratio to downsize to before computing the render pass.
  138373. * @param camera The camera to apply the render pass to.
  138374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138375. * @param engine The engine which the post process will be applied. (default: current engine)
  138376. * @param reusable If the post process can be reused on the same frame. (default: false)
  138377. * @param textureType Type of textures used when performing the post process. (default: 0)
  138378. * @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)
  138379. */
  138380. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138381. }
  138382. }
  138383. declare module BABYLON {
  138384. /**
  138385. * PostProcessRenderPipeline
  138386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138387. */
  138388. export class PostProcessRenderPipeline {
  138389. private engine;
  138390. private _renderEffects;
  138391. private _renderEffectsForIsolatedPass;
  138392. /**
  138393. * List of inspectable custom properties (used by the Inspector)
  138394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138395. */
  138396. inspectableCustomProperties: IInspectable[];
  138397. /**
  138398. * @hidden
  138399. */
  138400. protected _cameras: Camera[];
  138401. /** @hidden */
  138402. _name: string;
  138403. /**
  138404. * Gets pipeline name
  138405. */
  138406. get name(): string;
  138407. /** Gets the list of attached cameras */
  138408. get cameras(): Camera[];
  138409. /**
  138410. * Initializes a PostProcessRenderPipeline
  138411. * @param engine engine to add the pipeline to
  138412. * @param name name of the pipeline
  138413. */
  138414. constructor(engine: Engine, name: string);
  138415. /**
  138416. * Gets the class name
  138417. * @returns "PostProcessRenderPipeline"
  138418. */
  138419. getClassName(): string;
  138420. /**
  138421. * If all the render effects in the pipeline are supported
  138422. */
  138423. get isSupported(): boolean;
  138424. /**
  138425. * Adds an effect to the pipeline
  138426. * @param renderEffect the effect to add
  138427. */
  138428. addEffect(renderEffect: PostProcessRenderEffect): void;
  138429. /** @hidden */
  138430. _rebuild(): void;
  138431. /** @hidden */
  138432. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138433. /** @hidden */
  138434. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138435. /** @hidden */
  138436. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138437. /** @hidden */
  138438. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138439. /** @hidden */
  138440. _attachCameras(cameras: Camera, unique: boolean): void;
  138441. /** @hidden */
  138442. _attachCameras(cameras: Camera[], unique: boolean): void;
  138443. /** @hidden */
  138444. _detachCameras(cameras: Camera): void;
  138445. /** @hidden */
  138446. _detachCameras(cameras: Nullable<Camera[]>): void;
  138447. /** @hidden */
  138448. _update(): void;
  138449. /** @hidden */
  138450. _reset(): void;
  138451. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138452. /**
  138453. * Disposes of the pipeline
  138454. */
  138455. dispose(): void;
  138456. }
  138457. }
  138458. declare module BABYLON {
  138459. /**
  138460. * PostProcessRenderPipelineManager class
  138461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138462. */
  138463. export class PostProcessRenderPipelineManager {
  138464. private _renderPipelines;
  138465. /**
  138466. * Initializes a PostProcessRenderPipelineManager
  138467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138468. */
  138469. constructor();
  138470. /**
  138471. * Gets the list of supported render pipelines
  138472. */
  138473. get supportedPipelines(): PostProcessRenderPipeline[];
  138474. /**
  138475. * Adds a pipeline to the manager
  138476. * @param renderPipeline The pipeline to add
  138477. */
  138478. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138479. /**
  138480. * Attaches a camera to the pipeline
  138481. * @param renderPipelineName The name of the pipeline to attach to
  138482. * @param cameras the camera to attach
  138483. * @param unique if the camera can be attached multiple times to the pipeline
  138484. */
  138485. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138486. /**
  138487. * Detaches a camera from the pipeline
  138488. * @param renderPipelineName The name of the pipeline to detach from
  138489. * @param cameras the camera to detach
  138490. */
  138491. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138492. /**
  138493. * Enables an effect by name on a pipeline
  138494. * @param renderPipelineName the name of the pipeline to enable the effect in
  138495. * @param renderEffectName the name of the effect to enable
  138496. * @param cameras the cameras that the effect should be enabled on
  138497. */
  138498. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138499. /**
  138500. * Disables an effect by name on a pipeline
  138501. * @param renderPipelineName the name of the pipeline to disable the effect in
  138502. * @param renderEffectName the name of the effect to disable
  138503. * @param cameras the cameras that the effect should be disabled on
  138504. */
  138505. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138506. /**
  138507. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138508. */
  138509. update(): void;
  138510. /** @hidden */
  138511. _rebuild(): void;
  138512. /**
  138513. * Disposes of the manager and pipelines
  138514. */
  138515. dispose(): void;
  138516. }
  138517. }
  138518. declare module BABYLON {
  138519. interface Scene {
  138520. /** @hidden (Backing field) */
  138521. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138522. /**
  138523. * Gets the postprocess render pipeline manager
  138524. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138525. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138526. */
  138527. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138528. }
  138529. /**
  138530. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138531. */
  138532. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138533. /**
  138534. * The component name helpfull to identify the component in the list of scene components.
  138535. */
  138536. readonly name: string;
  138537. /**
  138538. * The scene the component belongs to.
  138539. */
  138540. scene: Scene;
  138541. /**
  138542. * Creates a new instance of the component for the given scene
  138543. * @param scene Defines the scene to register the component in
  138544. */
  138545. constructor(scene: Scene);
  138546. /**
  138547. * Registers the component in a given scene
  138548. */
  138549. register(): void;
  138550. /**
  138551. * Rebuilds the elements related to this component in case of
  138552. * context lost for instance.
  138553. */
  138554. rebuild(): void;
  138555. /**
  138556. * Disposes the component and the associated ressources
  138557. */
  138558. dispose(): void;
  138559. private _gatherRenderTargets;
  138560. }
  138561. }
  138562. declare module BABYLON {
  138563. /**
  138564. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138565. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138566. */
  138567. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138568. private _scene;
  138569. private _camerasToBeAttached;
  138570. /**
  138571. * ID of the sharpen post process,
  138572. */
  138573. private readonly SharpenPostProcessId;
  138574. /**
  138575. * @ignore
  138576. * ID of the image processing post process;
  138577. */
  138578. readonly ImageProcessingPostProcessId: string;
  138579. /**
  138580. * @ignore
  138581. * ID of the Fast Approximate Anti-Aliasing post process;
  138582. */
  138583. readonly FxaaPostProcessId: string;
  138584. /**
  138585. * ID of the chromatic aberration post process,
  138586. */
  138587. private readonly ChromaticAberrationPostProcessId;
  138588. /**
  138589. * ID of the grain post process
  138590. */
  138591. private readonly GrainPostProcessId;
  138592. /**
  138593. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138594. */
  138595. sharpen: SharpenPostProcess;
  138596. private _sharpenEffect;
  138597. private bloom;
  138598. /**
  138599. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138600. */
  138601. depthOfField: DepthOfFieldEffect;
  138602. /**
  138603. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138604. */
  138605. fxaa: FxaaPostProcess;
  138606. /**
  138607. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138608. */
  138609. imageProcessing: ImageProcessingPostProcess;
  138610. /**
  138611. * Chromatic aberration post process which will shift rgb colors in the image
  138612. */
  138613. chromaticAberration: ChromaticAberrationPostProcess;
  138614. private _chromaticAberrationEffect;
  138615. /**
  138616. * Grain post process which add noise to the image
  138617. */
  138618. grain: GrainPostProcess;
  138619. private _grainEffect;
  138620. /**
  138621. * Glow post process which adds a glow to emissive areas of the image
  138622. */
  138623. private _glowLayer;
  138624. /**
  138625. * Animations which can be used to tweak settings over a period of time
  138626. */
  138627. animations: Animation[];
  138628. private _imageProcessingConfigurationObserver;
  138629. private _sharpenEnabled;
  138630. private _bloomEnabled;
  138631. private _depthOfFieldEnabled;
  138632. private _depthOfFieldBlurLevel;
  138633. private _fxaaEnabled;
  138634. private _imageProcessingEnabled;
  138635. private _defaultPipelineTextureType;
  138636. private _bloomScale;
  138637. private _chromaticAberrationEnabled;
  138638. private _grainEnabled;
  138639. private _buildAllowed;
  138640. /**
  138641. * Gets active scene
  138642. */
  138643. get scene(): Scene;
  138644. /**
  138645. * Enable or disable the sharpen process from the pipeline
  138646. */
  138647. set sharpenEnabled(enabled: boolean);
  138648. get sharpenEnabled(): boolean;
  138649. private _resizeObserver;
  138650. private _hardwareScaleLevel;
  138651. private _bloomKernel;
  138652. /**
  138653. * Specifies the size of the bloom blur kernel, relative to the final output size
  138654. */
  138655. get bloomKernel(): number;
  138656. set bloomKernel(value: number);
  138657. /**
  138658. * Specifies the weight of the bloom in the final rendering
  138659. */
  138660. private _bloomWeight;
  138661. /**
  138662. * Specifies the luma threshold for the area that will be blurred by the bloom
  138663. */
  138664. private _bloomThreshold;
  138665. private _hdr;
  138666. /**
  138667. * The strength of the bloom.
  138668. */
  138669. set bloomWeight(value: number);
  138670. get bloomWeight(): number;
  138671. /**
  138672. * The strength of the bloom.
  138673. */
  138674. set bloomThreshold(value: number);
  138675. get bloomThreshold(): number;
  138676. /**
  138677. * The scale of the bloom, lower value will provide better performance.
  138678. */
  138679. set bloomScale(value: number);
  138680. get bloomScale(): number;
  138681. /**
  138682. * Enable or disable the bloom from the pipeline
  138683. */
  138684. set bloomEnabled(enabled: boolean);
  138685. get bloomEnabled(): boolean;
  138686. private _rebuildBloom;
  138687. /**
  138688. * If the depth of field is enabled.
  138689. */
  138690. get depthOfFieldEnabled(): boolean;
  138691. set depthOfFieldEnabled(enabled: boolean);
  138692. /**
  138693. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138694. */
  138695. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138696. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138697. /**
  138698. * If the anti aliasing is enabled.
  138699. */
  138700. set fxaaEnabled(enabled: boolean);
  138701. get fxaaEnabled(): boolean;
  138702. private _samples;
  138703. /**
  138704. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138705. */
  138706. set samples(sampleCount: number);
  138707. get samples(): number;
  138708. /**
  138709. * If image processing is enabled.
  138710. */
  138711. set imageProcessingEnabled(enabled: boolean);
  138712. get imageProcessingEnabled(): boolean;
  138713. /**
  138714. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138715. */
  138716. set glowLayerEnabled(enabled: boolean);
  138717. get glowLayerEnabled(): boolean;
  138718. /**
  138719. * Gets the glow layer (or null if not defined)
  138720. */
  138721. get glowLayer(): Nullable<GlowLayer>;
  138722. /**
  138723. * Enable or disable the chromaticAberration process from the pipeline
  138724. */
  138725. set chromaticAberrationEnabled(enabled: boolean);
  138726. get chromaticAberrationEnabled(): boolean;
  138727. /**
  138728. * Enable or disable the grain process from the pipeline
  138729. */
  138730. set grainEnabled(enabled: boolean);
  138731. get grainEnabled(): boolean;
  138732. /**
  138733. * @constructor
  138734. * @param name - The rendering pipeline name (default: "")
  138735. * @param hdr - If high dynamic range textures should be used (default: true)
  138736. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138737. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138738. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138739. */
  138740. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138741. /**
  138742. * Get the class name
  138743. * @returns "DefaultRenderingPipeline"
  138744. */
  138745. getClassName(): string;
  138746. /**
  138747. * Force the compilation of the entire pipeline.
  138748. */
  138749. prepare(): void;
  138750. private _hasCleared;
  138751. private _prevPostProcess;
  138752. private _prevPrevPostProcess;
  138753. private _setAutoClearAndTextureSharing;
  138754. private _depthOfFieldSceneObserver;
  138755. private _buildPipeline;
  138756. private _disposePostProcesses;
  138757. /**
  138758. * Adds a camera to the pipeline
  138759. * @param camera the camera to be added
  138760. */
  138761. addCamera(camera: Camera): void;
  138762. /**
  138763. * Removes a camera from the pipeline
  138764. * @param camera the camera to remove
  138765. */
  138766. removeCamera(camera: Camera): void;
  138767. /**
  138768. * Dispose of the pipeline and stop all post processes
  138769. */
  138770. dispose(): void;
  138771. /**
  138772. * Serialize the rendering pipeline (Used when exporting)
  138773. * @returns the serialized object
  138774. */
  138775. serialize(): any;
  138776. /**
  138777. * Parse the serialized pipeline
  138778. * @param source Source pipeline.
  138779. * @param scene The scene to load the pipeline to.
  138780. * @param rootUrl The URL of the serialized pipeline.
  138781. * @returns An instantiated pipeline from the serialized object.
  138782. */
  138783. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138784. }
  138785. }
  138786. declare module BABYLON {
  138787. /** @hidden */
  138788. export var lensHighlightsPixelShader: {
  138789. name: string;
  138790. shader: string;
  138791. };
  138792. }
  138793. declare module BABYLON {
  138794. /** @hidden */
  138795. export var depthOfFieldPixelShader: {
  138796. name: string;
  138797. shader: string;
  138798. };
  138799. }
  138800. declare module BABYLON {
  138801. /**
  138802. * BABYLON.JS Chromatic Aberration GLSL Shader
  138803. * Author: Olivier Guyot
  138804. * Separates very slightly R, G and B colors on the edges of the screen
  138805. * Inspired by Francois Tarlier & Martins Upitis
  138806. */
  138807. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138808. /**
  138809. * @ignore
  138810. * The chromatic aberration PostProcess id in the pipeline
  138811. */
  138812. LensChromaticAberrationEffect: string;
  138813. /**
  138814. * @ignore
  138815. * The highlights enhancing PostProcess id in the pipeline
  138816. */
  138817. HighlightsEnhancingEffect: string;
  138818. /**
  138819. * @ignore
  138820. * The depth-of-field PostProcess id in the pipeline
  138821. */
  138822. LensDepthOfFieldEffect: string;
  138823. private _scene;
  138824. private _depthTexture;
  138825. private _grainTexture;
  138826. private _chromaticAberrationPostProcess;
  138827. private _highlightsPostProcess;
  138828. private _depthOfFieldPostProcess;
  138829. private _edgeBlur;
  138830. private _grainAmount;
  138831. private _chromaticAberration;
  138832. private _distortion;
  138833. private _highlightsGain;
  138834. private _highlightsThreshold;
  138835. private _dofDistance;
  138836. private _dofAperture;
  138837. private _dofDarken;
  138838. private _dofPentagon;
  138839. private _blurNoise;
  138840. /**
  138841. * @constructor
  138842. *
  138843. * Effect parameters are as follow:
  138844. * {
  138845. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138846. * edge_blur: number; // from 0 to x (1 for realism)
  138847. * distortion: number; // from 0 to x (1 for realism)
  138848. * grain_amount: number; // from 0 to 1
  138849. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138850. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138851. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138852. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138853. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138854. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138855. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138856. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138857. * }
  138858. * Note: if an effect parameter is unset, effect is disabled
  138859. *
  138860. * @param name The rendering pipeline name
  138861. * @param parameters - An object containing all parameters (see above)
  138862. * @param scene The scene linked to this pipeline
  138863. * @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)
  138864. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138865. */
  138866. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138867. /**
  138868. * Get the class name
  138869. * @returns "LensRenderingPipeline"
  138870. */
  138871. getClassName(): string;
  138872. /**
  138873. * Gets associated scene
  138874. */
  138875. get scene(): Scene;
  138876. /**
  138877. * Gets or sets the edge blur
  138878. */
  138879. get edgeBlur(): number;
  138880. set edgeBlur(value: number);
  138881. /**
  138882. * Gets or sets the grain amount
  138883. */
  138884. get grainAmount(): number;
  138885. set grainAmount(value: number);
  138886. /**
  138887. * Gets or sets the chromatic aberration amount
  138888. */
  138889. get chromaticAberration(): number;
  138890. set chromaticAberration(value: number);
  138891. /**
  138892. * Gets or sets the depth of field aperture
  138893. */
  138894. get dofAperture(): number;
  138895. set dofAperture(value: number);
  138896. /**
  138897. * Gets or sets the edge distortion
  138898. */
  138899. get edgeDistortion(): number;
  138900. set edgeDistortion(value: number);
  138901. /**
  138902. * Gets or sets the depth of field distortion
  138903. */
  138904. get dofDistortion(): number;
  138905. set dofDistortion(value: number);
  138906. /**
  138907. * Gets or sets the darken out of focus amount
  138908. */
  138909. get darkenOutOfFocus(): number;
  138910. set darkenOutOfFocus(value: number);
  138911. /**
  138912. * Gets or sets a boolean indicating if blur noise is enabled
  138913. */
  138914. get blurNoise(): boolean;
  138915. set blurNoise(value: boolean);
  138916. /**
  138917. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138918. */
  138919. get pentagonBokeh(): boolean;
  138920. set pentagonBokeh(value: boolean);
  138921. /**
  138922. * Gets or sets the highlight grain amount
  138923. */
  138924. get highlightsGain(): number;
  138925. set highlightsGain(value: number);
  138926. /**
  138927. * Gets or sets the highlight threshold
  138928. */
  138929. get highlightsThreshold(): number;
  138930. set highlightsThreshold(value: number);
  138931. /**
  138932. * Sets the amount of blur at the edges
  138933. * @param amount blur amount
  138934. */
  138935. setEdgeBlur(amount: number): void;
  138936. /**
  138937. * Sets edge blur to 0
  138938. */
  138939. disableEdgeBlur(): void;
  138940. /**
  138941. * Sets the amout of grain
  138942. * @param amount Amount of grain
  138943. */
  138944. setGrainAmount(amount: number): void;
  138945. /**
  138946. * Set grain amount to 0
  138947. */
  138948. disableGrain(): void;
  138949. /**
  138950. * Sets the chromatic aberration amount
  138951. * @param amount amount of chromatic aberration
  138952. */
  138953. setChromaticAberration(amount: number): void;
  138954. /**
  138955. * Sets chromatic aberration amount to 0
  138956. */
  138957. disableChromaticAberration(): void;
  138958. /**
  138959. * Sets the EdgeDistortion amount
  138960. * @param amount amount of EdgeDistortion
  138961. */
  138962. setEdgeDistortion(amount: number): void;
  138963. /**
  138964. * Sets edge distortion to 0
  138965. */
  138966. disableEdgeDistortion(): void;
  138967. /**
  138968. * Sets the FocusDistance amount
  138969. * @param amount amount of FocusDistance
  138970. */
  138971. setFocusDistance(amount: number): void;
  138972. /**
  138973. * Disables depth of field
  138974. */
  138975. disableDepthOfField(): void;
  138976. /**
  138977. * Sets the Aperture amount
  138978. * @param amount amount of Aperture
  138979. */
  138980. setAperture(amount: number): void;
  138981. /**
  138982. * Sets the DarkenOutOfFocus amount
  138983. * @param amount amount of DarkenOutOfFocus
  138984. */
  138985. setDarkenOutOfFocus(amount: number): void;
  138986. private _pentagonBokehIsEnabled;
  138987. /**
  138988. * Creates a pentagon bokeh effect
  138989. */
  138990. enablePentagonBokeh(): void;
  138991. /**
  138992. * Disables the pentagon bokeh effect
  138993. */
  138994. disablePentagonBokeh(): void;
  138995. /**
  138996. * Enables noise blur
  138997. */
  138998. enableNoiseBlur(): void;
  138999. /**
  139000. * Disables noise blur
  139001. */
  139002. disableNoiseBlur(): void;
  139003. /**
  139004. * Sets the HighlightsGain amount
  139005. * @param amount amount of HighlightsGain
  139006. */
  139007. setHighlightsGain(amount: number): void;
  139008. /**
  139009. * Sets the HighlightsThreshold amount
  139010. * @param amount amount of HighlightsThreshold
  139011. */
  139012. setHighlightsThreshold(amount: number): void;
  139013. /**
  139014. * Disables highlights
  139015. */
  139016. disableHighlights(): void;
  139017. /**
  139018. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  139019. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  139020. */
  139021. dispose(disableDepthRender?: boolean): void;
  139022. private _createChromaticAberrationPostProcess;
  139023. private _createHighlightsPostProcess;
  139024. private _createDepthOfFieldPostProcess;
  139025. private _createGrainTexture;
  139026. }
  139027. }
  139028. declare module BABYLON {
  139029. /** @hidden */
  139030. export var ssao2PixelShader: {
  139031. name: string;
  139032. shader: string;
  139033. };
  139034. }
  139035. declare module BABYLON {
  139036. /** @hidden */
  139037. export var ssaoCombinePixelShader: {
  139038. name: string;
  139039. shader: string;
  139040. };
  139041. }
  139042. declare module BABYLON {
  139043. /**
  139044. * Render pipeline to produce ssao effect
  139045. */
  139046. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  139047. /**
  139048. * @ignore
  139049. * The PassPostProcess id in the pipeline that contains the original scene color
  139050. */
  139051. SSAOOriginalSceneColorEffect: string;
  139052. /**
  139053. * @ignore
  139054. * The SSAO PostProcess id in the pipeline
  139055. */
  139056. SSAORenderEffect: string;
  139057. /**
  139058. * @ignore
  139059. * The horizontal blur PostProcess id in the pipeline
  139060. */
  139061. SSAOBlurHRenderEffect: string;
  139062. /**
  139063. * @ignore
  139064. * The vertical blur PostProcess id in the pipeline
  139065. */
  139066. SSAOBlurVRenderEffect: string;
  139067. /**
  139068. * @ignore
  139069. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139070. */
  139071. SSAOCombineRenderEffect: string;
  139072. /**
  139073. * The output strength of the SSAO post-process. Default value is 1.0.
  139074. */
  139075. totalStrength: number;
  139076. /**
  139077. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  139078. */
  139079. maxZ: number;
  139080. /**
  139081. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  139082. */
  139083. minZAspect: number;
  139084. private _samples;
  139085. /**
  139086. * Number of samples used for the SSAO calculations. Default value is 8
  139087. */
  139088. set samples(n: number);
  139089. get samples(): number;
  139090. private _textureSamples;
  139091. /**
  139092. * Number of samples to use for antialiasing
  139093. */
  139094. set textureSamples(n: number);
  139095. get textureSamples(): number;
  139096. /**
  139097. * Ratio object used for SSAO ratio and blur ratio
  139098. */
  139099. private _ratio;
  139100. /**
  139101. * Dynamically generated sphere sampler.
  139102. */
  139103. private _sampleSphere;
  139104. /**
  139105. * Blur filter offsets
  139106. */
  139107. private _samplerOffsets;
  139108. private _expensiveBlur;
  139109. /**
  139110. * If bilateral blur should be used
  139111. */
  139112. set expensiveBlur(b: boolean);
  139113. get expensiveBlur(): boolean;
  139114. /**
  139115. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139116. */
  139117. radius: number;
  139118. /**
  139119. * The base color of the SSAO post-process
  139120. * The final result is "base + ssao" between [0, 1]
  139121. */
  139122. base: number;
  139123. /**
  139124. * Support test.
  139125. */
  139126. static get IsSupported(): boolean;
  139127. private _scene;
  139128. private _depthTexture;
  139129. private _normalTexture;
  139130. private _randomTexture;
  139131. private _originalColorPostProcess;
  139132. private _ssaoPostProcess;
  139133. private _blurHPostProcess;
  139134. private _blurVPostProcess;
  139135. private _ssaoCombinePostProcess;
  139136. /**
  139137. * Gets active scene
  139138. */
  139139. get scene(): Scene;
  139140. /**
  139141. * @constructor
  139142. * @param name The rendering pipeline name
  139143. * @param scene The scene linked to this pipeline
  139144. * @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 }
  139145. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139146. */
  139147. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139148. /**
  139149. * Get the class name
  139150. * @returns "SSAO2RenderingPipeline"
  139151. */
  139152. getClassName(): string;
  139153. /**
  139154. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139155. */
  139156. dispose(disableGeometryBufferRenderer?: boolean): void;
  139157. private _createBlurPostProcess;
  139158. /** @hidden */
  139159. _rebuild(): void;
  139160. private _bits;
  139161. private _radicalInverse_VdC;
  139162. private _hammersley;
  139163. private _hemisphereSample_uniform;
  139164. private _generateHemisphere;
  139165. private _createSSAOPostProcess;
  139166. private _createSSAOCombinePostProcess;
  139167. private _createRandomTexture;
  139168. /**
  139169. * Serialize the rendering pipeline (Used when exporting)
  139170. * @returns the serialized object
  139171. */
  139172. serialize(): any;
  139173. /**
  139174. * Parse the serialized pipeline
  139175. * @param source Source pipeline.
  139176. * @param scene The scene to load the pipeline to.
  139177. * @param rootUrl The URL of the serialized pipeline.
  139178. * @returns An instantiated pipeline from the serialized object.
  139179. */
  139180. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139181. }
  139182. }
  139183. declare module BABYLON {
  139184. /** @hidden */
  139185. export var ssaoPixelShader: {
  139186. name: string;
  139187. shader: string;
  139188. };
  139189. }
  139190. declare module BABYLON {
  139191. /**
  139192. * Render pipeline to produce ssao effect
  139193. */
  139194. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139195. /**
  139196. * @ignore
  139197. * The PassPostProcess id in the pipeline that contains the original scene color
  139198. */
  139199. SSAOOriginalSceneColorEffect: string;
  139200. /**
  139201. * @ignore
  139202. * The SSAO PostProcess id in the pipeline
  139203. */
  139204. SSAORenderEffect: string;
  139205. /**
  139206. * @ignore
  139207. * The horizontal blur PostProcess id in the pipeline
  139208. */
  139209. SSAOBlurHRenderEffect: string;
  139210. /**
  139211. * @ignore
  139212. * The vertical blur PostProcess id in the pipeline
  139213. */
  139214. SSAOBlurVRenderEffect: string;
  139215. /**
  139216. * @ignore
  139217. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139218. */
  139219. SSAOCombineRenderEffect: string;
  139220. /**
  139221. * The output strength of the SSAO post-process. Default value is 1.0.
  139222. */
  139223. totalStrength: number;
  139224. /**
  139225. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139226. */
  139227. radius: number;
  139228. /**
  139229. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139230. * Must not be equal to fallOff and superior to fallOff.
  139231. * Default value is 0.0075
  139232. */
  139233. area: number;
  139234. /**
  139235. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139236. * Must not be equal to area and inferior to area.
  139237. * Default value is 0.000001
  139238. */
  139239. fallOff: number;
  139240. /**
  139241. * The base color of the SSAO post-process
  139242. * The final result is "base + ssao" between [0, 1]
  139243. */
  139244. base: number;
  139245. private _scene;
  139246. private _depthTexture;
  139247. private _randomTexture;
  139248. private _originalColorPostProcess;
  139249. private _ssaoPostProcess;
  139250. private _blurHPostProcess;
  139251. private _blurVPostProcess;
  139252. private _ssaoCombinePostProcess;
  139253. private _firstUpdate;
  139254. /**
  139255. * Gets active scene
  139256. */
  139257. get scene(): Scene;
  139258. /**
  139259. * @constructor
  139260. * @param name - The rendering pipeline name
  139261. * @param scene - The scene linked to this pipeline
  139262. * @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 }
  139263. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139264. */
  139265. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139266. /**
  139267. * Get the class name
  139268. * @returns "SSAORenderingPipeline"
  139269. */
  139270. getClassName(): string;
  139271. /**
  139272. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139273. */
  139274. dispose(disableDepthRender?: boolean): void;
  139275. private _createBlurPostProcess;
  139276. /** @hidden */
  139277. _rebuild(): void;
  139278. private _createSSAOPostProcess;
  139279. private _createSSAOCombinePostProcess;
  139280. private _createRandomTexture;
  139281. }
  139282. }
  139283. declare module BABYLON {
  139284. /** @hidden */
  139285. export var screenSpaceReflectionPixelShader: {
  139286. name: string;
  139287. shader: string;
  139288. };
  139289. }
  139290. declare module BABYLON {
  139291. /**
  139292. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139293. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139294. */
  139295. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139296. /**
  139297. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139298. */
  139299. threshold: number;
  139300. /**
  139301. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139302. */
  139303. strength: number;
  139304. /**
  139305. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139306. */
  139307. reflectionSpecularFalloffExponent: number;
  139308. /**
  139309. * 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]
  139310. */
  139311. step: number;
  139312. /**
  139313. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139314. */
  139315. roughnessFactor: number;
  139316. private _geometryBufferRenderer;
  139317. private _enableSmoothReflections;
  139318. private _reflectionSamples;
  139319. private _smoothSteps;
  139320. /**
  139321. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139322. * @param name The name of the effect.
  139323. * @param scene The scene containing the objects to calculate reflections.
  139324. * @param options The required width/height ratio to downsize to before computing the render pass.
  139325. * @param camera The camera to apply the render pass to.
  139326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139327. * @param engine The engine which the post process will be applied. (default: current engine)
  139328. * @param reusable If the post process can be reused on the same frame. (default: false)
  139329. * @param textureType Type of textures used when performing the post process. (default: 0)
  139330. * @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)
  139331. */
  139332. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139333. /**
  139334. * Gets wether or not smoothing reflections is enabled.
  139335. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139336. */
  139337. get enableSmoothReflections(): boolean;
  139338. /**
  139339. * Sets wether or not smoothing reflections is enabled.
  139340. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139341. */
  139342. set enableSmoothReflections(enabled: boolean);
  139343. /**
  139344. * Gets the number of samples taken while computing reflections. More samples count is high,
  139345. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139346. */
  139347. get reflectionSamples(): number;
  139348. /**
  139349. * Sets the number of samples taken while computing reflections. More samples count is high,
  139350. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139351. */
  139352. set reflectionSamples(samples: number);
  139353. /**
  139354. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139355. * more the post-process will require GPU power and can generate a drop in FPS.
  139356. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139357. */
  139358. get smoothSteps(): number;
  139359. set smoothSteps(steps: number);
  139360. private _updateEffectDefines;
  139361. }
  139362. }
  139363. declare module BABYLON {
  139364. /** @hidden */
  139365. export var standardPixelShader: {
  139366. name: string;
  139367. shader: string;
  139368. };
  139369. }
  139370. declare module BABYLON {
  139371. /**
  139372. * Standard rendering pipeline
  139373. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139374. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139375. */
  139376. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139377. /**
  139378. * Public members
  139379. */
  139380. /**
  139381. * Post-process which contains the original scene color before the pipeline applies all the effects
  139382. */
  139383. originalPostProcess: Nullable<PostProcess>;
  139384. /**
  139385. * Post-process used to down scale an image x4
  139386. */
  139387. downSampleX4PostProcess: Nullable<PostProcess>;
  139388. /**
  139389. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139390. */
  139391. brightPassPostProcess: Nullable<PostProcess>;
  139392. /**
  139393. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139394. */
  139395. blurHPostProcesses: PostProcess[];
  139396. /**
  139397. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139398. */
  139399. blurVPostProcesses: PostProcess[];
  139400. /**
  139401. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139402. */
  139403. textureAdderPostProcess: Nullable<PostProcess>;
  139404. /**
  139405. * Post-process used to create volumetric lighting effect
  139406. */
  139407. volumetricLightPostProcess: Nullable<PostProcess>;
  139408. /**
  139409. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139410. */
  139411. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139412. /**
  139413. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139414. */
  139415. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139416. /**
  139417. * Post-process used to merge the volumetric light effect and the real scene color
  139418. */
  139419. volumetricLightMergePostProces: Nullable<PostProcess>;
  139420. /**
  139421. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139422. */
  139423. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139424. /**
  139425. * Base post-process used to calculate the average luminance of the final image for HDR
  139426. */
  139427. luminancePostProcess: Nullable<PostProcess>;
  139428. /**
  139429. * Post-processes used to create down sample post-processes in order to get
  139430. * the average luminance of the final image for HDR
  139431. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139432. */
  139433. luminanceDownSamplePostProcesses: PostProcess[];
  139434. /**
  139435. * Post-process used to create a HDR effect (light adaptation)
  139436. */
  139437. hdrPostProcess: Nullable<PostProcess>;
  139438. /**
  139439. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139440. */
  139441. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139442. /**
  139443. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139444. */
  139445. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139446. /**
  139447. * Post-process used to merge the final HDR post-process and the real scene color
  139448. */
  139449. hdrFinalPostProcess: Nullable<PostProcess>;
  139450. /**
  139451. * Post-process used to create a lens flare effect
  139452. */
  139453. lensFlarePostProcess: Nullable<PostProcess>;
  139454. /**
  139455. * Post-process that merges the result of the lens flare post-process and the real scene color
  139456. */
  139457. lensFlareComposePostProcess: Nullable<PostProcess>;
  139458. /**
  139459. * Post-process used to create a motion blur effect
  139460. */
  139461. motionBlurPostProcess: Nullable<PostProcess>;
  139462. /**
  139463. * Post-process used to create a depth of field effect
  139464. */
  139465. depthOfFieldPostProcess: Nullable<PostProcess>;
  139466. /**
  139467. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139468. */
  139469. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139470. /**
  139471. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139472. */
  139473. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139474. /**
  139475. * Represents the brightness threshold in order to configure the illuminated surfaces
  139476. */
  139477. brightThreshold: number;
  139478. /**
  139479. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139480. */
  139481. blurWidth: number;
  139482. /**
  139483. * Sets if the blur for highlighted surfaces must be only horizontal
  139484. */
  139485. horizontalBlur: boolean;
  139486. /**
  139487. * Gets the overall exposure used by the pipeline
  139488. */
  139489. get exposure(): number;
  139490. /**
  139491. * Sets the overall exposure used by the pipeline
  139492. */
  139493. set exposure(value: number);
  139494. /**
  139495. * Texture used typically to simulate "dirty" on camera lens
  139496. */
  139497. lensTexture: Nullable<Texture>;
  139498. /**
  139499. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139500. */
  139501. volumetricLightCoefficient: number;
  139502. /**
  139503. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139504. */
  139505. volumetricLightPower: number;
  139506. /**
  139507. * Used the set the blur intensity to smooth the volumetric lights
  139508. */
  139509. volumetricLightBlurScale: number;
  139510. /**
  139511. * Light (spot or directional) used to generate the volumetric lights rays
  139512. * The source light must have a shadow generate so the pipeline can get its
  139513. * depth map
  139514. */
  139515. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139516. /**
  139517. * For eye adaptation, represents the minimum luminance the eye can see
  139518. */
  139519. hdrMinimumLuminance: number;
  139520. /**
  139521. * For eye adaptation, represents the decrease luminance speed
  139522. */
  139523. hdrDecreaseRate: number;
  139524. /**
  139525. * For eye adaptation, represents the increase luminance speed
  139526. */
  139527. hdrIncreaseRate: number;
  139528. /**
  139529. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139530. */
  139531. get hdrAutoExposure(): boolean;
  139532. /**
  139533. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139534. */
  139535. set hdrAutoExposure(value: boolean);
  139536. /**
  139537. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139538. */
  139539. lensColorTexture: Nullable<Texture>;
  139540. /**
  139541. * The overall strengh for the lens flare effect
  139542. */
  139543. lensFlareStrength: number;
  139544. /**
  139545. * Dispersion coefficient for lens flare ghosts
  139546. */
  139547. lensFlareGhostDispersal: number;
  139548. /**
  139549. * Main lens flare halo width
  139550. */
  139551. lensFlareHaloWidth: number;
  139552. /**
  139553. * Based on the lens distortion effect, defines how much the lens flare result
  139554. * is distorted
  139555. */
  139556. lensFlareDistortionStrength: number;
  139557. /**
  139558. * Configures the blur intensity used for for lens flare (halo)
  139559. */
  139560. lensFlareBlurWidth: number;
  139561. /**
  139562. * Lens star texture must be used to simulate rays on the flares and is available
  139563. * in the documentation
  139564. */
  139565. lensStarTexture: Nullable<Texture>;
  139566. /**
  139567. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139568. * flare effect by taking account of the dirt texture
  139569. */
  139570. lensFlareDirtTexture: Nullable<Texture>;
  139571. /**
  139572. * Represents the focal length for the depth of field effect
  139573. */
  139574. depthOfFieldDistance: number;
  139575. /**
  139576. * Represents the blur intensity for the blurred part of the depth of field effect
  139577. */
  139578. depthOfFieldBlurWidth: number;
  139579. /**
  139580. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139581. */
  139582. get motionStrength(): number;
  139583. /**
  139584. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139585. */
  139586. set motionStrength(strength: number);
  139587. /**
  139588. * Gets wether or not the motion blur post-process is object based or screen based.
  139589. */
  139590. get objectBasedMotionBlur(): boolean;
  139591. /**
  139592. * Sets wether or not the motion blur post-process should be object based or screen based
  139593. */
  139594. set objectBasedMotionBlur(value: boolean);
  139595. /**
  139596. * List of animations for the pipeline (IAnimatable implementation)
  139597. */
  139598. animations: Animation[];
  139599. /**
  139600. * Private members
  139601. */
  139602. private _scene;
  139603. private _currentDepthOfFieldSource;
  139604. private _basePostProcess;
  139605. private _fixedExposure;
  139606. private _currentExposure;
  139607. private _hdrAutoExposure;
  139608. private _hdrCurrentLuminance;
  139609. private _motionStrength;
  139610. private _isObjectBasedMotionBlur;
  139611. private _floatTextureType;
  139612. private _camerasToBeAttached;
  139613. private _ratio;
  139614. private _bloomEnabled;
  139615. private _depthOfFieldEnabled;
  139616. private _vlsEnabled;
  139617. private _lensFlareEnabled;
  139618. private _hdrEnabled;
  139619. private _motionBlurEnabled;
  139620. private _fxaaEnabled;
  139621. private _screenSpaceReflectionsEnabled;
  139622. private _motionBlurSamples;
  139623. private _volumetricLightStepsCount;
  139624. private _samples;
  139625. /**
  139626. * @ignore
  139627. * Specifies if the bloom pipeline is enabled
  139628. */
  139629. get BloomEnabled(): boolean;
  139630. set BloomEnabled(enabled: boolean);
  139631. /**
  139632. * @ignore
  139633. * Specifies if the depth of field pipeline is enabed
  139634. */
  139635. get DepthOfFieldEnabled(): boolean;
  139636. set DepthOfFieldEnabled(enabled: boolean);
  139637. /**
  139638. * @ignore
  139639. * Specifies if the lens flare pipeline is enabed
  139640. */
  139641. get LensFlareEnabled(): boolean;
  139642. set LensFlareEnabled(enabled: boolean);
  139643. /**
  139644. * @ignore
  139645. * Specifies if the HDR pipeline is enabled
  139646. */
  139647. get HDREnabled(): boolean;
  139648. set HDREnabled(enabled: boolean);
  139649. /**
  139650. * @ignore
  139651. * Specifies if the volumetric lights scattering effect is enabled
  139652. */
  139653. get VLSEnabled(): boolean;
  139654. set VLSEnabled(enabled: boolean);
  139655. /**
  139656. * @ignore
  139657. * Specifies if the motion blur effect is enabled
  139658. */
  139659. get MotionBlurEnabled(): boolean;
  139660. set MotionBlurEnabled(enabled: boolean);
  139661. /**
  139662. * Specifies if anti-aliasing is enabled
  139663. */
  139664. get fxaaEnabled(): boolean;
  139665. set fxaaEnabled(enabled: boolean);
  139666. /**
  139667. * Specifies if screen space reflections are enabled.
  139668. */
  139669. get screenSpaceReflectionsEnabled(): boolean;
  139670. set screenSpaceReflectionsEnabled(enabled: boolean);
  139671. /**
  139672. * Specifies the number of steps used to calculate the volumetric lights
  139673. * Typically in interval [50, 200]
  139674. */
  139675. get volumetricLightStepsCount(): number;
  139676. set volumetricLightStepsCount(count: number);
  139677. /**
  139678. * Specifies the number of samples used for the motion blur effect
  139679. * Typically in interval [16, 64]
  139680. */
  139681. get motionBlurSamples(): number;
  139682. set motionBlurSamples(samples: number);
  139683. /**
  139684. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139685. */
  139686. get samples(): number;
  139687. set samples(sampleCount: number);
  139688. /**
  139689. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139690. * @constructor
  139691. * @param name The rendering pipeline name
  139692. * @param scene The scene linked to this pipeline
  139693. * @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)
  139694. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139695. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139696. */
  139697. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139698. private _buildPipeline;
  139699. private _createDownSampleX4PostProcess;
  139700. private _createBrightPassPostProcess;
  139701. private _createBlurPostProcesses;
  139702. private _createTextureAdderPostProcess;
  139703. private _createVolumetricLightPostProcess;
  139704. private _createLuminancePostProcesses;
  139705. private _createHdrPostProcess;
  139706. private _createLensFlarePostProcess;
  139707. private _createDepthOfFieldPostProcess;
  139708. private _createMotionBlurPostProcess;
  139709. private _getDepthTexture;
  139710. private _disposePostProcesses;
  139711. /**
  139712. * Dispose of the pipeline and stop all post processes
  139713. */
  139714. dispose(): void;
  139715. /**
  139716. * Serialize the rendering pipeline (Used when exporting)
  139717. * @returns the serialized object
  139718. */
  139719. serialize(): any;
  139720. /**
  139721. * Parse the serialized pipeline
  139722. * @param source Source pipeline.
  139723. * @param scene The scene to load the pipeline to.
  139724. * @param rootUrl The URL of the serialized pipeline.
  139725. * @returns An instantiated pipeline from the serialized object.
  139726. */
  139727. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139728. /**
  139729. * Luminance steps
  139730. */
  139731. static LuminanceSteps: number;
  139732. }
  139733. }
  139734. declare module BABYLON {
  139735. /** @hidden */
  139736. export var tonemapPixelShader: {
  139737. name: string;
  139738. shader: string;
  139739. };
  139740. }
  139741. declare module BABYLON {
  139742. /** Defines operator used for tonemapping */
  139743. export enum TonemappingOperator {
  139744. /** Hable */
  139745. Hable = 0,
  139746. /** Reinhard */
  139747. Reinhard = 1,
  139748. /** HejiDawson */
  139749. HejiDawson = 2,
  139750. /** Photographic */
  139751. Photographic = 3
  139752. }
  139753. /**
  139754. * Defines a post process to apply tone mapping
  139755. */
  139756. export class TonemapPostProcess extends PostProcess {
  139757. private _operator;
  139758. /** Defines the required exposure adjustement */
  139759. exposureAdjustment: number;
  139760. /**
  139761. * Creates a new TonemapPostProcess
  139762. * @param name defines the name of the postprocess
  139763. * @param _operator defines the operator to use
  139764. * @param exposureAdjustment defines the required exposure adjustement
  139765. * @param camera defines the camera to use (can be null)
  139766. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139767. * @param engine defines the hosting engine (can be ignore if camera is set)
  139768. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139769. */
  139770. constructor(name: string, _operator: TonemappingOperator,
  139771. /** Defines the required exposure adjustement */
  139772. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139773. }
  139774. }
  139775. declare module BABYLON {
  139776. /** @hidden */
  139777. export var volumetricLightScatteringPixelShader: {
  139778. name: string;
  139779. shader: string;
  139780. };
  139781. }
  139782. declare module BABYLON {
  139783. /** @hidden */
  139784. export var volumetricLightScatteringPassVertexShader: {
  139785. name: string;
  139786. shader: string;
  139787. };
  139788. }
  139789. declare module BABYLON {
  139790. /** @hidden */
  139791. export var volumetricLightScatteringPassPixelShader: {
  139792. name: string;
  139793. shader: string;
  139794. };
  139795. }
  139796. declare module BABYLON {
  139797. /**
  139798. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139799. */
  139800. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139801. private _volumetricLightScatteringPass;
  139802. private _volumetricLightScatteringRTT;
  139803. private _viewPort;
  139804. private _screenCoordinates;
  139805. private _cachedDefines;
  139806. /**
  139807. * If not undefined, the mesh position is computed from the attached node position
  139808. */
  139809. attachedNode: {
  139810. position: Vector3;
  139811. };
  139812. /**
  139813. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139814. */
  139815. customMeshPosition: Vector3;
  139816. /**
  139817. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139818. */
  139819. useCustomMeshPosition: boolean;
  139820. /**
  139821. * If the post-process should inverse the light scattering direction
  139822. */
  139823. invert: boolean;
  139824. /**
  139825. * The internal mesh used by the post-process
  139826. */
  139827. mesh: Mesh;
  139828. /**
  139829. * @hidden
  139830. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139831. */
  139832. get useDiffuseColor(): boolean;
  139833. set useDiffuseColor(useDiffuseColor: boolean);
  139834. /**
  139835. * Array containing the excluded meshes not rendered in the internal pass
  139836. */
  139837. excludedMeshes: AbstractMesh[];
  139838. /**
  139839. * Controls the overall intensity of the post-process
  139840. */
  139841. exposure: number;
  139842. /**
  139843. * Dissipates each sample's contribution in range [0, 1]
  139844. */
  139845. decay: number;
  139846. /**
  139847. * Controls the overall intensity of each sample
  139848. */
  139849. weight: number;
  139850. /**
  139851. * Controls the density of each sample
  139852. */
  139853. density: number;
  139854. /**
  139855. * @constructor
  139856. * @param name The post-process name
  139857. * @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)
  139858. * @param camera The camera that the post-process will be attached to
  139859. * @param mesh The mesh used to create the light scattering
  139860. * @param samples The post-process quality, default 100
  139861. * @param samplingModeThe post-process filtering mode
  139862. * @param engine The babylon engine
  139863. * @param reusable If the post-process is reusable
  139864. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139865. */
  139866. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139867. /**
  139868. * Returns the string "VolumetricLightScatteringPostProcess"
  139869. * @returns "VolumetricLightScatteringPostProcess"
  139870. */
  139871. getClassName(): string;
  139872. private _isReady;
  139873. /**
  139874. * Sets the new light position for light scattering effect
  139875. * @param position The new custom light position
  139876. */
  139877. setCustomMeshPosition(position: Vector3): void;
  139878. /**
  139879. * Returns the light position for light scattering effect
  139880. * @return Vector3 The custom light position
  139881. */
  139882. getCustomMeshPosition(): Vector3;
  139883. /**
  139884. * Disposes the internal assets and detaches the post-process from the camera
  139885. */
  139886. dispose(camera: Camera): void;
  139887. /**
  139888. * Returns the render target texture used by the post-process
  139889. * @return the render target texture used by the post-process
  139890. */
  139891. getPass(): RenderTargetTexture;
  139892. private _meshExcluded;
  139893. private _createPass;
  139894. private _updateMeshScreenCoordinates;
  139895. /**
  139896. * Creates a default mesh for the Volumeric Light Scattering post-process
  139897. * @param name The mesh name
  139898. * @param scene The scene where to create the mesh
  139899. * @return the default mesh
  139900. */
  139901. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139902. }
  139903. }
  139904. declare module BABYLON {
  139905. interface Scene {
  139906. /** @hidden (Backing field) */
  139907. _boundingBoxRenderer: BoundingBoxRenderer;
  139908. /** @hidden (Backing field) */
  139909. _forceShowBoundingBoxes: boolean;
  139910. /**
  139911. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139912. */
  139913. forceShowBoundingBoxes: boolean;
  139914. /**
  139915. * Gets the bounding box renderer associated with the scene
  139916. * @returns a BoundingBoxRenderer
  139917. */
  139918. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139919. }
  139920. interface AbstractMesh {
  139921. /** @hidden (Backing field) */
  139922. _showBoundingBox: boolean;
  139923. /**
  139924. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139925. */
  139926. showBoundingBox: boolean;
  139927. }
  139928. /**
  139929. * Component responsible of rendering the bounding box of the meshes in a scene.
  139930. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139931. */
  139932. export class BoundingBoxRenderer implements ISceneComponent {
  139933. /**
  139934. * The component name helpfull to identify the component in the list of scene components.
  139935. */
  139936. readonly name: string;
  139937. /**
  139938. * The scene the component belongs to.
  139939. */
  139940. scene: Scene;
  139941. /**
  139942. * Color of the bounding box lines placed in front of an object
  139943. */
  139944. frontColor: Color3;
  139945. /**
  139946. * Color of the bounding box lines placed behind an object
  139947. */
  139948. backColor: Color3;
  139949. /**
  139950. * Defines if the renderer should show the back lines or not
  139951. */
  139952. showBackLines: boolean;
  139953. /**
  139954. * @hidden
  139955. */
  139956. renderList: SmartArray<BoundingBox>;
  139957. private _colorShader;
  139958. private _vertexBuffers;
  139959. private _indexBuffer;
  139960. private _fillIndexBuffer;
  139961. private _fillIndexData;
  139962. /**
  139963. * Instantiates a new bounding box renderer in a scene.
  139964. * @param scene the scene the renderer renders in
  139965. */
  139966. constructor(scene: Scene);
  139967. /**
  139968. * Registers the component in a given scene
  139969. */
  139970. register(): void;
  139971. private _evaluateSubMesh;
  139972. private _activeMesh;
  139973. private _prepareRessources;
  139974. private _createIndexBuffer;
  139975. /**
  139976. * Rebuilds the elements related to this component in case of
  139977. * context lost for instance.
  139978. */
  139979. rebuild(): void;
  139980. /**
  139981. * @hidden
  139982. */
  139983. reset(): void;
  139984. /**
  139985. * Render the bounding boxes of a specific rendering group
  139986. * @param renderingGroupId defines the rendering group to render
  139987. */
  139988. render(renderingGroupId: number): void;
  139989. /**
  139990. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139991. * @param mesh Define the mesh to render the occlusion bounding box for
  139992. */
  139993. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139994. /**
  139995. * Dispose and release the resources attached to this renderer.
  139996. */
  139997. dispose(): void;
  139998. }
  139999. }
  140000. declare module BABYLON {
  140001. interface Scene {
  140002. /** @hidden (Backing field) */
  140003. _depthRenderer: {
  140004. [id: string]: DepthRenderer;
  140005. };
  140006. /**
  140007. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  140008. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  140009. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140010. * @returns the created depth renderer
  140011. */
  140012. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  140013. /**
  140014. * Disables a depth renderer for a given camera
  140015. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  140016. */
  140017. disableDepthRenderer(camera?: Nullable<Camera>): void;
  140018. }
  140019. /**
  140020. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  140021. * in several rendering techniques.
  140022. */
  140023. export class DepthRendererSceneComponent implements ISceneComponent {
  140024. /**
  140025. * The component name helpfull to identify the component in the list of scene components.
  140026. */
  140027. readonly name: string;
  140028. /**
  140029. * The scene the component belongs to.
  140030. */
  140031. scene: Scene;
  140032. /**
  140033. * Creates a new instance of the component for the given scene
  140034. * @param scene Defines the scene to register the component in
  140035. */
  140036. constructor(scene: Scene);
  140037. /**
  140038. * Registers the component in a given scene
  140039. */
  140040. register(): void;
  140041. /**
  140042. * Rebuilds the elements related to this component in case of
  140043. * context lost for instance.
  140044. */
  140045. rebuild(): void;
  140046. /**
  140047. * Disposes the component and the associated ressources
  140048. */
  140049. dispose(): void;
  140050. private _gatherRenderTargets;
  140051. private _gatherActiveCameraRenderTargets;
  140052. }
  140053. }
  140054. declare module BABYLON {
  140055. /** @hidden */
  140056. export var outlinePixelShader: {
  140057. name: string;
  140058. shader: string;
  140059. };
  140060. }
  140061. declare module BABYLON {
  140062. /** @hidden */
  140063. export var outlineVertexShader: {
  140064. name: string;
  140065. shader: string;
  140066. };
  140067. }
  140068. declare module BABYLON {
  140069. interface Scene {
  140070. /** @hidden */
  140071. _outlineRenderer: OutlineRenderer;
  140072. /**
  140073. * Gets the outline renderer associated with the scene
  140074. * @returns a OutlineRenderer
  140075. */
  140076. getOutlineRenderer(): OutlineRenderer;
  140077. }
  140078. interface AbstractMesh {
  140079. /** @hidden (Backing field) */
  140080. _renderOutline: boolean;
  140081. /**
  140082. * Gets or sets a boolean indicating if the outline must be rendered as well
  140083. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  140084. */
  140085. renderOutline: boolean;
  140086. /** @hidden (Backing field) */
  140087. _renderOverlay: boolean;
  140088. /**
  140089. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140090. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140091. */
  140092. renderOverlay: boolean;
  140093. }
  140094. /**
  140095. * This class is responsible to draw bothe outline/overlay of meshes.
  140096. * It should not be used directly but through the available method on mesh.
  140097. */
  140098. export class OutlineRenderer implements ISceneComponent {
  140099. /**
  140100. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140101. */
  140102. private static _StencilReference;
  140103. /**
  140104. * The name of the component. Each component must have a unique name.
  140105. */
  140106. name: string;
  140107. /**
  140108. * The scene the component belongs to.
  140109. */
  140110. scene: Scene;
  140111. /**
  140112. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140113. */
  140114. zOffset: number;
  140115. private _engine;
  140116. private _effect;
  140117. private _cachedDefines;
  140118. private _savedDepthWrite;
  140119. /**
  140120. * Instantiates a new outline renderer. (There could be only one per scene).
  140121. * @param scene Defines the scene it belongs to
  140122. */
  140123. constructor(scene: Scene);
  140124. /**
  140125. * Register the component to one instance of a scene.
  140126. */
  140127. register(): void;
  140128. /**
  140129. * Rebuilds the elements related to this component in case of
  140130. * context lost for instance.
  140131. */
  140132. rebuild(): void;
  140133. /**
  140134. * Disposes the component and the associated ressources.
  140135. */
  140136. dispose(): void;
  140137. /**
  140138. * Renders the outline in the canvas.
  140139. * @param subMesh Defines the sumesh to render
  140140. * @param batch Defines the batch of meshes in case of instances
  140141. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140142. */
  140143. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140144. /**
  140145. * Returns whether or not the outline renderer is ready for a given submesh.
  140146. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140147. * @param subMesh Defines the submesh to check readyness for
  140148. * @param useInstances Defines wheter wee are trying to render instances or not
  140149. * @returns true if ready otherwise false
  140150. */
  140151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140152. private _beforeRenderingMesh;
  140153. private _afterRenderingMesh;
  140154. }
  140155. }
  140156. declare module BABYLON {
  140157. /**
  140158. * Defines the basic options interface of a Sprite Frame Source Size.
  140159. */
  140160. export interface ISpriteJSONSpriteSourceSize {
  140161. /**
  140162. * number of the original width of the Frame
  140163. */
  140164. w: number;
  140165. /**
  140166. * number of the original height of the Frame
  140167. */
  140168. h: number;
  140169. }
  140170. /**
  140171. * Defines the basic options interface of a Sprite Frame Data.
  140172. */
  140173. export interface ISpriteJSONSpriteFrameData {
  140174. /**
  140175. * number of the x offset of the Frame
  140176. */
  140177. x: number;
  140178. /**
  140179. * number of the y offset of the Frame
  140180. */
  140181. y: number;
  140182. /**
  140183. * number of the width of the Frame
  140184. */
  140185. w: number;
  140186. /**
  140187. * number of the height of the Frame
  140188. */
  140189. h: number;
  140190. }
  140191. /**
  140192. * Defines the basic options interface of a JSON Sprite.
  140193. */
  140194. export interface ISpriteJSONSprite {
  140195. /**
  140196. * string name of the Frame
  140197. */
  140198. filename: string;
  140199. /**
  140200. * ISpriteJSONSpriteFrame basic object of the frame data
  140201. */
  140202. frame: ISpriteJSONSpriteFrameData;
  140203. /**
  140204. * boolean to flag is the frame was rotated.
  140205. */
  140206. rotated: boolean;
  140207. /**
  140208. * boolean to flag is the frame was trimmed.
  140209. */
  140210. trimmed: boolean;
  140211. /**
  140212. * ISpriteJSONSpriteFrame basic object of the source data
  140213. */
  140214. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140215. /**
  140216. * ISpriteJSONSpriteFrame basic object of the source data
  140217. */
  140218. sourceSize: ISpriteJSONSpriteSourceSize;
  140219. }
  140220. /**
  140221. * Defines the basic options interface of a JSON atlas.
  140222. */
  140223. export interface ISpriteJSONAtlas {
  140224. /**
  140225. * Array of objects that contain the frame data.
  140226. */
  140227. frames: Array<ISpriteJSONSprite>;
  140228. /**
  140229. * object basic object containing the sprite meta data.
  140230. */
  140231. meta?: object;
  140232. }
  140233. }
  140234. declare module BABYLON {
  140235. /** @hidden */
  140236. export var spriteMapPixelShader: {
  140237. name: string;
  140238. shader: string;
  140239. };
  140240. }
  140241. declare module BABYLON {
  140242. /** @hidden */
  140243. export var spriteMapVertexShader: {
  140244. name: string;
  140245. shader: string;
  140246. };
  140247. }
  140248. declare module BABYLON {
  140249. /**
  140250. * Defines the basic options interface of a SpriteMap
  140251. */
  140252. export interface ISpriteMapOptions {
  140253. /**
  140254. * Vector2 of the number of cells in the grid.
  140255. */
  140256. stageSize?: Vector2;
  140257. /**
  140258. * Vector2 of the size of the output plane in World Units.
  140259. */
  140260. outputSize?: Vector2;
  140261. /**
  140262. * Vector3 of the position of the output plane in World Units.
  140263. */
  140264. outputPosition?: Vector3;
  140265. /**
  140266. * Vector3 of the rotation of the output plane.
  140267. */
  140268. outputRotation?: Vector3;
  140269. /**
  140270. * number of layers that the system will reserve in resources.
  140271. */
  140272. layerCount?: number;
  140273. /**
  140274. * number of max animation frames a single cell will reserve in resources.
  140275. */
  140276. maxAnimationFrames?: number;
  140277. /**
  140278. * number cell index of the base tile when the system compiles.
  140279. */
  140280. baseTile?: number;
  140281. /**
  140282. * boolean flip the sprite after its been repositioned by the framing data.
  140283. */
  140284. flipU?: boolean;
  140285. /**
  140286. * Vector3 scalar of the global RGB values of the SpriteMap.
  140287. */
  140288. colorMultiply?: Vector3;
  140289. }
  140290. /**
  140291. * Defines the IDisposable interface in order to be cleanable from resources.
  140292. */
  140293. export interface ISpriteMap extends IDisposable {
  140294. /**
  140295. * String name of the SpriteMap.
  140296. */
  140297. name: string;
  140298. /**
  140299. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140300. */
  140301. atlasJSON: ISpriteJSONAtlas;
  140302. /**
  140303. * Texture of the SpriteMap.
  140304. */
  140305. spriteSheet: Texture;
  140306. /**
  140307. * The parameters to initialize the SpriteMap with.
  140308. */
  140309. options: ISpriteMapOptions;
  140310. }
  140311. /**
  140312. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140313. */
  140314. export class SpriteMap implements ISpriteMap {
  140315. /** The Name of the spriteMap */
  140316. name: string;
  140317. /** The JSON file with the frame and meta data */
  140318. atlasJSON: ISpriteJSONAtlas;
  140319. /** The systems Sprite Sheet Texture */
  140320. spriteSheet: Texture;
  140321. /** Arguments passed with the Constructor */
  140322. options: ISpriteMapOptions;
  140323. /** Public Sprite Storage array, parsed from atlasJSON */
  140324. sprites: Array<ISpriteJSONSprite>;
  140325. /** Returns the Number of Sprites in the System */
  140326. get spriteCount(): number;
  140327. /** Returns the Position of Output Plane*/
  140328. get position(): Vector3;
  140329. /** Returns the Position of Output Plane*/
  140330. set position(v: Vector3);
  140331. /** Returns the Rotation of Output Plane*/
  140332. get rotation(): Vector3;
  140333. /** Returns the Rotation of Output Plane*/
  140334. set rotation(v: Vector3);
  140335. /** Sets the AnimationMap*/
  140336. get animationMap(): RawTexture;
  140337. /** Sets the AnimationMap*/
  140338. set animationMap(v: RawTexture);
  140339. /** Scene that the SpriteMap was created in */
  140340. private _scene;
  140341. /** Texture Buffer of Float32 that holds tile frame data*/
  140342. private _frameMap;
  140343. /** Texture Buffers of Float32 that holds tileMap data*/
  140344. private _tileMaps;
  140345. /** Texture Buffer of Float32 that holds Animation Data*/
  140346. private _animationMap;
  140347. /** Custom ShaderMaterial Central to the System*/
  140348. private _material;
  140349. /** Custom ShaderMaterial Central to the System*/
  140350. private _output;
  140351. /** Systems Time Ticker*/
  140352. private _time;
  140353. /**
  140354. * Creates a new SpriteMap
  140355. * @param name defines the SpriteMaps Name
  140356. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140357. * @param spriteSheet is the Texture that the Sprites are on.
  140358. * @param options a basic deployment configuration
  140359. * @param scene The Scene that the map is deployed on
  140360. */
  140361. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140362. /**
  140363. * Returns tileID location
  140364. * @returns Vector2 the cell position ID
  140365. */
  140366. getTileID(): Vector2;
  140367. /**
  140368. * Gets the UV location of the mouse over the SpriteMap.
  140369. * @returns Vector2 the UV position of the mouse interaction
  140370. */
  140371. getMousePosition(): Vector2;
  140372. /**
  140373. * Creates the "frame" texture Buffer
  140374. * -------------------------------------
  140375. * Structure of frames
  140376. * "filename": "Falling-Water-2.png",
  140377. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140378. * "rotated": true,
  140379. * "trimmed": true,
  140380. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140381. * "sourceSize": {"w":32,"h":32}
  140382. * @returns RawTexture of the frameMap
  140383. */
  140384. private _createFrameBuffer;
  140385. /**
  140386. * Creates the tileMap texture Buffer
  140387. * @param buffer normally and array of numbers, or a false to generate from scratch
  140388. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140389. * @returns RawTexture of the tileMap
  140390. */
  140391. private _createTileBuffer;
  140392. /**
  140393. * Modifies the data of the tileMaps
  140394. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140395. * @param pos is the iVector2 Coordinates of the Tile
  140396. * @param tile The SpriteIndex of the new Tile
  140397. */
  140398. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140399. /**
  140400. * Creates the animationMap texture Buffer
  140401. * @param buffer normally and array of numbers, or a false to generate from scratch
  140402. * @returns RawTexture of the animationMap
  140403. */
  140404. private _createTileAnimationBuffer;
  140405. /**
  140406. * Modifies the data of the animationMap
  140407. * @param cellID is the Index of the Sprite
  140408. * @param _frame is the target Animation frame
  140409. * @param toCell is the Target Index of the next frame of the animation
  140410. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140411. * @param speed is a global scalar of the time variable on the map.
  140412. */
  140413. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140414. /**
  140415. * Exports the .tilemaps file
  140416. */
  140417. saveTileMaps(): void;
  140418. /**
  140419. * Imports the .tilemaps file
  140420. * @param url of the .tilemaps file
  140421. */
  140422. loadTileMaps(url: string): void;
  140423. /**
  140424. * Release associated resources
  140425. */
  140426. dispose(): void;
  140427. }
  140428. }
  140429. declare module BABYLON {
  140430. /**
  140431. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140432. * @see http://doc.babylonjs.com/babylon101/sprites
  140433. */
  140434. export class SpritePackedManager extends SpriteManager {
  140435. /** defines the packed manager's name */
  140436. name: string;
  140437. /**
  140438. * Creates a new sprite manager from a packed sprite sheet
  140439. * @param name defines the manager's name
  140440. * @param imgUrl defines the sprite sheet url
  140441. * @param capacity defines the maximum allowed number of sprites
  140442. * @param scene defines the hosting scene
  140443. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140444. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140445. * @param samplingMode defines the smapling mode to use with spritesheet
  140446. * @param fromPacked set to true; do not alter
  140447. */
  140448. constructor(
  140449. /** defines the packed manager's name */
  140450. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140451. }
  140452. }
  140453. declare module BABYLON {
  140454. /**
  140455. * Defines the list of states available for a task inside a AssetsManager
  140456. */
  140457. export enum AssetTaskState {
  140458. /**
  140459. * Initialization
  140460. */
  140461. INIT = 0,
  140462. /**
  140463. * Running
  140464. */
  140465. RUNNING = 1,
  140466. /**
  140467. * Done
  140468. */
  140469. DONE = 2,
  140470. /**
  140471. * Error
  140472. */
  140473. ERROR = 3
  140474. }
  140475. /**
  140476. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140477. */
  140478. export abstract class AbstractAssetTask {
  140479. /**
  140480. * Task name
  140481. */ name: string;
  140482. /**
  140483. * Callback called when the task is successful
  140484. */
  140485. onSuccess: (task: any) => void;
  140486. /**
  140487. * Callback called when the task is not successful
  140488. */
  140489. onError: (task: any, message?: string, exception?: any) => void;
  140490. /**
  140491. * Creates a new AssetsManager
  140492. * @param name defines the name of the task
  140493. */
  140494. constructor(
  140495. /**
  140496. * Task name
  140497. */ name: string);
  140498. private _isCompleted;
  140499. private _taskState;
  140500. private _errorObject;
  140501. /**
  140502. * Get if the task is completed
  140503. */
  140504. get isCompleted(): boolean;
  140505. /**
  140506. * Gets the current state of the task
  140507. */
  140508. get taskState(): AssetTaskState;
  140509. /**
  140510. * Gets the current error object (if task is in error)
  140511. */
  140512. get errorObject(): {
  140513. message?: string;
  140514. exception?: any;
  140515. };
  140516. /**
  140517. * Internal only
  140518. * @hidden
  140519. */
  140520. _setErrorObject(message?: string, exception?: any): void;
  140521. /**
  140522. * Execute the current task
  140523. * @param scene defines the scene where you want your assets to be loaded
  140524. * @param onSuccess is a callback called when the task is successfully executed
  140525. * @param onError is a callback called if an error occurs
  140526. */
  140527. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140528. /**
  140529. * Execute the current task
  140530. * @param scene defines the scene where you want your assets to be loaded
  140531. * @param onSuccess is a callback called when the task is successfully executed
  140532. * @param onError is a callback called if an error occurs
  140533. */
  140534. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140535. /**
  140536. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140537. * This can be used with failed tasks that have the reason for failure fixed.
  140538. */
  140539. reset(): void;
  140540. private onErrorCallback;
  140541. private onDoneCallback;
  140542. }
  140543. /**
  140544. * Define the interface used by progress events raised during assets loading
  140545. */
  140546. export interface IAssetsProgressEvent {
  140547. /**
  140548. * Defines the number of remaining tasks to process
  140549. */
  140550. remainingCount: number;
  140551. /**
  140552. * Defines the total number of tasks
  140553. */
  140554. totalCount: number;
  140555. /**
  140556. * Defines the task that was just processed
  140557. */
  140558. task: AbstractAssetTask;
  140559. }
  140560. /**
  140561. * Class used to share progress information about assets loading
  140562. */
  140563. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140564. /**
  140565. * Defines the number of remaining tasks to process
  140566. */
  140567. remainingCount: number;
  140568. /**
  140569. * Defines the total number of tasks
  140570. */
  140571. totalCount: number;
  140572. /**
  140573. * Defines the task that was just processed
  140574. */
  140575. task: AbstractAssetTask;
  140576. /**
  140577. * Creates a AssetsProgressEvent
  140578. * @param remainingCount defines the number of remaining tasks to process
  140579. * @param totalCount defines the total number of tasks
  140580. * @param task defines the task that was just processed
  140581. */
  140582. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140583. }
  140584. /**
  140585. * Define a task used by AssetsManager to load meshes
  140586. */
  140587. export class MeshAssetTask extends AbstractAssetTask {
  140588. /**
  140589. * Defines the name of the task
  140590. */
  140591. name: string;
  140592. /**
  140593. * Defines the list of mesh's names you want to load
  140594. */
  140595. meshesNames: any;
  140596. /**
  140597. * Defines the root url to use as a base to load your meshes and associated resources
  140598. */
  140599. rootUrl: string;
  140600. /**
  140601. * Defines the filename of the scene to load from
  140602. */
  140603. sceneFilename: string;
  140604. /**
  140605. * Gets the list of loaded meshes
  140606. */
  140607. loadedMeshes: Array<AbstractMesh>;
  140608. /**
  140609. * Gets the list of loaded particle systems
  140610. */
  140611. loadedParticleSystems: Array<IParticleSystem>;
  140612. /**
  140613. * Gets the list of loaded skeletons
  140614. */
  140615. loadedSkeletons: Array<Skeleton>;
  140616. /**
  140617. * Gets the list of loaded animation groups
  140618. */
  140619. loadedAnimationGroups: Array<AnimationGroup>;
  140620. /**
  140621. * Callback called when the task is successful
  140622. */
  140623. onSuccess: (task: MeshAssetTask) => void;
  140624. /**
  140625. * Callback called when the task is successful
  140626. */
  140627. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140628. /**
  140629. * Creates a new MeshAssetTask
  140630. * @param name defines the name of the task
  140631. * @param meshesNames defines the list of mesh's names you want to load
  140632. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140633. * @param sceneFilename defines the filename of the scene to load from
  140634. */
  140635. constructor(
  140636. /**
  140637. * Defines the name of the task
  140638. */
  140639. name: string,
  140640. /**
  140641. * Defines the list of mesh's names you want to load
  140642. */
  140643. meshesNames: any,
  140644. /**
  140645. * Defines the root url to use as a base to load your meshes and associated resources
  140646. */
  140647. rootUrl: string,
  140648. /**
  140649. * Defines the filename of the scene to load from
  140650. */
  140651. sceneFilename: string);
  140652. /**
  140653. * Execute the current task
  140654. * @param scene defines the scene where you want your assets to be loaded
  140655. * @param onSuccess is a callback called when the task is successfully executed
  140656. * @param onError is a callback called if an error occurs
  140657. */
  140658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140659. }
  140660. /**
  140661. * Define a task used by AssetsManager to load text content
  140662. */
  140663. export class TextFileAssetTask extends AbstractAssetTask {
  140664. /**
  140665. * Defines the name of the task
  140666. */
  140667. name: string;
  140668. /**
  140669. * Defines the location of the file to load
  140670. */
  140671. url: string;
  140672. /**
  140673. * Gets the loaded text string
  140674. */
  140675. text: string;
  140676. /**
  140677. * Callback called when the task is successful
  140678. */
  140679. onSuccess: (task: TextFileAssetTask) => void;
  140680. /**
  140681. * Callback called when the task is successful
  140682. */
  140683. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140684. /**
  140685. * Creates a new TextFileAssetTask object
  140686. * @param name defines the name of the task
  140687. * @param url defines the location of the file to load
  140688. */
  140689. constructor(
  140690. /**
  140691. * Defines the name of the task
  140692. */
  140693. name: string,
  140694. /**
  140695. * Defines the location of the file to load
  140696. */
  140697. url: string);
  140698. /**
  140699. * Execute the current task
  140700. * @param scene defines the scene where you want your assets to be loaded
  140701. * @param onSuccess is a callback called when the task is successfully executed
  140702. * @param onError is a callback called if an error occurs
  140703. */
  140704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140705. }
  140706. /**
  140707. * Define a task used by AssetsManager to load binary data
  140708. */
  140709. export class BinaryFileAssetTask extends AbstractAssetTask {
  140710. /**
  140711. * Defines the name of the task
  140712. */
  140713. name: string;
  140714. /**
  140715. * Defines the location of the file to load
  140716. */
  140717. url: string;
  140718. /**
  140719. * Gets the lodaded data (as an array buffer)
  140720. */
  140721. data: ArrayBuffer;
  140722. /**
  140723. * Callback called when the task is successful
  140724. */
  140725. onSuccess: (task: BinaryFileAssetTask) => void;
  140726. /**
  140727. * Callback called when the task is successful
  140728. */
  140729. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140730. /**
  140731. * Creates a new BinaryFileAssetTask object
  140732. * @param name defines the name of the new task
  140733. * @param url defines the location of the file to load
  140734. */
  140735. constructor(
  140736. /**
  140737. * Defines the name of the task
  140738. */
  140739. name: string,
  140740. /**
  140741. * Defines the location of the file to load
  140742. */
  140743. url: string);
  140744. /**
  140745. * Execute the current task
  140746. * @param scene defines the scene where you want your assets to be loaded
  140747. * @param onSuccess is a callback called when the task is successfully executed
  140748. * @param onError is a callback called if an error occurs
  140749. */
  140750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140751. }
  140752. /**
  140753. * Define a task used by AssetsManager to load images
  140754. */
  140755. export class ImageAssetTask extends AbstractAssetTask {
  140756. /**
  140757. * Defines the name of the task
  140758. */
  140759. name: string;
  140760. /**
  140761. * Defines the location of the image to load
  140762. */
  140763. url: string;
  140764. /**
  140765. * Gets the loaded images
  140766. */
  140767. image: HTMLImageElement;
  140768. /**
  140769. * Callback called when the task is successful
  140770. */
  140771. onSuccess: (task: ImageAssetTask) => void;
  140772. /**
  140773. * Callback called when the task is successful
  140774. */
  140775. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140776. /**
  140777. * Creates a new ImageAssetTask
  140778. * @param name defines the name of the task
  140779. * @param url defines the location of the image to load
  140780. */
  140781. constructor(
  140782. /**
  140783. * Defines the name of the task
  140784. */
  140785. name: string,
  140786. /**
  140787. * Defines the location of the image to load
  140788. */
  140789. url: string);
  140790. /**
  140791. * Execute the current task
  140792. * @param scene defines the scene where you want your assets to be loaded
  140793. * @param onSuccess is a callback called when the task is successfully executed
  140794. * @param onError is a callback called if an error occurs
  140795. */
  140796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140797. }
  140798. /**
  140799. * Defines the interface used by texture loading tasks
  140800. */
  140801. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140802. /**
  140803. * Gets the loaded texture
  140804. */
  140805. texture: TEX;
  140806. }
  140807. /**
  140808. * Define a task used by AssetsManager to load 2D textures
  140809. */
  140810. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140811. /**
  140812. * Defines the name of the task
  140813. */
  140814. name: string;
  140815. /**
  140816. * Defines the location of the file to load
  140817. */
  140818. url: string;
  140819. /**
  140820. * Defines if mipmap should not be generated (default is false)
  140821. */
  140822. noMipmap?: boolean | undefined;
  140823. /**
  140824. * Defines if texture must be inverted on Y axis (default is false)
  140825. */
  140826. invertY?: boolean | undefined;
  140827. /**
  140828. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140829. */
  140830. samplingMode: number;
  140831. /**
  140832. * Gets the loaded texture
  140833. */
  140834. texture: Texture;
  140835. /**
  140836. * Callback called when the task is successful
  140837. */
  140838. onSuccess: (task: TextureAssetTask) => void;
  140839. /**
  140840. * Callback called when the task is successful
  140841. */
  140842. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140843. /**
  140844. * Creates a new TextureAssetTask object
  140845. * @param name defines the name of the task
  140846. * @param url defines the location of the file to load
  140847. * @param noMipmap defines if mipmap should not be generated (default is false)
  140848. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140849. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140850. */
  140851. constructor(
  140852. /**
  140853. * Defines the name of the task
  140854. */
  140855. name: string,
  140856. /**
  140857. * Defines the location of the file to load
  140858. */
  140859. url: string,
  140860. /**
  140861. * Defines if mipmap should not be generated (default is false)
  140862. */
  140863. noMipmap?: boolean | undefined,
  140864. /**
  140865. * Defines if texture must be inverted on Y axis (default is false)
  140866. */
  140867. invertY?: boolean | undefined,
  140868. /**
  140869. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140870. */
  140871. samplingMode?: number);
  140872. /**
  140873. * Execute the current task
  140874. * @param scene defines the scene where you want your assets to be loaded
  140875. * @param onSuccess is a callback called when the task is successfully executed
  140876. * @param onError is a callback called if an error occurs
  140877. */
  140878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140879. }
  140880. /**
  140881. * Define a task used by AssetsManager to load cube textures
  140882. */
  140883. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140884. /**
  140885. * Defines the name of the task
  140886. */
  140887. name: string;
  140888. /**
  140889. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140890. */
  140891. url: string;
  140892. /**
  140893. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140894. */
  140895. extensions?: string[] | undefined;
  140896. /**
  140897. * Defines if mipmaps should not be generated (default is false)
  140898. */
  140899. noMipmap?: boolean | undefined;
  140900. /**
  140901. * Defines the explicit list of files (undefined by default)
  140902. */
  140903. files?: string[] | undefined;
  140904. /**
  140905. * Gets the loaded texture
  140906. */
  140907. texture: CubeTexture;
  140908. /**
  140909. * Callback called when the task is successful
  140910. */
  140911. onSuccess: (task: CubeTextureAssetTask) => void;
  140912. /**
  140913. * Callback called when the task is successful
  140914. */
  140915. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140916. /**
  140917. * Creates a new CubeTextureAssetTask
  140918. * @param name defines the name of the task
  140919. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140920. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140921. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140922. * @param files defines the explicit list of files (undefined by default)
  140923. */
  140924. constructor(
  140925. /**
  140926. * Defines the name of the task
  140927. */
  140928. name: string,
  140929. /**
  140930. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140931. */
  140932. url: string,
  140933. /**
  140934. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140935. */
  140936. extensions?: string[] | undefined,
  140937. /**
  140938. * Defines if mipmaps should not be generated (default is false)
  140939. */
  140940. noMipmap?: boolean | undefined,
  140941. /**
  140942. * Defines the explicit list of files (undefined by default)
  140943. */
  140944. files?: string[] | undefined);
  140945. /**
  140946. * Execute the current task
  140947. * @param scene defines the scene where you want your assets to be loaded
  140948. * @param onSuccess is a callback called when the task is successfully executed
  140949. * @param onError is a callback called if an error occurs
  140950. */
  140951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140952. }
  140953. /**
  140954. * Define a task used by AssetsManager to load HDR cube textures
  140955. */
  140956. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140957. /**
  140958. * Defines the name of the task
  140959. */
  140960. name: string;
  140961. /**
  140962. * Defines the location of the file to load
  140963. */
  140964. url: string;
  140965. /**
  140966. * Defines the desired size (the more it increases the longer the generation will be)
  140967. */
  140968. size: number;
  140969. /**
  140970. * Defines if mipmaps should not be generated (default is false)
  140971. */
  140972. noMipmap: boolean;
  140973. /**
  140974. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140975. */
  140976. generateHarmonics: boolean;
  140977. /**
  140978. * 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)
  140979. */
  140980. gammaSpace: boolean;
  140981. /**
  140982. * Internal Use Only
  140983. */
  140984. reserved: boolean;
  140985. /**
  140986. * Gets the loaded texture
  140987. */
  140988. texture: HDRCubeTexture;
  140989. /**
  140990. * Callback called when the task is successful
  140991. */
  140992. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140993. /**
  140994. * Callback called when the task is successful
  140995. */
  140996. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140997. /**
  140998. * Creates a new HDRCubeTextureAssetTask object
  140999. * @param name defines the name of the task
  141000. * @param url defines the location of the file to load
  141001. * @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.
  141002. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141003. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141004. * @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)
  141005. * @param reserved Internal use only
  141006. */
  141007. constructor(
  141008. /**
  141009. * Defines the name of the task
  141010. */
  141011. name: string,
  141012. /**
  141013. * Defines the location of the file to load
  141014. */
  141015. url: string,
  141016. /**
  141017. * Defines the desired size (the more it increases the longer the generation will be)
  141018. */
  141019. size: number,
  141020. /**
  141021. * Defines if mipmaps should not be generated (default is false)
  141022. */
  141023. noMipmap?: boolean,
  141024. /**
  141025. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141026. */
  141027. generateHarmonics?: boolean,
  141028. /**
  141029. * 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)
  141030. */
  141031. gammaSpace?: boolean,
  141032. /**
  141033. * Internal Use Only
  141034. */
  141035. reserved?: boolean);
  141036. /**
  141037. * Execute the current task
  141038. * @param scene defines the scene where you want your assets to be loaded
  141039. * @param onSuccess is a callback called when the task is successfully executed
  141040. * @param onError is a callback called if an error occurs
  141041. */
  141042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141043. }
  141044. /**
  141045. * Define a task used by AssetsManager to load Equirectangular cube textures
  141046. */
  141047. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  141048. /**
  141049. * Defines the name of the task
  141050. */
  141051. name: string;
  141052. /**
  141053. * Defines the location of the file to load
  141054. */
  141055. url: string;
  141056. /**
  141057. * Defines the desired size (the more it increases the longer the generation will be)
  141058. */
  141059. size: number;
  141060. /**
  141061. * Defines if mipmaps should not be generated (default is false)
  141062. */
  141063. noMipmap: boolean;
  141064. /**
  141065. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141066. * but the standard material would require them in Gamma space) (default is true)
  141067. */
  141068. gammaSpace: boolean;
  141069. /**
  141070. * Gets the loaded texture
  141071. */
  141072. texture: EquiRectangularCubeTexture;
  141073. /**
  141074. * Callback called when the task is successful
  141075. */
  141076. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  141077. /**
  141078. * Callback called when the task is successful
  141079. */
  141080. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  141081. /**
  141082. * Creates a new EquiRectangularCubeTextureAssetTask object
  141083. * @param name defines the name of the task
  141084. * @param url defines the location of the file to load
  141085. * @param size defines the desired size (the more it increases the longer the generation will be)
  141086. * If the size is omitted this implies you are using a preprocessed cubemap.
  141087. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141088. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141089. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141090. * (default is true)
  141091. */
  141092. constructor(
  141093. /**
  141094. * Defines the name of the task
  141095. */
  141096. name: string,
  141097. /**
  141098. * Defines the location of the file to load
  141099. */
  141100. url: string,
  141101. /**
  141102. * Defines the desired size (the more it increases the longer the generation will be)
  141103. */
  141104. size: number,
  141105. /**
  141106. * Defines if mipmaps should not be generated (default is false)
  141107. */
  141108. noMipmap?: boolean,
  141109. /**
  141110. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141111. * but the standard material would require them in Gamma space) (default is true)
  141112. */
  141113. gammaSpace?: boolean);
  141114. /**
  141115. * Execute the current task
  141116. * @param scene defines the scene where you want your assets to be loaded
  141117. * @param onSuccess is a callback called when the task is successfully executed
  141118. * @param onError is a callback called if an error occurs
  141119. */
  141120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141121. }
  141122. /**
  141123. * This class can be used to easily import assets into a scene
  141124. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141125. */
  141126. export class AssetsManager {
  141127. private _scene;
  141128. private _isLoading;
  141129. protected _tasks: AbstractAssetTask[];
  141130. protected _waitingTasksCount: number;
  141131. protected _totalTasksCount: number;
  141132. /**
  141133. * Callback called when all tasks are processed
  141134. */
  141135. onFinish: (tasks: AbstractAssetTask[]) => void;
  141136. /**
  141137. * Callback called when a task is successful
  141138. */
  141139. onTaskSuccess: (task: AbstractAssetTask) => void;
  141140. /**
  141141. * Callback called when a task had an error
  141142. */
  141143. onTaskError: (task: AbstractAssetTask) => void;
  141144. /**
  141145. * Callback called when a task is done (whatever the result is)
  141146. */
  141147. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141148. /**
  141149. * Observable called when all tasks are processed
  141150. */
  141151. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141152. /**
  141153. * Observable called when a task had an error
  141154. */
  141155. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141156. /**
  141157. * Observable called when all tasks were executed
  141158. */
  141159. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141160. /**
  141161. * Observable called when a task is done (whatever the result is)
  141162. */
  141163. onProgressObservable: Observable<IAssetsProgressEvent>;
  141164. /**
  141165. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141166. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141167. */
  141168. useDefaultLoadingScreen: boolean;
  141169. /**
  141170. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141171. * when all assets have been downloaded.
  141172. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141173. */
  141174. autoHideLoadingUI: boolean;
  141175. /**
  141176. * Creates a new AssetsManager
  141177. * @param scene defines the scene to work on
  141178. */
  141179. constructor(scene: Scene);
  141180. /**
  141181. * Add a MeshAssetTask to the list of active tasks
  141182. * @param taskName defines the name of the new task
  141183. * @param meshesNames defines the name of meshes to load
  141184. * @param rootUrl defines the root url to use to locate files
  141185. * @param sceneFilename defines the filename of the scene file
  141186. * @returns a new MeshAssetTask object
  141187. */
  141188. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141189. /**
  141190. * Add a TextFileAssetTask to the list of active tasks
  141191. * @param taskName defines the name of the new task
  141192. * @param url defines the url of the file to load
  141193. * @returns a new TextFileAssetTask object
  141194. */
  141195. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141196. /**
  141197. * Add a BinaryFileAssetTask to the list of active tasks
  141198. * @param taskName defines the name of the new task
  141199. * @param url defines the url of the file to load
  141200. * @returns a new BinaryFileAssetTask object
  141201. */
  141202. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141203. /**
  141204. * Add a ImageAssetTask to the list of active tasks
  141205. * @param taskName defines the name of the new task
  141206. * @param url defines the url of the file to load
  141207. * @returns a new ImageAssetTask object
  141208. */
  141209. addImageTask(taskName: string, url: string): ImageAssetTask;
  141210. /**
  141211. * Add a TextureAssetTask to the list of active tasks
  141212. * @param taskName defines the name of the new task
  141213. * @param url defines the url of the file to load
  141214. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141215. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141216. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141217. * @returns a new TextureAssetTask object
  141218. */
  141219. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141220. /**
  141221. * Add a CubeTextureAssetTask to the list of active tasks
  141222. * @param taskName defines the name of the new task
  141223. * @param url defines the url of the file to load
  141224. * @param extensions defines the extension to use to load the cube map (can be null)
  141225. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141226. * @param files defines the list of files to load (can be null)
  141227. * @returns a new CubeTextureAssetTask object
  141228. */
  141229. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141230. /**
  141231. *
  141232. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141233. * @param taskName defines the name of the new task
  141234. * @param url defines the url of the file to load
  141235. * @param size defines the size you want for the cubemap (can be null)
  141236. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141237. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141238. * @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)
  141239. * @param reserved Internal use only
  141240. * @returns a new HDRCubeTextureAssetTask object
  141241. */
  141242. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141243. /**
  141244. *
  141245. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141246. * @param taskName defines the name of the new task
  141247. * @param url defines the url of the file to load
  141248. * @param size defines the size you want for the cubemap (can be null)
  141249. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141250. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141251. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141252. * @returns a new EquiRectangularCubeTextureAssetTask object
  141253. */
  141254. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141255. /**
  141256. * Remove a task from the assets manager.
  141257. * @param task the task to remove
  141258. */
  141259. removeTask(task: AbstractAssetTask): void;
  141260. private _decreaseWaitingTasksCount;
  141261. private _runTask;
  141262. /**
  141263. * Reset the AssetsManager and remove all tasks
  141264. * @return the current instance of the AssetsManager
  141265. */
  141266. reset(): AssetsManager;
  141267. /**
  141268. * Start the loading process
  141269. * @return the current instance of the AssetsManager
  141270. */
  141271. load(): AssetsManager;
  141272. /**
  141273. * Start the loading process as an async operation
  141274. * @return a promise returning the list of failed tasks
  141275. */
  141276. loadAsync(): Promise<void>;
  141277. }
  141278. }
  141279. declare module BABYLON {
  141280. /**
  141281. * Wrapper class for promise with external resolve and reject.
  141282. */
  141283. export class Deferred<T> {
  141284. /**
  141285. * The promise associated with this deferred object.
  141286. */
  141287. readonly promise: Promise<T>;
  141288. private _resolve;
  141289. private _reject;
  141290. /**
  141291. * The resolve method of the promise associated with this deferred object.
  141292. */
  141293. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141294. /**
  141295. * The reject method of the promise associated with this deferred object.
  141296. */
  141297. get reject(): (reason?: any) => void;
  141298. /**
  141299. * Constructor for this deferred object.
  141300. */
  141301. constructor();
  141302. }
  141303. }
  141304. declare module BABYLON {
  141305. /**
  141306. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141307. */
  141308. export class MeshExploder {
  141309. private _centerMesh;
  141310. private _meshes;
  141311. private _meshesOrigins;
  141312. private _toCenterVectors;
  141313. private _scaledDirection;
  141314. private _newPosition;
  141315. private _centerPosition;
  141316. /**
  141317. * Explodes meshes from a center mesh.
  141318. * @param meshes The meshes to explode.
  141319. * @param centerMesh The mesh to be center of explosion.
  141320. */
  141321. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141322. private _setCenterMesh;
  141323. /**
  141324. * Get class name
  141325. * @returns "MeshExploder"
  141326. */
  141327. getClassName(): string;
  141328. /**
  141329. * "Exploded meshes"
  141330. * @returns Array of meshes with the centerMesh at index 0.
  141331. */
  141332. getMeshes(): Array<Mesh>;
  141333. /**
  141334. * Explodes meshes giving a specific direction
  141335. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141336. */
  141337. explode(direction?: number): void;
  141338. }
  141339. }
  141340. declare module BABYLON {
  141341. /**
  141342. * Class used to help managing file picking and drag'n'drop
  141343. */
  141344. export class FilesInput {
  141345. /**
  141346. * List of files ready to be loaded
  141347. */
  141348. static get FilesToLoad(): {
  141349. [key: string]: File;
  141350. };
  141351. /**
  141352. * Callback called when a file is processed
  141353. */
  141354. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141355. private _engine;
  141356. private _currentScene;
  141357. private _sceneLoadedCallback;
  141358. private _progressCallback;
  141359. private _additionalRenderLoopLogicCallback;
  141360. private _textureLoadingCallback;
  141361. private _startingProcessingFilesCallback;
  141362. private _onReloadCallback;
  141363. private _errorCallback;
  141364. private _elementToMonitor;
  141365. private _sceneFileToLoad;
  141366. private _filesToLoad;
  141367. /**
  141368. * Creates a new FilesInput
  141369. * @param engine defines the rendering engine
  141370. * @param scene defines the hosting scene
  141371. * @param sceneLoadedCallback callback called when scene is loaded
  141372. * @param progressCallback callback called to track progress
  141373. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141374. * @param textureLoadingCallback callback called when a texture is loading
  141375. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141376. * @param onReloadCallback callback called when a reload is requested
  141377. * @param errorCallback callback call if an error occurs
  141378. */
  141379. 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);
  141380. private _dragEnterHandler;
  141381. private _dragOverHandler;
  141382. private _dropHandler;
  141383. /**
  141384. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141385. * @param elementToMonitor defines the DOM element to track
  141386. */
  141387. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141388. /**
  141389. * Release all associated resources
  141390. */
  141391. dispose(): void;
  141392. private renderFunction;
  141393. private drag;
  141394. private drop;
  141395. private _traverseFolder;
  141396. private _processFiles;
  141397. /**
  141398. * Load files from a drop event
  141399. * @param event defines the drop event to use as source
  141400. */
  141401. loadFiles(event: any): void;
  141402. private _processReload;
  141403. /**
  141404. * Reload the current scene from the loaded files
  141405. */
  141406. reload(): void;
  141407. }
  141408. }
  141409. declare module BABYLON {
  141410. /**
  141411. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141412. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141413. */
  141414. export class SceneOptimization {
  141415. /**
  141416. * Defines the priority of this optimization (0 by default which means first in the list)
  141417. */
  141418. priority: number;
  141419. /**
  141420. * Gets a string describing the action executed by the current optimization
  141421. * @returns description string
  141422. */
  141423. getDescription(): string;
  141424. /**
  141425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141426. * @param scene defines the current scene where to apply this optimization
  141427. * @param optimizer defines the current optimizer
  141428. * @returns true if everything that can be done was applied
  141429. */
  141430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141431. /**
  141432. * Creates the SceneOptimization object
  141433. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141434. * @param desc defines the description associated with the optimization
  141435. */
  141436. constructor(
  141437. /**
  141438. * Defines the priority of this optimization (0 by default which means first in the list)
  141439. */
  141440. priority?: number);
  141441. }
  141442. /**
  141443. * Defines an optimization used to reduce the size of render target textures
  141444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141445. */
  141446. export class TextureOptimization extends SceneOptimization {
  141447. /**
  141448. * Defines the priority of this optimization (0 by default which means first in the list)
  141449. */
  141450. priority: number;
  141451. /**
  141452. * 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
  141453. */
  141454. maximumSize: number;
  141455. /**
  141456. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141457. */
  141458. step: number;
  141459. /**
  141460. * Gets a string describing the action executed by the current optimization
  141461. * @returns description string
  141462. */
  141463. getDescription(): string;
  141464. /**
  141465. * Creates the TextureOptimization object
  141466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141467. * @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
  141468. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141469. */
  141470. constructor(
  141471. /**
  141472. * Defines the priority of this optimization (0 by default which means first in the list)
  141473. */
  141474. priority?: number,
  141475. /**
  141476. * 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
  141477. */
  141478. maximumSize?: number,
  141479. /**
  141480. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141481. */
  141482. step?: number);
  141483. /**
  141484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141485. * @param scene defines the current scene where to apply this optimization
  141486. * @param optimizer defines the current optimizer
  141487. * @returns true if everything that can be done was applied
  141488. */
  141489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141490. }
  141491. /**
  141492. * Defines an optimization used to increase or decrease the rendering resolution
  141493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141494. */
  141495. export class HardwareScalingOptimization extends SceneOptimization {
  141496. /**
  141497. * Defines the priority of this optimization (0 by default which means first in the list)
  141498. */
  141499. priority: number;
  141500. /**
  141501. * Defines the maximum scale to use (2 by default)
  141502. */
  141503. maximumScale: number;
  141504. /**
  141505. * Defines the step to use between two passes (0.5 by default)
  141506. */
  141507. step: number;
  141508. private _currentScale;
  141509. private _directionOffset;
  141510. /**
  141511. * Gets a string describing the action executed by the current optimization
  141512. * @return description string
  141513. */
  141514. getDescription(): string;
  141515. /**
  141516. * Creates the HardwareScalingOptimization object
  141517. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141518. * @param maximumScale defines the maximum scale to use (2 by default)
  141519. * @param step defines the step to use between two passes (0.5 by default)
  141520. */
  141521. constructor(
  141522. /**
  141523. * Defines the priority of this optimization (0 by default which means first in the list)
  141524. */
  141525. priority?: number,
  141526. /**
  141527. * Defines the maximum scale to use (2 by default)
  141528. */
  141529. maximumScale?: number,
  141530. /**
  141531. * Defines the step to use between two passes (0.5 by default)
  141532. */
  141533. step?: number);
  141534. /**
  141535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141536. * @param scene defines the current scene where to apply this optimization
  141537. * @param optimizer defines the current optimizer
  141538. * @returns true if everything that can be done was applied
  141539. */
  141540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141541. }
  141542. /**
  141543. * Defines an optimization used to remove shadows
  141544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141545. */
  141546. export class ShadowsOptimization extends SceneOptimization {
  141547. /**
  141548. * Gets a string describing the action executed by the current optimization
  141549. * @return description string
  141550. */
  141551. getDescription(): string;
  141552. /**
  141553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141554. * @param scene defines the current scene where to apply this optimization
  141555. * @param optimizer defines the current optimizer
  141556. * @returns true if everything that can be done was applied
  141557. */
  141558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141559. }
  141560. /**
  141561. * Defines an optimization used to turn post-processes off
  141562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141563. */
  141564. export class PostProcessesOptimization extends SceneOptimization {
  141565. /**
  141566. * Gets a string describing the action executed by the current optimization
  141567. * @return description string
  141568. */
  141569. getDescription(): string;
  141570. /**
  141571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141572. * @param scene defines the current scene where to apply this optimization
  141573. * @param optimizer defines the current optimizer
  141574. * @returns true if everything that can be done was applied
  141575. */
  141576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141577. }
  141578. /**
  141579. * Defines an optimization used to turn lens flares off
  141580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141581. */
  141582. export class LensFlaresOptimization extends SceneOptimization {
  141583. /**
  141584. * Gets a string describing the action executed by the current optimization
  141585. * @return description string
  141586. */
  141587. getDescription(): string;
  141588. /**
  141589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141590. * @param scene defines the current scene where to apply this optimization
  141591. * @param optimizer defines the current optimizer
  141592. * @returns true if everything that can be done was applied
  141593. */
  141594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141595. }
  141596. /**
  141597. * Defines an optimization based on user defined callback.
  141598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141599. */
  141600. export class CustomOptimization extends SceneOptimization {
  141601. /**
  141602. * Callback called to apply the custom optimization.
  141603. */
  141604. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141605. /**
  141606. * Callback called to get custom description
  141607. */
  141608. onGetDescription: () => string;
  141609. /**
  141610. * Gets a string describing the action executed by the current optimization
  141611. * @returns description string
  141612. */
  141613. getDescription(): string;
  141614. /**
  141615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141616. * @param scene defines the current scene where to apply this optimization
  141617. * @param optimizer defines the current optimizer
  141618. * @returns true if everything that can be done was applied
  141619. */
  141620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141621. }
  141622. /**
  141623. * Defines an optimization used to turn particles off
  141624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141625. */
  141626. export class ParticlesOptimization extends SceneOptimization {
  141627. /**
  141628. * Gets a string describing the action executed by the current optimization
  141629. * @return description string
  141630. */
  141631. getDescription(): string;
  141632. /**
  141633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141634. * @param scene defines the current scene where to apply this optimization
  141635. * @param optimizer defines the current optimizer
  141636. * @returns true if everything that can be done was applied
  141637. */
  141638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141639. }
  141640. /**
  141641. * Defines an optimization used to turn render targets off
  141642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141643. */
  141644. export class RenderTargetsOptimization extends SceneOptimization {
  141645. /**
  141646. * Gets a string describing the action executed by the current optimization
  141647. * @return description string
  141648. */
  141649. getDescription(): string;
  141650. /**
  141651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141652. * @param scene defines the current scene where to apply this optimization
  141653. * @param optimizer defines the current optimizer
  141654. * @returns true if everything that can be done was applied
  141655. */
  141656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141657. }
  141658. /**
  141659. * Defines an optimization used to merge meshes with compatible materials
  141660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141661. */
  141662. export class MergeMeshesOptimization extends SceneOptimization {
  141663. private static _UpdateSelectionTree;
  141664. /**
  141665. * Gets or sets a boolean which defines if optimization octree has to be updated
  141666. */
  141667. static get UpdateSelectionTree(): boolean;
  141668. /**
  141669. * Gets or sets a boolean which defines if optimization octree has to be updated
  141670. */
  141671. static set UpdateSelectionTree(value: boolean);
  141672. /**
  141673. * Gets a string describing the action executed by the current optimization
  141674. * @return description string
  141675. */
  141676. getDescription(): string;
  141677. private _canBeMerged;
  141678. /**
  141679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141680. * @param scene defines the current scene where to apply this optimization
  141681. * @param optimizer defines the current optimizer
  141682. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141683. * @returns true if everything that can be done was applied
  141684. */
  141685. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141686. }
  141687. /**
  141688. * Defines a list of options used by SceneOptimizer
  141689. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141690. */
  141691. export class SceneOptimizerOptions {
  141692. /**
  141693. * Defines the target frame rate to reach (60 by default)
  141694. */
  141695. targetFrameRate: number;
  141696. /**
  141697. * Defines the interval between two checkes (2000ms by default)
  141698. */
  141699. trackerDuration: number;
  141700. /**
  141701. * Gets the list of optimizations to apply
  141702. */
  141703. optimizations: SceneOptimization[];
  141704. /**
  141705. * Creates a new list of options used by SceneOptimizer
  141706. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141707. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141708. */
  141709. constructor(
  141710. /**
  141711. * Defines the target frame rate to reach (60 by default)
  141712. */
  141713. targetFrameRate?: number,
  141714. /**
  141715. * Defines the interval between two checkes (2000ms by default)
  141716. */
  141717. trackerDuration?: number);
  141718. /**
  141719. * Add a new optimization
  141720. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141721. * @returns the current SceneOptimizerOptions
  141722. */
  141723. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141724. /**
  141725. * Add a new custom optimization
  141726. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141727. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141728. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141729. * @returns the current SceneOptimizerOptions
  141730. */
  141731. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141732. /**
  141733. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141734. * @param targetFrameRate defines the target frame rate (60 by default)
  141735. * @returns a SceneOptimizerOptions object
  141736. */
  141737. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141738. /**
  141739. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141740. * @param targetFrameRate defines the target frame rate (60 by default)
  141741. * @returns a SceneOptimizerOptions object
  141742. */
  141743. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141744. /**
  141745. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141746. * @param targetFrameRate defines the target frame rate (60 by default)
  141747. * @returns a SceneOptimizerOptions object
  141748. */
  141749. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141750. }
  141751. /**
  141752. * Class used to run optimizations in order to reach a target frame rate
  141753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141754. */
  141755. export class SceneOptimizer implements IDisposable {
  141756. private _isRunning;
  141757. private _options;
  141758. private _scene;
  141759. private _currentPriorityLevel;
  141760. private _targetFrameRate;
  141761. private _trackerDuration;
  141762. private _currentFrameRate;
  141763. private _sceneDisposeObserver;
  141764. private _improvementMode;
  141765. /**
  141766. * Defines an observable called when the optimizer reaches the target frame rate
  141767. */
  141768. onSuccessObservable: Observable<SceneOptimizer>;
  141769. /**
  141770. * Defines an observable called when the optimizer enables an optimization
  141771. */
  141772. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141773. /**
  141774. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141775. */
  141776. onFailureObservable: Observable<SceneOptimizer>;
  141777. /**
  141778. * Gets a boolean indicating if the optimizer is in improvement mode
  141779. */
  141780. get isInImprovementMode(): boolean;
  141781. /**
  141782. * Gets the current priority level (0 at start)
  141783. */
  141784. get currentPriorityLevel(): number;
  141785. /**
  141786. * Gets the current frame rate checked by the SceneOptimizer
  141787. */
  141788. get currentFrameRate(): number;
  141789. /**
  141790. * Gets or sets the current target frame rate (60 by default)
  141791. */
  141792. get targetFrameRate(): number;
  141793. /**
  141794. * Gets or sets the current target frame rate (60 by default)
  141795. */
  141796. set targetFrameRate(value: number);
  141797. /**
  141798. * Gets or sets the current interval between two checks (every 2000ms by default)
  141799. */
  141800. get trackerDuration(): number;
  141801. /**
  141802. * Gets or sets the current interval between two checks (every 2000ms by default)
  141803. */
  141804. set trackerDuration(value: number);
  141805. /**
  141806. * Gets the list of active optimizations
  141807. */
  141808. get optimizations(): SceneOptimization[];
  141809. /**
  141810. * Creates a new SceneOptimizer
  141811. * @param scene defines the scene to work on
  141812. * @param options defines the options to use with the SceneOptimizer
  141813. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141814. * @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)
  141815. */
  141816. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141817. /**
  141818. * Stops the current optimizer
  141819. */
  141820. stop(): void;
  141821. /**
  141822. * Reset the optimizer to initial step (current priority level = 0)
  141823. */
  141824. reset(): void;
  141825. /**
  141826. * Start the optimizer. By default it will try to reach a specific framerate
  141827. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141828. */
  141829. start(): void;
  141830. private _checkCurrentState;
  141831. /**
  141832. * Release all resources
  141833. */
  141834. dispose(): void;
  141835. /**
  141836. * Helper function to create a SceneOptimizer with one single line of code
  141837. * @param scene defines the scene to work on
  141838. * @param options defines the options to use with the SceneOptimizer
  141839. * @param onSuccess defines a callback to call on success
  141840. * @param onFailure defines a callback to call on failure
  141841. * @returns the new SceneOptimizer object
  141842. */
  141843. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141844. }
  141845. }
  141846. declare module BABYLON {
  141847. /**
  141848. * Class used to serialize a scene into a string
  141849. */
  141850. export class SceneSerializer {
  141851. /**
  141852. * Clear cache used by a previous serialization
  141853. */
  141854. static ClearCache(): void;
  141855. /**
  141856. * Serialize a scene into a JSON compatible object
  141857. * @param scene defines the scene to serialize
  141858. * @returns a JSON compatible object
  141859. */
  141860. static Serialize(scene: Scene): any;
  141861. /**
  141862. * Serialize a mesh into a JSON compatible object
  141863. * @param toSerialize defines the mesh to serialize
  141864. * @param withParents defines if parents must be serialized as well
  141865. * @param withChildren defines if children must be serialized as well
  141866. * @returns a JSON compatible object
  141867. */
  141868. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141869. }
  141870. }
  141871. declare module BABYLON {
  141872. /**
  141873. * Class used to host texture specific utilities
  141874. */
  141875. export class TextureTools {
  141876. /**
  141877. * Uses the GPU to create a copy texture rescaled at a given size
  141878. * @param texture Texture to copy from
  141879. * @param width defines the desired width
  141880. * @param height defines the desired height
  141881. * @param useBilinearMode defines if bilinear mode has to be used
  141882. * @return the generated texture
  141883. */
  141884. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141885. }
  141886. }
  141887. declare module BABYLON {
  141888. /**
  141889. * This represents the different options available for the video capture.
  141890. */
  141891. export interface VideoRecorderOptions {
  141892. /** Defines the mime type of the video. */
  141893. mimeType: string;
  141894. /** Defines the FPS the video should be recorded at. */
  141895. fps: number;
  141896. /** Defines the chunk size for the recording data. */
  141897. recordChunckSize: number;
  141898. /** The audio tracks to attach to the recording. */
  141899. audioTracks?: MediaStreamTrack[];
  141900. }
  141901. /**
  141902. * This can help with recording videos from BabylonJS.
  141903. * This is based on the available WebRTC functionalities of the browser.
  141904. *
  141905. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141906. */
  141907. export class VideoRecorder {
  141908. private static readonly _defaultOptions;
  141909. /**
  141910. * Returns whether or not the VideoRecorder is available in your browser.
  141911. * @param engine Defines the Babylon Engine.
  141912. * @returns true if supported otherwise false.
  141913. */
  141914. static IsSupported(engine: Engine): boolean;
  141915. private readonly _options;
  141916. private _canvas;
  141917. private _mediaRecorder;
  141918. private _recordedChunks;
  141919. private _fileName;
  141920. private _resolve;
  141921. private _reject;
  141922. /**
  141923. * True when a recording is already in progress.
  141924. */
  141925. get isRecording(): boolean;
  141926. /**
  141927. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141928. * @param engine Defines the BabylonJS Engine you wish to record.
  141929. * @param options Defines options that can be used to customize the capture.
  141930. */
  141931. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141932. /**
  141933. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141934. */
  141935. stopRecording(): void;
  141936. /**
  141937. * Starts recording the canvas for a max duration specified in parameters.
  141938. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141939. * If null no automatic download will start and you can rely on the promise to get the data back.
  141940. * @param maxDuration Defines the maximum recording time in seconds.
  141941. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141942. * @return A promise callback at the end of the recording with the video data in Blob.
  141943. */
  141944. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141945. /**
  141946. * Releases internal resources used during the recording.
  141947. */
  141948. dispose(): void;
  141949. private _handleDataAvailable;
  141950. private _handleError;
  141951. private _handleStop;
  141952. }
  141953. }
  141954. declare module BABYLON {
  141955. /**
  141956. * Class containing a set of static utilities functions for screenshots
  141957. */
  141958. export class ScreenshotTools {
  141959. /**
  141960. * Captures a screenshot of the current rendering
  141961. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141962. * @param engine defines the rendering engine
  141963. * @param camera defines the source camera
  141964. * @param size This parameter can be set to a single number or to an object with the
  141965. * following (optional) properties: precision, width, height. If a single number is passed,
  141966. * it will be used for both width and height. If an object is passed, the screenshot size
  141967. * will be derived from the parameters. The precision property is a multiplier allowing
  141968. * rendering at a higher or lower resolution
  141969. * @param successCallback defines the callback receives a single parameter which contains the
  141970. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141971. * src parameter of an <img> to display it
  141972. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141973. * Check your browser for supported MIME types
  141974. */
  141975. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141976. /**
  141977. * Captures a screenshot of the current rendering
  141978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141979. * @param engine defines the rendering engine
  141980. * @param camera defines the source camera
  141981. * @param size This parameter can be set to a single number or to an object with the
  141982. * following (optional) properties: precision, width, height. If a single number is passed,
  141983. * it will be used for both width and height. If an object is passed, the screenshot size
  141984. * will be derived from the parameters. The precision property is a multiplier allowing
  141985. * rendering at a higher or lower resolution
  141986. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141987. * Check your browser for supported MIME types
  141988. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141989. * to the src parameter of an <img> to display it
  141990. */
  141991. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141992. /**
  141993. * Generates an image screenshot from the specified camera.
  141994. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141995. * @param engine The engine to use for rendering
  141996. * @param camera The camera to use for rendering
  141997. * @param size This parameter can be set to a single number or to an object with the
  141998. * following (optional) properties: precision, width, height. If a single number is passed,
  141999. * it will be used for both width and height. If an object is passed, the screenshot size
  142000. * will be derived from the parameters. The precision property is a multiplier allowing
  142001. * rendering at a higher or lower resolution
  142002. * @param successCallback The callback receives a single parameter which contains the
  142003. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142004. * src parameter of an <img> to display it
  142005. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142006. * Check your browser for supported MIME types
  142007. * @param samples Texture samples (default: 1)
  142008. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142009. * @param fileName A name for for the downloaded file.
  142010. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142011. */
  142012. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  142013. /**
  142014. * Generates an image screenshot from the specified camera.
  142015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142016. * @param engine The engine to use for rendering
  142017. * @param camera The camera to use for rendering
  142018. * @param size This parameter can be set to a single number or to an object with the
  142019. * following (optional) properties: precision, width, height. If a single number is passed,
  142020. * it will be used for both width and height. If an object is passed, the screenshot size
  142021. * will be derived from the parameters. The precision property is a multiplier allowing
  142022. * rendering at a higher or lower resolution
  142023. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142024. * Check your browser for supported MIME types
  142025. * @param samples Texture samples (default: 1)
  142026. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142027. * @param fileName A name for for the downloaded file.
  142028. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142029. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142030. * to the src parameter of an <img> to display it
  142031. */
  142032. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  142033. /**
  142034. * Gets height and width for screenshot size
  142035. * @private
  142036. */
  142037. private static _getScreenshotSize;
  142038. }
  142039. }
  142040. declare module BABYLON {
  142041. /**
  142042. * Interface for a data buffer
  142043. */
  142044. export interface IDataBuffer {
  142045. /**
  142046. * Reads bytes from the data buffer.
  142047. * @param byteOffset The byte offset to read
  142048. * @param byteLength The byte length to read
  142049. * @returns A promise that resolves when the bytes are read
  142050. */
  142051. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  142052. /**
  142053. * The byte length of the buffer.
  142054. */
  142055. readonly byteLength: number;
  142056. }
  142057. /**
  142058. * Utility class for reading from a data buffer
  142059. */
  142060. export class DataReader {
  142061. /**
  142062. * The data buffer associated with this data reader.
  142063. */
  142064. readonly buffer: IDataBuffer;
  142065. /**
  142066. * The current byte offset from the beginning of the data buffer.
  142067. */
  142068. byteOffset: number;
  142069. private _dataView;
  142070. private _dataByteOffset;
  142071. /**
  142072. * Constructor
  142073. * @param buffer The buffer to read
  142074. */
  142075. constructor(buffer: IDataBuffer);
  142076. /**
  142077. * Loads the given byte length.
  142078. * @param byteLength The byte length to load
  142079. * @returns A promise that resolves when the load is complete
  142080. */
  142081. loadAsync(byteLength: number): Promise<void>;
  142082. /**
  142083. * Read a unsigned 32-bit integer from the currently loaded data range.
  142084. * @returns The 32-bit integer read
  142085. */
  142086. readUint32(): number;
  142087. /**
  142088. * Read a byte array from the currently loaded data range.
  142089. * @param byteLength The byte length to read
  142090. * @returns The byte array read
  142091. */
  142092. readUint8Array(byteLength: number): Uint8Array;
  142093. /**
  142094. * Read a string from the currently loaded data range.
  142095. * @param byteLength The byte length to read
  142096. * @returns The string read
  142097. */
  142098. readString(byteLength: number): string;
  142099. /**
  142100. * Skips the given byte length the currently loaded data range.
  142101. * @param byteLength The byte length to skip
  142102. */
  142103. skipBytes(byteLength: number): void;
  142104. }
  142105. }
  142106. declare module BABYLON {
  142107. /**
  142108. * Class for storing data to local storage if available or in-memory storage otherwise
  142109. */
  142110. export class DataStorage {
  142111. private static _Storage;
  142112. private static _GetStorage;
  142113. /**
  142114. * Reads a string from the data storage
  142115. * @param key The key to read
  142116. * @param defaultValue The value if the key doesn't exist
  142117. * @returns The string value
  142118. */
  142119. static ReadString(key: string, defaultValue: string): string;
  142120. /**
  142121. * Writes a string to the data storage
  142122. * @param key The key to write
  142123. * @param value The value to write
  142124. */
  142125. static WriteString(key: string, value: string): void;
  142126. /**
  142127. * Reads a boolean from the data storage
  142128. * @param key The key to read
  142129. * @param defaultValue The value if the key doesn't exist
  142130. * @returns The boolean value
  142131. */
  142132. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  142133. /**
  142134. * Writes a boolean to the data storage
  142135. * @param key The key to write
  142136. * @param value The value to write
  142137. */
  142138. static WriteBoolean(key: string, value: boolean): void;
  142139. /**
  142140. * Reads a number from the data storage
  142141. * @param key The key to read
  142142. * @param defaultValue The value if the key doesn't exist
  142143. * @returns The number value
  142144. */
  142145. static ReadNumber(key: string, defaultValue: number): number;
  142146. /**
  142147. * Writes a number to the data storage
  142148. * @param key The key to write
  142149. * @param value The value to write
  142150. */
  142151. static WriteNumber(key: string, value: number): void;
  142152. }
  142153. }
  142154. declare module BABYLON {
  142155. /**
  142156. * Options used for hit testing
  142157. */
  142158. export interface IWebXRHitTestOptions {
  142159. /**
  142160. * Only test when user interacted with the scene. Default - hit test every frame
  142161. */
  142162. testOnPointerDownOnly?: boolean;
  142163. /**
  142164. * The node to use to transform the local results to world coordinates
  142165. */
  142166. worldParentNode?: TransformNode;
  142167. }
  142168. /**
  142169. * Interface defining the babylon result of raycasting/hit-test
  142170. */
  142171. export interface IWebXRHitResult {
  142172. /**
  142173. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142174. */
  142175. transformationMatrix: Matrix;
  142176. /**
  142177. * The native hit test result
  142178. */
  142179. xrHitResult: XRHitResult;
  142180. }
  142181. /**
  142182. * The currently-working hit-test module.
  142183. * Hit test (or Ray-casting) is used to interact with the real world.
  142184. * For further information read here - https://github.com/immersive-web/hit-test
  142185. */
  142186. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142187. /**
  142188. * options to use when constructing this feature
  142189. */
  142190. readonly options: IWebXRHitTestOptions;
  142191. private _direction;
  142192. private _mat;
  142193. private _onSelectEnabled;
  142194. private _origin;
  142195. /**
  142196. * The module's name
  142197. */
  142198. static readonly Name: string;
  142199. /**
  142200. * The (Babylon) version of this module.
  142201. * This is an integer representing the implementation version.
  142202. * This number does not correspond to the WebXR specs version
  142203. */
  142204. static readonly Version: number;
  142205. /**
  142206. * Populated with the last native XR Hit Results
  142207. */
  142208. lastNativeXRHitResults: XRHitResult[];
  142209. /**
  142210. * Triggered when new babylon (transformed) hit test results are available
  142211. */
  142212. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142213. /**
  142214. * Creates a new instance of the (legacy version) hit test feature
  142215. * @param _xrSessionManager an instance of WebXRSessionManager
  142216. * @param options options to use when constructing this feature
  142217. */
  142218. constructor(_xrSessionManager: WebXRSessionManager,
  142219. /**
  142220. * options to use when constructing this feature
  142221. */
  142222. options?: IWebXRHitTestOptions);
  142223. /**
  142224. * execute a hit test with an XR Ray
  142225. *
  142226. * @param xrSession a native xrSession that will execute this hit test
  142227. * @param xrRay the ray (position and direction) to use for ray-casting
  142228. * @param referenceSpace native XR reference space to use for the hit-test
  142229. * @param filter filter function that will filter the results
  142230. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142231. */
  142232. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142233. /**
  142234. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142235. * @param event the (select) event to use to select with
  142236. * @param referenceSpace the reference space to use for this hit test
  142237. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142238. */
  142239. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142240. /**
  142241. * attach this feature
  142242. * Will usually be called by the features manager
  142243. *
  142244. * @returns true if successful.
  142245. */
  142246. attach(): boolean;
  142247. /**
  142248. * detach this feature.
  142249. * Will usually be called by the features manager
  142250. *
  142251. * @returns true if successful.
  142252. */
  142253. detach(): boolean;
  142254. /**
  142255. * Dispose this feature and all of the resources attached
  142256. */
  142257. dispose(): void;
  142258. protected _onXRFrame(frame: XRFrame): void;
  142259. private _onHitTestResults;
  142260. private _onSelect;
  142261. }
  142262. }
  142263. declare module BABYLON {
  142264. /**
  142265. * Options used in the plane detector module
  142266. */
  142267. export interface IWebXRPlaneDetectorOptions {
  142268. /**
  142269. * The node to use to transform the local results to world coordinates
  142270. */
  142271. worldParentNode?: TransformNode;
  142272. }
  142273. /**
  142274. * A babylon interface for a WebXR plane.
  142275. * A Plane is actually a polygon, built from N points in space
  142276. *
  142277. * Supported in chrome 79, not supported in canary 81 ATM
  142278. */
  142279. export interface IWebXRPlane {
  142280. /**
  142281. * a babylon-assigned ID for this polygon
  142282. */
  142283. id: number;
  142284. /**
  142285. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142286. */
  142287. polygonDefinition: Array<Vector3>;
  142288. /**
  142289. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142290. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142291. */
  142292. transformationMatrix: Matrix;
  142293. /**
  142294. * the native xr-plane object
  142295. */
  142296. xrPlane: XRPlane;
  142297. }
  142298. /**
  142299. * The plane detector is used to detect planes in the real world when in AR
  142300. * For more information see https://github.com/immersive-web/real-world-geometry/
  142301. */
  142302. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142303. private _options;
  142304. private _detectedPlanes;
  142305. private _enabled;
  142306. private _lastFrameDetected;
  142307. /**
  142308. * The module's name
  142309. */
  142310. static readonly Name: string;
  142311. /**
  142312. * The (Babylon) version of this module.
  142313. * This is an integer representing the implementation version.
  142314. * This number does not correspond to the WebXR specs version
  142315. */
  142316. static readonly Version: number;
  142317. /**
  142318. * Observers registered here will be executed when a new plane was added to the session
  142319. */
  142320. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142321. /**
  142322. * Observers registered here will be executed when a plane is no longer detected in the session
  142323. */
  142324. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142325. /**
  142326. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142327. * This can execute N times every frame
  142328. */
  142329. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142330. /**
  142331. * construct a new Plane Detector
  142332. * @param _xrSessionManager an instance of xr Session manager
  142333. * @param _options configuration to use when constructing this feature
  142334. */
  142335. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142336. /**
  142337. * Dispose this feature and all of the resources attached
  142338. */
  142339. dispose(): void;
  142340. protected _onXRFrame(frame: XRFrame): void;
  142341. private _init;
  142342. private _updatePlaneWithXRPlane;
  142343. /**
  142344. * avoiding using Array.find for global support.
  142345. * @param xrPlane the plane to find in the array
  142346. */
  142347. private findIndexInPlaneArray;
  142348. }
  142349. }
  142350. declare module BABYLON {
  142351. /**
  142352. * Configuration options of the anchor system
  142353. */
  142354. export interface IWebXRAnchorSystemOptions {
  142355. /**
  142356. * Should a new anchor be added every time a select event is triggered
  142357. */
  142358. addAnchorOnSelect?: boolean;
  142359. /**
  142360. * should the anchor system use plane detection.
  142361. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142362. */
  142363. usePlaneDetection?: boolean;
  142364. /**
  142365. * a node that will be used to convert local to world coordinates
  142366. */
  142367. worldParentNode?: TransformNode;
  142368. }
  142369. /**
  142370. * A babylon container for an XR Anchor
  142371. */
  142372. export interface IWebXRAnchor {
  142373. /**
  142374. * A babylon-assigned ID for this anchor
  142375. */
  142376. id: number;
  142377. /**
  142378. * Transformation matrix to apply to an object attached to this anchor
  142379. */
  142380. transformationMatrix: Matrix;
  142381. /**
  142382. * The native anchor object
  142383. */
  142384. xrAnchor: XRAnchor;
  142385. }
  142386. /**
  142387. * An implementation of the anchor system of WebXR.
  142388. * Note that the current documented implementation is not available in any browser. Future implementations
  142389. * will use the frame to create an anchor and not the session or a detected plane
  142390. * For further information see https://github.com/immersive-web/anchors/
  142391. */
  142392. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142393. private _options;
  142394. private _enabled;
  142395. private _hitTestModule;
  142396. private _lastFrameDetected;
  142397. private _onSelect;
  142398. private _planeDetector;
  142399. private _trackedAnchors;
  142400. /**
  142401. * The module's name
  142402. */
  142403. static readonly Name: string;
  142404. /**
  142405. * The (Babylon) version of this module.
  142406. * This is an integer representing the implementation version.
  142407. * This number does not correspond to the WebXR specs version
  142408. */
  142409. static readonly Version: number;
  142410. /**
  142411. * Observers registered here will be executed when a new anchor was added to the session
  142412. */
  142413. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142414. /**
  142415. * Observers registered here will be executed when an anchor was removed from the session
  142416. */
  142417. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142418. /**
  142419. * Observers registered here will be executed when an existing anchor updates
  142420. * This can execute N times every frame
  142421. */
  142422. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142423. /**
  142424. * constructs a new anchor system
  142425. * @param _xrSessionManager an instance of WebXRSessionManager
  142426. * @param _options configuration object for this feature
  142427. */
  142428. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142429. /**
  142430. * Add anchor at a specific XR point.
  142431. *
  142432. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142433. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142434. * @returns a promise the fulfills when the anchor was created
  142435. */
  142436. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142437. /**
  142438. * attach this feature
  142439. * Will usually be called by the features manager
  142440. *
  142441. * @returns true if successful.
  142442. */
  142443. attach(): boolean;
  142444. /**
  142445. * detach this feature.
  142446. * Will usually be called by the features manager
  142447. *
  142448. * @returns true if successful.
  142449. */
  142450. detach(): boolean;
  142451. /**
  142452. * Dispose this feature and all of the resources attached
  142453. */
  142454. dispose(): void;
  142455. /**
  142456. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142457. * @param hitTestModule the hit-test module to use.
  142458. */
  142459. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142460. /**
  142461. * set the plane detector to use in order to create anchors from frames
  142462. * @param planeDetector the plane-detector module to use
  142463. * @param enable enable plane-anchors. default is true
  142464. */
  142465. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142466. protected _onXRFrame(frame: XRFrame): void;
  142467. /**
  142468. * avoiding using Array.find for global support.
  142469. * @param xrAnchor the plane to find in the array
  142470. */
  142471. private _findIndexInAnchorArray;
  142472. private _updateAnchorWithXRFrame;
  142473. }
  142474. }
  142475. declare module BABYLON {
  142476. /**
  142477. * Options interface for the background remover plugin
  142478. */
  142479. export interface IWebXRBackgroundRemoverOptions {
  142480. /**
  142481. * Further background meshes to disable when entering AR
  142482. */
  142483. backgroundMeshes?: AbstractMesh[];
  142484. /**
  142485. * flags to configure the removal of the environment helper.
  142486. * If not set, the entire background will be removed. If set, flags should be set as well.
  142487. */
  142488. environmentHelperRemovalFlags?: {
  142489. /**
  142490. * Should the skybox be removed (default false)
  142491. */
  142492. skyBox?: boolean;
  142493. /**
  142494. * Should the ground be removed (default false)
  142495. */
  142496. ground?: boolean;
  142497. };
  142498. /**
  142499. * don't disable the environment helper
  142500. */
  142501. ignoreEnvironmentHelper?: boolean;
  142502. }
  142503. /**
  142504. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142505. */
  142506. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142507. /**
  142508. * read-only options to be used in this module
  142509. */
  142510. readonly options: IWebXRBackgroundRemoverOptions;
  142511. /**
  142512. * The module's name
  142513. */
  142514. static readonly Name: string;
  142515. /**
  142516. * The (Babylon) version of this module.
  142517. * This is an integer representing the implementation version.
  142518. * This number does not correspond to the WebXR specs version
  142519. */
  142520. static readonly Version: number;
  142521. /**
  142522. * registered observers will be triggered when the background state changes
  142523. */
  142524. onBackgroundStateChangedObservable: Observable<boolean>;
  142525. /**
  142526. * constructs a new background remover module
  142527. * @param _xrSessionManager the session manager for this module
  142528. * @param options read-only options to be used in this module
  142529. */
  142530. constructor(_xrSessionManager: WebXRSessionManager,
  142531. /**
  142532. * read-only options to be used in this module
  142533. */
  142534. options?: IWebXRBackgroundRemoverOptions);
  142535. /**
  142536. * attach this feature
  142537. * Will usually be called by the features manager
  142538. *
  142539. * @returns true if successful.
  142540. */
  142541. attach(): boolean;
  142542. /**
  142543. * detach this feature.
  142544. * Will usually be called by the features manager
  142545. *
  142546. * @returns true if successful.
  142547. */
  142548. detach(): boolean;
  142549. /**
  142550. * Dispose this feature and all of the resources attached
  142551. */
  142552. dispose(): void;
  142553. protected _onXRFrame(_xrFrame: XRFrame): void;
  142554. private _setBackgroundState;
  142555. }
  142556. }
  142557. declare module BABYLON {
  142558. /**
  142559. * Options for the controller physics feature
  142560. */
  142561. export class IWebXRControllerPhysicsOptions {
  142562. /**
  142563. * Should the headset get its own impostor
  142564. */
  142565. enableHeadsetImpostor?: boolean;
  142566. /**
  142567. * Optional parameters for the headset impostor
  142568. */
  142569. headsetImpostorParams?: {
  142570. /**
  142571. * The type of impostor to create. Default is sphere
  142572. */
  142573. impostorType: number;
  142574. /**
  142575. * the size of the impostor. Defaults to 10cm
  142576. */
  142577. impostorSize?: number | {
  142578. width: number;
  142579. height: number;
  142580. depth: number;
  142581. };
  142582. /**
  142583. * Friction definitions
  142584. */
  142585. friction?: number;
  142586. /**
  142587. * Restitution
  142588. */
  142589. restitution?: number;
  142590. };
  142591. /**
  142592. * The physics properties of the future impostors
  142593. */
  142594. physicsProperties?: {
  142595. /**
  142596. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142597. * Note that this requires a physics engine that supports mesh impostors!
  142598. */
  142599. useControllerMesh?: boolean;
  142600. /**
  142601. * The type of impostor to create. Default is sphere
  142602. */
  142603. impostorType?: number;
  142604. /**
  142605. * the size of the impostor. Defaults to 10cm
  142606. */
  142607. impostorSize?: number | {
  142608. width: number;
  142609. height: number;
  142610. depth: number;
  142611. };
  142612. /**
  142613. * Friction definitions
  142614. */
  142615. friction?: number;
  142616. /**
  142617. * Restitution
  142618. */
  142619. restitution?: number;
  142620. };
  142621. /**
  142622. * the xr input to use with this pointer selection
  142623. */
  142624. xrInput: WebXRInput;
  142625. }
  142626. /**
  142627. * Add physics impostor to your webxr controllers,
  142628. * including naive calculation of their linear and angular velocity
  142629. */
  142630. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142631. private readonly _options;
  142632. private _attachController;
  142633. private _controllers;
  142634. private _debugMode;
  142635. private _delta;
  142636. private _headsetImpostor?;
  142637. private _headsetMesh?;
  142638. private _lastTimestamp;
  142639. private _tmpQuaternion;
  142640. private _tmpVector;
  142641. /**
  142642. * The module's name
  142643. */
  142644. static readonly Name: string;
  142645. /**
  142646. * The (Babylon) version of this module.
  142647. * This is an integer representing the implementation version.
  142648. * This number does not correspond to the webxr specs version
  142649. */
  142650. static readonly Version: number;
  142651. /**
  142652. * Construct a new Controller Physics Feature
  142653. * @param _xrSessionManager the corresponding xr session manager
  142654. * @param _options options to create this feature with
  142655. */
  142656. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142657. /**
  142658. * @hidden
  142659. * enable debugging - will show console outputs and the impostor mesh
  142660. */
  142661. _enablePhysicsDebug(): void;
  142662. /**
  142663. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142664. * @param xrController the controller to add
  142665. */
  142666. addController(xrController: WebXRInputSource): void;
  142667. /**
  142668. * attach this feature
  142669. * Will usually be called by the features manager
  142670. *
  142671. * @returns true if successful.
  142672. */
  142673. attach(): boolean;
  142674. /**
  142675. * detach this feature.
  142676. * Will usually be called by the features manager
  142677. *
  142678. * @returns true if successful.
  142679. */
  142680. detach(): boolean;
  142681. /**
  142682. * Get the headset impostor, if enabled
  142683. * @returns the impostor
  142684. */
  142685. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142686. /**
  142687. * Get the physics impostor of a specific controller.
  142688. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142689. * @param controller the controller or the controller id of which to get the impostor
  142690. * @returns the impostor or null
  142691. */
  142692. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142693. /**
  142694. * Update the physics properties provided in the constructor
  142695. * @param newProperties the new properties object
  142696. */
  142697. setPhysicsProperties(newProperties: {
  142698. impostorType?: number;
  142699. impostorSize?: number | {
  142700. width: number;
  142701. height: number;
  142702. depth: number;
  142703. };
  142704. friction?: number;
  142705. restitution?: number;
  142706. }): void;
  142707. protected _onXRFrame(_xrFrame: any): void;
  142708. private _detachController;
  142709. }
  142710. }
  142711. declare module BABYLON {
  142712. /**
  142713. * The motion controller class for all microsoft mixed reality controllers
  142714. */
  142715. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142716. protected readonly _mapping: {
  142717. defaultButton: {
  142718. "valueNodeName": string;
  142719. "unpressedNodeName": string;
  142720. "pressedNodeName": string;
  142721. };
  142722. defaultAxis: {
  142723. "valueNodeName": string;
  142724. "minNodeName": string;
  142725. "maxNodeName": string;
  142726. };
  142727. buttons: {
  142728. "xr-standard-trigger": {
  142729. "rootNodeName": string;
  142730. "componentProperty": string;
  142731. "states": string[];
  142732. };
  142733. "xr-standard-squeeze": {
  142734. "rootNodeName": string;
  142735. "componentProperty": string;
  142736. "states": string[];
  142737. };
  142738. "xr-standard-touchpad": {
  142739. "rootNodeName": string;
  142740. "labelAnchorNodeName": string;
  142741. "touchPointNodeName": string;
  142742. };
  142743. "xr-standard-thumbstick": {
  142744. "rootNodeName": string;
  142745. "componentProperty": string;
  142746. "states": string[];
  142747. };
  142748. };
  142749. axes: {
  142750. "xr-standard-touchpad": {
  142751. "x-axis": {
  142752. "rootNodeName": string;
  142753. };
  142754. "y-axis": {
  142755. "rootNodeName": string;
  142756. };
  142757. };
  142758. "xr-standard-thumbstick": {
  142759. "x-axis": {
  142760. "rootNodeName": string;
  142761. };
  142762. "y-axis": {
  142763. "rootNodeName": string;
  142764. };
  142765. };
  142766. };
  142767. };
  142768. /**
  142769. * The base url used to load the left and right controller models
  142770. */
  142771. static MODEL_BASE_URL: string;
  142772. /**
  142773. * The name of the left controller model file
  142774. */
  142775. static MODEL_LEFT_FILENAME: string;
  142776. /**
  142777. * The name of the right controller model file
  142778. */
  142779. static MODEL_RIGHT_FILENAME: string;
  142780. profileId: string;
  142781. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142782. protected _getFilenameAndPath(): {
  142783. filename: string;
  142784. path: string;
  142785. };
  142786. protected _getModelLoadingConstraints(): boolean;
  142787. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142788. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142789. protected _updateModel(): void;
  142790. }
  142791. }
  142792. declare module BABYLON {
  142793. /**
  142794. * The motion controller class for oculus touch (quest, rift).
  142795. * This class supports legacy mapping as well the standard xr mapping
  142796. */
  142797. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142798. private _forceLegacyControllers;
  142799. private _modelRootNode;
  142800. /**
  142801. * The base url used to load the left and right controller models
  142802. */
  142803. static MODEL_BASE_URL: string;
  142804. /**
  142805. * The name of the left controller model file
  142806. */
  142807. static MODEL_LEFT_FILENAME: string;
  142808. /**
  142809. * The name of the right controller model file
  142810. */
  142811. static MODEL_RIGHT_FILENAME: string;
  142812. /**
  142813. * Base Url for the Quest controller model.
  142814. */
  142815. static QUEST_MODEL_BASE_URL: string;
  142816. profileId: string;
  142817. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142818. protected _getFilenameAndPath(): {
  142819. filename: string;
  142820. path: string;
  142821. };
  142822. protected _getModelLoadingConstraints(): boolean;
  142823. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142824. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142825. protected _updateModel(): void;
  142826. /**
  142827. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142828. * between the touch and touch 2.
  142829. */
  142830. private _isQuest;
  142831. }
  142832. }
  142833. declare module BABYLON {
  142834. /**
  142835. * The motion controller class for the standard HTC-Vive controllers
  142836. */
  142837. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142838. private _modelRootNode;
  142839. /**
  142840. * The base url used to load the left and right controller models
  142841. */
  142842. static MODEL_BASE_URL: string;
  142843. /**
  142844. * File name for the controller model.
  142845. */
  142846. static MODEL_FILENAME: string;
  142847. profileId: string;
  142848. /**
  142849. * Create a new Vive motion controller object
  142850. * @param scene the scene to use to create this controller
  142851. * @param gamepadObject the corresponding gamepad object
  142852. * @param handness the handness of the controller
  142853. */
  142854. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142855. protected _getFilenameAndPath(): {
  142856. filename: string;
  142857. path: string;
  142858. };
  142859. protected _getModelLoadingConstraints(): boolean;
  142860. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142861. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142862. protected _updateModel(): void;
  142863. }
  142864. }
  142865. declare module BABYLON {
  142866. /**
  142867. * A cursor which tracks a point on a path
  142868. */
  142869. export class PathCursor {
  142870. private path;
  142871. /**
  142872. * Stores path cursor callbacks for when an onchange event is triggered
  142873. */
  142874. private _onchange;
  142875. /**
  142876. * The value of the path cursor
  142877. */
  142878. value: number;
  142879. /**
  142880. * The animation array of the path cursor
  142881. */
  142882. animations: Animation[];
  142883. /**
  142884. * Initializes the path cursor
  142885. * @param path The path to track
  142886. */
  142887. constructor(path: Path2);
  142888. /**
  142889. * Gets the cursor point on the path
  142890. * @returns A point on the path cursor at the cursor location
  142891. */
  142892. getPoint(): Vector3;
  142893. /**
  142894. * Moves the cursor ahead by the step amount
  142895. * @param step The amount to move the cursor forward
  142896. * @returns This path cursor
  142897. */
  142898. moveAhead(step?: number): PathCursor;
  142899. /**
  142900. * Moves the cursor behind by the step amount
  142901. * @param step The amount to move the cursor back
  142902. * @returns This path cursor
  142903. */
  142904. moveBack(step?: number): PathCursor;
  142905. /**
  142906. * Moves the cursor by the step amount
  142907. * If the step amount is greater than one, an exception is thrown
  142908. * @param step The amount to move the cursor
  142909. * @returns This path cursor
  142910. */
  142911. move(step: number): PathCursor;
  142912. /**
  142913. * Ensures that the value is limited between zero and one
  142914. * @returns This path cursor
  142915. */
  142916. private ensureLimits;
  142917. /**
  142918. * Runs onchange callbacks on change (used by the animation engine)
  142919. * @returns This path cursor
  142920. */
  142921. private raiseOnChange;
  142922. /**
  142923. * Executes a function on change
  142924. * @param f A path cursor onchange callback
  142925. * @returns This path cursor
  142926. */
  142927. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142928. }
  142929. }
  142930. declare module BABYLON {
  142931. /** @hidden */
  142932. export var blurPixelShader: {
  142933. name: string;
  142934. shader: string;
  142935. };
  142936. }
  142937. declare module BABYLON {
  142938. /** @hidden */
  142939. export var pointCloudVertexDeclaration: {
  142940. name: string;
  142941. shader: string;
  142942. };
  142943. }
  142944. // Mixins
  142945. interface Window {
  142946. mozIndexedDB: IDBFactory;
  142947. webkitIndexedDB: IDBFactory;
  142948. msIndexedDB: IDBFactory;
  142949. webkitURL: typeof URL;
  142950. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142951. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142952. WebGLRenderingContext: WebGLRenderingContext;
  142953. MSGesture: MSGesture;
  142954. CANNON: any;
  142955. AudioContext: AudioContext;
  142956. webkitAudioContext: AudioContext;
  142957. PointerEvent: any;
  142958. Math: Math;
  142959. Uint8Array: Uint8ArrayConstructor;
  142960. Float32Array: Float32ArrayConstructor;
  142961. mozURL: typeof URL;
  142962. msURL: typeof URL;
  142963. VRFrameData: any; // WebVR, from specs 1.1
  142964. DracoDecoderModule: any;
  142965. setImmediate(handler: (...args: any[]) => void): number;
  142966. }
  142967. interface HTMLCanvasElement {
  142968. requestPointerLock(): void;
  142969. msRequestPointerLock?(): void;
  142970. mozRequestPointerLock?(): void;
  142971. webkitRequestPointerLock?(): void;
  142972. /** Track wether a record is in progress */
  142973. isRecording: boolean;
  142974. /** Capture Stream method defined by some browsers */
  142975. captureStream(fps?: number): MediaStream;
  142976. }
  142977. interface CanvasRenderingContext2D {
  142978. msImageSmoothingEnabled: boolean;
  142979. }
  142980. interface MouseEvent {
  142981. mozMovementX: number;
  142982. mozMovementY: number;
  142983. webkitMovementX: number;
  142984. webkitMovementY: number;
  142985. msMovementX: number;
  142986. msMovementY: number;
  142987. }
  142988. interface Navigator {
  142989. mozGetVRDevices: (any: any) => any;
  142990. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142991. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142992. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142993. webkitGetGamepads(): Gamepad[];
  142994. msGetGamepads(): Gamepad[];
  142995. webkitGamepads(): Gamepad[];
  142996. }
  142997. interface HTMLVideoElement {
  142998. mozSrcObject: any;
  142999. }
  143000. interface Math {
  143001. fround(x: number): number;
  143002. imul(a: number, b: number): number;
  143003. }
  143004. interface WebGLRenderingContext {
  143005. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  143006. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  143007. vertexAttribDivisor(index: number, divisor: number): void;
  143008. createVertexArray(): any;
  143009. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  143010. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  143011. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  143012. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  143013. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  143014. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  143015. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  143016. // Queries
  143017. createQuery(): WebGLQuery;
  143018. deleteQuery(query: WebGLQuery): void;
  143019. beginQuery(target: number, query: WebGLQuery): void;
  143020. endQuery(target: number): void;
  143021. getQueryParameter(query: WebGLQuery, pname: number): any;
  143022. getQuery(target: number, pname: number): any;
  143023. MAX_SAMPLES: number;
  143024. RGBA8: number;
  143025. READ_FRAMEBUFFER: number;
  143026. DRAW_FRAMEBUFFER: number;
  143027. UNIFORM_BUFFER: number;
  143028. HALF_FLOAT_OES: number;
  143029. RGBA16F: number;
  143030. RGBA32F: number;
  143031. R32F: number;
  143032. RG32F: number;
  143033. RGB32F: number;
  143034. R16F: number;
  143035. RG16F: number;
  143036. RGB16F: number;
  143037. RED: number;
  143038. RG: number;
  143039. R8: number;
  143040. RG8: number;
  143041. UNSIGNED_INT_24_8: number;
  143042. DEPTH24_STENCIL8: number;
  143043. MIN: number;
  143044. MAX: number;
  143045. /* Multiple Render Targets */
  143046. drawBuffers(buffers: number[]): void;
  143047. readBuffer(src: number): void;
  143048. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  143049. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  143050. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  143051. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  143052. // Occlusion Query
  143053. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  143054. ANY_SAMPLES_PASSED: number;
  143055. QUERY_RESULT_AVAILABLE: number;
  143056. QUERY_RESULT: number;
  143057. }
  143058. interface WebGLProgram {
  143059. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  143060. }
  143061. interface EXT_disjoint_timer_query {
  143062. QUERY_COUNTER_BITS_EXT: number;
  143063. TIME_ELAPSED_EXT: number;
  143064. TIMESTAMP_EXT: number;
  143065. GPU_DISJOINT_EXT: number;
  143066. QUERY_RESULT_EXT: number;
  143067. QUERY_RESULT_AVAILABLE_EXT: number;
  143068. queryCounterEXT(query: WebGLQuery, target: number): void;
  143069. createQueryEXT(): WebGLQuery;
  143070. beginQueryEXT(target: number, query: WebGLQuery): void;
  143071. endQueryEXT(target: number): void;
  143072. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  143073. deleteQueryEXT(query: WebGLQuery): void;
  143074. }
  143075. interface WebGLUniformLocation {
  143076. _currentState: any;
  143077. }
  143078. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  143079. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  143080. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  143081. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143082. interface WebGLRenderingContext {
  143083. readonly RASTERIZER_DISCARD: number;
  143084. readonly DEPTH_COMPONENT24: number;
  143085. readonly TEXTURE_3D: number;
  143086. readonly TEXTURE_2D_ARRAY: number;
  143087. readonly TEXTURE_COMPARE_FUNC: number;
  143088. readonly TEXTURE_COMPARE_MODE: number;
  143089. readonly COMPARE_REF_TO_TEXTURE: number;
  143090. readonly TEXTURE_WRAP_R: number;
  143091. readonly HALF_FLOAT: number;
  143092. readonly RGB8: number;
  143093. readonly RED_INTEGER: number;
  143094. readonly RG_INTEGER: number;
  143095. readonly RGB_INTEGER: number;
  143096. readonly RGBA_INTEGER: number;
  143097. readonly R8_SNORM: number;
  143098. readonly RG8_SNORM: number;
  143099. readonly RGB8_SNORM: number;
  143100. readonly RGBA8_SNORM: number;
  143101. readonly R8I: number;
  143102. readonly RG8I: number;
  143103. readonly RGB8I: number;
  143104. readonly RGBA8I: number;
  143105. readonly R8UI: number;
  143106. readonly RG8UI: number;
  143107. readonly RGB8UI: number;
  143108. readonly RGBA8UI: number;
  143109. readonly R16I: number;
  143110. readonly RG16I: number;
  143111. readonly RGB16I: number;
  143112. readonly RGBA16I: number;
  143113. readonly R16UI: number;
  143114. readonly RG16UI: number;
  143115. readonly RGB16UI: number;
  143116. readonly RGBA16UI: number;
  143117. readonly R32I: number;
  143118. readonly RG32I: number;
  143119. readonly RGB32I: number;
  143120. readonly RGBA32I: number;
  143121. readonly R32UI: number;
  143122. readonly RG32UI: number;
  143123. readonly RGB32UI: number;
  143124. readonly RGBA32UI: number;
  143125. readonly RGB10_A2UI: number;
  143126. readonly R11F_G11F_B10F: number;
  143127. readonly RGB9_E5: number;
  143128. readonly RGB10_A2: number;
  143129. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  143130. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  143131. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  143132. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  143133. readonly DEPTH_COMPONENT32F: number;
  143134. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143135. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143136. 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;
  143137. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143138. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143139. readonly TRANSFORM_FEEDBACK: number;
  143140. readonly INTERLEAVED_ATTRIBS: number;
  143141. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143142. createTransformFeedback(): WebGLTransformFeedback;
  143143. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143144. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143145. beginTransformFeedback(primitiveMode: number): void;
  143146. endTransformFeedback(): void;
  143147. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143148. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143149. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143150. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143151. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143152. }
  143153. interface ImageBitmap {
  143154. readonly width: number;
  143155. readonly height: number;
  143156. close(): void;
  143157. }
  143158. interface WebGLQuery extends WebGLObject {
  143159. }
  143160. declare var WebGLQuery: {
  143161. prototype: WebGLQuery;
  143162. new(): WebGLQuery;
  143163. };
  143164. interface WebGLSampler extends WebGLObject {
  143165. }
  143166. declare var WebGLSampler: {
  143167. prototype: WebGLSampler;
  143168. new(): WebGLSampler;
  143169. };
  143170. interface WebGLSync extends WebGLObject {
  143171. }
  143172. declare var WebGLSync: {
  143173. prototype: WebGLSync;
  143174. new(): WebGLSync;
  143175. };
  143176. interface WebGLTransformFeedback extends WebGLObject {
  143177. }
  143178. declare var WebGLTransformFeedback: {
  143179. prototype: WebGLTransformFeedback;
  143180. new(): WebGLTransformFeedback;
  143181. };
  143182. interface WebGLVertexArrayObject extends WebGLObject {
  143183. }
  143184. declare var WebGLVertexArrayObject: {
  143185. prototype: WebGLVertexArrayObject;
  143186. new(): WebGLVertexArrayObject;
  143187. };
  143188. // Type definitions for WebVR API
  143189. // Project: https://w3c.github.io/webvr/
  143190. // Definitions by: six a <https://github.com/lostfictions>
  143191. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143192. interface VRDisplay extends EventTarget {
  143193. /**
  143194. * Dictionary of capabilities describing the VRDisplay.
  143195. */
  143196. readonly capabilities: VRDisplayCapabilities;
  143197. /**
  143198. * z-depth defining the far plane of the eye view frustum
  143199. * enables mapping of values in the render target depth
  143200. * attachment to scene coordinates. Initially set to 10000.0.
  143201. */
  143202. depthFar: number;
  143203. /**
  143204. * z-depth defining the near plane of the eye view frustum
  143205. * enables mapping of values in the render target depth
  143206. * attachment to scene coordinates. Initially set to 0.01.
  143207. */
  143208. depthNear: number;
  143209. /**
  143210. * An identifier for this distinct VRDisplay. Used as an
  143211. * association point in the Gamepad API.
  143212. */
  143213. readonly displayId: number;
  143214. /**
  143215. * A display name, a user-readable name identifying it.
  143216. */
  143217. readonly displayName: string;
  143218. readonly isConnected: boolean;
  143219. readonly isPresenting: boolean;
  143220. /**
  143221. * If this VRDisplay supports room-scale experiences, the optional
  143222. * stage attribute contains details on the room-scale parameters.
  143223. */
  143224. readonly stageParameters: VRStageParameters | null;
  143225. /**
  143226. * Passing the value returned by `requestAnimationFrame` to
  143227. * `cancelAnimationFrame` will unregister the callback.
  143228. * @param handle Define the hanle of the request to cancel
  143229. */
  143230. cancelAnimationFrame(handle: number): void;
  143231. /**
  143232. * Stops presenting to the VRDisplay.
  143233. * @returns a promise to know when it stopped
  143234. */
  143235. exitPresent(): Promise<void>;
  143236. /**
  143237. * Return the current VREyeParameters for the given eye.
  143238. * @param whichEye Define the eye we want the parameter for
  143239. * @returns the eye parameters
  143240. */
  143241. getEyeParameters(whichEye: string): VREyeParameters;
  143242. /**
  143243. * Populates the passed VRFrameData with the information required to render
  143244. * the current frame.
  143245. * @param frameData Define the data structure to populate
  143246. * @returns true if ok otherwise false
  143247. */
  143248. getFrameData(frameData: VRFrameData): boolean;
  143249. /**
  143250. * Get the layers currently being presented.
  143251. * @returns the list of VR layers
  143252. */
  143253. getLayers(): VRLayer[];
  143254. /**
  143255. * Return a VRPose containing the future predicted pose of the VRDisplay
  143256. * when the current frame will be presented. The value returned will not
  143257. * change until JavaScript has returned control to the browser.
  143258. *
  143259. * The VRPose will contain the position, orientation, velocity,
  143260. * and acceleration of each of these properties.
  143261. * @returns the pose object
  143262. */
  143263. getPose(): VRPose;
  143264. /**
  143265. * Return the current instantaneous pose of the VRDisplay, with no
  143266. * prediction applied.
  143267. * @returns the current instantaneous pose
  143268. */
  143269. getImmediatePose(): VRPose;
  143270. /**
  143271. * The callback passed to `requestAnimationFrame` will be called
  143272. * any time a new frame should be rendered. When the VRDisplay is
  143273. * presenting the callback will be called at the native refresh
  143274. * rate of the HMD. When not presenting this function acts
  143275. * identically to how window.requestAnimationFrame acts. Content should
  143276. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143277. * asynchronously from other displays and at differing refresh rates.
  143278. * @param callback Define the eaction to run next frame
  143279. * @returns the request handle it
  143280. */
  143281. requestAnimationFrame(callback: FrameRequestCallback): number;
  143282. /**
  143283. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143284. * Repeat calls while already presenting will update the VRLayers being displayed.
  143285. * @param layers Define the list of layer to present
  143286. * @returns a promise to know when the request has been fulfilled
  143287. */
  143288. requestPresent(layers: VRLayer[]): Promise<void>;
  143289. /**
  143290. * Reset the pose for this display, treating its current position and
  143291. * orientation as the "origin/zero" values. VRPose.position,
  143292. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143293. * updated when calling resetPose(). This should be called in only
  143294. * sitting-space experiences.
  143295. */
  143296. resetPose(): void;
  143297. /**
  143298. * The VRLayer provided to the VRDisplay will be captured and presented
  143299. * in the HMD. Calling this function has the same effect on the source
  143300. * canvas as any other operation that uses its source image, and canvases
  143301. * created without preserveDrawingBuffer set to true will be cleared.
  143302. * @param pose Define the pose to submit
  143303. */
  143304. submitFrame(pose?: VRPose): void;
  143305. }
  143306. declare var VRDisplay: {
  143307. prototype: VRDisplay;
  143308. new(): VRDisplay;
  143309. };
  143310. interface VRLayer {
  143311. leftBounds?: number[] | Float32Array | null;
  143312. rightBounds?: number[] | Float32Array | null;
  143313. source?: HTMLCanvasElement | null;
  143314. }
  143315. interface VRDisplayCapabilities {
  143316. readonly canPresent: boolean;
  143317. readonly hasExternalDisplay: boolean;
  143318. readonly hasOrientation: boolean;
  143319. readonly hasPosition: boolean;
  143320. readonly maxLayers: number;
  143321. }
  143322. interface VREyeParameters {
  143323. /** @deprecated */
  143324. readonly fieldOfView: VRFieldOfView;
  143325. readonly offset: Float32Array;
  143326. readonly renderHeight: number;
  143327. readonly renderWidth: number;
  143328. }
  143329. interface VRFieldOfView {
  143330. readonly downDegrees: number;
  143331. readonly leftDegrees: number;
  143332. readonly rightDegrees: number;
  143333. readonly upDegrees: number;
  143334. }
  143335. interface VRFrameData {
  143336. readonly leftProjectionMatrix: Float32Array;
  143337. readonly leftViewMatrix: Float32Array;
  143338. readonly pose: VRPose;
  143339. readonly rightProjectionMatrix: Float32Array;
  143340. readonly rightViewMatrix: Float32Array;
  143341. readonly timestamp: number;
  143342. }
  143343. interface VRPose {
  143344. readonly angularAcceleration: Float32Array | null;
  143345. readonly angularVelocity: Float32Array | null;
  143346. readonly linearAcceleration: Float32Array | null;
  143347. readonly linearVelocity: Float32Array | null;
  143348. readonly orientation: Float32Array | null;
  143349. readonly position: Float32Array | null;
  143350. readonly timestamp: number;
  143351. }
  143352. interface VRStageParameters {
  143353. sittingToStandingTransform?: Float32Array;
  143354. sizeX?: number;
  143355. sizeY?: number;
  143356. }
  143357. interface Navigator {
  143358. getVRDisplays(): Promise<VRDisplay[]>;
  143359. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143360. }
  143361. interface Window {
  143362. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143363. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143364. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143365. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143366. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143367. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143368. }
  143369. interface Gamepad {
  143370. readonly displayId: number;
  143371. }
  143372. type XRSessionMode =
  143373. | "inline"
  143374. | "immersive-vr"
  143375. | "immersive-ar";
  143376. type XRReferenceSpaceType =
  143377. | "viewer"
  143378. | "local"
  143379. | "local-floor"
  143380. | "bounded-floor"
  143381. | "unbounded";
  143382. type XREnvironmentBlendMode =
  143383. | "opaque"
  143384. | "additive"
  143385. | "alpha-blend";
  143386. type XRVisibilityState =
  143387. | "visible"
  143388. | "visible-blurred"
  143389. | "hidden";
  143390. type XRHandedness =
  143391. | "none"
  143392. | "left"
  143393. | "right";
  143394. type XRTargetRayMode =
  143395. | "gaze"
  143396. | "tracked-pointer"
  143397. | "screen";
  143398. type XREye =
  143399. | "none"
  143400. | "left"
  143401. | "right";
  143402. interface XRSpace extends EventTarget {
  143403. }
  143404. interface XRRenderState {
  143405. depthNear?: number;
  143406. depthFar?: number;
  143407. inlineVerticalFieldOfView?: number;
  143408. baseLayer?: XRWebGLLayer;
  143409. }
  143410. interface XRInputSource {
  143411. handedness: XRHandedness;
  143412. targetRayMode: XRTargetRayMode;
  143413. targetRaySpace: XRSpace;
  143414. gripSpace: XRSpace | undefined;
  143415. gamepad: Gamepad | undefined;
  143416. profiles: Array<string>;
  143417. }
  143418. interface XRSessionInit {
  143419. optionalFeatures?: XRReferenceSpaceType[];
  143420. requiredFeatures?: XRReferenceSpaceType[];
  143421. }
  143422. interface XRSession extends XRAnchorCreator {
  143423. addEventListener: Function;
  143424. removeEventListener: Function;
  143425. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143426. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143427. requestAnimationFrame: Function;
  143428. end(): Promise<void>;
  143429. renderState: XRRenderState;
  143430. inputSources: Array<XRInputSource>;
  143431. // AR hit test
  143432. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143433. updateWorldTrackingState(options: {
  143434. planeDetectionState?: { enabled: boolean; }
  143435. }): void;
  143436. }
  143437. interface XRReferenceSpace extends XRSpace {
  143438. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143439. onreset: any;
  143440. }
  143441. type XRPlaneSet = Set<XRPlane>;
  143442. type XRAnchorSet = Set<XRAnchor>;
  143443. interface XRFrame {
  143444. session: XRSession;
  143445. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143446. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143447. // Anchors
  143448. trackedAnchors?: XRAnchorSet;
  143449. // Planes
  143450. worldInformation: {
  143451. detectedPlanes?: XRPlaneSet;
  143452. };
  143453. }
  143454. interface XRViewerPose extends XRPose {
  143455. views: Array<XRView>;
  143456. }
  143457. interface XRPose {
  143458. transform: XRRigidTransform;
  143459. emulatedPosition: boolean;
  143460. }
  143461. interface XRWebGLLayerOptions {
  143462. antialias?: boolean;
  143463. depth?: boolean;
  143464. stencil?: boolean;
  143465. alpha?: boolean;
  143466. multiview?: boolean;
  143467. framebufferScaleFactor?: number;
  143468. }
  143469. declare var XRWebGLLayer: {
  143470. prototype: XRWebGLLayer;
  143471. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143472. };
  143473. interface XRWebGLLayer {
  143474. framebuffer: WebGLFramebuffer;
  143475. framebufferWidth: number;
  143476. framebufferHeight: number;
  143477. getViewport: Function;
  143478. }
  143479. declare class XRRigidTransform {
  143480. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143481. position: DOMPointReadOnly;
  143482. orientation: DOMPointReadOnly;
  143483. matrix: Float32Array;
  143484. inverse: XRRigidTransform;
  143485. }
  143486. interface XRView {
  143487. eye: XREye;
  143488. projectionMatrix: Float32Array;
  143489. transform: XRRigidTransform;
  143490. }
  143491. interface XRInputSourceChangeEvent {
  143492. session: XRSession;
  143493. removed: Array<XRInputSource>;
  143494. added: Array<XRInputSource>;
  143495. }
  143496. interface XRInputSourceEvent extends Event {
  143497. readonly frame: XRFrame;
  143498. readonly inputSource: XRInputSource;
  143499. }
  143500. // Experimental(er) features
  143501. declare class XRRay {
  143502. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143503. origin: DOMPointReadOnly;
  143504. direction: DOMPointReadOnly;
  143505. matrix: Float32Array;
  143506. }
  143507. interface XRHitResult {
  143508. hitMatrix: Float32Array;
  143509. }
  143510. interface XRAnchor {
  143511. // remove?
  143512. id?: string;
  143513. anchorSpace: XRSpace;
  143514. lastChangedTime: number;
  143515. detach(): void;
  143516. }
  143517. interface XRPlane extends XRAnchorCreator {
  143518. orientation: "Horizontal" | "Vertical";
  143519. planeSpace: XRSpace;
  143520. polygon: Array<DOMPointReadOnly>;
  143521. lastChangedTime: number;
  143522. }
  143523. interface XRAnchorCreator {
  143524. // AR Anchors
  143525. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143526. }